mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 03:00:13 +01:00
core: ignore host part when comparing routes for route-manager
(cherry picked from commit b78562570a)
This commit is contained in:
parent
674b224bc1
commit
be19ec0739
4 changed files with 36 additions and 11 deletions
|
|
@ -377,7 +377,7 @@ _route_equals_ignoring_ifindex (const VTableIP *vtable, const NMPlatformIPXRoute
|
|||
r2_backup.rx.metric = (guint32) r2_metric;
|
||||
r2 = &r2_backup;
|
||||
}
|
||||
return vtable->vt->route_cmp (r1, r2) == 0;
|
||||
return vtable->vt->route_cmp (r1, r2, FALSE) == 0;
|
||||
}
|
||||
|
||||
static NMPlatformIPXRoute *
|
||||
|
|
|
|||
|
|
@ -4291,11 +4291,16 @@ nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6A
|
|||
}
|
||||
|
||||
int
|
||||
nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b)
|
||||
nm_platform_ip4_route_cmp_full (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, gboolean consider_host_part)
|
||||
{
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, network);
|
||||
if (consider_host_part)
|
||||
_CMP_FIELD (a, b, network);
|
||||
else {
|
||||
_CMP_DIRECT (nm_utils_ip4_address_clear_host_address (a->network, a->plen),
|
||||
nm_utils_ip4_address_clear_host_address (b->network, b->plen));
|
||||
}
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD (a, b, metric);
|
||||
_CMP_FIELD (a, b, gateway);
|
||||
|
|
@ -4319,11 +4324,19 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route
|
|||
}
|
||||
|
||||
int
|
||||
nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b)
|
||||
nm_platform_ip6_route_cmp_full (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b, gboolean consider_host_part)
|
||||
{
|
||||
_CMP_SELF (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD_MEMCMP (a, b, network);
|
||||
if (consider_host_part)
|
||||
_CMP_FIELD_MEMCMP (a, b, network);
|
||||
else {
|
||||
struct in6_addr n1, n2;
|
||||
|
||||
nm_utils_ip6_address_clear_host_address (&n1, &a->network, a->plen);
|
||||
nm_utils_ip6_address_clear_host_address (&n2, &b->network, b->plen);
|
||||
_CMP_DIRECT_MEMCMP (&n1, &n2, sizeof (struct in6_addr));
|
||||
}
|
||||
_CMP_FIELD (a, b, plen);
|
||||
_CMP_FIELD (a, b, metric);
|
||||
_CMP_FIELD_MEMCMP (a, b, gateway);
|
||||
|
|
@ -4541,7 +4554,7 @@ const NMPlatformVTableRoute nm_platform_vtable_route_v4 = {
|
|||
.is_ip4 = TRUE,
|
||||
.addr_family = AF_INET,
|
||||
.sizeof_route = sizeof (NMPlatformIP4Route),
|
||||
.route_cmp = (int (*) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b)) nm_platform_ip4_route_cmp,
|
||||
.route_cmp = (int (*) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b, gboolean consider_host_part)) nm_platform_ip4_route_cmp_full,
|
||||
.route_to_string = (const char *(*) (const NMPlatformIPXRoute *route, char *buf, gsize len)) nm_platform_ip4_route_to_string,
|
||||
.route_get_all = nm_platform_ip4_route_get_all,
|
||||
.route_add = _vtr_v4_route_add,
|
||||
|
|
@ -4554,7 +4567,7 @@ const NMPlatformVTableRoute nm_platform_vtable_route_v6 = {
|
|||
.is_ip4 = FALSE,
|
||||
.addr_family = AF_INET6,
|
||||
.sizeof_route = sizeof (NMPlatformIP6Route),
|
||||
.route_cmp = (int (*) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b)) nm_platform_ip6_route_cmp,
|
||||
.route_cmp = (int (*) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b, gboolean consider_host_part)) nm_platform_ip6_route_cmp_full,
|
||||
.route_to_string = (const char *(*) (const NMPlatformIPXRoute *route, char *buf, gsize len)) nm_platform_ip6_route_to_string,
|
||||
.route_get_all = nm_platform_ip6_route_get_all,
|
||||
.route_add = _vtr_v6_route_add,
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ typedef struct {
|
|||
gboolean is_ip4;
|
||||
int addr_family;
|
||||
gsize sizeof_route;
|
||||
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b);
|
||||
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b, gboolean consider_host_part);
|
||||
const char *(*route_to_string) (const NMPlatformIPXRoute *route, char *buf, gsize len);
|
||||
GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
||||
gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric);
|
||||
|
|
@ -1019,8 +1019,20 @@ int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVla
|
|||
int nm_platform_lnk_vxlan_cmp (const NMPlatformLnkVxlan *a, const NMPlatformLnkVxlan *b);
|
||||
int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b);
|
||||
int nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b);
|
||||
int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b);
|
||||
int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b);
|
||||
int nm_platform_ip4_route_cmp_full (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, gboolean consider_host_part);
|
||||
int nm_platform_ip6_route_cmp_full (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b, gboolean consider_host_part);
|
||||
|
||||
static inline int
|
||||
nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b)
|
||||
{
|
||||
return nm_platform_ip4_route_cmp_full (a, b, TRUE);
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b)
|
||||
{
|
||||
return nm_platform_ip6_route_cmp_full (a, b, TRUE);
|
||||
}
|
||||
|
||||
gboolean nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self);
|
||||
gboolean nm_platform_check_support_user_ipv6ll (NMPlatform *self);
|
||||
|
|
|
|||
|
|
@ -806,7 +806,7 @@ _assert_route_check (const NMPlatformVTableRoute *vtable, gboolean has, const NM
|
|||
c.r6 = route->r6;
|
||||
c.rx.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (c.rx.rt_source);
|
||||
}
|
||||
if (!r || vtable->route_cmp (r, &c) != 0) {
|
||||
if (!r || vtable->route_cmp (r, &c, TRUE) != 0) {
|
||||
g_error ("Invalid route. Expect %s, has %s",
|
||||
vtable->route_to_string (&c, NULL, 0),
|
||||
vtable->route_to_string (r, buf, sizeof (buf)));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue