NetworkManager/1000-platform-fix-capturing-addresses-from-platform-for-assuming-after-restart.patch
Wen Liang bd7882e37c platform: fix capturing IPv4 addresses from platform for assuming after restart
Related: #1916192

Signed-off-by: Wen Liang <wenliang@redhat.com>
2021-08-19 12:25:57 -04:00

49 lines
2.2 KiB
Diff

From af06ca8b1190240146f746f8aeca6fd11bfbe6ad Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 19 Aug 2021 13:35:27 +0200
Subject: [PATCH] platform: fix capturing addresses from platform for assuming
after restart
Commit c631aa48f034 ('platform: capture NMIP[46]Config from platform
with correct (reversed) order of IP addresses') changed this for IPv6
and IPv4, but it's not correct for IPv4.
For IPv6, later `ip addr add` calls adds a new primary address, which
is also listed in `ip addr show` first. Hence, as NMIP6Config tracks
addresses in increasing priority, while NMPlatform tracks them as
exposed by kernel, the order when appending addresses form platform
to NMIP6Config must be reversed.
That is not the case for IPv4. For IPv4, later `ip addr add` calls
add a secondary IP address. Also, in `ip addr show` output they are
appended. Consequently, IPv4 addresses are tracked by NMPlatform with
decreasing priority (in the reverse order than for IPv6).
Fix constructing the NMIP4Config by fixing the address order. This is
important, because during restart devices get assumed and our code would
configure the order of addresses as it finds them.
Fixes: c631aa48f034 ('platform: capture NMIP[46]Config from platform with correct (reversed) order of IP addresses')
(cherry picked from commit c380893dc6757e30b429f968bc90bc1edda68998)
(cherry picked from commit 605373b38ab463826bd7eb80408fb2cfae07ee91)
---
src/core/nm-ip4-config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/nm-ip4-config.c b/src/core/nm-ip4-config.c
index 90531d0291..52a8faa791 100644
--- a/src/core/nm-ip4-config.c
+++ b/src/core/nm-ip4-config.c
@@ -543,7 +543,7 @@ nm_ip4_config_capture(NMDedupMultiIndex *multi_idx, NMPlatform *platform, int if
head_entry = nm_platform_lookup_object(platform, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex);
if (head_entry) {
- nmp_cache_iter_for_each_reverse (&iter, head_entry, &plobj) {
+ nmp_cache_iter_for_each (&iter, head_entry, &plobj) {
if (!_nm_ip_config_add_obj(priv->multi_idx,
&priv->idx_ip4_addresses_,
ifindex,
--
2.26.3