Commit graph

9671 commits

Author SHA1 Message Date
Thomas Haller
e730ae7600 core/tests: add checks in test for test_add_route_with_source() 2017-09-13 08:17:31 +02:00
Thomas Haller
79cb13bc5c platform: use distinct hash seed for nmp_object_id_hash() of routes 2017-09-13 08:17:31 +02:00
Thomas Haller
944006d485 core: add nm_utils_ip4_address_same_prefix() function 2017-09-13 08:17:31 +02:00
Thomas Haller
846b02880d core: fix invalid assertion in nm_ip6_config_get_num_routes().
Fixes: cfd1851c00
2017-09-13 08:17:31 +02:00
Thomas Haller
eb948e793e core: fix invalid assertion in nm_ip4_config_get_num_routes()
Fixes: 935411e5c0
2017-09-13 08:17:30 +02:00
Thomas Haller
3c84dd15e0 core/dhcp: use addr-family parameter for instead of boolean
In many cases we want to treat IPv4 and IPv6 generically. That looks nicer
if we distingish by an @addr_family integer, instead of a boolean.

Replace the @is_ipv6 boolean with an @addr_family paramter. The @is_ipv6
boolean is inconsistent with other places where we use @is_ipv4 to
indicate the opposite. Eventually, we should use @addr_family
everywhere.

Also, at the call site it's not immediately clear what TRUE/FALSE means,
here AF_INET/AF_INET6 is better.
2017-09-11 15:05:57 +02:00
Thomas Haller
1aa36dde94 device: enable support for ipv6.dhcp-timeout
- cleanup data type and use guint32 consistently. We might want to
  introduce a new "infinity" value. But since libnm's
  NM_SETTING_IP_CONFIG_DHCP_TIMEOUT asserts against the range
  0 - G_MAXINT32, we cannot express it as -1 anyway. So, infinity
  will have the numerical value G_MAXINT32, hence guint32 is just
  fine.

- make use of existing ipv6.dhcp-timeout setting and add global
  default configuration in NetworkManager.conf

- instead of having subclasses call nm_device_set_dhcp_timeout(),
  add a virtual function get_dhcp_timeout().
2017-09-11 15:05:57 +02:00
Francesco Giudici
fa46736013 dhcp: dhclient: fix daemon start when dhcp-timeout is specified
A typo in the new dhcp-timeout option caused the dhclient daemon to exit
with error when the dhcp-timeout option was specified.
This prevents dhcp connection to be upped.

Fixes: 82ef497cc9
2017-09-11 14:52:51 +02:00
Beniamino Galvani
44e71d70ea ppp: rename the interface only when necessary
Previously when the interface created by pppd was already the one we
expected, we would rename it to itself and remove the device from the
manager. Don't do it.

Fixes: 6c3195931e
2017-09-08 14:29:02 +02:00
Thomas Haller
77ec302714 core: rework handling of default-routes and drop NMDefaultRouteManager
Remove NMDefaultRouteManager. Instead, add the default-route to the
NMIP4Config/NMIP6Config instance.

This basically reverts commit e8824f6a52.
We added NMDefaultRouteManager because we used the corresponding to `ip
route replace` when configuring routes. That would replace default-routes
on other interfaces so we needed a central manager to coordinate routes.
Now, we use the corresponding of `ip route append` to configure routes,
and each interface can configure routes indepdentently.

In NMDevice, when creating the default-route, ignore @auto_method for
external devices. We shall not touch these devices.

Especially the code in NMPolicy regarding selection of the best-device
seems wrong. It probably needs further adjustments in the future.
Especially get_best_ip_config() should be replaced, because this
distinction VPN vs. devices seems wrong to me.
Thereby, remove the @ignore_never_default argument. It was added by
commit bb75026004, I don't think it's
needed anymore.

This brings another change. Now that we track default-routes in
NMIP4Config/NMIP6Config, they are also exposed on D-Bus like regular
routes. I think that makes sense, but it is a change in behavior, as
previously such routes were not exposed there.
2017-09-08 11:11:21 +02:00
Thomas Haller
0918b4914d core: support tracking default-route in NMIP4Config/NMIP6Config
Default-routes are for the most part like regular routes. Add support to
track them like regular routes in NMIP4Config/NMIP6Config.

One thing is, sometimes we need to figure out whether an ip-config
instance has a default-route. For that, keep track of the best
default-route (there might be multiple) and expose it. That is
the most complicated part of this patch, because there are so many
places where the list of routes gets modified (replace, intersect,
subtract, merge, add), and they all need to take care of updating
the best default-route.

In a next patch, NMDefaultRouteManager will be dropped and default-routes
will be tracked by NMIP4Config/NMIP6Config.
2017-09-08 11:11:21 +02:00
Thomas Haller
96f1358eef core: return new route from _nm_ip_config_add_obj()
Later we will need the exact instance that we just added (or the previously
existing one, if the new route is already tracked).
2017-09-08 11:05:05 +02:00
Thomas Haller
ead1ffd9bc core/trivial: rename test functions _nmtst_nm_ip*_config_*() to _nmtst_ip*_config_*() 2017-09-08 11:05:05 +02:00
Thomas Haller
e805201f4b platform: delete routes after adding in nm_platform_ip_route_sync()
Previously, we would first delete routes that are not to be added,
before adding the new ones.

This has the advantage, that even if delete removes the wrong route,
add would restore the expected state. This tries to workaround the fact
that RTM_DELROUTE allows for wild-card fields, and might delete the
wrong route.

However, for example when bumping the route metric after connectivty
check (removing the default-route with metric 20100 and adding the one
with metric 100), there is a short moment when there is no
default-route.

To avoid that, don't do delete-then-add, but add-then-delete.
2017-09-08 11:05:05 +02:00
Thomas Haller
7ab40b9e10 core: ignore routes from non-main table in nm_ip4_config_capture()
and nm_ip6_config_capture().
2017-09-08 11:05:05 +02:00
Thomas Haller
199499967a core: don't loop twice over routes in nm_ip4_config_capture()
and nm_ip6_config_capture().
2017-09-08 11:05:05 +02:00
Thomas Haller
315bd0a97d core: add nm_utils_connection_has_default_route()
Taken from "src/nm-default-route-manager.c".
2017-09-08 11:05:04 +02:00
Thomas Haller
e99a603944 device: expose nm_device_get_ip_route_metric() function
Will be used later.
2017-09-08 11:05:04 +02:00
Thomas Haller
c16e871888 core: nm_utils_ip_route_metric_normalize() util
Functions that take and addr_family argument are just nicer
to use at places where we treat IPv4 and IPv6 generically.
2017-09-08 11:05:04 +02:00
Thomas Haller
6801cd65bf platform: add nm_clear_nmp_object() util 2017-09-08 11:05:04 +02:00
Thomas Haller
a0ca607080 core: return new object from _nm_ip_config_add_obj()
Will be used later.
2017-09-08 11:05:04 +02:00
Thomas Haller
546e12417a core: use _nm_ip_config_add_obj() in nm_ip4_config_replace() for routes
Avoid calling nm_dedup_multi_index_add() directly, like we do for all other places.
Instead, call the wrapper _nm_ip_config_add_obj() which does some pre-precessing.

In practice, the result is exactly the same (at the moment). But there should by
only one way to add the route.
2017-09-08 11:05:04 +02:00
Thomas Haller
af1ad0eed7 core/tests: add test for nm_ip6_config_replace() 2017-09-08 11:05:04 +02:00
Thomas Haller
b3254da173 platform/trivial: add code comments 2017-09-08 11:05:04 +02:00
Thomas Haller
5c7e0654eb policy: take reference to best_device/activating_device
Don't rely on manager keeping them alive long enough. E.g.
get-best-device() is used when resetting the best device,
however, it accesses the current device (hence, it relies
on manager removing the device from the list, but keeping
it alive long enough).
2017-09-08 11:05:04 +02:00
Thomas Haller
f8cb6dcbb1 policy: cleanup setting default_device/activating_device
- _LOGt() whenever the properties change.
- some minor refactoring
2017-09-08 11:05:04 +02:00
Thomas Haller
a75f528618 policy: don't re-lookup the best device during update_system_hostname()
We already track the best device as priv->default_device4 / priv->default_device6.
Don't try to look it up again. If the cached values from @priv are invalid/outdated,
that should be fixed instead.

This was already introduced by commit 773c006a4c.
But I don't think it should be done.
2017-09-08 11:05:04 +02:00
Thomas Haller
8881c11f93 policy: always check for hostname from DHCPv6 in update_system_hostname()
There is no reason for if-else-if. If DHCPv4 doesn't provide a hostname (but we
are doing DHCP), just check for DHCPv6.
2017-09-08 11:05:04 +02:00
Thomas Haller
9574472f9b policy: refactor setting hostname from DHCP in update_system_hostname() 2017-09-08 11:05:04 +02:00
Thomas Haller
ac5350fef2 dns: use 127.0.0.53 address in /etc/resolv.conf with systemd-resolved
https://bugzilla.gnome.org/show_bug.cgi?id=787378
2017-09-07 15:29:57 +02:00
Beniamino Galvani
2f3e978f57 ifnet: ensure an error is always returned when add fails
There are many places where the function can fail without returning an
error, leading to a crash. Fix this.
2017-09-07 15:09:15 +02:00
Thomas Haller
10fc74819c vpn: only rely on ip route get to resolve route to external VPN gateway
Until recently, we would only consier the IP config of the parent device
to determine the route to the external VPN gateway. We changed that, to
additionally improve the guess by letting kernel resolve the route.

Now, drop checking the parent's config entirely. The only thing that
matters is the here and now runtime configuraion on the parent device.
And for that we ask kernel to resolve the route.
2017-09-07 12:00:36 +02:00
Thomas Haller
f6dabee068 vpn: improve resolving route to external VPN gateway by restricting oif
Previously, we would try to resolve the route in general (unrestricted
to a certain ifindex), and reject it the result wasn't on the parent
device.

Now, use the oif argument, and resolve the route only on the parent device.

The problem is that kernel would pretend that the destination is onlink, if
there is no route to it. Hence, hack around that by only accepting an onlink
route, if the VPN gateway itself is site-local. Yes, there are scenarios where
this will still lead to a wrong guess. See related bug rh#1489343 for kernel.
2017-09-07 11:57:44 +02:00
Thomas Haller
7046ce5332 platform: add oif argument to nm_platform_ip_route_get()
Analog to `ip route get $DST oif $IFACE`.
2017-09-07 11:14:27 +02:00
Thomas Haller
cac10198f6 vpn: apply parent config in nm_vpn_connection_apply_config() first
In practice, it shouldn't matter much, because NM may frequently
reapply the IP config. Hence, it anyway must cope with the fact that
IP config from a previous iteration is already applied on the VPN device,
before applying it to the parent device.

Anyway, it makes a bit more sense to apply it first the the parent device.
2017-09-07 11:14:27 +02:00
Thomas Haller
c8e6f3e5fb vpn: fix ifindex of parent IP config in apply_parent_device_config()
When creating the NMIP4Config/NMIP6Config instance, we must always use the right
ifindex. That is the ifindex, on which we want to apply the config. It also means,
that for device-based VPNs (those with priv->ip_ifindex set, like OpenVPN), the
parent's config must have the ip-ifindex of the parent device. Not of the
VPN's device.

One effect of this bug is that in add_ip4_vpn_gateway_route() we resolve
the route to the external gateway and only accept it if it's on the
parent device. But since the ifindex of the config was wrong, we would accept
route on the wrong interface.

https://bugzilla.gnome.org/show_bug.cgi?id=787370
2017-09-07 11:14:27 +02:00
Beniamino Galvani
bb99a0e433 platform: refetch IPv6 address if still present after deletion
After commit 5a69b27a64 ("platform: let platform operations only
consider kernel response") the platform only relies on kernel messages
and doesn't check if a deleted object is gone from the cache. For IPv6
addresses it can happen that the RTM_DELADDR comes after the ack, and
this causes random failures in test /address/ipv6/general-2:

 [10.8009] platform: address: deleting IPv6 address 2001:db8:a🅱️1:2:3:4/64, ifindex 12 dev nm-test-device
 [10.8009] platform-linux: delayed-action: schedule wait-for-nl-response (seq 55, timeout in 0.199999680, response-type 0)
 [10.8009] platform-linux: delayed-action: handle wait-for-nl-response (any)
 [10.8009] platform-linux: netlink: recvmsg: new message (2), flags 0x0100, seq 55
 [10.8009] platform-linux: delayed-action: complete wait-for-nl-response (seq 55, timeout in 0.199980533, response-type 0, success)
 [10.8009] platform-linux: do-delete-ip6-address[12: 2001:db8:a🅱️1:2:3:4]: success
 **
 NetworkManager:ERROR:src/platform/tests/test-common.c:1127:_ip_address_del: assertion failed: (external_command)

Use the same workaround in place for the addition of IPv6 addresses,
i.e. refetch the object if the address is still present after the ack.
2017-09-07 09:50:59 +02:00
Beniamino Galvani
04182dcc9a platform: fix coding style (missing braces) 2017-09-07 09:50:16 +02:00
Thomas Haller
5c42cdb287 all: use _nm_utils_ip4_*() utils functions 2017-09-05 18:44:04 +02:00
Thomas Haller
a47153f5b8 ifcfg-rh/tests: test backward compatibility reading routes with "via (null)"
Due to a bug, NetworkManager used to write device routes with "via (null)".
That was fixed in commit af8aac9b54 and
bug rh#1452648.

Add a unit test to ensure we keep accepting such (invalid) routes that
NetworkManager once wrote.
2017-09-05 13:28:21 +02:00
Thomas Haller
699c97af2d core: don't require manageable device in unmanaged_to_disconnected()
It seems the assert there is too strict. I don't really understand why
it fails, but I also don't see why the assert is supposed to hold.
Just return in case the device is unmanagable at this point.

The activation shall fail later.

Traceback from a test build of commit a7aca2ab08:

  #0  0x00007fdb28ffb643 in g_logv (log_domain=0x7fdb2b584cc9 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fff10630200) at gmessages.c:1086
  #1  0x00007fdb28ffb7bf in g_log (log_domain=log_domain@entry=0x7fdb2b584cc9 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7fdb29069190 "%s: assertion '%s' failed") at gmessages.c:1119
  #2  0x00007fdb28ffb7f9 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7fdb2b584cc9 "NetworkManager", pretty_function=pretty_function@entry=0x7fdb2b54fee0 <__func__.38922> "unmanaged_to_disconnected", expression=expression@entry=0x7fdb2b54d450 "nm_device_get_managed (device, FALSE)") at gmessages.c:1128
  #3  0x00007fdb2b36e05b in unmanaged_to_disconnected (device=device@entry=0x7fdb2d2384f0 [NMDeviceVlan]) at src/nm-manager.c:3201
  #4  0x00007fdb2b37eb3a in _internal_activate_generic (error=0x7fff106303d0, active=0x7fdb2d1d4550 [NMActRequest], self=0x0) at src/nm-manager.c:3430
  #5  0x00007fdb2b37eb3a in _internal_activate_generic (self=self@entry=0x7fdb2d02b090 [NMManager], active=active@entry=0x7fdb2d1d4550 [NMActRequest], error=error@entry=0x7fff10630450) at src/nm-manager.c:3458
  #6  0x00007fdb2b37fe90 in _activation_auth_done (active=0x7fdb2d1d4550 [NMActRequest], success=1, error_desc=0x0, user_data1=0x7fdb2d02b090, user_data2=0x7fdb0800bec0) at src/nm-manager.c:3866
  #7  0x00007fdb2b4cc9d7 in auth_done (chain=0x7fdb2d17de30, error=0x0, unused=<optimized out>, user_data=<optimized out>) at src/nm-active-connection.c:929
  #8  0x00007fdb2b4d6884 in auth_chain_finish (user_data=0x7fdb2d17de30) at src/nm-auth-utils.c:92
  #9  0x00007fdb28ff4d7a in g_main_context_dispatch (context=0x7fdb2cff2e00) at gmain.c:3152
  #10 0x00007fdb28ff4d7a in g_main_context_dispatch (context=context@entry=0x7fdb2cff2e00) at gmain.c:3767
  #11 0x00007fdb28ff50b8 in g_main_context_iterate (context=0x7fdb2cff2e00, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3838
  #12 0x00007fdb28ff538a in g_main_loop_run (loop=0x7fdb2cff2ec0) at gmain.c:4032
  #13 0x00007fdb2b349ed7 in main (argc=1, argv=0x7fff106307a8) at src/main.c:438

https://bugzilla.redhat.com/show_bug.cgi?id=1478911
2017-09-04 21:49:35 +02:00
Thomas Haller
a17195b844 device: extend wait time for carrier after MTU change
Especially during an MTU change, the driver might need longer to
bring back carrier. In this case, extend the wait time.

https://bugzilla.redhat.com/show_bug.cgi?id=1487702
2017-09-04 21:44:10 +02:00
Thomas Haller
17e984d4cb systemd: merge branch systemd into master
Seems there is nothing relevant really. Just do our regular
resync to keep the diff to upstream systemd small.
2017-09-04 12:52:54 +02:00
Thomas Haller
770ad94cba systemd: update code from upstream (2017-09-04)
This is a direct dump from systemd git on 2017-09-04, git commit
c792ec2e3512a672881fc847ff432e26b641c9c9.

======

SYSTEMD_DIR=../systemd
COMMIT=c792ec2e3512a672881fc847ff432e26b641c9c9

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/process-util.h"
nm_copy_sd "src/basic/process-util.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2017-09-04 12:50:11 +02:00
Thomas Haller
7b64334042 platform: fix deleting routes in nm_platform_ip_route_sync()
The condition was wrong resulting in sync() not deleting route
when it should.

Fixes: f0de7d347f
2017-09-02 16:50:24 +02:00
Beniamino Galvani
981f90e324 device: don't release external slaves on state change
If the slave is 'external' we should never touch it, in particular we
should not release the link from its master; we only have to remove it
from master's list.

https://bugzilla.redhat.com/show_bug.cgi?id=1442361
2017-09-02 10:38:28 +02:00
Beniamino Galvani
9e99590508 device: don't promote slave devices to managed
Previously, if a master device had internal state 'managed', we would
promote the slave to 'managed' as well. However,

 - if the slave is 'external', it should stay as is because we don't
   want to start managing it

 - if the slave is 'assumed', it will become managed when the
   activation succeeds, so it's not necessary to do it here

Fixes: 850c977953
2017-09-02 10:38:27 +02:00
Thomas Haller
1b421645e4 core: ignore host-routes routes when matching generated connection
When we generate the connection in nm_device_generate_connection(), we
add all routes that have rt_source (roundtrip(NM_IP_CONFIG_SOURCE_USER)).
Especially since commit e470e13922, this
includes automatically added host-routes to the gateway, added by
ip4_config_merge_and_apply().

Later, during nm_utils_match_connection() this route most not prevent
matching. Either nm_device_generate_connection() should not add it, or
nm_utils_match_connection() should ignore it.

I think adjusting the matching is better, because ip-configs are used
for several things, including exposing routes on D-Bus. We don't want
to hide this route on D-Bus.

Fixes: e470e13922

https://bugzilla.redhat.com/show_bug.cgi?id=1487384
2017-09-01 15:55:29 +02:00
Beniamino Galvani
4fe884ad7e team: wait that existing instance is killed before starting teamd again
teamd uses a PID file to guarantee a single instance is running for
each device. If we spawn a new teamd process without waiting the
termination of the existing one, the new process can fail:

 <debug> [1486191713.2530] kill child process 'teamd' (2676): wait for process to terminate after sending SIGTERM (15) (send SIGKILL in 2000 milliseconds)...
 ...
 <debug> [1486191713.2539] device[0x7f737f5d7c40] (team1): running: /usr/bin/teamd -o -n -U -D -N -t team1 -c {"runner": {"name": "activebackup"}} -gg
 Using team device "team1".
 Using PID file "/var/run/teamd/team1.pid"
 This program is not intended to be run as root.
 Daemon already running on PID 2676.
 Failed: File exists

To avoid this, keep track that a kill is in progress and postpone the
start of teamd.

https://bugzilla.redhat.com/show_bug.cgi?id=1415641
2017-09-01 09:40:21 +02:00
Thomas Haller
35f189f1eb platform: ignore RTM_*LINK messages for unknown ifi_family (AF_BRIDGE)
When unenslaving an interface from a bridge, kernel sends a RTM_DELLINK
message with ifi_family AF_BRIDGE. We only care about regular
RTM_DELLINK/RTM_NEWLINK messages, ignore all but ifi_family AF_UNSPEC.

There is also test_nl_bugs_spuroius_dellink(), added in commit
8a87a91813 for related bug rh#1302037.
The workaround was masking a bug in NetworkManager (to not ignore AF_BRIDGE
messages) and can now be removed as well.
2017-08-31 20:01:45 +02:00