diff options
author | Thomas Haller <thaller@redhat.com> | 2017-07-19 12:33:42 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-07-26 16:58:50 +0200 |
commit | 6ac2991e231b4b93084ef35d2b4d7781b536575a (patch) | |
tree | 1504462b58eb46e57b1017ed005cc5678dfcd79b | |
parent | 4c69cbf1a80806abb67ba4c103b6879f34f6f5d5 (diff) | |
download | NetworkManager-th/platform-route.tar.gz |
WIP: platform: properly handle same routes in platform cacheth/platform-route
From kernel's point of view, you can add a new routes as long as
there is no existing route that is exactly identical. That effectively
means, that every field of the route is part of the ID.
Currently, we handle that wrong, thus when kernel notifies platform
about two such routes, we would wrongly merge them together.
For example:
ip link add dev0 type dummy
ip link add dev1 type dummy
ip link set dev0 up
ip link set dev1 up
ip addr add 192.168.200.4/24 dev dev0
ip addr add 192.168.201.4/24 dev dev1
ip route add 10.132.5.0/24 dev dev0
ip route append 10.132.5.0/24 via 192.168.212.1 dev dev0
ip route append 10.132.5.0/24 via 192.168.212.1 dev dev0 proto 5
ip route show dev dev0
ip route add 1:2:3:4:5::/64 via fe80::1:a dev dev0
ip route append 1:2:3:4:5::/64 via fe80::1:b dev dev0
ip route append 1:2:3:4:5::/64 via fe80::1:b dev dev0 proto 5
ip -6 route show dev dev0
Note the difference here are the netlink flags:
`ip route append` (NLM_F_CREATE|NLM_F_APPEND)
`ip route prepend` (NLM_F_CREATE)
`ip route add` (NLM_F_CREATE|NLM_F_EXCL)
`ip route change` (NLM_F_REPLACE)
`ip route replace` (NLM_F_CREATE|NLM_F_REPLACE)
Extend platform to consider every property of a route to be part
of the ID.
-rw-r--r-- | src/platform/nm-platform.c | 24 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 5 | ||||
-rw-r--r-- | src/platform/nmp-object.c | 12 |
3 files changed, 6 insertions, 35 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 078afa28f6..fc1f35b5f6 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -4738,12 +4738,6 @@ nm_platform_ip4_route_hash (const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpT if (obj) { switch (cmp_type) { - case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE: - h = NM_HASH_COMBINE (h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen)); - h = NM_HASH_COMBINE (h, obj->plen); - h = NM_HASH_COMBINE (h, obj->metric); - h = NM_HASH_COMBINE (h, obj->ifindex); - break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID: case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID: h = NM_HASH_COMBINE (h, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen)); @@ -4789,12 +4783,6 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route { NM_CMP_SELF (a, b); switch (cmp_type) { - case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE: - NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX (a->network, b->network, MIN (a->plen, b->plen)); - NM_CMP_FIELD (a, b, plen); - NM_CMP_FIELD (a, b, metric); - NM_CMP_FIELD (a, b, ifindex); - break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID: case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID: NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX (a->network, b->network, MIN (a->plen, b->plen)); @@ -4841,12 +4829,6 @@ nm_platform_ip6_route_hash (const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpT if (obj) { switch (cmp_type) { - case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE: - h = NM_HASH_COMBINE_IN6ADDR_PREFIX (h, &obj->network, obj->plen); - h = NM_HASH_COMBINE (h, obj->plen); - h = NM_HASH_COMBINE (h, obj->metric); - h = NM_HASH_COMBINE (h, obj->ifindex); - break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID: case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID: h = NM_HASH_COMBINE_IN6ADDR_PREFIX (h, &obj->network, obj->plen); @@ -4893,12 +4875,6 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route { NM_CMP_SELF (a, b); switch (cmp_type) { - case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE: - NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX (&a->network, &b->network, MIN (a->plen, b->plen)); - NM_CMP_FIELD (a, b, plen); - NM_CMP_FIELD (a, b, metric); - NM_CMP_FIELD (a, b, ifindex); - break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID: case NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID: NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX (&a->network, &b->network, MIN (a->plen, b->plen)); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 5c2c21ad3f..a2128e49a9 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -88,11 +88,6 @@ typedef enum { * according to NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID. */ NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID, - /* FIXME: this type is what NMPCache currently uses for object identity. - * Eventually, we want to use NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID, - * which is the same what kernel does. */ - NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE, - /* compare all fields as they make sense for kernel. For example, * a route destination 192.168.1.5/24 is not accepted by kernel and * we treat it identical to 192.168.1.0/24. Semantically these diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index 6d719bc458..b13e6bcd67 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -988,14 +988,14 @@ _vt_cmd_plobj_id_copy (ip4_route, NMPlatformIP4Route, { dst->plen = src->plen; dst->metric = src->metric; dst->network = src->network; - nm_assert (nm_platform_ip4_route_cmp (dst, src, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE) == 0); + nm_assert (nm_platform_ip4_route_cmp (dst, src, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) == 0); }); _vt_cmd_plobj_id_copy (ip6_route, NMPlatformIP6Route, { dst->ifindex = src->ifindex; dst->plen = src->plen; dst->metric = src->metric; dst->network = src->network; - nm_assert (nm_platform_ip6_route_cmp (dst, src, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE) == 0); + nm_assert (nm_platform_ip6_route_cmp (dst, src, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) == 0); }); /* Uses internally nmp_object_copy(), hence it also violates the const @@ -1057,9 +1057,9 @@ _vt_cmd_plobj_id_equal (ip6_address, NMPlatformIP6Address, /* for IPv6 addresses, the prefix length is not part of the primary identifier. */ && IN6_ARE_ADDR_EQUAL (&obj1->address, &obj2->address)); _vt_cmd_plobj_id_equal (ip4_route, NMPlatformIP4Route, - nm_platform_ip4_route_cmp (obj1, obj2, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE) == 0); + nm_platform_ip4_route_cmp (obj1, obj2, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) == 0); _vt_cmd_plobj_id_equal (ip6_route, NMPlatformIP6Route, - nm_platform_ip6_route_cmp (obj1, obj2, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE) == 0); + nm_platform_ip6_route_cmp (obj1, obj2, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) == 0); guint nmp_object_id_hash (const NMPObject *obj) @@ -1108,10 +1108,10 @@ _vt_cmd_plobj_id_hash (ip6_address, NMPlatformIP6Address, { hash = NM_HASH_COMBINE (hash, nm_utils_in6_addr_hash (&obj->address)); }) _vt_cmd_plobj_id_hash (ip4_route, NMPlatformIP4Route, { - hash = nm_platform_ip4_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE); + hash = nm_platform_ip4_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID); }) _vt_cmd_plobj_id_hash (ip6_route, NMPlatformIP6Route, { - hash = nm_platform_ip6_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID_CACHE); + hash = nm_platform_ip6_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID); }) gboolean |