Commit Graph

7207 Commits

Author SHA1 Message Date
Beniamino Galvani
1e39b2320d dhcp: detect NMIP4Config 'metered' flag based on ANDROID_METERED DHCP option
Some versions of Android's DHCP server send option 43 (Vendor specific
information) with value "ANDROID_METERED" in Wi-Fi hotspot mode.

Mark the NMIP4Config as metered when such option is received.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
3c2f4a17f9 systemd/dhcp: add support for vendor specific DHCP option
This adds support for DHCP option 43 (Vendor Specific Information) to
the internal DHCP client. The option carries an opaque object of n
octets, interpreted by vendor-specific code on the clients and
servers.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
68db65b727 core: add 'metered' flag to NMIP4Config
Some DHCP servers send specific options to give a hint that clients
should avoid unneeded data usage.

Add a metered flag to NMIP4Config to keep track of this information.
2015-06-09 18:18:45 +02:00
Beniamino Galvani
bbbf522941 core,libnm: add 'metered' property to NMDevice 2015-06-09 18:11:25 +02:00
Thomas Haller
d4f828c887 platform: expose nm_platform_signal_change_type_to_string() 2015-06-05 16:52:50 +02:00
Thomas Haller
2f3fd86dc5 platform: refactor support_kernel_extended_ifa_flags to static variable
Whether we have support depends on the kernel, and is not
per NMLinuxPlatform instance.
2015-06-05 16:52:50 +02:00
Thomas Haller
95333d84bc platform: move ethtool_get_link_speed() to nm-platform-utils 2015-06-05 16:52:50 +02:00
Thomas Haller
299af02e40 platform: move supports_mii_carrier_detect() to nmp_utils_mii_supports_carrier_detect() 2015-06-05 16:52:50 +02:00
Thomas Haller
ac84b22fc7 platform: move ethtool_*() to nmp_utils_ethtool_*() 2015-06-05 16:52:50 +02:00
Thomas Haller
398819c3ac platform: factor out ethtool_get_wake_on_lan() function 2015-06-05 16:52:50 +02:00
Thomas Haller
ba084b5b90 platform: factor out ethtool_get_peer_ifindex() function 2015-06-05 16:52:50 +02:00
Thomas Haller
4be9394864 platform: factor out ethtool_supports_vlans() function 2015-06-05 16:52:50 +02:00
Thomas Haller
2b8f3331d7 platform/trivial: move ethtool_supports_carrier_detect() code 2015-06-05 16:52:50 +02:00
Thomas Haller
77a3767d1e platform: move code udev_get_driver() to nmp_utils_udev_get_driver() 2015-06-05 16:52:50 +02:00
Thomas Haller
ce700d94f5 platform: add nm-platform-utils.[ch] files
There is no general purpose file for platform utilities.
We only have nm-platform.h, which contains (mostly) functions
that operate on a NMPlatform instance (and that can be mocked
using NMFakePlatform).

Add a new file for independent utility functions. nm-platform-utils.c
should not call into functions having a NMPlatform instance, to
have them independent from platform caching and the platform
singleton.
2015-06-05 16:52:50 +02:00
Thomas Haller
d7a312d17a platform: move nm_platform_query_devices() to nm-manager
nm_platform_query_devices() would raise an 'added' signal
for all its links. That is bad style because it could
confuse other listeners for platform signals which don't
expect such artificial change signals.

The public API of NMPlatform already gives NMManager the ability
to 'pull' all the links and iterate them itself.

Before, nm_platform_query_devices() would also initialize udev
devices, so there was a more compelling reason for this function.
2015-06-05 16:52:50 +02:00
Thomas Haller
d6ce01f115 platform: merge setup_devices() function into constructed()
We already populate the netlink cache in constructed(). No need
to wait with udev devices until nm_platform_query_devices(). Just
do it right away.

Add a hack to keep 'lo' default-unmanaged. Now that we load
udev devices earlier, we end up clearing the default-unmanged
flag on 'lo', which has bad consequences.
2015-06-05 16:52:49 +02:00
Lubomir Rintel
ed01c975d8 tests: use a user ns to fake root 2015-06-05 16:52:49 +02:00
Lubomir Rintel
f9dd7f0d84 tests: allow running the link test without a writeable sysfs
This fixes the test run in a container/our NETNS/NEWUSER test jail.
2015-06-05 16:52:49 +02:00
Thomas Haller
39f2b51abb core: add option to suppress error logging if nm_utils_modprobe() fails
We don't want error logging for nm_platform_link_add() which
tries to load the bonding module. Later we will run tests as non-root,
where modprobe will fail. Logging an error would break the tests.
2015-06-05 16:52:49 +02:00
Lubomir Rintel
ce2ea51ed0 Revert "core: avoid loading GIO modules"
This reverts commit 6a841c0cd1.

We do actually need the modules for connectivity checking.
2015-06-05 16:04:27 +02:00
Thomas Haller
f3c61f8141 device: remove reading ipv6 privacy setting from sysctl
Since introduction for support of ip6-privacy (use_tempaddr,
RFC4941) with commit d376270bfe,
the sysctl value from /etc was always read first.

This is problematic, because an explicit setting in the
connection should not be ignored over a global configuration.

Drop that old behavior. It was also problematic, because we did
not read any files under /etc/sysctl.d (except for sysctl.conf).
Also, we did not honor per-interface configurations.

Now we also use as last fallback the value from
/proc/sys/net/ipv6/conf/default/use_tempaddr
That has the advantage of falling back to the system default value
so that NM doesn't need to have it's own default policy
(Related: https://bugzilla.redhat.com/show_bug.cgi?id=1187525).

This is a change in behavior.
2015-06-05 12:38:30 +02:00
Thomas Haller
e729dd70ae device: add global configuration default for ip6-privacy (use_tempaddr, RFC4941)
Support default value for setting 'ipv6.ip6-privacy' in
NetworkManager.conf.

If the global value is unset, preserve old behavior of looking into
/etc/sycctl.conf first. That behavior was introduced with commit
d376270bfe, since we support ip6-privacy
setting.

If the global value is set to "unknown", add a new fallback
that instead reads the runtime value from
  "/proc/sys/net/ipv6/conf/default/use_tempaddr"
This seems more sensible behavior because we fallback to sysctl,
but instead of looking at static files in /etc, read /proc.
But to preserve the old behavior, we only do that when a global
value is configured at all.

https://bugzilla.gnome.org/show_bug.cgi?id=721200
2015-06-05 12:38:30 +02:00
Thomas Haller
59a991725a device: make route-metric configurable per-device
The route-metric can be configured per connection via the
ipv4.route-metric and ipv6.route-metric fields. When the
value is left at -1 (the default), we would determine the
route-metric based on the device type (nm_device_get_priority()).

Extend that scheme by making the default value overwritable in
NetworkManager.conf.
2015-06-05 12:38:30 +02:00
Thomas Haller
dc0193ac02 config: support a [connection] section to NetworkManager.conf to specify connection defaults
Add support for a new section [connection] in NetworkManager.conf.
If the connection leaves an option at "unknown"/"default", we can
support overwriting the value from global configuration.

We also support other sections that are named with "connection"
as a prefix, such as [connection2], [connection-wifi]. This is
to support multiple default values that can be applied depending
on the used device.

I think this has great potential. Only downside is that when
the user looks at a connection value, it will see that it is
unspecified. But the actually used value depends on the device
type and might not be obvious.

https://bugzilla.gnome.org/show_bug.cgi?id=695383
https://bugzilla.redhat.com/show_bug.cgi?id=1164677
2015-06-05 12:38:29 +02:00
Thomas Haller
f031b926c4 config: publish nm_config_keyfile_get_boolean() utility function 2015-06-05 12:38:29 +02:00
Thomas Haller
3fb60edf9f device: add device-spec "type:"
Support a device-spec to match by device-type.
This matches on the value as shown by

  nmcli -f GENERAL.TYPE device show
2015-06-05 12:38:29 +02:00
Thomas Haller
e9e9d44468 device: add nm_device_get_type_description() function
Add a function to get a concise representation of the
device type.

libnm already has nm_device_get_type_description() for that
and it is shown by

  nmcli -f GENERAL.TYPE device show

Reimplement that function for nm-core. Just take care that the
two implementations don't diverge.
2015-06-05 12:38:29 +02:00
Thomas Haller
51b1fd976f ifcfg-rh: distinguish in reader and writer between unset and empty dns-options 2015-06-05 12:26:48 +02:00
Thomas Haller
a8dd1b5358 libnm: make dns-options support an "undefined" default value
We want to distinguish between "no-options/empty" and "unset/default".
The latter can be interpreted by NM to use a default set of options.
2015-06-05 12:26:48 +02:00
Thomas Haller
0348bc9195 ifcfg-rh: add svSetValueFull() to support writing empty values
svSetValue() treated the empty word like %NULL.
Handle empty differently from unset.
2015-06-05 12:26:48 +02:00
Thomas Haller
51255d8b64 ifcfg-rh: fix svSetValue() to properly handle empty variables
svSetValue() called svGetValue() which would return %NULL
for empty variables. That is wrong, because it caused svSetValue()
to add the variable anew.
2015-06-05 12:26:48 +02:00
Thomas Haller
c6efbeccf3 ifcfg-rh: use svGetValueFull() in svGetValueInt64()
Previously, it would silently accept a value set to "empty".
This is however not a valid number and we should raise a
warning just like for any other invalid number.
2015-06-05 12:26:48 +02:00
Thomas Haller
33aaa730c5 ifcfg-rh: add svGetValueFull() function 2015-06-05 12:26:48 +02:00
Thomas Haller
32871deecc ifcfg-rh: refactor svSetValue() and svEscape() not to clone string needlessly
In the most cases we don't expect that our values need
escaping. No need to do an additional copy of the unmodified
string.
2015-06-05 12:26:48 +02:00
Thomas Haller
bc75cd53a8 core: detect route-metric when creating nm-generated-assumed connection
When generating a connection to assume it, also record the route-metric.
Do that by looking at the metric of the (best) default-route.

This is especially important since d51975ed92.
Now NM would also manage the default-route for assumed connections.
So the generated assumed connection would have a route metric based on
the device type, which might differ from the external configuration.
This caused NM to replace the externally configured default-route.

https://bugzilla.gnome.org/show_bug.cgi?id=750405
2015-06-05 11:08:03 +02:00
Thomas Haller
ca3fb3edcd trival: add code comment 2015-06-04 17:48:34 +02:00
Lubomir Rintel
6a841c0cd1 core: avoid loading GIO modules
Turns out the dconf modules is leaky and breaks the valgrind run. In any case,
it's not a good idea to load the modules for the daemon, it just takes time
and memory.

On a Fedora/x86_64 desktop it adds up to 5M to the RSS.
2015-06-04 14:29:10 +02:00
Beniamino Galvani
3bc097b084 device: don't assume by default IPv6LL-only connections
Add the new configuration option 'assume-ipv6ll-only' which specifies
the devices for which NM will try to assume an existing IPv6LL-only
configuration.

The new default behavior is to ignore such configurations since IPv6LL
addresses are automatically assigned by the kernel when the device is
brought up and thus the presence of an IPv6LL address doesn't mean
that the device was configured by the administrator.

The previous behavior was to always assume IPv6LL-only configurations
but this often had the unwanted effect of preventing other on-disk
configurations to be activated. To preserve the old behavior the
option must be set to '*'.

https://bugzilla.redhat.com/show_bug.cgi?id=1138426
2015-06-02 14:04:54 +02:00
Thomas Haller
0aed4e2388 ifcfg-rh: better detect alias files
Alias files have a ':' to separate the base name from their
alias. But we didn't always ensure not to write-out files without
colon, and also initscripts doesn't have that restriction.

We should detect alias files and handle them properly (e.g. by
reloading the base file).

This fixes an error that a `nmcli con load` would have tried to
load the alias file. Also extend load_connection() to support
passing filenames other then the base file.

We only have to handle this in plugin.c. Inside reader.c we always
have the normalized base filename.

Or detection of alias files only looks whether the filename has a ':'
and whether a corresponding base file exists.
2015-06-02 12:57:52 +02:00
Thomas Haller
2e87df8408 ifcfg-rh: escape colon in generated filename
A colon indicates an alias file. It should be escaped.
2015-06-02 12:57:52 +02:00
Thomas Haller
8be9e832b5 ifcfg-rh: refactor utils_should_ignore_file() to return early 2015-06-02 12:57:52 +02:00
Thomas Haller
4ef8c0c90c ifcfg-rh: also read alias file for dhcp connections
Previously, if the main ifcfg file doesn't define any
static ip addresses, any alias files would be ignored.

We should also allow alias files with (pure) 'dhcp' connections,
just like initscripts do.

Reported-by: Marek Hulan <mhulan@redhat.com>
2015-06-02 12:57:52 +02:00
Thomas Haller
900aa016b1 ifcfg-rh: log warning when loading of connection fails
connection_from_file() used to log a warning about failure,
but only when an @error argument was given.

update_connection() didn't ensure that in several cases,
so we would not log any failure reason when an ifcfg file
failed to read.

This behavior of controlling logging by passing @error (or not)
is unexpected. Instead, refactor the code so that the caller
can do appropriate logging.
Another reason for this refactoring is that PARSE_WARNING() does
not mention the file for which the failure is and uses some extra
indention that looks wrong. IOW, connection_from_file() doesn't
have the context to give the logging line a proper formatting.
2015-06-02 12:57:52 +02:00
Lubomir Rintel
3811a68389 systemd-dhcp: fix build with Linux 3.2.0 headers
Fixes build on Ubuntu 12.04.

systemd/src/libsystemd-network/dhcp-network.c: In function '_bind_raw_socket':
systemd/src/libsystemd-network/dhcp-network.c:75:17: error: 'BPF_XOR' undeclared (first use in this function)
systemd/src/libsystemd-network/dhcp-network.c:75:17: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [libsystemd_nm_la-dhcp-network.lo] Error 1
2015-06-02 12:30:03 +02:00
Lubomir Rintel
22b99e3bbb ppp-manager: fix build with Linux 3.2.0 headers
Fixes build with Ubuntu 12.04.

In file included from ppp-manager/nm-ppp-manager.c:42:0:
/usr/include/linux/if_ppp.h:103:16: error: field 'b' has incomplete type
/usr/include/linux/if_ppp.h:108:21: error: field 'b' has incomplete type
2015-06-02 12:30:03 +02:00
Lubomir Rintel
eb2b8c2798 build: use compat version of g_clear_pointer()
Ubuntu 12.04 has an ancient version of glib, which we nevertheless support.
2015-06-02 12:30:03 +02:00
Lubomir Rintel
36f7669a4c core: don't assume the loopback interface is called "lo"
I did a "ip link set lo name yolo" and now my NetworkManager triggers an
assertion failure. :( Nevertheless, the loopback interface is always ifindex=1.
2015-06-01 17:30:24 +00:00
Lubomir Rintel
ef295ddeef platform-linux: allow netlink messages from non-privileged user namespaces
Just check they're from kernel.
2015-06-01 17:30:20 +00:00
Thomas Haller
b8b1a01d96 build: rename file "include/nm-utils-internal.h" to "nm-macros-internal.h"
We already have "nm-utils*.h" and "NetworkManagerUtils.h" headers. Rename
"include/nm-utils-internal.h" to "nm-macros-internal.h". I think that
name is better, because this file is header-only, internal, and
repository-wide.

Also, it will never contain non-header-only declarations because
there is no backing object file under "include/".
It will only contain macros and inline functions.
2015-06-01 14:47:08 +02:00