Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
f5c800885b ifcfg-rh: fix writing/reading TOS for routes in hexadecimal
iproute2 expects TOS in hex.

This is a change in behavior.
2017-08-03 18:51:57 +02:00
Thomas Haller
9be9cab646 core: implement NMIP4Config's and NMIP6Config's route equality based on nm_platform_ipx_route_cmp()
There are various notions of how to compare routes. Collect them all
in nm_platform_ip4_route_cmp(), nm_platform_ip4_route_hash(),
nm_platform_ip6_route_cmp(), and nm_platform_ip6_route_hash().

This way, we have them side-by-side, which makes the differences more
discoverable.
2017-08-03 18:51:35 +02:00
Thomas Haller
7141a3b87a platform: cleanup handling metric paramters for non-exclusive routes 2017-08-03 18:33:00 +02:00
Thomas Haller
93fd03277f platform: cleanup handling locks for non-exclusive routes 2017-08-03 18:33:00 +02:00
Thomas Haller
19a709069a platform: print lock paramters of route
It is valid to set "lock" for a property with numeric value 0.

    # ip route append 192.168.7.0/24 dev bond0 window lock 0
    # ip route append 192.168.7.0/24 dev bond0 window 0
    # ip route append 192.168.7.0/24 dev bond0 window lock 10
    # ip route append 192.168.7.0/24 dev bond0 window 10
    # ip -4 -d route show dev bond0
    unicast 192.168.7.0/24 proto boot scope link linkdown
    unicast 192.168.7.0/24 proto boot scope link linkdown
    unicast 192.168.7.0/24 proto boot scope link linkdown window lock 10
    unicast 192.168.7.0/24 proto boot scope link linkdown window 10

Our to-string methods should accurately print the content of
the routes. Note that iproute2 fails to do so too.
2017-08-03 18:33:00 +02:00
Thomas Haller
bf348cde69 platform: cleanup handling "window" for non-exclusive routes 2017-08-03 18:33:00 +02:00
Thomas Haller
8fc669c02a platform: use route src/src_plen when deleting IPv6 route 2017-08-03 18:33:00 +02:00
Thomas Haller
415e00d086 platform: use route pref_src when deleting IP route 2017-08-03 18:32:59 +02:00
Thomas Haller
8e4c5b173f platform: use route mss when deleting IP route
The mss (advmss, RTA_METRICS.RTAX_ADVMSS) is in a way part of
the ID for IPv4 routes. That is, you can add multiple IPv4 routes, that
only differ by mss.

On the other hand, that is not the case for IPv6. Two IPv6 routes
that only differ by mss are considered the same.

Another issue is, that you cannot selectively delete an IPv4 route based
on the mss:

    ip netns del x
    ip netns add x
    IP() {
      ip netns exec x ip "$@"
    }

    IP link add type veth
    IP link set veth0 name v
    IP link set veth1 up
    IP link set v up

    IP route append 192.168.7.0/24 dev v advmss 6
    IP route append 192.168.7.0/24 dev v advmss 7

    IP -d route show dev v

    IP route delete 192.168.7.0/24 dev v advmss 7

    IP -d route show dev v

It seems for deleting routes, kernel ignores mss (which doesn't really
matter for IPv6, but does so for IPv4).
2017-08-03 18:32:59 +02:00
Thomas Haller
88da13f0b2 platform: use correct gateway for deleting route
Routes may only differ by their gateway. When deleting
a route, we must specify the exact gateway to delete.
2017-08-03 18:32:59 +02:00
Thomas Haller
a041e431da platform: use correct scope for deleting IPv4 route
Refactor _nl_msg_new_route() to obtain the route scope (rtm_scope)
from the NMPObject, instead of a separate argument.

That way, when deleting an IPv4 route, we don't pick the first route
that matches (RT_SCOPE_NOWHERE), but use the actual scope of the route
that we want to delete. That matters, if there are more then one
otherwise identical routes that only differ by their scope.

For kernel, the scope of IPv6 routes is always global
(RT_SCOPE_UNIVERSE).

Also, during ip4_route_add() initialize the intermediate @obj to have
the values as we expect them after adding the route. That is necessary
to use it in _nl_msg_new_route(). But also nicer for consistency.

Also, move the scope_inv field in NMPlatformIP4Route to let the other
in_addr_t fields life side by side.
2017-08-03 18:32:59 +02:00
Thomas Haller
5a422af0d1 platform: use proper rt_source of route for add and delete
_nl_msg_new_route() should not get extra arguments, but instead
use all parameters from the NMPObject argument. This will allow
during nm_platform_ip_route_delete() to pick the exact route
that should be deleted.

Also, in ip4_route_add()/ip6_route_add(), keep the stack-allocated
@obj object consistent with what we expect to add. That is, set
the rt_source argument to the value of what the route will have
after kernel adds it. That might be necessary, because
do_add_addrroute() searches the cache for @obj.
2017-08-03 18:32:59 +02:00
Thomas Haller
b94e25e269 platform: drop duplicate cmd_obj_stackinit_id() virtual function
It can be implemented solely based on cmd_plobj_id_copy().
2017-08-03 18:32:59 +02:00
Thomas Haller
372f14a6ef platform: add compare functions for routes with different compare semantics
Routes are complicated.

`ip route add` and `ip route append` behaves differently with respect to
determine whether an existing route is idential or not.

Extend the cmp() and hash() functions to have a compare type, that
covers the different semantics.
2017-08-03 18:32:59 +02:00
Thomas Haller
54f8c2ac22 core: add nm_utils_ip6_address_same_prefix_cmp() helper
Useful for sorting/comparing.
2017-07-31 15:13:31 +02:00
Thomas Haller
8d03caf599 shared: cleanup NM_CMP_*() macros 2017-07-31 15:13:31 +02:00
Thomas Haller
b9fd352eca shared: move NM_CMP_*() helper macros to shared header 2017-07-31 15:13:31 +02:00
Thomas Haller
c8f3cd51ac platform/trivial: rename cmp helper macros 2017-07-31 15:13:31 +02:00
Beniamino Galvani
3bd5a83eff platform: fix failed assertion with cloned route
platform-linux: event-notification: NEWROUTE, seq 5: fd02::2/128 via fd01::1 dev 17 metric 0 mss 0 rt-src rt-unspec src ::/0 cloned mtu 1400
NetworkManager:ERROR:src/platform/nmp-object.h:614:ASSERT_nmp_cache_ops: assertion failed: (obj_old || obj_new)

Fixes: 9440eefb6d
2017-07-31 09:51:45 +02:00
Beniamino Galvani
565adb4df2 ppp: fix generation of IP config received from pppd
Since commit 22edeb5b69 ("core: track addresses for
NMIP4Config/NMIP6Config via NMDedupMultiIndex"), addresses can be
added to a IP config only after the ifindex has been set.

Fixes: 22edeb5b69
2017-07-28 10:37:23 +02:00
Beniamino Galvani
1b09fba19e core: fix IPv6 address lookup
Fixes: 22edeb5b69
2017-07-27 17:52:05 +02:00
Beniamino Galvani
1dd4fec550 platform: fix IPv4 secondary address detection
If the subnet index was built without the @full_index flag, secondary
addresses are not present in the hash table.

Fixes: 5fcca9ba3e
2017-07-27 16:44:27 +02:00
Beniamino Galvani
17ec3aef2f bridge: introduce a bridge.group-forward-mask connection property
https://bugzilla.redhat.com/show_bug.cgi?id=1358615
2017-07-27 09:35:11 +02:00
Beniamino Galvani
5414239988 platform: fix IPv4 address lookup in nm_platform_ip4_address_sync()
Fixes: 5fcca9ba3e
2017-07-26 17:27:05 +02:00
Beniamino Galvani
2f4dfd0f2e device: don't set a fake permanent hardware address
Software devices don't have a permanent hardware address and thus it
doesn't make sense to enforce the 'fake' (generated) permanent one
when cloned-mac-address=permanent.  Also, setting the fake permanent
address on bond devices, prevents them from inheriting the first slave
hardware address, so let's just skip the setting of MAC when
cloned-mac-address=permanent and there is no real permanent address.

https://bugzilla.redhat.com/show_bug.cgi?id=1472965
2017-07-26 14:05:38 +02:00
Beniamino Galvani
7382441433 checkpoint: document flags availability
Flags DELETE_NEW_CONNECTIONS and DISCONNECT_NEW_DEVICES were added in
1.6, document that.

https://bugzilla.redhat.com/show_bug.cgi?id=1474039
2017-07-25 23:11:38 +02:00
Beniamino Galvani
378a2f2486 libnm-core: clarify the meaning of the connection.permissions property
https://bugzilla.redhat.com/show_bug.cgi?id=1457939
2017-07-25 18:01:51 +02:00
Beniamino Galvani
4b51f5b1a8 libnm-core: improve documentation for ipv4.dhcp-client-id property
https://bugzilla.redhat.com/show_bug.cgi?id=1468358
2017-07-25 17:47:01 +02:00
Thomas Haller
e260f2a08a travis: fix travis build to use Ubuntu 12.04 LTS (Precise Pangolin)
Travis used by default Ubuntu 12.04 which is now EOL. Hence, the default
changed.

Eventually, we may want to upgrade the tests to run on Ubuntu 14.04.5
LTS (Trusty Tahr). But for that we need to adjust the travis test
script.

For now, explicitly select precise.

https://blog.travis-ci.com/2017-07-11-trusty-as-default-linux-is-coming?utm_source=web&utm_medium=banner&&utm_campaign=trusty-default
2017-07-25 16:24:34 +02:00
Thomas Haller
230287a5a4 libnm: fix settings-doc after update in libnm-core doc string
Fixes: 51e1215c85
2017-07-25 16:21:38 +02:00
Thomas Haller
51e1215c85 device: deprecate "bridge.mac-address" for "ethernet.cloned-mac-address" setting
The settings "bridge.mac-address" and "ethernet.cloned-mac-address" have an
overlapping meaning. If the former is unset, fallback to the latter.

Effectively, "bridge.mac-address" is deprecated in favor of
"ethernet.cloned-mac-address", which is more powerful as it supports
various modes like "stable". However, if a connection specifies
"bridge.mac-address", it is used when creating the bridge interface,
while "ethernet.cloned-mac-address" is used shortly after, during
activation.
2017-07-25 15:38:30 +02:00
Thomas Haller
459e76bdfe platform: consolidate debug logging during link-add
Don't log both in NMPlatform and NMLinuxPlatform.
Also, log all provided arguments.
2017-07-25 15:20:30 +02:00
Thomas Haller
f0adca00f3 core: fix creating lower-case MAC address with nm_utils_hwaddr_ntoa_buf()
There is only one caller at the moment, and he passes TRUE anyway.
2017-07-25 15:17:50 +02:00
Beniamino Galvani
25f2f33273 device: fix address check in start_sharing()
Fixes: 22edeb5b69
2017-07-25 14:49:50 +02:00
Beniamino Galvani
24b8429ee3 core: emit notify signals for addresses/routes in nm_ipX_config_replace
Fixes: 22edeb5b69
Fixes: 935411e5c0
Fixes: cfd1851c00
2017-07-25 14:49:50 +02:00
Thomas Haller
b2d21817ad core: fix setting output argument in nm_utils_stable_id_parse()
This bug has no consequences, as the only caller already initialized
the output variable to NULL.

Fixes: f0d40525df
2017-07-25 13:09:45 +02:00
Beniamino Galvani
81b2d77795 platform: nmp-object: fix memory leak
Fixes: 9440eefb6d
2017-07-25 09:03:54 +02:00
Richard Fontana
0c6f88d4f0 Make licensing of contributions more explicit
Signed-off-by: Richard Fontana <rfontana@redhat.com>

https://mail.gnome.org/archives/networkmanager-list/2017-July/msg00034.html
2017-07-25 07:16:35 +02:00
Thomas Haller
394ed959f4 core: merge branch 'th/dedup-multi-v2-bgo785004'
https://bugzilla.gnome.org/show_bug.cgi?id=785004
2017-07-25 06:44:34 +02:00
Thomas Haller
5f99512366 core: prevent invalid routes in NMIP4Config/NMIP6Config
Kernel requires that the host part of a route (based on network/plen)
is zero. Routes with non-zero host part don't really exist.

In settings (NMIPRoute), we don't enforce that. Hence we must ensure
that we don't let such invalid routes into NMIP4Config/NMIP6Config.

Also at other places where we obtain routes from untrusted sources,
we must sanitize them first.

Also add an assertion to catch such bugs.
2017-07-25 06:44:13 +02:00
Thomas Haller
5e5aa39c97 core: allow omitting @src argument in nm_utils_ip6_address_clear_host_address()
For convenience, to clear the address inplace, allow to leave @src NULL,
instead of requiring to set @src to @dst.

The only problem is, if you make use of this extended behavior and later backport
the use to an older branch, ensure that you cherry-pick this commit too.
That is easy to miss, but you are testing the backport, right?
2017-07-25 06:44:13 +02:00
Thomas Haller
4057a31017 core: simplify NMDedupMultiIter by storing CList pointer
Let next and head pointers point to the CList value, instead of
NMDedupMultiEntry.
2017-07-25 06:44:12 +02:00
Thomas Haller
2861c59116 platform: pass full route object to platform delete function
Contrary to addresses, routes have no ID. When deleting a route,
you cannot just specify certain properties like network/plen,metric.

Well, actually you can specify only certain properties, but then kernel
will treat unspecified properties as wildcard and delete the first matching
route. That is not something we want, because we need to be in control which
exact route shall be deleted.

Also, rtm_tos *must* match. Even if we like the wildcard behavior,
we would need to pass TOS to nm_platform_ip4_route_delete() to be
able to delete routes with non-zero TOS. So, while certain properties
may be omitted, some must not. See how test_ip4_route_options() was
broken.

For NetworkManager it only makes ever sense to call delete on a route,
if the route is already fully known. Which means, we only delete routes
that we have already in the platform cache (otherwise, how would we know
that there is something to delete). Because of that, no longer have separate
IPv4 and IPv6 functions. Instead, have nm_platform_ip_route_delete() which
accepts a full NMPObject from the platform cache.

The code in core doesn't jet make use of this new functionality. It will
in the future.

At least, it fixes deleting routes with differing TOS.
2017-07-25 06:44:12 +02:00
Thomas Haller
5b09f7151b platform: fix return value for do_delete_object()
The return value for the delete methods checks whether the object
is actually deleted. That is questionable behavior, because if the netlink
request succeeds, there is little point in checking with the platform cache.
As it is, it is racy.

Anyway, the previous value was totally wrong.

But it also uncovers another platform bug, which currently breaks
route tests. Will be fixed next.
2017-07-25 06:44:12 +02:00
Thomas Haller
5fcca9ba3e platform: refactor nm_platform_ip4_address_sync()
To reuse array of NMPObject instances instead of creating
a GArray clone.

Also get rid of the nm_platform_ipx_address_get_all() functions.
2017-07-25 06:44:12 +02:00
Thomas Haller
f749920f9c core: cache GVariant for NMIP4Config/NMIP6Config's "route-data" and "routes" 2017-07-25 06:44:12 +02:00
Thomas Haller
22edeb5b69 core: track addresses for NMIP4Config/NMIP6Config via NMDedupMultiIndex
Reasons:

 - it adds an O(1) lookup index for accessing NMIPxConfig's addresses.
   Hence, operations like merge/intersect have now runtime O(n) instead
   of O(n^2).
   Arguably, we expect low numbers of addresses in general. For low
   numbers, the O(n^2) doesn't matter and quite likely in those cases
   the previous implementation was just fine -- maybe even faster.
   But the simple case works fine either way. It's important to scale
   well in the exceptional case.
 - the tracked objects can be shared between the various NMPI4Config,
   NMIP6Config instances with NMPlatform and everybody else.
 - the NMPObject can be treated generically, meaning it enables code to
   handle both IPv4 and IPv6, or addresses and routes. See for example
   _nm_ip_config_add_obj().
 - I want core to evolve to somewhere where we don't keep copies of
   NMPlatformIP4Address, et al. instances. Instead they shall all be
   shared. I hope this will reduce memory consumption (although tracking a
   reference consumes some memory too). Also, it shortcuts nmp_object_equal()
   when comparing the same object. Calling nmp_object_equal() on the
   identical objects would be a common case after the hash function
   pre-evaluates equality.
2017-07-25 06:44:12 +02:00
Thomas Haller
74816a2237 core: rename self argument for NMIP4Config and NMIP6Config
The @config name is inconsistent. We name the self argument
commonly @self.
2017-07-25 06:44:12 +02:00
Thomas Haller
1c5d98292a c-list: add c_list_sort()
Add a stable, recursive merge sort for CList.

This could be improved by doing an iterative implementation.
The recursive implementation's stack depth is not an issue,
as it is bound by O(ln(n)). But an iterative implementation
would safe the overhead of O(n*log(n)) function calls and be
potentially faster.
2017-07-25 06:42:14 +02:00
Thomas Haller
824c8aba3d route-manager: fix timeout for cleanup device-route monitoring
The timeout was wrongly set to a huge number, and would never hit.
This leaked some data, that we could instead clean up. It's not
serious however.
2017-07-25 06:26:34 +02:00