diff options
author | Thomas Haller <thaller@redhat.com> | 2017-07-26 09:25:21 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-08-03 18:32:59 +0200 |
commit | 415e00d086d52a6fddc1442bc058df951d630db1 (patch) | |
tree | fa74864ee16d748c7c27c4c60e44b94466bc0bff | |
parent | 8e4c5b173f4994c3763a9f0216a78f30541b1dca (diff) | |
download | NetworkManager-415e00d086d52a6fddc1442bc058df951d630db1.tar.gz |
platform: use route pref_src when deleting IP route
-rw-r--r-- | src/platform/nm-linux-platform.c | 13 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 2 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 13 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index f0b753e446..7022dc0bb9 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2419,7 +2419,6 @@ static struct nl_msg * _nl_msg_new_route (int nlmsg_type, int nlmsg_flags, const NMPObject *obj, - gconstpointer pref_src, gconstpointer src, guint8 src_plen, guint32 window, @@ -2472,8 +2471,13 @@ _nl_msg_new_route (int nlmsg_type, NLA_PUT_U32 (msg, RTA_PRIORITY, obj->ip_route.metric); - if (pref_src) - NLA_PUT (msg, RTA_PREFSRC, addr_len, pref_src); + if (is_v4) { + if (NMP_OBJECT_CAST_IP4_ROUTE (obj)->pref_src) + NLA_PUT (msg, RTA_PREFSRC, addr_len, &obj->ip4_route.pref_src); + } else { + if (!IN6_IS_ADDR_UNSPECIFIED (&NMP_OBJECT_CAST_IP6_ROUTE (obj)->pref_src)) + NLA_PUT (msg, RTA_PREFSRC, addr_len, &obj->ip6_route.pref_src); + } if ( obj->ip_route.mss || window || cwnd || initcwnd || initrwnd || mtu || lock) { @@ -5704,7 +5708,6 @@ ip4_route_add (NMPlatform *platform, const NMPlatformIP4Route *route) nlmsg = _nl_msg_new_route (RTM_NEWROUTE, NLM_F_CREATE | NLM_F_REPLACE, &obj, - route->pref_src ? &route->pref_src : NULL, NULL, 0, route->window, @@ -5731,7 +5734,6 @@ ip6_route_add (NMPlatform *platform, const NMPlatformIP6Route *route) nlmsg = _nl_msg_new_route (RTM_NEWROUTE, NLM_F_CREATE | NLM_F_REPLACE, &obj, - !IN6_IS_ADDR_UNSPECIFIED (&route->pref_src) ? &route->pref_src : NULL, !IN6_IS_ADDR_UNSPECIFIED (&route->src) ? &route->src : NULL, route->src_plen, route->window, @@ -5791,7 +5793,6 @@ ip_route_delete (NMPlatform *platform, 0, obj, NULL, - NULL, 0, 0, 0, diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 45022254d0..47d4946009 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -4755,6 +4755,7 @@ nm_platform_ip4_route_hash (const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpT h = NM_HASH_COMBINE (h, obj->scope_inv); h = NM_HASH_COMBINE (h, obj->gateway); h = NM_HASH_COMBINE (h, obj->mss); + h = NM_HASH_COMBINE (h, obj->pref_src); } break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY: @@ -4811,6 +4812,7 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route NM_CMP_FIELD (a, b, scope_inv); NM_CMP_FIELD (a, b, gateway); NM_CMP_FIELD (a, b, mss); + NM_CMP_FIELD (a, b, pref_src); } break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY: diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 4f8e5c762a..9b2e789c37 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -391,8 +391,10 @@ struct _NMPlatformIP4Route { /* RTA_GATEWAY. The gateway is part of the primary key for a route */ in_addr_t gateway; - /* RTA_PREFSRC/rtnl_route_get_pref_src(). A value of zero means that - * no pref-src is set. */ + /* RTA_PREFSRC (called "src" by iproute2). + * + * pref_src is part of the ID of an IPv4 route. When deleting a route, + * pref_src must match, unless set to 0.0.0.0 to match any. */ in_addr_t pref_src; /* The bitwise inverse of the route scope rtm_scope. It is inverted so that the @@ -416,7 +418,14 @@ struct _NMPlatformIP6Route { /* RTA_GATEWAY. The gateway is part of the primary key for a route */ struct in6_addr gateway; + /* RTA_PREFSRC (called "src" by iproute2). + * + * pref_src is not part of the ID for an IPv6 route. You cannot add two + * routes that only differ by pref_src. + * + * When deleting a route, pref_src is ignored by kernel. */ struct in6_addr pref_src; + struct in6_addr src; guint8 src_plen; }; |