diff options
author | Thomas Haller <thaller@redhat.com> | 2017-07-19 12:33:42 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-07-25 06:46:30 +0200 |
commit | 23feca2f946d1f3e12317962a6dc5320597466c4 (patch) | |
tree | 8d38944b174d6571a482c9c5fb8fee64e6c82ff7 | |
parent | 538f7cd4e0ec872bef979d7d741146975c07c1b0 (diff) | |
download | NetworkManager-th/dedup-multi-v3.tar.gz |
WIP: platform: properly handle same routes in platform cacheth/dedup-multi-v3
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/nmp-object.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index b6a51e58bc..f36e55b099 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -1020,16 +1020,10 @@ _vt_cmd_plobj_id_copy (ip6_address, NMPlatformIP6Address, { dst->address = src->address; }); _vt_cmd_plobj_id_copy (ip4_route, NMPlatformIP4Route, { - dst->ifindex = src->ifindex; - dst->plen = src->plen; - dst->metric = src->metric; - dst->network = src->network; + *dst = *src; }); _vt_cmd_plobj_id_copy (ip6_route, NMPlatformIP6Route, { - dst->ifindex = src->ifindex; - dst->plen = src->plen; - dst->metric = src->metric; - dst->network = src->network; + *dst = *src; }); /* Uses internally nmp_object_copy(), hence it also violates the const @@ -1091,20 +1085,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, - obj1->ifindex == obj2->ifindex - && obj1->plen == obj2->plen - && obj1->metric == obj2->metric - && nm_utils_ip4_address_clear_host_address (obj1->network, obj1->plen) == nm_utils_ip4_address_clear_host_address (obj2->network, obj2->plen)); + nm_platform_ip4_route_cmp_full (obj1, obj2, TRUE) == 0); _vt_cmd_plobj_id_equal (ip6_route, NMPlatformIP6Route, - obj1->ifindex == obj2->ifindex - && obj1->plen == obj2->plen - && obj1->metric == obj2->metric - && ({ - struct in6_addr n1, n2; - - IN6_ARE_ADDR_EQUAL(nm_utils_ip6_address_clear_host_address (&n1, &obj1->network, obj1->plen), - nm_utils_ip6_address_clear_host_address (&n2, &obj2->network, obj2->plen)); - })); + nm_platform_ip6_route_cmp_full (obj1, obj2, TRUE) == 0); guint nmp_object_id_hash (const NMPObject *obj) @@ -1154,21 +1137,11 @@ _vt_cmd_plobj_id_hash (ip6_address, NMPlatformIP6Address, { }) _vt_cmd_plobj_id_hash (ip4_route, NMPlatformIP4Route, { hash = (guint) 2569857221u; - hash = hash + ((guint) obj->ifindex); - hash = NM_HASH_COMBINE (hash, obj->plen); - hash = NM_HASH_COMBINE (hash, obj->metric); - hash = NM_HASH_COMBINE (hash, nm_utils_ip4_address_clear_host_address (obj->network, obj->plen)); + hash = NM_HASH_COMBINE (hash, nm_platform_ip4_route_hash (obj)); }) _vt_cmd_plobj_id_hash (ip6_route, NMPlatformIP6Route, { hash = (guint) 3999787007u; - hash = hash + ((guint) obj->ifindex); - hash = NM_HASH_COMBINE (hash, obj->plen); - hash = NM_HASH_COMBINE (hash, obj->metric); - hash = NM_HASH_COMBINE (hash, - ({ - struct in6_addr n1; - nm_utils_in6_addr_hash (nm_utils_ip6_address_clear_host_address (&n1, &obj->network, obj->plen)); - })); + hash = NM_HASH_COMBINE (hash, nm_platform_ip6_route_hash (obj)); }) gboolean |