Revert "ipv6: preserve insertion order for same-scope addresses"
Subsystems (5)
PATCH 1/1 Revert "ipv6: preserve insertion order for same-scope addresses"
Chris Adams reported that preserving insertion order for same-scope addresses is causing SSH connections to be dropped after stopping a VM while running NetworkManager.
NetworkManager is caching the networking information from the system and later operating with it. It relies on the order of IPv6 addresses to configure routes for outgoing traffic. Revert to the previous ordering.
This reverts commit cb3de96eea66f5e4a580086c6a1be46e765f97f4.
--- net/ipv6/addrconf.c | 2 +- tools/testing/selftests/net/ioam6.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +1 -1
@@ -1013,7 +1013,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)list_for_each (p, &idev->addr_list) {struct inet6_ifaddr *ifa = list_entry(p, struct inet6_ifaddr, if_list); -if (ifp_scope >ipv6_addr_src_scope (&ifa->addr)) +if (ifp_scope >=ipv6_addr_src_scope (&ifa->addr))break ; }
tools/testing/selftests/net/ioam6.sh +1 -1
@@ -273,8 +273,8 @@ setup() ip -netns $ioam_node_beta link set ioam-veth-betaR name veth1 &>/dev/null ip -netns $ioam_node_gamma link set ioam-veth-gamma name veth0 &>/dev/null - ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null + ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null ip -netns $ioam_node_alpha link set veth0 up &>/dev/null ip -netns $ioam_node_alpha link set lo up &>/dev/null ip -netns $ioam_node_alpha route add 2001:db8:2::/64 \
Signature · 1 line
2.54.0
Quoted 7 lines · On Thu, 28 May 2026 13:11:23 +0200 Fernando Fernandez Mancera…
Chris Adams reported that preserving insertion order for same-scope addresses is causing SSH connections to be dropped after stopping a VM while running NetworkManager.
NetworkManager is caching the networking information from the system and later operating with it. It relies on the order of IPv6 addresses to configure routes for outgoing traffic.
I think this paragraph should make it clear that NetworkManager relies on a _reversed_ order (first inserted is returned last), and that it's the opposite compared to IPv4.
Quoted 1 line
Revert to the previous ordering.
See my concern from:
https://lore.kernel.org/all/20260528131250.1352ab48@elisabeth/
(sorry, I sent that email moments after you sent this patch it seems). It fixes the issue for NetworkManager assuming it's the only issue, but it causes a regression for others.
If this revert is the only practical solution, so be it. I'm just wondering if it really is.
Quoted 38 lines
This reverts commit
cb3de96eea66f5e4a580086c6a1be46e765f97f4.Fixes cb3de96eea66 ("ipv6: preserve insertion order for same-scope addresses")Reported-by Chris Adams <[email protected]>Signed-off-by Fernando Fernandez Mancera <[email protected]>--- net/ipv6/addrconf.c | 2 +- tools/testing/selftests/net/ioam6.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)net/ipv6/addrconf.c +1
-1@@ -1013,7 +1013,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)list_for_each (p, &idev->addr_list) {struct inet6_ifaddr *ifa = list_entry(p, struct inet6_ifaddr, if_list); -if (ifp_scope >ipv6_addr_src_scope (&ifa->addr)) +if (ifp_scope >=ipv6_addr_src_scope (&ifa->addr))break ; }tools/testing/selftests/net/ioam6.sh +1
-1@@ -273,8 +273,8 @@ setup() ip -netns $ioam_node_beta link set ioam-veth-betaR name veth1 &>/dev/null ip -netns $ioam_node_gamma link set ioam-veth-gamma name veth0 &>/dev/null - ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null + ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null ip -netns $ioam_node_alpha link set veth0 up &>/dev/null ip -netns $ioam_node_alpha link set lo up &>/dev/null ip -netns $ioam_node_alpha route add 2001:db8:2::/64 \
Signature · 1 line
Stefano
Quoted 7 lines · Stefano Brivio
Quoted 4 lines · On Thu, 28 May 2026 13:11:23 +0200 Fernando Fernandez Mancera…
Chris Adams reported that preserving insertion order for same-scope addresses is causing SSH connections to be dropped after stopping a VM while running NetworkManager.
Quoted 8 lines
Quoted 3 lines
NetworkManager is caching the networking information from the system and later operating with it. It relies on the order of IPv6 addresses to configure routes for outgoing traffic.
I think this paragraph should make it clear that NetworkManager relies on a _reversed_ order (first inserted is returned last), and that it's the opposite compared to IPv4.
FWIW; I still think that NetworkManager relies on the ordering but not for the route.. AFAIU, the route should be for the prefix and should not change at all.
So I need to figure out what is changing and document it properly on the commit.
Quoted 52 lines
Quoted 1 line
Revert to the previous ordering.
See my concern from:
https://lore.kernel.org/all/20260528131250.1352ab48@elisabeth/(sorry, I sent that email moments after you sent this patch it seems). It fixes the issue for NetworkManager assuming it's the only issue, but it causes a regression for others.
If this revert is the only practical solution, so be it. I'm just wondering if it really is.
Quoted 38 lines
This reverts commit
cb3de96eea66f5e4a580086c6a1be46e765f97f4.Fixes cb3de96eea66 ("ipv6: preserve insertion order for same-scope addresses")Reported-by Chris Adams <[email protected]>Signed-off-by Fernando Fernandez Mancera <[email protected]>--- net/ipv6/addrconf.c | 2 +- tools/testing/selftests/net/ioam6.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)net/ipv6/addrconf.c +1
-1@@ -1013,7 +1013,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)list_for_each (p, &idev->addr_list) {struct inet6_ifaddr *ifa = list_entry(p, struct inet6_ifaddr, if_list); -if (ifp_scope >ipv6_addr_src_scope (&ifa->addr)) +if (ifp_scope >=ipv6_addr_src_scope (&ifa->addr))break ; }tools/testing/selftests/net/ioam6.sh +1
-1@@ -273,8 +273,8 @@ setup() ip -netns $ioam_node_beta link set ioam-veth-betaR name veth1 &>/dev/null ip -netns $ioam_node_gamma link set ioam-veth-gamma name veth0 &>/dev/null - ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null ip -netns $ioam_node_alpha addr add 2001:db8:1::50/64 dev veth0 &>/dev/null + ip -netns $ioam_node_alpha addr add 2001:db8:1::2/64 dev veth0 &>/dev/null ip -netns $ioam_node_alpha link set veth0 up &>/dev/null ip -netns $ioam_node_alpha link set lo up &>/dev/null ip -netns $ioam_node_alpha route add 2001:db8:2::/64 \