Commit graph

11880 commits

Author SHA1 Message Date
Thomas Haller
4e0af0aa52 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.

(cherry picked from commit d7a312d17a)
2015-06-19 12:26:02 +02:00
Thomas Haller
acb39d4b31 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.

(cherry picked from commit d6ce01f115)
2015-06-19 12:26:02 +02:00
Lubomir Rintel
cf0a0ed576 tests: use a user ns to fake root
(cherry picked from commit ed01c975d8)
2015-06-19 12:26:02 +02:00
Lubomir Rintel
a030ac36d3 tests: allow running the link test without a writeable sysfs
This fixes the test run in a container/our NETNS/NEWUSER test jail.

(cherry picked from commit f9dd7f0d84)
2015-06-19 12:26:02 +02:00
Thomas Haller
90eb13a111 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.

(cherry picked from commit 39f2b51abb)
2015-06-19 12:26:02 +02:00
Thomas Haller
baf5f63374 utils: add NM_FLAGS_SET(), NM_FLAGS_UNSET() and NM_FLAGS_ASSIGN() macros
(cherry picked from commit 57958b93b6)
2015-06-19 12:26:02 +02:00
Thomas Haller
1d3c143948 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.

(cherry picked from commit b8b1a01d96)
2015-06-19 12:21:58 +02:00
Thomas Haller
88bdeecf7c utils: move NM_FLAGS_*() macros to header file "include/nm-utils-internal.h"
(cherry picked from commit dce00f0d10)
2015-06-19 12:21:58 +02:00
Jiří Klimeš
b7b47941c0 merge: activate slaves when master is activated (bgo #735052) (rh #1158529)
When a master connection is activated, check all its slaves and decide whether
they should be activated as well. This is done according to the
connection.autoconnect-slaves property.

https://bugzilla.gnome.org/show_bug.cgi?id=735052
https://bugzilla.redhat.com/show_bug.cgi?id=1158529

(cherry-picked from b18f328967)
2015-06-19 12:19:18 +02:00
Jiří Klimeš
94337e58b7 man: mention that connection.autoconnect-slaves property supports default value
(cherry picked from commit f05d41d358)
2015-06-19 12:18:52 +02:00
Jiří Klimeš
5318aec2c2 core: activate slaves when master is activated (bgo #735052) (rh #1158529)
When a master connection is activated, check all its slaves and decide whether
they should be activated as well. This is done according to the
autoconnect-slaves property.

https://bugzilla.gnome.org/show_bug.cgi?id=735052
https://bugzilla.redhat.com/show_bug.cgi?id=1158529
(cherry picked from commit f4582d812c)
2015-06-19 12:18:52 +02:00
Jiří Klimeš
c8826630a3 cli: add support for connection.autoconnect-slaves property
(cherry picked from commit c3093d9391)
2015-06-19 12:18:52 +02:00
Jiří Klimeš
8aa0b5b17d ifcfg-rh: read/write autoconnect-slaves property as AUTOCONNECT_SLAVES
AUTOCONNECT_SLAVES is an NetworkManager extension. initscripts always activate
slaves with the master connection for bond and team, and doesn't activate
automatically slaves for bridge.
NetworkManager behaviour is controlled by this variable. If the variable is
missing the default value from configuration file is used.

(cherry picked from commit 2a497eeadc)
2015-06-19 12:18:52 +02:00
Jiří Klimeš
408b631673 libnm: add autoconnect-slaves property to NMSettingConnection
The property is used for controlling whether slaves should be brought up with
a master connection. If 0, activating the master will not activate slaves.
But if set to 1, activating the master will bring up slaves as well.
The property can have the third state (-1), meaning that the value is default.
That is either a value set in the configuration file for the property, or 0.

(cherry picked from commit 6caafab258)
2015-06-19 12:18:51 +02:00
Jiří Klimeš
2f51ba50df 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

(cherry-picked from commit 18ecf48d7a)
2015-06-19 12:15:12 +02:00
Thomas Haller
1468f4edd2 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.

(cherry picked from commit f3c61f8141)
2015-06-19 12:10:52 +02:00
Thomas Haller
a6630e4fad 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
(cherry picked from commit e729dd70ae)
2015-06-19 12:10:52 +02:00
Thomas Haller
905cf30b51 libnm/doc: document behavior of setting ip6-privacy in /etc/sysctl.conf
https://bugzilla.gnome.org/show_bug.cgi?id=721200
(cherry picked from commit e4293788fc)
2015-06-19 12:10:52 +02:00
Thomas Haller
923aa9d727 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.

(cherry picked from commit 59a991725a)
2015-06-19 12:10:52 +02:00
Thomas Haller
a64e81703e 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

(cherry picked from commit dc0193ac02)
2015-06-19 12:10:51 +02:00
Thomas Haller
a76deff2f6 config: publish nm_config_keyfile_get_boolean() utility function
(cherry picked from commit f031b926c4)
2015-06-19 12:10:51 +02:00
Thomas Haller
1429ef7249 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

(cherry picked from commit 3fb60edf9f)
2015-06-19 12:10:51 +02:00
Thomas Haller
ddfa354400 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.

(cherry picked from commit e9e9d44468)
2015-06-19 12:10:51 +02:00
Thomas Haller
517e9fa0f0 ibft: avoid logging multiple lines when ibft fails
In case of error, ibft prints an error message to stderr
with two trailing newlines. This causes multiple lines
in our logfile. Replace newlines in the error message
by whitespaces.

(cherry picked from commit 205c109741)
2015-06-19 12:05:50 +02:00
Thomas Haller
060f7a463e build: add compile option to disable building of Wi-Fi plugin
Before, the Wi-Fi plugin was always build. Users who didn't want
to use it would simply drop "libnm-device-plugin-wifi.so".

Add a compile time option to disable needlessly building the plugin.

https://bugzilla.gnome.org/show_bug.cgi?id=743388
(cherry picked from commit 5439fbd77c)
2015-06-19 12:05:50 +02:00
Thomas Haller
9d75928bf3 build,tests: refactoring tests using TAP driver and improve valgrind script 2015-06-19 11:53:53 +02:00
Thomas Haller
afb885300f 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.

(cherry picked from commit 2a5d17eb5f)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
a48d92d525 tests: delete the valgrind logs if they're empty
(cherry picked from commit df0676ab00)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
c2233f4484 tests: don't limit the valgrind tracebacks to 12 frames
The glib tracebacks are typically longer.

(cherry picked from commit d909e76d9e)
2015-06-19 11:52:50 +02:00
Thomas Haller
4fa342aefc valgrind: add comment to valgrind suppression explaining how to reproduce
(cherry picked from commit 0554474720)
2015-06-19 11:52:50 +02:00
Thomas Haller
dfa26cb007 valgrind: add valgrind suppression for Fedora 22
Fixes for example valgrind tests for ./libnm/tests/test-nm-client:

    ==25772== Conditional jump or move depends on uninitialised value(s)
    ==25772==    at 0x40198D8: index (strchr.S:106)
    ==25772==    by 0x400777C: expand_dynamic_string_token (dl-load.c:369)
    ==25772==    by 0x400777C: fillin_rpath (dl-load.c:439)
    ==25772==    by 0x4007FCF: _dl_init_paths (dl-load.c:816)
    ==25772==    by 0x4002F38: dl_main (rtld.c:1194)
    ==25772==    by 0x401750F: _dl_sysdep_start (dl-sysdep.c:249)
    ==25772==    by 0x4004C20: _dl_start_final (rtld.c:306)
    ==25772==    by 0x4004C20: _dl_start (rtld.c:412)
    ==25772==    by 0x4000C97: ??? (in /usr/lib64/ld-2.21.so)
    ==25772==    by 0x1: ???
    ==25772==    by 0xFFEFFF6B2: ???
    ==25772==    by 0xFFEFFF6EF: ???
    ==25772==
    {
       <insert_a_suppression_name_here>
       Memcheck:Cond
       fun:index
       fun:expand_dynamic_string_token
       fun:fillin_rpath
       fun:_dl_init_paths
       fun:dl_main
       fun:_dl_sysdep_start
       fun:_dl_start_final
       fun:_dl_start
       obj:/usr/lib64/ld-2.21.so
       obj:*
       obj:*
       obj:*
    }

(cherry picked from commit d84ac1baca)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
0f95b5c345 builds: only enable TAP driver for glib >= 2.37.6
No TAP support for previous versions and --tap argument is silently ignored,
confusing the TAP driver.

(cherry picked from commit c47c06470a)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
c099e9d43b tests: don't try to connect to the private socket
Even if we're running the tests as root we still want to use the mock
service instead of whatever version of daemon runs on the test host.

(cherry picked from commit 02e3d6c286)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
2829fadcc1 tests: be a bit more helpful when valgrind tests fail
(cherry picked from commit dd959087a2)
2015-06-19 11:52:50 +02:00
Thomas Haller
38b2331440 test: fix running valgrind tests with NMTST_NO_VALGRIND
Fixes: 6463ce5dd9
(cherry picked from commit ce3d1533cc)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
fe3e32c034 tests: use the TAP formatter
The test results in standard format are easily integrated into CI systems.

(cherry picked from commit 6463ce5dd9)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
df11b267fd build: switch to parallel test harness
This will make it possible to use the TAP formatter.

(cherry picked from commit 380ed63318)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
30d37abbc0 tests: call g_test_run() even when skipping the test
It will return the 77 exit code itself. For TAP output it will also generate
the proper test skip marker.

(cherry picked from commit 14f4674f64)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
0e20868f4f tests: always spawn private d-bus
Parallel test runs would not be possible without this.

(cherry picked from commit d0e25ac8be)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
62172a9a9e tests: move all asserts into tests
Otherwise the TAP formatter would produce a plan-less output.

(cherry picked from commit f627d6db8e)
2015-06-19 11:52:49 +02:00
Thomas Haller
483a019110 build: add --enable-more-logging configure option
NM core uses nm-logging which is entirely configurable at runtime.
Other components use glib-logging, which can also be partly configured
via G_MESSAGES_DEBUG.

It makes sense to have a compile time option to enable some
logging statements that are only useful for heavy debugging.

For glib-logging, this is a way to enable/disable extra logging.
For nm-logging, we could alternatively configure a least log-level
that is enabled at compile time (that way, we could configure to prune all
LOGL_TRACE logging). While that might be useful (too), this gives
an alternative way to disable/enable logging.

Add a configure option --enable-more-logging and a NM_MORE_LOGGING define
for that.

If we don't find this useful after a while, we can simply remove it,
because our logging statements are not part of a "stable" behavior.

(cherry picked from commit 63593a19d8)
2015-06-19 11:52:49 +02:00
Thomas Haller
b67fbe9561 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().

(cherry picked from commit fe3e1849b7)
2015-06-19 11:52:49 +02:00
Thomas Haller
63e30f5024 build: add --enable-more-asserts configure option and nm_assert() macro
NM already has two kinds of assertions:
 - g_assert*(), conditionally compiled via #ifndef G_DISABLE_ASSERT
 - g_return*(), conditionally compiled via #ifndef G_DISABLE_CHECKS

In theory, one should be able to disable both asserts and NM should
still work correctly (and possibly more efficient). In practice,
hardly anybody is testing such a configuration and it might be broken.
Especially, we don't disable asserts for production builds, both because
of less test coverage and because it might reduce our ability to debug.

Add a new configure option --enable-more-asserts, which defines
NM_MORE_ASSERTS and nm_assert(). This is for expensive asserts,
that -- contrary to the asserts above -- are disabled by default.
This is useful for extended debugging.

(cherry picked from commit 08ecafd2bf)
2015-06-19 11:52:49 +02:00
Thomas Haller
d1a865628b test: make valgrind suppressions file configurable
Add a configure option --with-valgrind-suppressions=path to allow
specifying a different suppressions file.

(cherry picked from commit 4c9a836774)
2015-06-19 11:52:49 +02:00
Dan Williams
98c310ea8b merge: replace usage of dbus-glib in supplicant code with GDBus (bgo #744598)
(cherry picked from commit 19c0de8b88)
2015-06-19 11:51:49 +02:00
Thomas Haller
274be6cf88 supplicant: remove unused variable
(cherry picked from commit 02130cc157)
2015-06-19 11:51:25 +02:00
Dan Williams
9db6d6ad42 supplicant: remove unused nm-call-store.c/.h
(cherry picked from commit 9adbc05e1b)
2015-06-19 11:51:25 +02:00
Dan Williams
0de28bd08b supplicant: convert interface/config to GDBus
(cherry picked from commit 59c8192b22)
2015-06-19 11:51:25 +02:00
Dan Williams
7ea33e5c92 supplicant: clean up some whitespace
(cherry picked from commit 47fe1b3196)
2015-06-19 11:51:25 +02:00
Dan Williams
7b9cc94e66 supplicant: make NMSupplicantInterface independent of NMSupplicantManager
The Interface held a reference to the manager to listen for the 'available'
signal.  Instead of that, let's make the child unaware of the master to
keep the inheritance cleaner.

(cherry picked from commit 7ed2d7a809)
2015-06-19 11:51:25 +02:00