diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 2a743401b..6e0335d8d 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 gateway, guint32 mss, gconstpointer pref_src, gconstpointer src, @@ -2503,9 +2502,12 @@ _nl_msg_new_route (int nlmsg_type, } /* We currently don't have need for multi-hop routes... */ - if ( gateway - && memcmp (gateway, &nm_ip_addr_zero, addr_len) != 0) - NLA_PUT (msg, RTA_GATEWAY, addr_len, gateway); + if (is_v4) { + NLA_PUT (msg, RTA_GATEWAY, addr_len, &obj->ip4_route.gateway); + } else { + if (!IN6_IS_ADDR_UNSPECIFIED (&obj->ip6_route.gateway)) + NLA_PUT (msg, RTA_GATEWAY, addr_len, &obj->ip6_route.gateway); + } NLA_PUT_U32 (msg, RTA_OIF, obj->ip_route.ifindex); return msg; @@ -5702,7 +5704,6 @@ ip4_route_add (NMPlatform *platform, const NMPlatformIP4Route *route) nlmsg = _nl_msg_new_route (RTM_NEWROUTE, NLM_F_CREATE | NLM_F_REPLACE, &obj, - &route->gateway, route->mss, route->pref_src ? &route->pref_src : NULL, NULL, @@ -5731,7 +5732,6 @@ ip6_route_add (NMPlatform *platform, const NMPlatformIP6Route *route) nlmsg = _nl_msg_new_route (RTM_NEWROUTE, NLM_F_CREATE | NLM_F_REPLACE, &obj, - &route->gateway, route->mss, !IN6_IS_ADDR_UNSPECIFIED (&route->pref_src) ? &route->pref_src : NULL, !IN6_IS_ADDR_UNSPECIFIED (&route->src) ? &route->src : NULL, @@ -5792,7 +5792,6 @@ ip_route_delete (NMPlatform *platform, nlmsg = _nl_msg_new_route (RTM_DELROUTE, 0, obj, - NULL, 0, NULL, NULL, diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index c8b3e160c..a8820750b 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -4753,6 +4753,7 @@ nm_platform_ip4_route_hash (const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpT h = NM_HASH_COMBINE (h, obj->ifindex); h = NM_HASH_COMBINE (h, obj->rt_source); h = NM_HASH_COMBINE (h, obj->scope_inv); + h = NM_HASH_COMBINE (h, obj->gateway); } break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY: @@ -4807,6 +4808,7 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route NM_CMP_FIELD (a, b, ifindex); NM_CMP_FIELD (a, b, rt_source); NM_CMP_FIELD (a, b, scope_inv); + NM_CMP_FIELD (a, b, gateway); } break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY: @@ -4858,8 +4860,10 @@ nm_platform_ip6_route_hash (const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpT 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); - if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) + if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) { h = NM_HASH_COMBINE (h, obj->ifindex); + h = NM_HASH_COMBINE_IN6ADDR (h, &obj->gateway); + } break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY: case NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL: @@ -4910,8 +4914,10 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route 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); - if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) + if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) { NM_CMP_FIELD (a, b, ifindex); + NM_CMP_FIELD_IN6ADDR (a, b, gateway); + } break; case NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY: case NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL: diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 326abcdf2..3eb21a41b 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -377,6 +377,8 @@ typedef struct { struct _NMPlatformIP4Route { __NMPlatformIPRoute_COMMON; in_addr_t network; + + /* 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 @@ -400,7 +402,10 @@ struct _NMPlatformIP4Route { struct _NMPlatformIP6Route { __NMPlatformIPRoute_COMMON; struct in6_addr network; + + /* RTA_GATEWAY. The gateway is part of the primary key for a route */ struct in6_addr gateway; + struct in6_addr pref_src; struct in6_addr src; guint8 src_plen;