Skip to contentSkip to conversation

ipv6: fix ECMP route failover on carrier loss

PATCH Applied Sagarika Sharma 2 participants 4 messages Apr 30 – May 2

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover ipv6: fix ECMP route failover on carrier loss

This patchset resolves an issue where established IPv6 connections are unable to transition to alternative ECMP nexthops upon carrier loss.

Unlike IPv4, the IPv6 routing subsystem does not actively invalidate cached destinations during a NETDEV_CHANGE event. Sockets persist with dead routes, leading to stalled traffic or connection drops.

This series introduces a fix to trigger route invalidation by updating the route serial number on link carrier loss and provides a corresponding selftest to validate the failover behavior for IPv4 and IPv6.

---
v2:
- Changes to selftest addressing Ido’s and sashiko’s suggestions:
require_command for socat and tcpdump, EXIT trap, lower threshold
for test success, and fix exit code.
v1: https://lore.kernel.org/netdev/[email protected]/

Kuniyuki Iwashima (1):
selftest: net: Add test for TCP flow failover with ECMP routes.

Sagarika Sharma (1):
ipv6: update route serial number on NETDEV_CHANGE

 net/ipv6/route.c                              |   1 +
 tools/testing/selftests/net/Makefile          |   1 +
 .../selftests/net/tcp_ecmp_failover.sh        | 216 ++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100755 tools/testing/selftests/net/tcp_ecmp_failover.sh
Signature · 1 line
2.54.0.545.g6539524ca2-goog
#1 lore raw

PATCH v2 1/2 ipv6: update route serial number on NETDEV_CHANGE

When using IPv6 ECMP routes, if a netdev listed as a nexthop experiences a carrier change event (e.g., a bond device generating a NETDEV_CHANGE event after its slaves go linkdown), established connections utilizing that nexthop fail to fail over to other available nexthops. Instead, these connections stall or drop.

This happens because the IPv6 FIB code does not invalidate the socket's cached destination when a NETDEV_CHANGE event occurs. While fib6_ifdown() correctly marks the nexthop with RTNH_F_LINKDOWN, it leaves the route's serial number unchanged. As a result, sockets with a previously cached dst do not realize the route is no longer viable and continue to try using the non-functional nexthop.

This behavior contrasts with IPv4, which actively flushes cached destinations on a NETDEV_CHANGE event (see fib_netdev_event() in net/ipv4/fib_frontend.c).

Fix this by updating the route serial number in fib6_ifdown() when setting RTNH_F_LINKDOWN. This invalidates stale cached destinations, forcing sockets to perform a new route lookup and fail over to a functioning nexthop.

Fixes 51ebd3181572 ("ipv6: add support of equal cost multipath (ECMP)")
---
 net/ipv6/route.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv6/route.c +1 -0
index 19eb6b702227..0dc0316530ca 100644
@@ -4995,6 +4995,7 @@ static int fib6_ifdown(struct fib6_info *rt, void *p_arg)
 		    rt->fib6_flags & (RTF_LOCAL | RTF_ANYCAST))
 			break;
 		rt->fib6_nh->fib_nh_flags |= RTNH_F_LINKDOWN;
+		fib6_update_sernum(net, rt);
 		rt6_multipath_rebalance(rt);
 		break;
 	}
Signature · 1 line
2.54.0.545.g6539524ca2-goog
#2 lore raw

PATCH v2 2/2 selftest: net: Add test for TCP flow failover with ECMP routes.

In reply to Sagarika Sharma

From: Kuniyuki Iwashima <[email protected]>

Without the previous commit, TCP failed to switch to alternative IPv6 routes immediately upon carrier loss.

It would persist with the dead route until reaching the threshold net.ipv4.tcp_retries1, leading to unnecessary delays in failover.

Let's add a selftest for this scenario to ensure TCP fails over immediately upon a carrier loss event.

Before:
TEST: TCP IPv4 failover [ OK ]
TEST: TCP IPv6 failover [FAIL]

After:
TEST: TCP IPv4 failover [ OK ]
TEST: TCP IPv6 failover [ OK ]

---
v2: Add require_command, fix exit code and shellcheck warnings
except for SC2154 (netns allocation confuses shellcheck), lower threshold of packets captured for success.

---
 tools/testing/selftests/net/Makefile          |   1 +
 .../selftests/net/tcp_ecmp_failover.sh        | 216 ++++++++++++++++++
 2 files changed, 217 insertions(+)
 create mode 100755 tools/testing/selftests/net/tcp_ecmp_failover.sh
tools/testing/selftests/net/Makefile +1 -0
index a275ed584026..f3da38c54d27 100644
@@ -96,6 +96,7 @@ TEST_PROGS := \
 	srv6_hl2encap_red_l2vpn_test.sh \
 	srv6_iptunnel_cache.sh \
 	stress_reuseport_listen.sh \
+	tcp_ecmp_failover.sh \
 	tcp_fastopen_backup_key.sh \
 	test_bpf.sh \
 	test_bridge_backup_port.sh \
tools/testing/selftests/net/tcp_ecmp_failover.sh new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
2.54.0.545.g6539524ca2-goog
#3 lore raw
In reply to Sagarika Sharma
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 30 Apr 2026 20:08:59 +0000 you wrote:

This patchset resolves an issue where established IPv6 connections are unable to transition to alternative ECMP nexthops upon carrier loss.

Unlike IPv4, the IPv6 routing subsystem does not actively invalidate cached destinations during a NETDEV_CHANGE event. Sockets persist with dead routes, leading to stalled traffic or connection drops.

[...]

Here is the summary with links:
- [net,v2,1/2] ipv6: update route serial number on NETDEV_CHANGE

    https://git.kernel.org/netdev/net/c/4bc852006b62
  - [net,v2,2/2] selftest: net: Add test for TCP flow failover with ECMP routes.
    https://git.kernel.org/netdev/net/c/d1ae37dc6881

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html