Commit graph

12124 commits

Author SHA1 Message Date
Thomas Haller
db2fa9455d test: add nmtst_assert_resolve_relative_path_equals() function
(cherry picked from commit cbfa00219e)
2015-07-03 09:23:59 +02:00
Thomas Haller
f2b397acf2 build/trivial: cleanup Makefile.am by sorting EXTRA_DIST entries
(cherry picked from commit ad4e6f7fad)
2015-07-03 09:23:59 +02:00
Thomas Haller
d2b76543bf keyfile: merge branch 'th/keyfile-escape-file-bgo735824'
This changes behavior, in that we now ignore keyfiles that
start with a dot ('.'). This means, that connection with ids
starting with a dot, will be ignored.

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

(cherry picked from commit 6ccb888831)
2015-07-03 09:23:59 +02:00
Thomas Haller
9293ab5d66 keyfile: retry harder finding a suitable filename in writer()
Try harder to find a suitable filename by appending a counter
to the name.

https://bugzilla.gnome.org/show_bug.cgi?id=740738
(cherry picked from commit 3b1c5ee0fd)
2015-07-03 09:23:59 +02:00
Pavel Šimerda
0fe52b9cd7 keyfile: ignore all dot files (bgo#735824)
https://bugzilla.gnome.org/show_bug.cgi?id=735824
(cherry picked from commit 091732e13b)
2015-07-03 09:23:59 +02:00
Dan Winship
570582b316 keyfile: fix an uninitialized variable
read_field() was supposed to set *error to NULL if there was no error,
but it missed one case. (If **current was '\0'.)

(cherry picked from commit d746103d75)
2015-07-03 09:23:59 +02:00
Thomas Haller
7d065b018b keyfile: add nm_keyfile_plugin_utils_escape_filename() function
We have nm_keyfile_plugin_utils_should_ignore_file() to ignore certain
files based on patterns. We also need a matching escape function to
avoid saving connections with a name we would ignore later.

https://bugzilla.gnome.org/show_bug.cgi?id=735824
(cherry picked from commit a823217b1f)
2015-07-03 09:23:59 +02:00
Thomas Haller
5a63d42de4 keyfile: use locale independent g_ascii_strcasecmp()
https://bugzilla.gnome.org/show_bug.cgi?id=735824
(cherry picked from commit 904677dc88)
2015-07-03 09:23:59 +02:00
Lubomir Rintel
c7a1627ea1 platform: avoid assuming a permanent address is an ethernet address
This gets called for all links via link_get_permanent_address(). This could
easily be an infiniband address and we don't want to assert it's not.

(cherry picked from commit 31c8bd6b69)
2015-07-02 23:04:40 +02:00
Lubomir Rintel
fd06f0498f infiniband: don't crash if the parent interface is not yet there
Just bail politely just like vlans do.

(cherry picked from commit 1a5fec681b)
2015-07-02 23:04:39 +02:00
Thomas Haller
ce0893e532 platform: fix wrong removal of generated enums
Fixes: a130f72d74
(cherry picked from commit 17216ed453)
2015-07-02 16:59:21 +02:00
Thomas Haller
809ddb89f9 platform: mark internal enums to be skipped by glib-mkenums
No need to generate glib type information for these internal
enums.

(cherry picked from commit a130f72d74)
2015-07-02 16:26:54 +02:00
Lubomir Rintel
9dc446cd3f ifcfg-rh: correct the error handling for NM_CONTROLLED=no connections
We ought to set an error if we're returning NULL from
connection_from_file_full(). Also, printing out a warning ourselves makes no
sense -- the caller communicates this if we signal an error by returning NULL.

(cherry picked from commit e27aa5b4d7)
2015-07-02 15:19:47 +02:00
Lubomir Rintel
13cd646b9d ifcfg-rh: don't signal removal of the connection we didn't register
Removal of a NM_CONTROLLED=no connection and subsequent 'nmcli c reload' would
cause a crash.

(cherry picked from commit 3b853de2e9)
2015-07-02 15:19:46 +02:00
Thomas Haller
e3491b671c platform: minor refactor to logging and nm_platform_link_get_all()
Add trace logging to nm_platform_link_get_all().

(cherry picked from commit 49ade7a8da)
2015-07-02 15:05:14 +02:00
Thomas Haller
718433307d platform: remove unreachable code in nm_platform_link_get_all()
Linux platform tracks links by ifindex. Hence an ifindex must be unique
and positive. Just assert against it.

(cherry picked from commit 5b208e718a)
2015-07-02 15:04:44 +02:00
Thomas Haller
1cbd3314a0 platform/test: add test to call nm_platform_link_get_all()
(cherry picked from commit 6f5cb596ba)
2015-07-02 15:04:44 +02:00
Thomas Haller
5edba27fe4 platform: add trace-logging to nm_platform_link_get_all()
(cherry picked from commit 987515ea73)
2015-07-02 15:04:44 +02:00
Thomas Haller
41617b9605 platform: replace debug() log macro with _LOGD()
(cherry picked from commit c9aeefb5a1)
2015-07-02 15:04:44 +02:00
Thomas Haller
10c7479507 platform: add logging macros _LOGx() to nm-platform.c
(cherry picked from commit e0630023e5)
2015-07-02 15:04:44 +02:00
Thomas Haller
03491caf83 dispatcher: don't exit with failure in case D-Bus service stops
The initsystem should stop nm-dispatcher before stopping D-Bus
service. However, on some systems that is not implemented, so
nm-dispatcher should not exit with a failure message when the
system bus disappears.
Instead just assume that D-Bus service was stopped during shutdown
and exit gracefully.

Based-on-patch-by: Jacob <jacobgodserv@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=751017
(cherry picked from commit 8fdf198632)
2015-07-01 17:15:26 +02:00
Lubomir Rintel
a961ffc6a8 devices,platform: fix build with gcc
Warnings about missing initializers.

(cherry picked from commit 295c9818b0)
2015-07-01 16:36:18 +02:00
Thomas Haller
b774bde8ed core: merge branch 'th/device-route-bgo751264'
Several fixes to route and address handling in platform.
Especially refactor managing of IPv4 device routes and
let NMRouteManager handle them.

https://bugzilla.gnome.org/show_bug.cgi?id=751264
https://bugzilla.redhat.com/show_bug.cgi?id=1211287

(cherry picked from commit 1749ad4068)
2015-07-01 16:13:05 +02:00
Thomas Haller
42ac15c86f route-manager: manage IPv4 device-routes with NMRouteManager
When adding an IPv4 address, kernel will also add a device-route.
We don't want that route because it has the wrong metric. Instead,
we add our own route (with a different metric) and remove the
kernel-added one.

This could be avoided if kernel would support an IPv4 address flag
IFA_F_NOPREFIXROUTE like it does for IPv6 (see related bug rh#1221311).

One important thing is, that we want don't want to manage the
device-route on assumed devices. Note that this is correct behavior
if "assumed" means "do-not-touch".
If "assumed" means "seamlessly-takeover", then this is wrong.
Imagine we get a new DHCP address. In this case, we would not manage
the device-route on the assumed device. This cannot be fixed without
splitting unmanaged/assumed with related bug bgo 746440.
This is no regression as we would also not manage device-routes
for assumed devices previously.

We also don't want to remove the device-route if the user added
it externally. Note that here we behave wrongly too, because we
don't record externally added kernel routes in update_ip_config().
This still needs fixing.

Let IPv4 device-routes also be managed by NMRouteManager. NMRouteManager
has a list of all routes and can properly add, remove, and restore
the device route as needed.

One problem is, that the device-route does not get added immediately
with the address. It only appears some time later. This is solved
by NMRouteManager watching platform and if a matchin device-route shows up
within a short time after configuring  addresses, remove it.
If the route appears after the short timeout, assume they were added for
other reasons (e.g. by the user) and don't remove them.

https://bugzilla.gnome.org/show_bug.cgi?id=751264
https://bugzilla.redhat.com/show_bug.cgi?id=1211287
(cherry picked from commit 5f54a323d1)
2015-07-01 16:12:14 +02:00
Thomas Haller
4f161e4bea route-manager: consider also 'proto kernel' routes during route_flush()
(cherry picked from commit a96cba8845)
2015-07-01 16:10:50 +02:00
Thomas Haller
accf3d0f17 platform: properly consider address lifetimes in nm_platform_ip4_address_sync()
When checking whether an address from platform should be deleted, we
compare the address with our list of @known_addresses.
For that we must also check for expired lifetimes, because
@known_addresses might contain expired addresses.

(cherry picked from commit 8336bd2a83)
2015-07-01 16:10:50 +02:00
Thomas Haller
8532b83f46 route-manager: add argument @ignore_kernel_routes to route_sync()
Will be used later, no behavioral change yet.

(cherry picked from commit 347555795f)
2015-07-01 16:10:50 +02:00
Thomas Haller
a698b70d0f route-manager: process platform events before syncing routes
Let's ensure we have a fresh platform cache before starting
to sync.

(cherry picked from commit c5c612d711)
2015-07-01 16:10:50 +02:00
Thomas Haller
74da44e3df route-manager: keep a reference of the platform instance
Soon we will subscribe to the platform instance for change signals.
If a singleton instance uses another singleton instance, it should
keep a reference to it, especially if it subscribes to a signal
(that will be disconnected on dispose()).

(cherry picked from commit b79ade8975)
2015-07-01 16:10:50 +02:00
Thomas Haller
976726f221 libnm: add _nm_utils_ptrarray_find_binary_search() helper
(cherry picked from commit 650fec81e2)
2015-07-01 16:10:50 +02:00
Thomas Haller
300a7ab4d1 platform: expose routes with "proto kernel" too
Also expose routes with "proto kernel". But add a flag
to nm_platform_ipx_route_get_all() to hide them by default.

(cherry picked from commit 42664e8752)
2015-07-01 16:10:50 +02:00
Thomas Haller
7082f44c2f platform: change NMPlatformGetRouteMode enum to NMPlatformGetRouteFlags flags
By having flags instead of an enum/mode, we can encode more combinations
of filtering the result.

(cherry picked from commit d9dba6b662)
2015-07-01 16:10:50 +02:00
Thomas Haller
44cb5b6b62 platform/trivial: rename enum value NM_IP_CONFIG_SOURCE_RTPROT_KERNEL
This source type was platform internal up to now. Next we will expose it.

(cherry picked from commit 85bf9ded2e)
2015-07-01 16:10:50 +02:00
Thomas Haller
1d2ff90a5c core: minor refactoring iterating and removing list of routes
The previous version causes an unsigned integer underflow. That
is not wrong, but still change it.

Also use g_array_remove_index_fast() because the list of routes
is unsorted anyway.

(cherry picked from commit e7f3ccf7cd)
2015-07-01 16:10:49 +02:00
Thomas Haller
e04d0c6e6b platform: track pref_src field of IPv4 routes
(cherry picked from commit 7594e31220)
2015-07-01 16:10:49 +02:00
Thomas Haller
af0d99cdcc platform: fix setting valid lifetimes when constructing rtnl_addr object
build_rtnl_addr() has two parameters "lifetime" and "preferred". Both
count from *now*.

Fix nmp_object_to_nl() to properly set these timestamps. This bug had
not real consequences, because the only place where we use
nmp_object_to_nl() the arguments are 0.

(cherry picked from commit d0ed4de104)
2015-07-01 16:10:49 +02:00
Thomas Haller
a3c4bf81bb platform: move address lifetime utils function to nm-platform-utils.c
(cherry picked from commit 626a85530e)
2015-07-01 16:10:49 +02:00
Thomas Haller
14ef5f6b32 platform: prettify and line-wrap route_to_string() print statements
(cherry picked from commit 2170804213)
2015-07-01 16:10:37 +02:00
Thomas Haller
e7504376dc platform: fix initializing vlan_id for NMPlatformLink instance from libnl object
If the vlan-information is missing, we must consult the cache.

Fixes: 8a1f4beb65
(cherry picked from commit 871c4d90c7)
2015-07-01 15:47:08 +02:00
Beniamino Galvani
5fc247347f device: restart ping process when it exits with an error
When ping is launched to check the connectivity to the gateway it may
return earlier than the given timeout in case of error. When this
happens we need to respawn it until the timeout is reached.

While at it, increase maximum timeout value to 600 seconds.

https://bugzilla.redhat.com/show_bug.cgi?id=1128581
(cherry picked from commit e86f8354a7)
2015-07-01 13:51:06 +02:00
Thomas Haller
77cbaf611a core: merge branch 'th/device-cleanup-bgo751733'
https://bugzilla.gnome.org/show_bug.cgi?id=751733

(cherry picked from commit e3348b46bd)
2015-07-01 11:44:25 +02:00
Thomas Haller
5e3e45cc82 device: fix cleanup DHCP instance when unmanaging device on removed platform link
When the platform link gets removed outside of NetworkManager, we would
unmanage the device first. By checking the device state reason
NM_DEVICE_STATE_REASON_REMOVED, we would then not deconfigure the
interface, as it is already gone.

This was not correct because we must at least stop the dhcp client.
Otherwise the dhclient process keeps running. That meant, if the device
reappeared later, we would start dhclient again. Then we would find the
PID of the still running instance in the pidfile and kill it only than.

Fix it by replacing the 'deconfigure' boolean by a tri-state
'cleanup_type'.

(cherry picked from commit 3b21738d9c)
2015-07-01 11:41:15 +02:00
Thomas Haller
31f06008c7 dhcp: properly reap child process in nm_dhcp_client_stop_existing()
We kill the process based on the PID from the pidfile. This can be
our own child process so we must use nm_utils_kill_child_sync()
instead of nm_utils_kill_process_sync().

(cherry picked from commit c61c71a168)
2015-07-01 11:40:40 +02:00
Thomas Haller
fa9f7fe6e3 core: return parent pid from nm_utils_get_start_time_for_pid()
(cherry picked from commit 7c9eefa767)
2015-07-01 11:40:40 +02:00
Jiří Klimeš
a4a92299fb core: do not manage devices that are not initialized by platform
Commit 388b7830f3 added NM_UNMANAGED_PLATFORM_INIT.

Fixes: 388b7830f3
Fixes:Beaker: NetworkManager_Test35_veth_goes_to_unmanaged_state

(cherry picked from commit a396ad2ac1)
2015-06-30 15:52:37 +02:00
Thomas Haller
1cf9e989c1 core: fix memleak in nm_utils_get_start_time_for_pid() and parsing start-time
It was leaking @tokens in case of error. Also the error checking of
start-time with strtoull() was erroneous.

(cherry picked from commit 67057079a4)
2015-06-30 14:23:04 +02:00
Thomas Haller
cb29a2109f dhcp: wait at most 2000 msec to kill existing dhcp process
(cherry picked from commit 4fbd42a035)
2015-06-30 14:23:04 +02:00
Thomas Haller
69294f80f7 core: add @max_wait_msec argument to nm_utils_kill_process_sync()
(cherry picked from commit 7dc65df020)
2015-06-30 14:23:04 +02:00
Thomas Haller
c26294d6b0 core: fix nm_utils_kill_process_sync() not to hang for a zombie process
kill(pid,sig) can return success for zombie processes. This
caused nm_utils_kill_process_sync() to hang indefinitely.

Fix it by also checking the process state.

(cherry picked from commit 69c98a336e)
2015-06-30 14:23:04 +02:00
Lubomir Rintel
dfff2265d3 ipx-config: fix test
Fixes: c942a8c35b
(cherry picked from commit 5dc23a28f8)
2015-06-28 21:37:09 +02:00