Blame SOURCES/1007-platform-workaround-for-preserving-ipv6-address-rhbz2090280.patch

ce53a8
From 4c556203d93fdd143630431dded4e0e6ea24824e Mon Sep 17 00:00:00 2001
ce53a8
From: Thomas Haller <thaller@redhat.com>
ce53a8
Date: Thu, 9 Jun 2022 10:00:47 +0200
ce53a8
Subject: [PATCH 1/1] platform: workaround for preserving IPv6 address order
ce53a8
ce53a8
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/ ## 1021
ce53a8
---
ce53a8
 src/libnm-platform/nm-platform.c | 15 +++++++++++++++
ce53a8
 1 file changed, 15 insertions(+)
ce53a8
ce53a8
diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c
ce53a8
index f264ed7a45b2..120e50b3c772 100644
ce53a8
--- a/src/libnm-platform/nm-platform.c
ce53a8
+++ b/src/libnm-platform/nm-platform.c
ce53a8
@@ -3961,45 +3961,60 @@ nm_platform_ip_address_sync(NMPlatform *self,
ce53a8
         for (i = 0; i < addresses_prune->len; i++) {
ce53a8
             const NMPObject *prune_obj = addresses_prune->pdata[i];
ce53a8
 
ce53a8
             nm_assert(NM_IN_SET(NMP_OBJECT_GET_TYPE(prune_obj),
ce53a8
                                 NMP_OBJECT_TYPE_IP4_ADDRESS,
ce53a8
                                 NMP_OBJECT_TYPE_IP6_ADDRESS));
ce53a8
 
ce53a8
             if (nm_g_hash_table_contains(known_addresses_idx, prune_obj))
ce53a8
                 continue;
ce53a8
 
ce53a8
             nm_platform_ip_address_delete(self,
ce53a8
                                           addr_family,
ce53a8
                                           ifindex,
ce53a8
                                           NMP_OBJECT_CAST_IP_ADDRESS(prune_obj));
ce53a8
         }
ce53a8
     }
ce53a8
 
ce53a8
     /* @plat_addresses for IPv6 must be sorted in decreasing priority order (highest priority addresses first).
ce53a8
      * IPv4 are probably unsorted or sorted with lowest priority first, but their order doesn't matter because
ce53a8
      * we check the "secondary" flag. */
ce53a8
+    if (IS_IPv4) {
ce53a8
     plat_addresses = nm_platform_lookup_clone(
ce53a8
         self,
ce53a8
         nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex),
ce53a8
         NULL,
ce53a8
         NULL);
ce53a8
+    } else {
ce53a8
+        /* HACK: early 1.36 versions had a bug of not actually reordering the IPv6 addresses.
ce53a8
+         * This was fixed by commit cd4601802de5 ('platform: fix address order in
ce53a8
+         * nm_platform_ip_address_sync()').
ce53a8
+         *
ce53a8
+         * However, also in 1.36, the actually implemented order of IPv6 addresses is not
ce53a8
+         * the one we want ([1]). So disable the fix again, to not reorder IPv6 addresses.
ce53a8
+         *
ce53a8
+         * The effect is, that DHCPv6 addresses end up being preferred over SLAAC, because
ce53a8
+         * they get added later during activation. Of course, if any address gets added
ce53a8
+         * even later (like a new router appearing), then the order will be wrong again.
ce53a8
+         *
ce53a8
+         * [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1021 */
ce53a8
+    }
ce53a8
 
ce53a8
     if (nm_g_ptr_array_len(plat_addresses) > 0) {
ce53a8
         /* Delete addresses that interfere with our intended order. */
ce53a8
         if (IS_IPv4) {
ce53a8
             GHashTable   *known_subnets = NULL;
ce53a8
             GHashTable   *plat_subnets;
ce53a8
             gs_free bool *plat_handled_to_free = NULL;
ce53a8
             bool         *plat_handled         = NULL;
ce53a8
 
ce53a8
             /* For IPv4, we only consider it a conflict for addresses in the same
ce53a8
              * subnet. That's where kernel will assign a primary/secondary flag.
ce53a8
              * For different subnets, we don't define the order. */
ce53a8
 
ce53a8
             plat_subnets = ip4_addr_subnets_build_index(plat_addresses, TRUE, TRUE);
ce53a8
 
ce53a8
             for (i = 0; i < plat_addresses->len; i++) {
ce53a8
                 const NMPObject            *plat_obj = plat_addresses->pdata[i];
ce53a8
                 const NMPObject            *known_obj;
ce53a8
                 const NMPlatformIP4Address *plat_address;
ce53a8
                 const GPtrArray            *addr_list;
ce53a8
-- 
ce53a8
2.36.1