platform: workaround for preserving IPv6 address order

Before 1.34, DHCPv6 addresses were preferred over SLAAC addresses
and all was good. Well, actually, we didn't have any CI tests, so
whether it really worked is only an assumption. But it probably was.

With 1.36 this broke for two reasons:

1) 1.36 would now prefer SLAAC over DHCPv6 over manual addresses.
2) 1.36 would also not adjust the order of already existing addresses.
   This means, we first would get the SLAAC address and the DHCPv6
   address later. Adding the address later would mean that it becomes
   more important. This would go against 1), but due to 2) effectively
   DHCPv6 was still preferred over SLAAC.

Commit [1] would fix 2), but now the address order changed.
We will need to fix also 1), but in the meantime, disable parts of
commit [1] so that we still get the old behavior.

[1] cd4601802d ('platform: fix address order in nm_platform_ip_address_sync()')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/ ## 1021
This commit is contained in:
Thomas Haller 2022-06-09 10:00:47 +02:00
parent 5b8e7dac34
commit dc9e4a07e4
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -3978,11 +3978,26 @@ nm_platform_ip_address_sync(NMPlatform *self,
/* @plat_addresses for IPv6 must be sorted in decreasing priority order (highest priority addresses first).
* IPv4 are probably unsorted or sorted with lowest priority first, but their order doesn't matter because
* we check the "secondary" flag. */
plat_addresses = nm_platform_lookup_clone(
self,
nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex),
NULL,
NULL);
if (IS_IPv4) {
plat_addresses = nm_platform_lookup_clone(
self,
nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex),
NULL,
NULL);
} else {
/* HACK: early 1.36 versions had a bug of not actually reordering the IPv6 addresses.
* This was fixed by commit cd4601802de5 ('platform: fix address order in
* nm_platform_ip_address_sync()').
*
* However, also in 1.36, the actually implemented order of IPv6 addresses is not
* the one we want ([1]). So disable the fix again, to not reorder IPv6 addresses.
*
* The effect is, that DHCPv6 addresses end up being preferred over SLAAC, because
* they get added later during activation. Of course, if any address gets added
* even later (like a new router appearing), then the order will be wrong again.
*
* [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1021 */
}
if (nm_g_ptr_array_len(plat_addresses) > 0) {
/* Delete addresses that interfere with our intended order. */