Commit graph

11557 commits

Author SHA1 Message Date
Thomas Haller
fd10ed1e71 test: log message at g_test_assert_expected_messages()
When disabling assert-logging with no-expect-message,
print a line at every g_test_assert_expected_messages()
invocation.

(cherry picked from commit 373d09b042)
2015-04-10 18:30:24 +02:00
Thomas Haller
fec4e68f4d tests: check for no pending expected_messages on exit of tests
On the end of the test there should be no unchecked expected
messages. Register a destructor function in nmtst to assert
against that.

Also call nmtst_free() in the destructor. That way, we always release
the allocated data without requiring the test to do it explicitly.

(cherry picked from commit bb90127c2a)
2015-04-10 18:30:09 +02:00
Thomas Haller
0074bf032b test: add description of test behavior to nm-test-utils.h
(cherry picked from commit 745f2aceac)
2015-04-10 18:25:41 +02:00
Beniamino Galvani
d2e5e648d4 wifi: indicate 2ghz and 5ghz wifi device capabilities
Add new capabilities CAP_FREQ_2GHZ and CAP_FREQ_5GHZ to indicate the
frequency bands supported by a Wifi device.

Add also CAP_FREQ_VALID, which is set when the values of the other 2
capabilities are available.

Original patch by Dan Williams <dcbw@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723295
(cherry picked from commit aabc6fc57b)
2015-04-09 09:20:48 -05:00
Thomas Haller
06e8841d9d default-route-manager: cleanup logging macros
(cherry picked from commit 3179b45412)
2015-04-09 11:21:08 +02:00
Thomas Haller
7916dc0f4a default-route-manager: use NMPlatformVTableRoute
(cherry picked from commit 110200d5d4)
2015-04-09 11:21:08 +02:00
Thomas Haller
1ff6f6c304 platform: add VTable to handle IPv4 and IPv6 routes generically
(cherry picked from commit 290faa003d)
2015-04-09 11:21:08 +02:00
Thomas Haller
897ac18bbb test: add option in nmtst_platform_ip4_routes_equal() to ignore ordering
Same for nmtst_platform_ip6_routes_equal().

It's useful to check for equal routes ignoring the ordering.

(cherry picked from commit 57453189e0)

Conflicts:
	src/tests/test-route-manager.c
2015-04-09 11:21:08 +02:00
Thomas Haller
d0172aa4d6 platform/test: use g_print() in platform tests to indicate skip/fail
Don't use g_message() in platform tests for test messages.

This is a partial backport of commit 5fd3827,
  "route-manager/test: fix usage of g_assert_expect_message()"

(cherry picked from commit 5fd3827e49)
2015-04-09 11:21:03 +02:00
Thomas Haller
3b014ddef8 platform/test: split initialization of platform tests out
test-route-manager soon wants a different initialization

(cherry picked from commit 24288f713a)
2015-04-09 08:22:28 +02:00
Thomas Haller
643d412688 test: setup logging during nmtst_init_assert_logging()
Before, when having a test with nmtst_init_assert_logging(),
the caller was expected to setup logging separately according
to the log level that the test asserts against.

Since 5e74891b58, the logging
level can be reset via NMTST_DEBUG also for tests that
assert logging. In this case, it would be useful, if the test
would not overwrite the logging level that is set externally
via NMTST_DEBUG.

Instead, let the test pass the logging configuration to
nmtst_init_assert_logging(), and nmtst will setup logging
-- either according to NMTST_DEBUG or as passed in.

This way, setting the log level works also for no-expect-message
tests:

  NMTST_DEBUG="debug,no-expect-message,log-level=TRACE" $TEST

(cherry picked from commit b6d3b98655)
2015-04-09 08:22:28 +02:00
Thomas Haller
8eefbce9fa platform: don't write debug message to stderr
Use nm-logging instead.

(cherry picked from commit 07f95c371c)
2015-04-09 08:22:28 +02:00
Thomas Haller
c0534e9a6d test: fix enabling DEBUG logging for tests
For glog messages to print any debug messages, we must set G_MESSAGES_DEBUG.
nmtst does this for us if we set @is_debug. But fix the condition to
also set G_MESSAGES_DEBUG if set set c_log_level to DEBUG or TRACE.

(cherry picked from commit 3abeb7f2b9)
2015-04-09 08:22:28 +02:00
Thomas Haller
ad5159156a test: fix parsing of NMTST_SEED_RAND
(cherry picked from commit 0a2c0d12e8)
2015-04-09 08:22:28 +02:00
Thomas Haller
ba43bfc0b7 test: change message about random seed in nmtst
Make it clear, that you can overwrite the seed by setting the
environment variable NMTST_SEED_RAND.

(cherry picked from commit 44a963c894)
2015-04-09 08:22:28 +02:00
Lubomir Rintel
a34961ec70 build: fix clang + glib 2.43 build
Known glib issue. Fixes Fedora 22 build.

(cherry picked from commit 5206a9b28d)
2015-04-09 08:19:47 +02:00
Lubomir Rintel
474ac6c528 build: disable warnings that trigger known clang problems
Fixes build with clang 3.5 on Fedora 21.

(cherry picked from commit f0740aff88)
2015-04-09 08:19:47 +02:00
Lubomir Rintel
53b51b307f build: disable warnings where macros expand to tautological comparisons
(cherry picked from commit 3ccc6f290d)
2015-04-09 08:19:47 +02:00
Dan Winship
2b08803a2e libnm-core: fix VPN error domain (bgo #745997)
In theory, NM_VPN_PLUGIN_ERROR should have names under
org.freedesktop.NetworkManager.VPN.Plugin, but for historical reasons,
it's actually org.freedesktop.NetworkManager.VPN.Error.

(cherry picked from commit 773f047eef)
2015-04-07 12:53:34 -04:00
Dan Williams
4f4e570a7d team: respawn teamd instead of exiting (rh #1145988) (bgo #745903) 2015-04-02 15:03:25 -05:00
Dan Williams
7ad0e83b4a team: ratelimit teamd spawning 2015-04-02 15:00:39 -05:00
Dan Williams
57c3e8fd25 team: respawn teamd when it exits instead of failing activation (rh #1145988)
teamd can recover interface state on its own, so if it died unexpectedly
we don't need to fail the device.  Also, if for some reason a teamd is
already up and running when activating the interface, we can ask for
its configuration and if it has the same configuration we are about to
use, just talk to the existing copy instead of killing it.
2015-04-02 14:59:59 -05:00
Bernd Edlinger
4903c127e1 wifi: clear WPAS_REMOVED_TAG when scanning Wi-Fi AP
(cherry picked from commit 47c505523c72b6454dec4681c0edda535c3a2e91)
(cherry picked from commit 1282b468bd)

https://bugzilla.gnome.org/show_bug.cgi?id=733105
2015-04-02 17:48:31 +02:00
Lubomir Rintel
c9910b35bd device: use UNMANAGED reason instead of REMOVED when unmanaging devices upon quit
Since f85513b (device: do not touch sysctls after the device was removed) the
device is not unconfigured/cleaned up when it's removed. When we're quitting
the device is not actually removed, we're just unmanaging it -- let's just
use a different reason so that the cleanup runs.

Fixes: f85513b8e4
(cherry picked from commit 0f71335d52)
2015-04-02 17:22:54 +02:00
Beniamino Galvani
398681e794 build: fix compile warnings in DNS manager
Fixes the following warnings in nm-dns-manager.c with NETCONFIG_PATH set:

  dns-manager/nm-dns-manager.c: In function 'dispatch_netconfig':
  dns-manager/nm-dns-manager.c:313:2: warning: implicit declaration of function 'waitpid' [-Wimplicit-function-declaration]
    ret = waitpid (pid, NULL, 0);
    ^
  dns-manager/nm-dns-manager.c:271:14: warning: unused variable 'tmp' [-Wunused-variable]
    char *str, *tmp;
                ^
  dns-manager/nm-dns-manager.c:329:13: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
    return ret > 0;
               ^
2015-04-01 16:01:26 +02:00
Beniamino Galvani
2dc4871af9 build: fix compile error in DNS manager
Fixes the following error in nm-dns-manager.c with NETCONFIG_PATH set:

  dns-manager/nm-dns-manager.c:320:4: error: too many arguments to function 'g_set_error_literal'
      g_set_error_literal (error,
2015-04-01 16:01:23 +02:00
Lubomir Rintel
216b28d7ff device: progress the device activation if it has a valid assumed connection
If we detect a LL address and this not decide to readd it, don't stop at
ip-config; progress to ip-check.

Fixes: 396dc2b3b4
(cherry picked from commit dc1928a0d0)
2015-04-01 15:00:01 +02:00
Dan Williams
c08144a3d6 merge: respawn DNS plugin children if they quit unexpectedly (bgo #728342) 2015-03-27 17:00:01 -05:00
Dan Williams
fc7913b308 dns: refresh DNS if plugin child quits unexpectedly (bgo #728342)
If the child dies, or something kills the child externally, refresh
DNS which should respawn the child, similar to what we do with
wpa_supplicant, teamd, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=728342
2015-03-27 16:59:27 -05:00
Dan Williams
ba593c9d9d dns: ensure that update_dns() always returns a GError on failure
Callers may expect this, so make sure we do it.
2015-03-27 16:41:09 -05:00
Dan Williams
74b712ca5d dns: refactor building IP config lists for plugins (bgo #728342)
Don't bother building the lists if no DNS plugins are enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=728342
2015-03-27 16:20:55 -05:00
Dan Williams
10aff12526 dns: kill plugin child synchronously to avoid restart race (rh #1161232) (bgo #728342)
NM was killing the dnsmasq local caching nameserver process and immediately
starting a new one, and new process couldn't bind to 127.0.0.1 because the
old one hadn't quit yet.  Thus the new process quit, and the user was
left with no split DNS at all.

While this does introduce more synchronous waiting into the connection
process, it's not that much time and NM will kill dnsmasq if it hasn't
quit after 1 second.  The longer-term fix is to use dnsmasq's D-Bus
interface to update DNS without respawning it.

https://bugzilla.gnome.org/show_bug.cgi?id=728342
https://bugzilla.redhat.com/show_bug.cgi?id=1161232
2015-03-27 16:20:55 -05:00
Dan Williams
4df69a5576 merge: use dev_id when constructing interface identifiers (rh #1101809)
Some devices (s390 and ipvlan) use the same MAC address for
different interfaces, but dev_id differentiates them.  So we
must use dev_id to avoid IID conflicts.

https://bugzilla.redhat.com/show_bug.cgi?id=1101809
2015-03-27 15:26:33 -05:00
Dan Williams
c4b9f397c8 core: use dev_id when calculating the interface IPv6 IID (rh #1101809)
Some device types (s390 OSA and ipvlan) can use the same link-layer address
for multiple virtual interfaces, and the kernel used the dev_id property
to differentiate these devices when constructing the IID.  NM should do
this too to prevent IID clashes.

https://bugzilla.redhat.com/show_bug.cgi?id=1101809
2015-03-27 15:24:49 -05:00
Dan Williams
51fd5a9bd7 platform: add nm_platform_link_get_dev_id()
Some devices (s390 OSA and ipvlan) use the same link layer address
for different interfaces, and dev_id is what differentiates them.
2015-03-27 15:24:48 -05:00
Dan Williams
f3902ca423 platform: update code documentation for nm_platform_link_get_physical_port_id() 2015-03-27 15:18:03 -05:00
Jiří Klimeš
cd5c9043fa libnm-util: allow 0.0.0.0/1 route in verify() (rh #1203904)
OpenVPN uses a trick to override default route by adding these two routes:
0.0.0.0/1 and 128.0.0.0/1.
We should allow this and only refuse real default route (i.e. prefix == 0).

Also verify IPv6 addresses and routes.

See:
man openvpn (search for def1)
https://community.openvpn.net/openvpn/wiki/IgnoreRedirectGateway

https://bugzilla.redhat.com/show_bug.cgi?id=1203904

(cherry picked from commit ba35c63db6)
2015-03-24 12:27:02 +01:00
Thomas Haller
9fa5e9af58 libnm/keyfile: sort keyfile entries and nm_connection_for_each_setting_value()
Fix the order for keyfile writer. It is nicer to have a fixed, sensible
order with [connection] first.

Do this by sorting the order in nm_connection_for_each_setting_value()
and nm_setting_enumerate_values().

This is a partial backport of merge 89c88f2480

https://mail.gnome.org/archives/networkmanager-list/2015-March/msg00050.html
2015-03-20 13:35:50 +01:00
Thomas Haller
dbcb88517a libnm: sort properties for nm_setting_enumerate_values()
The sort order of nm_setting_enumerate_values() affects the
order in which keyfile writer serializes the properties.

Have a defined, stable sort order by sorting the properties
by name (with prefering id,uuid,type for NMSettingConnection).

(cherry picked from commit 58f08c8c9c)
2015-03-20 13:34:44 +01:00
Thomas Haller
0a7af4f69b libnm: sort settings for nm_connection_for_each_setting_value()
nm_connection_for_each_setting_value() is used by keyfile writer to iterate
over the settings and write the keyfile entires. The order there is important
as g_key_file_to_data() prints the groups in the order they were created.

To have a stable order and to have the [connection] entry first, sort the
settings.

(cherry picked from commit e50fbe466b)
2015-03-20 13:33:15 +01:00
Thomas Haller
6c63fe5028 test: fix printing error in nmtst_assert_connection_equals()
(cherry picked from commit 3790d8db2e)
2015-03-20 13:32:32 +01:00
Thomas Haller
669a8484c6 test: fix __NMTST_LOG() macro to allow format-string-only argument
We want to be able to call __NMTST_LOG(g_message, "hallo"); without
additional format string arguments.

(cherry picked from commit 94cc7ca4f8)
2015-03-20 13:32:29 +01:00
Thomas Haller
844a9c0dcd libnm: merge branch 'th/wep-key-bgo745890'
Don't verify() secrets.

https://bugzilla.gnome.org/show_bug.cgi?id=745890

(cherry picked from commit 3ef2a5364b)
2015-03-20 13:07:42 +01:00
Thomas Haller
4cc06783ab libnm: accept unknown WEP key type in nm_utils_wep_key_valid()
libnm-core treated the UNKNOWN WEP key type as KEY. Relax that
and try to guess the correct type based on the key.

This is for example important if you have a valid connection with
  wep-key-type=0 (unknown)
If you request passwords for such a connection, the user cannot
enter them in password format -- but there is no UI indication
that the password must be KEY.

(cherry picked from commit 628f47285d)
2015-03-20 13:07:10 +01:00
Thomas Haller
1bbe6c1c51 libnm: don't check for valid passwords in NMSetting:verify()
We must never fail verification of a connection based on a password
because the password is re-requested during activation.

Otherwise, if the user enters an invalid password for a (previously)
valid connection, the connection becomes invalid. NetworkManager does
not expect or handle that requesting password can make a connection
invalid.
Invalid passwords should be treated as wrong passwords. Only a UI
(such as nm-connection-editor or nmcli) should validate passwords
against a certain scheme.

Note that there is need_secrets() which on the contrary must check for
valid passwords.

Error scenario:

  Connect to a WEP Wi-Fi, via `nmcli device wifi connect SSID`. The
  generated connection has wep-key-type=0 (UNKNOWN) and wep-key-flags=0.
  When trying to connect, NM will ask for secrets and set the wep-key0
  field. After that, verification can fail (e.g. if the password is longer
  then 64 chars).

(cherry picked from commit dbbedce21f)
2015-03-20 13:07:10 +01:00
Thomas Haller
2d20640967 libgsystem: update copy of gsystem-local-alloc.h
Taken from libgsystem:src/gsystem-local-alloc.c
(commit ad3a28c5f2520d0688730aa83eaee815fb9a5762).

(cherry picked from commit 0429ed85ad)
2015-03-20 12:53:26 +01:00
Thomas Haller
3ac59b84c5 core: merge branch 'th/main-order-bgo746254'
Some refactoring of the main() functions for NetworkManager and
nm-iface-helper. Most notably, start the D-Bus service earlier so
that NetworkManager starts faster.

https://bugzilla.gnome.org/show_bug.cgi?id=746254

(cherry picked from commit 6ce7b7df96)
2015-03-20 12:51:48 +01:00
Thomas Haller
e860c0e4ea main: (order) early start D-Bus service
systemd considers the startup time of NetworkManager until the D-Bus
service is claimed. By doing that earlier, this time is significantly
reduced.
This has the advantage, that services that are ordered to start
after NetworkManager can start earlier. Most notably, 'network.target'
orders itself After=NetworkManager.service and many services are ordered
After=network.target.

  $ systemd-analyze blame | grep NetworkManager.service

(cherry picked from commit 21562052ec)

Conflicts:
	src/main.c
2015-03-20 12:47:09 +01:00
Thomas Haller
b24d44cb2d main: (order) move run_from_build_dir check before setting up logging
Or: move setup of nm-logging immediately after it is really needed:
before setup of config.

(cherry picked from commit 7fe0f349ce)
2015-03-20 12:43:31 +01:00
Thomas Haller
06d038cd58 main: (order) earlier create rundir
Create the rundir earlier and before setting up nm-logging.
nm_main_utils_ensure_rundir() errors out with fprintf(stderr)
and does not need nm-logging.

(cherry picked from commit 49cfe64874)
2015-03-20 12:43:31 +01:00