Commit Graph

13873 Commits

Author SHA1 Message Date
Thomas Haller
acef8c6a1b contrib/rpm: let NetworkManager package own '/etc/NetworkManager/' directory 2015-06-08 17:48:33 +02:00
Thomas Haller
d38c3851f8 platform: merge branch 'th/platform_refact_caching-bgo747981' (early part)
- add new file 'nm-platform-utils.c' and moves some independent utility
  functions there (ethtool, udev).
- some refactoring of platform code, including initialization of
  NMPlatform instance.
- run platform tests in a separate user namespace, which allow
  us to run root-tests as non-root.

https://bugzilla.gnome.org/show_bug.cgi?id=747981
2015-06-05 16:54:06 +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
Thomas Haller
57958b93b6 utils: add NM_FLAGS_SET(), NM_FLAGS_UNSET() and NM_FLAGS_ASSIGN() macros 2015-06-05 16:52:49 +02:00
Thomas Haller
fe3e1849b7 core: make nm_assert() always compile condition
Even if asserts are not enabled, still let the compiler see what we would
assert. Otherwise, we get warnings about unused variables or we migth miss
compile errors inside nm_assert().
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
18ecf48d7a merge branch 'th/connection-defaults-bgo695383'
- support new [connection] section in NetworkManager.conf
- allow configuring a default value for ipvx.route-metric
- allow configuring a default value for ipv6.ip6-privacy
  and read the fallback configuration from sysctl.

https://bugzilla.gnome.org/show_bug.cgi?id=695383
https://bugzilla.gnome.org/show_bug.cgi?id=721200
https://bugzilla.redhat.com/show_bug.cgi?id=1187525
2015-06-05 12:52:52 +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
e4293788fc libnm/doc: document behavior of setting ip6-privacy in /etc/sysctl.conf
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
ec972ad305 merge branch 'th/default-dns-options-bgo749648'
- some enhancements and bugfixes to ifcfg-rh utils
- fix and refactoring nmcli value-to-string conversion
- add new default value for dns-options

https://bugzilla.gnome.org/show_bug.cgi?id=749648
2015-06-05 12:31:37 +02:00
Thomas Haller
230099aa52 cli: show dns-options default value
You can reset the default value via

  $ nmcli connection modify id CON ipv4.dns-options ""

and set an empty value with

  $ nmcli connection modify id CON ipv4.dns-options " "
2015-06-05 12:26:48 +02:00
Thomas Haller
f81d7242c3 cli: add DEFINE_GETTER_WITH_DEFAULT() macro 2015-06-05 12:26:48 +02:00
Thomas Haller
350900d0a5 cli: stack allocate search string in nmc_properties_find() 2015-06-05 12:26:48 +02:00
Thomas Haller
035e31327b cli: refactor nmc_add_prop_funcs() to use variadic macro
The advantage of this is that if we later add another function
pointer we don't have to touch any existing calls which would
only pass NULL to that argument.

Using a variadic argument and partial initialization of an
auto variable gives us that flexibility.
2015-06-05 12:26:48 +02:00
Thomas Haller
16f089ce64 cli: do not create a copy of static strings for nmc_properties hash
The keys of the hash are static strings. No need to make a copy of it.
If we ever need dynamics properties, we should intern those strings.
2015-06-05 12:26:48 +02:00
Thomas Haller
8a14851f93 cli: refactor property to string conversion
Instead of having a get_func() and out2in_func(), have only one
get_func() that accepts an argument of the output format.

This way, a conversion to parsable input format, doesn't have to go
first thourgh get_func() and mangle the pretty string in out2in_func().

This fixes conversions via nmc_property_out2in_cut_paren().
For example, nmc_property_802_1X_get_private_key_password_flags()
would return a localized string _("0 (none)"). There is no guarantee
that out2in_func() would find the expected output format after
localizing.

This also fixes nmc_property_out2in_routes() which expected
a format "dst =" (would be "ip =") and expects mandatory
'nh' and 'mt' arguments. In fact, the regex didn't match and
nmc_property_out2in_routes() always failed.

While at it, also combine the implementation of
nmc_property_ipv4_get_routes() and nmc_property_ipv6_get_routes().
2015-06-05 12:26:48 +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
d5e948e482 libnm/test: test compare_property() to handle default values
Add a test case to check whether compare/diff works correctly.
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
7478c4b54a libnm: fix compare_property() to handle default values
Before, get_property_for_dbus() would @ignore_defaults.
That is for example wrong for properties of type G_TYPE_STRV.

In this case, if one operand has the property at its default
(NULL) and the other has it to an empty string list, both would
compare equal.

This has the effect that different settings might compare equal.
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
2a5d17eb5f valgrind: rework run-test-valgrind.sh script not to print unrelated message
If the valgrind logfile is empty, don't log an error message with
the location of the logfile.

Also, if the test didn't fail due to memleaks, log a different message.
2015-06-04 17:48:34 +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