Commit Graph

13873 Commits

Author SHA1 Message Date
Thomas Haller
885d187d23 libnm: add _nm_utils_strv_cleanup() function 2015-07-02 15:50:03 +02:00
Thomas Haller
69f2d22bfe glib-compat: backport g_key_file_save_to_file() 2015-07-02 15:50:03 +02:00
Thomas Haller
f8c9863d55 config: fix order of processing [connection] sections in NMConfig
We support the "NetworkManager.conf" sections '[connection]' and
'[connection.\+]' (with arbitrary suffix).

Fix the order of how we evaluate these section.

Note that the literal '[connection]' section is always evaluated lastly
after any other '[connection.\+]' section.

Within one file, we want to evaluate the sections in top-to-bottom
order. But accross multiple files, we want to order them
later-files-first. That gives a reasonable behavior if the user
looks at one file, and also if he wants to overwrite configuration
via configuration snippets like "conf.d/99-last.conf".

Note that if a later file extends/overwrites a section defined in an
earlier file, the section is still considered with lower priority
This is intentional, because the user ~extends~ a lower priority
section. If he wants to add a higher priority section, he should
choose a new suffix.

Fixes: dc0193ac02
2015-07-02 15:50:03 +02:00
Thomas Haller
aa7a53bc67 libnm-keyfile: ensure g_key_file_get_groups() sets the length argument
Under certain cases, if g_key_file_get_groups() fails, it might not set the
out argument @length. Play it safe and initialize it.
2015-07-02 15:50:03 +02:00
Lubomir Rintel
e27aa5b4d7 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.
2015-07-02 15:16:48 +02:00
Lubomir Rintel
3b853de2e9 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.
2015-07-02 15:16:48 +02:00
Thomas Haller
49ade7a8da platform: minor refactor to logging and nm_platform_link_get_all()
Add trace logging to nm_platform_link_get_all().
2015-07-02 15:02:49 +02:00
Thomas Haller
5b208e718a 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.
2015-07-02 15:01:45 +02:00
Thomas Haller
6f5cb596ba platform/test: add test to call nm_platform_link_get_all() 2015-07-02 14:52:21 +02:00
Thomas Haller
987515ea73 platform: add trace-logging to nm_platform_link_get_all() 2015-07-02 14:42:08 +02:00
Thomas Haller
c9aeefb5a1 platform: replace debug() log macro with _LOGD() 2015-07-02 14:37:31 +02:00
Thomas Haller
e0630023e5 platform: add logging macros _LOGx() to nm-platform.c 2015-07-02 14:33:40 +02:00
Petr Vorel
ac497ccd6c autogen.sh: print errors to stderr, printf instead echo -n
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2015-07-02 09:55:32 +02:00
Lubomir Rintel
39ed60dc60 merge,cli: branch 'lr/cli-add-properties'
Make it possible to specify properties upon connection addition.

Addresses all these:

https://bugzilla.gnome.org/show_bug.cgi?id=750590
https://bugzilla.gnome.org/show_bug.cgi?id=698076
https://bugzilla.gnome.org/show_bug.cgi?id=740749
2015-07-02 09:34:09 +02:00
Lubomir Rintel
81f1e3da4f cli: add bash completion for 'nmcli c add -- <property list>'
Use the editor to obtain a list of possible properties for a type of
connection. Let 'nmcli c modify' completion reuse it as well, to avoid code
duplication.
2015-07-02 09:33:58 +02:00
Lubomir Rintel
b3e57cf3ca cli: allow specifying arbitrary properties on "nmcli c add"
Syntax: nmcli c add ... -- [+|-]<setting>.<property> <value> ...
2015-07-02 09:33:58 +02:00
Lubomir Rintel
15149d915f cli: refactor: split connection property reader from do_connection_modify()
No functional change.

We'll need it for specifying the properties on connection addition.
2015-07-02 09:33:58 +02:00
Lubomir Rintel
df69bd1625 cli: trivial: move is_property_valid()
This removes one extra forward definition and saves one in future.
2015-07-02 09:33:58 +02:00
Thomas Haller
8fdf198632 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
2015-07-01 17:13:52 +02:00
Lubomir Rintel
295c9818b0 devices,platform: fix build with gcc
Warnings about missing initializers.
2015-07-01 16:35:52 +02:00
Lubomir Rintel
4ffd57f83d service: harden the NetworkManager service a bit
Tested with dnsmasq (ipv4.method=shared), openvpn & vpnc.

https://bugzilla.gnome.org/show_bug.cgi?id=750598
2015-07-01 16:26:15 +02:00
Thomas Haller
1749ad4068 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
2015-07-01 16:06:36 +02:00
Thomas Haller
5f54a323d1 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
2015-07-01 16:02:10 +02:00
Thomas Haller
a96cba8845 route-manager: consider also 'proto kernel' routes during route_flush() 2015-07-01 16:02:10 +02:00
Thomas Haller
8336bd2a83 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.
2015-07-01 16:02:10 +02:00
Thomas Haller
347555795f route-manager: add argument @ignore_kernel_routes to route_sync()
Will be used later, no behavioral change yet.
2015-07-01 16:02:10 +02:00
Thomas Haller
c5c612d711 route-manager: process platform events before syncing routes
Let's ensure we have a fresh platform cache before starting
to sync.
2015-07-01 16:02:10 +02:00
Thomas Haller
b79ade8975 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()).
2015-07-01 16:02:09 +02:00
Thomas Haller
650fec81e2 libnm: add _nm_utils_ptrarray_find_binary_search() helper 2015-07-01 16:02:09 +02:00
Thomas Haller
42664e8752 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.
2015-07-01 16:00:21 +02:00
Thomas Haller
d9dba6b662 platform: change NMPlatformGetRouteMode enum to NMPlatformGetRouteFlags flags
By having flags instead of an enum/mode, we can encode more combinations
of filtering the result.
2015-07-01 16:00:21 +02:00
Thomas Haller
85bf9ded2e 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.
2015-07-01 16:00:21 +02:00
Thomas Haller
e7f3ccf7cd 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.
2015-07-01 15:47:29 +02:00
Thomas Haller
7594e31220 platform: track pref_src field of IPv4 routes 2015-07-01 15:47:28 +02:00
Thomas Haller
d0ed4de104 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.
2015-07-01 15:47:28 +02:00
Thomas Haller
626a85530e platform: move address lifetime utils function to nm-platform-utils.c 2015-07-01 15:47:28 +02:00
Thomas Haller
871c4d90c7 platform: fix initializing vlan_id for NMPlatformLink instance from libnl object
If the vlan-information is missing, we must consult the cache.

Fixes: 8a1f4beb65
2015-07-01 15:46:01 +02:00
Beniamino Galvani
e86f8354a7 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
2015-07-01 13:42:41 +02:00
Thomas Haller
e3348b46bd core: merge branch 'th/device-cleanup-bgo751733'
https://bugzilla.gnome.org/show_bug.cgi?id=751733
2015-07-01 11:39:46 +02:00
Thomas Haller
3b21738d9c 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'.
2015-07-01 11:16:35 +02:00
Thomas Haller
c61c71a168 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().
2015-06-30 16:15:17 +02:00
Thomas Haller
7c9eefa767 core: return parent pid from nm_utils_get_start_time_for_pid() 2015-06-30 16:15:17 +02:00
Jiří Klimeš
a396ad2ac1 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
2015-06-30 15:49:06 +02:00
Thomas Haller
67057079a4 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.
2015-06-30 14:19:30 +02:00
Thomas Haller
4fbd42a035 dhcp: wait at most 2000 msec to kill existing dhcp process 2015-06-30 14:19:30 +02:00
Thomas Haller
7dc65df020 core: add @max_wait_msec argument to nm_utils_kill_process_sync() 2015-06-30 14:19:30 +02:00
Thomas Haller
69c98a336e 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.
2015-06-30 14:19:15 +02:00
Thomas Haller
d90d5f5af0 device/trivial: refactor declaration of NMUnmanagedFlags enum flags 2015-06-29 15:02:43 +02:00
Lubomir Rintel
5dc23a28f8 ipx-config: fix test
Fixes: c942a8c35b
2015-06-28 21:34:47 +02:00
Lubomir Rintel
c942a8c35b ipx-config: correct nm_ipx_config_merge() setting priorities
ip[46]_config_merge_and_apply() do assume the settings that are merged later in
override the previously set ones and not the other way around. Otherwise e.g. a
gateway address from DHCP could override what's set in the connection.
2015-06-28 21:20:46 +02:00