[PATCH net 2/2] selftests: net: test flushing IPv4 nexthop routes in compat mode

From: Yuen Su

Date: Wed Nov 18 2026 - 03:46:28 EST


Exercise ip route flush on a route with a nexthop group while the dump
includes both the group's ID and the expanded paths. Check that the
flush succeeds and that the route is gone.

Both checks fail before the IPv4 delete fix and pass after it in a
QEMU/KVM guest with unmodified iproute2. Codex assisted with adding
the case to the existing compatibility selftest and running it.

Signed-off-by: Yuen Su <zypulsecore@xxxxxxxxx>
---
tools/testing/selftests/net/fib_nexthops.sh | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
index adbec51..d3c8cf8 100755
--- a/tools/testing/selftests/net/fib_nexthops.sh
+++ b/tools/testing/selftests/net/fib_nexthops.sh
@@ -2183,6 +2183,13 @@ ipv4_compat_mode()
stop_ip_monitor $ipmout 3
log_test $? 0 "IPv4 compat mode on - nexthop change"

+ run_cmd "$IP route add 192.0.2.1/32 nhid 122"
+ log_test $? 0 "IPv4 compat mode on - add route for flush"
+ run_cmd "$IP route flush to exact 192.0.2.1/32"
+ log_test $? 0 "IPv4 compat mode on - route flush"
+ check_route "192.0.2.1" ""
+ log_test $? 0 "IPv4 compat mode on - route removed by flush"
+
sysctl_nexthop_compat_mode_set 0 "IPv4"

# cleanup