diff options
author | Thomas Haller <thaller@redhat.com> | 2017-04-13 18:58:22 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-04-15 00:37:22 +0200 |
commit | ae8d98391a6c2c6a2b7b77b7b3809d7a181c5bee (patch) | |
tree | ad03ecaa4d6b0a466067f512fb61a6636b8de133 /src/platform | |
parent | 514d79fc8528c036a49cdfe48ce0ff5fe0974114 (diff) | |
download | NetworkManager-ae8d98391a6c2c6a2b7b77b7b3809d7a181c5bee.tar.gz |
platform: only consider net part of routes for route cache's ID
Routes with a non-zero host part are not allowed by kernel and
don't really exist. We didn't reject such routes in users configuration,
so various part of NM allow such routes. NM should silently strip
the host part.
Extend the cache's route ID to clear the host part too.
Note that NM's handling of routes is fundamentally flawed, as
for kernels routes don't have an "id" (or rather: all properties
of a route are part of it's ID, not only the family,ifindex,
network/plen and metric tuple (see related bug rh#1337855).
(cherry picked from commit 57b0dce083a1991530e14735588d873e441f26fa)
Diffstat (limited to 'src/platform')
-rw-r--r-- | src/platform/nmp-object.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index 719b2c4d80..b27d9e33b6 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -805,12 +805,17 @@ _vt_cmd_plobj_id_equal (ip4_route, NMPlatformIP4Route, obj1->ifindex == obj2->ifindex && obj1->plen == obj2->plen && obj1->metric == obj2->metric - && obj1->network == obj2->network); + && nm_utils_ip4_address_clear_host_address (obj1->network, obj1->plen) == nm_utils_ip4_address_clear_host_address (obj2->network, obj2->plen)); _vt_cmd_plobj_id_equal (ip6_route, NMPlatformIP6Route, obj1->ifindex == obj2->ifindex && obj1->plen == obj2->plen && obj1->metric == obj2->metric - && IN6_ARE_ADDR_EQUAL( &obj1->network, &obj2->network)); + && ({ + 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)); + })); guint nmp_object_id_hash (const NMPObject *obj) @@ -864,14 +869,17 @@ _vt_cmd_plobj_id_hash (ip4_route, NMPlatformIP4Route, { hash = hash + ((guint) obj->ifindex); hash = hash * 33 + ((guint) obj->plen); hash = hash * 33 + ((guint) obj->metric); - hash = hash * 33 + ((guint) obj->network); + hash = hash * 33 + ((guint) nm_utils_ip4_address_clear_host_address (obj->network, obj->plen)); }) _vt_cmd_plobj_id_hash (ip6_route, NMPlatformIP6Route, { hash = (guint) 3999787007u; hash = hash + ((guint) obj->ifindex); hash = hash * 33 + ((guint) obj->plen); hash = hash * 33 + ((guint) obj->metric); - hash = hash * 33 + _id_hash_ip6_addr (&obj->network); + hash = hash * 33 + ({ + struct in6_addr n1; + _id_hash_ip6_addr (nm_utils_ip6_address_clear_host_address (&n1, &obj->network, obj->plen)); + }); }) gboolean |