Skip to content

Commit 46c1ef0

Browse files
mrprekuba-moo
authored andcommitted
selftests: net: add test for IPv4 route with loopback IPv6 nexthop
Add a regression test for a kernel panic that occurs when an IPv4 route references an IPv6 nexthop object created on the loopback device. The test creates an IPv6 nexthop on lo, binds an IPv4 route to it, then triggers a route lookup via ping to verify the kernel does not crash. ./fib_nexthops.sh Tests passed: 249 Tests failed: 0 Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Jiayuan Chen <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 21ec927 commit 46c1ef0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tools/testing/selftests/net/fib_nexthops.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,17 @@ ipv4_withv6_fcnal()
16721672

16731673
run_cmd "$IP ro replace 172.16.101.1/32 via inet6 2001:db8:50::1 dev veth1"
16741674
log_test $? 2 "IPv4 route with invalid IPv6 gateway"
1675+
1676+
# Test IPv4 route with loopback IPv6 nexthop
1677+
# Regression test: loopback IPv6 nexthop was misclassified as reject
1678+
# route, skipping nhc_pcpu_rth_output allocation, causing panic when
1679+
# an IPv4 route references it and triggers __mkroute_output().
1680+
run_cmd "$IP -6 nexthop add id 20 dev lo"
1681+
run_cmd "$IP ro add 172.20.20.0/24 nhid 20"
1682+
run_cmd "ip netns exec $me ping -c1 -W1 172.20.20.1"
1683+
log_test $? 1 "IPv4 route with loopback IPv6 nexthop (no crash)"
1684+
run_cmd "$IP ro del 172.20.20.0/24"
1685+
run_cmd "$IP nexthop del id 20"
16751686
}
16761687

16771688
ipv4_fcnal_runtime()

0 commit comments

Comments
 (0)