From 03bf4a34251b9fb23cff564df00f0bd3defbb95a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 8 Sep 2022 08:43:14 +0200 Subject: [PATCH 1/6] platform/tests: use NM_ETHER_ADDR_INIT() macro --- src/core/platform/tests/test-link.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index 29e75446ad..d97d272dc0 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -1301,19 +1301,19 @@ test_software_detect(gconstpointer user_data) nmtstp_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BR_VLAN_STATS_ENABLED) ? TRUE : FALSE; - lnk_bridge.group_fwd_mask = 8; - lnk_bridge.group_addr = (NMEtherAddr){{0x01, 0x80, 0xC2, 0x00, 0x00, 0x08}}; - lnk_bridge.mcast_snooping = TRUE; - lnk_bridge.mcast_router = 1; - lnk_bridge.mcast_query_use_ifaddr = TRUE; - lnk_bridge.mcast_querier = TRUE; - lnk_bridge.mcast_hash_max = 1024; - lnk_bridge.mcast_last_member_count = 2; - lnk_bridge.mcast_startup_query_count = 3; - lnk_bridge.mcast_last_member_interval = 5000; - lnk_bridge.mcast_membership_interval = 25000; - lnk_bridge.mcast_querier_interval = 26000; - lnk_bridge.mcast_query_interval = 12000; + lnk_bridge.group_fwd_mask = 8; + lnk_bridge.group_addr = NM_ETHER_ADDR_INIT(0x01, 0x80, 0xC2, 0x00, 0x00, 0x08); + lnk_bridge.mcast_snooping = TRUE; + lnk_bridge.mcast_router = 1; + lnk_bridge.mcast_query_use_ifaddr = TRUE; + lnk_bridge.mcast_querier = TRUE; + lnk_bridge.mcast_hash_max = 1024; + lnk_bridge.mcast_last_member_count = 2; + lnk_bridge.mcast_startup_query_count = 3; + lnk_bridge.mcast_last_member_interval = 5000; + lnk_bridge.mcast_membership_interval = 25000; + lnk_bridge.mcast_querier_interval = 26000; + lnk_bridge.mcast_query_interval = 12000; lnk_bridge.mcast_query_response_interval = 5200; lnk_bridge.mcast_startup_query_interval = 3000; From c413d7c6574dc58c0bb39bc5d7b08d0d5961cff7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 8 Sep 2022 08:35:41 +0200 Subject: [PATCH 2/6] glib-aux: add NM_IN6ADDR_INIT() macro and use it --- src/libnm-glib-aux/nm-inet-utils.h | 24 ++++++++++++++++++++++++ src/libnm-platform/nm-platform.c | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/libnm-glib-aux/nm-inet-utils.h b/src/libnm-glib-aux/nm-inet-utils.h index d9246d459b..043ad79930 100644 --- a/src/libnm-glib-aux/nm-inet-utils.h +++ b/src/libnm-glib-aux/nm-inet-utils.h @@ -25,6 +25,30 @@ typedef struct _NMIPAddr { .array = { 0 } \ } +#define _NM_IN6ADDR_INIT(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af) \ + { \ + .s6_addr = { \ + (a0), \ + (a1), \ + (a2), \ + (a3), \ + (a4), \ + (a5), \ + (a6), \ + (a7), \ + (a8), \ + (a9), \ + (aa), \ + (ab), \ + (ac), \ + (ad), \ + (ae), \ + (af), \ + } \ + } + +#define NM_IN6ADDR_INIT(...) ((struct in6_addr) _NM_IN6ADDR_INIT(__VA_ARGS__)) + extern const NMIPAddr nm_ip_addr_zero; /* This doesn't really belong here, but since it's convenient to re-use nm_ip_addr_zero.ether_addr diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index ff635b33fe..b4ecc34e4e 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -4853,7 +4853,8 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, .table_coerced = nm_platform_route_table_coerce(local_table), .rt_pref = NM_ICMPV6_ROUTER_PREF_MEDIUM, .gateway = IN6ADDR_ANY_INIT, - .network = {{{0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}}, + .network = + NM_IN6ADDR_INIT(0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), }; } From 75349dc56669b06009d3d1cd13e6f21fd248a5b8 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Sun, 12 Jun 2022 19:50:09 -0400 Subject: [PATCH 3/6] glib-aux: add "NM_IPV4LO_NETWORK" defines and similar Co-authored-by: Thomas Haller --- src/libnm-glib-aux/nm-inet-utils.h | 10 +++++++--- src/libnm-glib-aux/tests/test-shared-general.c | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libnm-glib-aux/nm-inet-utils.h b/src/libnm-glib-aux/nm-inet-utils.h index 043ad79930..b730bda06d 100644 --- a/src/libnm-glib-aux/nm-inet-utils.h +++ b/src/libnm-glib-aux/nm-inet-utils.h @@ -254,15 +254,19 @@ gboolean nm_ip6_addr_is_ula(const struct in6_addr *address); /*****************************************************************************/ -#define NM_IPV4LL_NETWORK ((in_addr_t) htonl(0xA9FE0000lu)) -#define NM_IPV4LL_NETMASK ((in_addr_t) htonl(0xFFFF0000lu)) +#define NM_IPV4LL_NETWORK ((in_addr_t) htonl(0xA9FE0000lu)) /* 169.254.0.0 */ +#define NM_IPV4LL_NETMASK ((in_addr_t) htonl(0xFFFF0000lu)) /* 255.255.0.0 */ +#define NM_IPV4LO_NETWORK ((in_addr_t) htonl(0x7F000000lu)) /* 127.0.0.0 */ +#define NM_IPV4LO_NETMASK ((in_addr_t) htonl(0xFF000000lu)) /* 255.0.0.0 */ +#define NM_IPV4LO_PREFIXLEN 8 +#define NM_IPV4LO_ADDR1 ((in_addr_t) htonl(0x7F000001lu)) /* 127.0.0.1 */ static inline gboolean nm_ip4_addr_is_loopback(in_addr_t addr) { /* There is also IN_LOOPBACK() in , but there the * argument is in host order not `in_addr_t`. */ - return (addr & htonl(0xFF000000u)) == htonl(0x7F000000u); + return (addr & NM_IPV4LO_NETMASK) == NM_IPV4LO_NETWORK; } static inline gboolean diff --git a/src/libnm-glib-aux/tests/test-shared-general.c b/src/libnm-glib-aux/tests/test-shared-general.c index 5d9072e177..a49bbe0a20 100644 --- a/src/libnm-glib-aux/tests/test-shared-general.c +++ b/src/libnm-glib-aux/tests/test-shared-general.c @@ -259,6 +259,10 @@ test_nm_ip4_addr_is_loopback(void) g_assert(!nm_ip4_addr_is_loopback(nmtst_inet4_from_string("126.5.0.1"))); g_assert(!nm_ip4_addr_is_loopback(nmtst_inet4_from_string("128.5.0.1"))); g_assert(!nm_ip4_addr_is_loopback(nmtst_inet4_from_string("129.5.0.1"))); + g_assert_cmpint(nmtst_inet4_from_string("127.0.0.0"), ==, NM_IPV4LO_NETWORK); + g_assert_cmpint(nmtst_inet4_from_string("127.0.0.1"), ==, NM_IPV4LO_ADDR1); + g_assert_cmpint(nmtst_inet4_from_string("255.0.0.0"), ==, NM_IPV4LO_NETMASK); + g_assert_cmpint(nm_ip4_addr_netmask_to_prefix(NM_IPV4LO_NETMASK), ==, NM_IPV4LO_PREFIXLEN); } /*****************************************************************************/ From ef51d0f980bdadd8274aafc609f92a9730f0c55e Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Sun, 12 Jun 2022 19:50:09 -0400 Subject: [PATCH 4/6] libnm-base,all: add and use NM_LOOPBACK_IFINDEX define Co-authored-by: Thomas Haller --- src/core/devices/nm-device.c | 3 ++- src/core/nm-manager.c | 2 +- src/libnm-base/nm-base.h | 6 ++++++ src/libnm-platform/nm-platform.c | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 9f4c5bb7e8..132825af41 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -2737,7 +2737,8 @@ _ethtool_state_set(NMDevice *self) static gboolean is_loopback(NMDevice *self) { - return NM_IS_DEVICE_GENERIC(self) && NM_DEVICE_GET_PRIVATE(self)->ifindex == 1; + return NM_IS_DEVICE_GENERIC(self) + && NM_DEVICE_GET_PRIVATE(self)->ifindex == NM_LOOPBACK_IFINDEX; } gboolean diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index e198385c87..df890cdb6f 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -7087,7 +7087,7 @@ nm_manager_write_device_state(NMManager *self, NMDevice *device, int *out_ifinde ifindex = nm_device_get_ip_ifindex(device); if (ifindex <= 0) return FALSE; - if (ifindex == 1) { + if (ifindex == NM_LOOPBACK_IFINDEX) { /* ignore loopback */ return FALSE; } diff --git a/src/libnm-base/nm-base.h b/src/libnm-base/nm-base.h index ff062a18b8..a8d6b2c892 100644 --- a/src/libnm-base/nm-base.h +++ b/src/libnm-base/nm-base.h @@ -393,6 +393,12 @@ typedef struct { #define NM_BOND_PORT_QUEUE_ID_DEF 0 +/****************************************************************************/ + +/* ifindex generation is per-net namespace, and loopback is always the first + * device in the network namespace, thus any loopback device should get ifindex 1. */ +#define NM_LOOPBACK_IFINDEX 1 + /*****************************************************************************/ /* NM_CRYPTO_ERROR is part of public API in libnm (implemented in libnm-core). diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index b4ecc34e4e..e2c2df866b 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -948,9 +948,9 @@ _link_get_all_presort(gconstpointer p_a, gconstpointer p_b, gpointer sort_by_nam const NMPlatformLink *b = NMP_OBJECT_CAST_LINK(*((const NMPObject **) p_b)); /* Loopback always first */ - if (a->ifindex == 1) + if (a->ifindex == NM_LOOPBACK_IFINDEX) return -1; - if (b->ifindex == 1) + if (b->ifindex == NM_LOOPBACK_IFINDEX) return 1; if (GPOINTER_TO_INT(sort_by_name)) { From 96d266cf518f221df37008c87e49b42b09f7da89 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Thu, 8 Sep 2022 09:28:28 +0200 Subject: [PATCH 5/6] platform: add NMPIPAddressSyncFlags parameter to nm_platform_ip_address_sync() Previously, nm_platform_ip_address_sync() would always add the "IFA_F_NOPREFIXROUTE" flag. Add a way to let the caller control that. Add a flags argument, with a new flag "with-noprefixroute". By default (with flags "none"), nm_platform_ip_address_sync() would no longer add "IFA_F_NOPREFIXROUTE" flag, but the caller can now opt-in to that. The purpose is that on "lo" interface we will want to let kernel handle the prefix route. So have a per-ifindex opt-in for controlling this. During nm_platform_ip_address_flush() we use "none" flags, because the function anyway doesn't add any addresses, so it wouldn't matter. There is no change in behavior. Co-authored-by: Thomas Haller --- src/core/nm-l3cfg.c | 3 +- src/libnm-platform/nm-platform.c | 51 +++++++++++++++++++++----------- src/libnm-platform/nm-platform.h | 16 ++++++---- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 963e381b14..f2ed0f63fb 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -4559,7 +4559,8 @@ _l3_commit_one(NML3Cfg *self, addr_family, self->priv.ifindex, addresses, - addresses_prune); + addresses_prune, + NMP_IP_ADDRESS_SYNC_FLAGS_WITH_NOPREFIXROUTE); _nodev_routes_sync(self, addr_family, commit_type, routes_nodev); diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index e2c2df866b..68e1952c2f 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -4105,6 +4105,9 @@ ip6_address_scope_cmp_descending(gconstpointer p_a, gconstpointer p_b, gpointer * by the function. * Addresses that are both contained in @known_addresses and @addresses_prune * will be configured. + * @flags: #NMPIPAddressSyncFlags to affect the sync. If "with-noprefixroute" + * flag is set, the method will automatically set IFA_F_NOPREFIXROUTE for + * all addresses. * * A convenience function to synchronize addresses for a specific interface * with the least possible disturbance. It simply removes addresses that are @@ -4113,11 +4116,12 @@ ip6_address_scope_cmp_descending(gconstpointer p_a, gconstpointer p_b, gpointer * Returns: %TRUE on success. */ gboolean -nm_platform_ip_address_sync(NMPlatform *self, - int addr_family, - int ifindex, - GPtrArray *known_addresses, - GPtrArray *addresses_prune) +nm_platform_ip_address_sync(NMPlatform *self, + int addr_family, + int ifindex, + GPtrArray *known_addresses, + GPtrArray *addresses_prune, + NMPIPAddressSyncFlags flags) { gint32 now = 0; const int IS_IPv4 = NM_IS_IPv4(addr_family); @@ -4529,18 +4533,24 @@ next_plat:; nm_platform_ip4_broadcast_address_from_addr(&known_address->a4), lifetime, preferred, - IFA_F_NOPREFIXROUTE, + NM_FLAGS_HAS(flags, NMP_IP_ADDRESS_SYNC_FLAGS_WITH_NOPREFIXROUTE) + ? IFA_F_NOPREFIXROUTE + : 0, known_address->a4.label)) success = FALSE; } else { - if (!nm_platform_ip6_address_add(self, - ifindex, - known_address->a6.address, - known_address->a6.plen, - known_address->a6.peer_address, - lifetime, - preferred, - IFA_F_NOPREFIXROUTE | known_address->a6.n_ifa_flags)) + if (!nm_platform_ip6_address_add( + self, + ifindex, + known_address->a6.address, + known_address->a6.plen, + known_address->a6.peer_address, + lifetime, + preferred, + (NM_FLAGS_HAS(flags, NMP_IP_ADDRESS_SYNC_FLAGS_WITH_NOPREFIXROUTE) + ? IFA_F_NOPREFIXROUTE + : 0) + | known_address->a6.n_ifa_flags)) success = FALSE; } } @@ -4568,7 +4578,12 @@ nm_platform_ip_address_flush(NMPlatform *self, int addr_family, int ifindex) addresses_prune = nm_platform_ip_address_get_prune_list(self, addr_family2, ifindex, NULL, 0); - if (!nm_platform_ip_address_sync(self, addr_family2, ifindex, NULL, addresses_prune)) + if (!nm_platform_ip_address_sync(self, + addr_family2, + ifindex, + NULL, + addresses_prune, + NMP_IP_ADDRESS_SYNC_FLAGS_NONE)) success = FALSE; } return success; @@ -8634,7 +8649,8 @@ nm_platform_ip4_address_cmp(const NMPlatformIP4Address *a, * NetworkManager actively sets. * * NM actively only sets IFA_F_NOPREFIXROUTE (and IFA_F_MANAGETEMPADDR for IPv6), - * where nm_platform_ip_address_sync() always sets IFA_F_NOPREFIXROUTE. + * where nm_platform_ip_address_sync() sets IFA_F_NOPREFIXROUTE depending on + * NMP_IP_ADDRESS_SYNC_FLAGS_WITH_NOPREFIXROUTE. * There are thus no flags to compare for IPv4. */ NM_CMP_DIRECT(nm_platform_ip4_broadcast_address_from_addr(a), @@ -8702,7 +8718,8 @@ nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a, * NetworkManager actively sets. * * NM actively only sets IFA_F_NOPREFIXROUTE and IFA_F_MANAGETEMPADDR, - * where nm_platform_ip_address_sync() always sets IFA_F_NOPREFIXROUTE. + * where nm_platform_ip_address_sync() sets IFA_F_NOPREFIXROUTE depending on + * NMP_IP_ADDRESS_SYNC_FLAGS_WITH_NOPREFIXROUTE. * We thus only care about IFA_F_MANAGETEMPADDR. */ NM_CMP_DIRECT(a->n_ifa_flags & IFA_F_MANAGETEMPADDR, b->n_ifa_flags & IFA_F_MANAGETEMPADDR); diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 2570a47dda..9aaed5dd1f 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -2324,11 +2324,17 @@ nm_platform_ip_address_delete(NMPlatform * } } -gboolean nm_platform_ip_address_sync(NMPlatform *self, - int addr_family, - int ifindex, - GPtrArray *known_addresses, - GPtrArray *addresses_prune); +typedef enum { + NMP_IP_ADDRESS_SYNC_FLAGS_NONE = 0, + NMP_IP_ADDRESS_SYNC_FLAGS_WITH_NOPREFIXROUTE = (1 << 0), +} NMPIPAddressSyncFlags; + +gboolean nm_platform_ip_address_sync(NMPlatform *self, + int addr_family, + int ifindex, + GPtrArray *known_addresses, + GPtrArray *addresses_prune, + NMPIPAddressSyncFlags flags); GPtrArray * nm_platform_ip_address_get_prune_list(NMPlatform *self, From bd6e60f2dce071e1aebd87c523e66d530179c38c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 8 Sep 2022 09:47:04 +0200 Subject: [PATCH 6/6] platform: simplify nm_platform_ip_route_get_prune_list() to not reuse variables This optimization seems unnecessary. Just initialize a new route struct and use it. The advantage is that we can have the variable in the scope closer to where it's used, and don't need to think about what happens outside the scope. --- src/libnm-platform/nm-platform.c | 97 ++++++++++++++------------------ 1 file changed, 41 insertions(+), 56 deletions(-) diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 68e1952c2f..3dfe3404d4 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -4721,9 +4721,6 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, GPtrArray *routes_prune = NULL; const NMDedupMultiHeadEntry *head_entry; CList *iter; - NMPlatformIP4Route rt_local4; - NMPlatformIP6Route rt_local6; - NMPlatformIP6Route rt_mcast6; const NMPlatformLink *pllink; const NMPlatformLnkVrf *lnk_vrf; guint32 local_table; @@ -4748,10 +4745,6 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, lnk_vrf = nm_platform_link_get_lnk_vrf(self, pllink->master, NULL); local_table = lnk_vrf ? lnk_vrf->table : RT_TABLE_LOCAL; - rt_local4.plen = 0; - rt_local6.plen = 0; - rt_mcast6.plen = 0; - c_list_for_each (iter, &head_entry->lst_entries_head) { const NMPObject *obj = c_list_entry(iter, NMDedupMultiEntry, lst_entries)->obj; const NMPlatformIPXRoute *rt = NMP_OBJECT_CAST_IPX_ROUTE(obj); @@ -4783,29 +4776,26 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, && rt->rx.metric == 0 && rt->r4.scope_inv == nm_platform_route_scope_inv(RT_SCOPE_HOST) && rt->r4.gateway == INADDR_ANY) { - if (rt_local4.plen == 0) { - rt_local4 = (NMPlatformIP4Route){ - .ifindex = ifindex, - .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), - .plen = 32, - .rt_source = NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, - .metric = 0, - .table_coerced = nm_platform_route_table_coerce(local_table), - .scope_inv = nm_platform_route_scope_inv(RT_SCOPE_HOST), - .gateway = INADDR_ANY, - }; - } - - /* the possible "network" depends on the addresses we have. We don't check that - * carefully. If the other parameters match, we assume that this route is the one - * generated by kernel. */ - rt_local4.network = rt->r4.network; - rt_local4.pref_src = rt->r4.pref_src; + const NMPlatformIP4Route r = { + .ifindex = ifindex, + .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), + .plen = 32, + .rt_source = NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, + .metric = 0, + .table_coerced = nm_platform_route_table_coerce(local_table), + .scope_inv = nm_platform_route_scope_inv(RT_SCOPE_HOST), + .gateway = INADDR_ANY, + /* the possible "network" depends on the addresses we have. We don't check that + * carefully. If the other parameters match, we assume that this route is the one + * generated by kernel. */ + .network = rt->r4.network, + .pref_src = rt->r4.pref_src, + }; /* to be more confident about comparing the value, use our nm_platform_ip4_route_cmp() * implementation. That will also consider parameters that we leave unspecified here. */ if (nm_platform_ip4_route_cmp(&rt->r4, - &rt_local4, + &r, NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) == 0) continue; @@ -4820,23 +4810,20 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, && rt->rx.plen == 128 && rt->rx.rt_source == NM_IP_CONFIG_SOURCE_RTPROT_KERNEL && rt->rx.metric == 0 && rt->r6.rt_pref == NM_ICMPV6_ROUTER_PREF_MEDIUM && IN6_IS_ADDR_UNSPECIFIED(&rt->r6.gateway)) { - if (rt_local6.plen == 0) { - rt_local6 = (NMPlatformIP6Route){ - .ifindex = ifindex, - .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), - .plen = 128, - .rt_source = NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, - .metric = 0, - .table_coerced = nm_platform_route_table_coerce(local_table), - .rt_pref = NM_ICMPV6_ROUTER_PREF_MEDIUM, - .gateway = IN6ADDR_ANY_INIT, - }; - } - - rt_local6.network = rt->r6.network; + const NMPlatformIP6Route r = { + .ifindex = ifindex, + .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), + .plen = 128, + .rt_source = NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, + .metric = 0, + .table_coerced = nm_platform_route_table_coerce(local_table), + .rt_pref = NM_ICMPV6_ROUTER_PREF_MEDIUM, + .gateway = IN6ADDR_ANY_INIT, + .network = rt->r6.network, + }; if (nm_platform_ip6_route_cmp(&rt->r6, - &rt_local6, + &r, NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) == 0) continue; @@ -4858,23 +4845,21 @@ nm_platform_ip_route_get_prune_list(NMPlatform *self, && rt->rx.plen == 8 && rt->rx.rt_source == NM_IP_CONFIG_SOURCE_RTPROT_BOOT && rt->rx.metric == 256 && rt->r6.rt_pref == NM_ICMPV6_ROUTER_PREF_MEDIUM && IN6_IS_ADDR_UNSPECIFIED(&rt->r6.gateway)) { - if (rt_mcast6.plen == 0) { - rt_mcast6 = (NMPlatformIP6Route){ - .ifindex = ifindex, - .type_coerced = nm_platform_route_type_coerce(RTN_UNICAST), - .plen = 8, - .rt_source = NM_IP_CONFIG_SOURCE_RTPROT_BOOT, - .metric = 256, - .table_coerced = nm_platform_route_table_coerce(local_table), - .rt_pref = NM_ICMPV6_ROUTER_PREF_MEDIUM, - .gateway = IN6ADDR_ANY_INIT, - .network = - NM_IN6ADDR_INIT(0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - }; - } + const NMPlatformIP6Route r = { + .ifindex = ifindex, + .type_coerced = nm_platform_route_type_coerce(RTN_UNICAST), + .plen = 8, + .rt_source = NM_IP_CONFIG_SOURCE_RTPROT_BOOT, + .metric = 256, + .table_coerced = nm_platform_route_table_coerce(local_table), + .rt_pref = NM_ICMPV6_ROUTER_PREF_MEDIUM, + .gateway = IN6ADDR_ANY_INIT, + .network = + NM_IN6ADDR_INIT(0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), + }; if (nm_platform_ip6_route_cmp(&rt->r6, - &rt_mcast6, + &r, NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY) == 0) continue;