Commit graph

9736 commits

Author SHA1 Message Date
Dan Winship
f229f4e201 core: re-attempt connection assumption when the device state changes
If the initial attempt to assume a connection on a device fails, and
the device remains un-activated, but then something changes its
configuration externally, try to generate a new connection and assume
that.
2014-06-06 10:11:19 -04:00
Dan Winship
a9a25973cc devices: update generated connections when the underlying IP config changes
If the IP config changes on a device that has assumed a generated
connection, then update the connection's NMSettingIP4Config /
NMSettingIP6Config, under the assumption that the configuration of
that device was in progress but incomplete when NM first observed it.
2014-06-06 10:11:19 -04:00
Dan Winship
14048089a1 settings: add 'nm_generated' flag on NMSettingsConnection
Add 'nm_generated' flag on NMSettingsConnection, and have NMManager
set it on generated connections that it assumes.
2014-06-06 10:11:19 -04:00
Dan Winship
6fd76323e0 core: tweak NMSettingIP[46]Config generation
NMIP4Config and NMIP6Config had methods to update an existing
NMSetting. However, the functions would really only work correctly if
the passed-in setting was empty.

Change them from "update_setting" to "create_setting", and have them
create the NMSetting themselves, and update NMDevice for that.

(If we need update_setting later, we can add it, after figuring out
exactly how it's actually supposed to work.)
2014-06-06 09:57:04 -04:00
Jiří Klimeš
dae8391436 cli: switch to the new-style readline typedefs (bgo #731294)
The old Function, CPFunction, CPPFunction and VFunction typedefs are
considered deprecated starting from readline 4.2 (though were not marked
as such): http://lists.gnu.org/archive/html/bug-bash/2000-10/msg00078.html
Compatibility typedefs have been in place up to readline 6.2 but were
removed with the 6.3 release thus causing build to break.
http://lists.gnu.org/archive/html/bug-readline/2014-04/msg00018.html

https://bugzilla.gnome.org/show_bug.cgi?id=731294
2014-06-06 11:34:23 +02:00
Thomas Haller
37aeee5f71 platform: merge branch 'th/bgo706293_platform_tests'
https://bugzilla.gnome.org/show_bug.cgi?id=706293

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:13:26 +02:00
Thomas Haller
48b5ba7cea nmtst: add NMTST_DEBUG=no-expect-message for debugging assert_message tests
Some tests want to assert against the messages logged using g_test_expect_message().
In this mode, nmtst will not log anything itself.

Interpret the option no-expect-message which turns g_test_expect_message()
into a NOP and turns logging on. The use of this is for debugging such
tests, without asserting against the messages but printing them instead.

For tests that are not in the assert_message mode, the option has no
effect.

Example:
  NMTST_DEBUG=debug,no-expect-message make -C src/settings/plugins/keyfile/tests/ check

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
9114794f65 nmtst: turn on g_debug() messages in nmtst_init() when debug logging is enabled
In tests nm-logging will directly write using g_log. Also, non-core components
use g_log() for logging. glib will not print messages with level
G_LOG_LEVEL_INFO or G_LOG_LEVEL_DEBUG unless G_MESSAGES_DEBUG is set.

When the user specifies NMTST_DEBUG turning on 'debug' or
'log-level=DEBUG' it can be reasonably assumed that he wants to see
debug messages. nmtst_init() now sets G_MESSAGES_DEBUG=all.

The user can disable this behaviour, by setting instead G_MESSAGES_DEBUG='',
because nmtst_init() will not reset an existing G_MESSAGES_DEBUG.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
8ce1eb3837 nmtst: add new mode where tests assert against logged messages (assert_messages)
In this mode, nmtst itself will not log anything and not set the logging
level. Also, it will set g_log_set_always_fatal().

This is for tests that want to assert against all logged messages via
g_test_expect_message().

In this mode also setting the logging level via NMTST_DEBUG variable has
no effect. The test is expected to manage the logging level itself and
changing the logging level might interfere with the test.

As a showcase, move keyfile/tests/test-keyfile.c to nmtst.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
ae863a6954 platform/test: allow running root tests as sudo
Call to nmtst_reexec_sudo(), which allows you to specify a program
via environment variable to exec the test.

This is useful to exec the test program with sudo.

  NMTST_DEBUG="no-debug,sudo-cmd=$PWD/tools/test-sudo-wrapper.sh" make -C src/platform/tests/ check

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
e3784fa618 platform/test: always run linux platform tests (will be skipped as non-root)
Always run the linux platform tests, even if called as non-root user.
In such a case, print a message and return 77 (signalizing that the test
was skipped).

Only if we configured with --enable-test=root, we enforce that the
user executes the tests as root.

Co-Authored-By: Pavel Šimerda <psimerda@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
0fde65a14e platform/test: workaround team bug in older kernel version
In older versions of team (e.g. Fedora 17), the master team device
stays up, even if no slaves are IFF_LOWER_UP. Workaround this bug.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller
1ff6e1b65e platform/test: fix expecting NM_PLATFORM_SOURCE_KERNEL in platform tests
In this case, the fake platform implementation was wrong in that it did
not set the source property of the route/address objects like linux
platform does. Fix the test and the fake platform.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Pavel Šimerda
fd41c989d5 platform: fix software device handling when announcing links
The handling for announcing links was broken resulting in
duplicate link-added signals from platform.

Co-Authored-By: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Pavel Šimerda
f008c9fbea platform/test: fix fake platform to emit signals synchronously (analog to Linux platform)
When adding a link, the Linux platform implementation raises the
link-changed signal synchronously. Fix the fake platform to behave identically
and also fix all the tests.

This also fixes the Linux platform tests for the most part because now the
test functions (and fake platform) behave like the Linux system
implementation.

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

Co-Authored-By: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Pavel Šimerda
accd10b501 platform/test: disable bonding tests if no bonding module is available
Co-Authored-By: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
79a99613c2 platform/test: use nm-test-utils.h in test-common
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
66e2e932b5 platform: add nm_platform_link_get()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
ed868a388b core: add compatibility wrapper for g_test_skip() to nm-glib-compat.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
284ef00d16 nmtst: call nm_utils_init() in nmtst_init()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
5d3bef5d3f nmtst: add nmtst_spawn_sync()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
7a7dd9203d nmtst: add nmtst_reexec_sudo() function
Interpret environment variable NMTST_DEBUG which allows
to specify 'sudo-cmd=CMD'. If the test program calls
nmtst_reexec_sudo(), it will `exec CMD "$0" "$@"`.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
9df3a23d26 nmtst: add nmtst_free()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
8af001eae4 nmtst: combine files nm-test-helpers.h and nm-test-utils.h
Move the content of nm-test-helpers.h to nm-test-utils.h
which completly replaces the older file.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
0e9cd4f6fc nmtst: add functions nmtst_platform_ip[46]_routes_equal
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
be56b26c7d nmtst: add functions nmtst_static_SIZE_NUM() to create a copy of a string returned from an internal buffer
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
5a58afcec9 nmtst: add nmtst_is_debug() and interpret environment NMTST_DEBUG
Also enable "DEBUG" logging conditionally depending on is_debug().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
64d09e5afe nmtst: add nmtst_initialized()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
86693d2378 nmtst: add parameter to nmtst_init to setup nm-logging
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
17c300b816 nmtst: include missing header file glib-object.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
d29cd00d2b nmtst: return const address from nmtst_inet6_from_string()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
237ee05887 nmtst: make all test functions "inline static"
'inline' is needed to avoid compiler warnings about unused
functions.
Marking them only as 'inline' was simply wrong and leads to
linker errors when including the header in different translation
units.

By making them "inline static" we also don't need to foward declare the
function prototype to avoid another compiler warning.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
a268b825d7 nmtst: move header file to include/ directory
https://bugzilla.gnome.org/show_bug.cgi?id=706293

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
d2ac129d65 nmtst: g_type_init() has been deprecated in GLib 2.35.0
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller
cb023c57a7 platform: improve logging on error in delete_object()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:55 +02:00
Thomas Haller
a895b58484 platform: don't log error for delete_object() if IPv6 address doesn't exist
This causes root platform tests to fail on rhel-7

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:55 +02:00
Jiří Klimeš
8b41e6e2ea libnm-glib: fix double unref() when object creation fails 2014-06-05 18:11:29 +02:00
Thomas Haller
f53a35e030 Merge branch 'th/bgo728791_vpn_SetConfig'
https://bugzilla.gnome.org/show_bug.cgi?id=728791

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 20:36:17 +02:00
Thomas Haller
0abe095f5d vpn: cleanup receiving VPN parameters and check for GValue types
https://bugzilla.gnome.org/show_bug.cgi?id=728791

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 20:30:45 +02:00
Thomas Haller
41ced630fb libnm-glib: fix resetting IP config during additional SetConfig() calls
When receiving updated VPN IP configuration from the helper after the
initial connect event, the library overwrites the already initialized
GValue fields by calling g_value_init() again. This is an error and causes
the following warning:

   (nm-openvpn-service:27645): GLib-GObject-WARNING **: gvalue.c:183: cannot initialize GValue with type gchararray, the value has already been initialized as gchararray

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 20:17:22 +02:00
Dan Winship
53857a3ef7 core: add debug logging to nm_utils_match_connection()
Related: rh#1086237
2014-06-04 11:24:05 -04:00
Dan Winship
d47b749a75 libnm-utils: remove INFERRABLE flag from properties we don't actually infer
ipv4.never-default, ipv4.may-fail, and ipv6.privacy were marked
INFERRABLE, but NMIP4Config / NMIP6Config didn't actually infer them,
so they could cause connections to not match themselves after a
restart.

(Found while debugging https://bugzilla.redhat.com/show_bug.cgi?id=1086237,
though this is not actually the problem there.)

Related: rh#1086237
2014-06-04 11:23:54 -04:00
Thomas Haller
43e4b1b6f7 firewall: merge branch 'th/rh1103782_firewall_zone_conflict'
https://bugzilla.redhat.com/show_bug.cgi?id=1103782

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 15:07:13 +02:00
Thomas Haller
c29388bf02 firewall: fix ZONE_CONFLICT when adding firewall interface to zone
Firewalld call addInterface() fails with ZONE_CONFLICT if the interface
is already part of another zone. This complicates the code in NM,
because we would have to keep better track of the zone in which the
interface currently is. Which might be quite difficult because
the zone might be changed from an external program (so we would have
to monitor the firewall configuration and work around potential races).

A better and simpler fix is to simply always use the changeZone() call.
This will do the right thing, regardless if the interface is already part
of a zone or not.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 14:54:11 +02:00
Thomas Haller
c598336de8 firewall: fix ZONE_CONFLICT when removing interface from zone
The firewalld removeInterface call fails with ZONE_CONFLICT when
removing an interface from a wrong zone. This can happen, when the
connection gets modified, while being active (which is related to
bgo#724041).

By not specifying any zone, we remove the interface from the zone
where it currently is added. This behavior was introduced in upstream
firewalld with commit cc3101ab70a3997228be7bc9f45a069c7fccfa36, March 2012,
r0_2_3-1.
This is the behavior we actually want and we don't have to keep proper track
of the current zone.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 14:54:11 +02:00
Thomas Haller
3bc38ad531 firewall: extend logging to show id for async dbus calls in NMFirewallManager
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 14:54:09 +02:00
Thomas Haller
e3605ab924 firewall: refactor allocation of CBInfo data in NMFirewallManager
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 14:45:08 +02:00
Thomas Haller
dde731f0ad firewall: refactor reentrancy for dispose() in NMFirewallManager
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 14:45:08 +02:00
Thomas Haller
69dc3f96c5 contrib/build: require readline library for nmcli in NetworkManager.spec
This is needed since commit 13b10607d4.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 12:05:03 +02:00
Thomas Haller
3b3e33f8ec core/logging: initialize level_names array with explicit array initilizer (trivial)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-04 10:37:50 +02:00