Commit 46c1ef0c authored by Jiayuan Chen's avatar Jiayuan Chen Committed by Jakub Kicinski
Browse files

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: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarJiayuan Chen <jiayuan.chen@shopee.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20260304113817.294966-3-jiayuan.chen@linux.dev


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 21ec9277
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1672,6 +1672,17 @@ ipv4_withv6_fcnal()

	run_cmd "$IP ro replace 172.16.101.1/32 via inet6 2001:db8:50::1 dev veth1"
	log_test $? 2 "IPv4 route with invalid IPv6 gateway"

	# Test IPv4 route with loopback IPv6 nexthop
	# Regression test: loopback IPv6 nexthop was misclassified as reject
	# route, skipping nhc_pcpu_rth_output allocation, causing panic when
	# an IPv4 route references it and triggers __mkroute_output().
	run_cmd "$IP -6 nexthop add id 20 dev lo"
	run_cmd "$IP ro add 172.20.20.0/24 nhid 20"
	run_cmd "ip netns exec $me ping -c1 -W1 172.20.20.1"
	log_test $? 1 "IPv4 route with loopback IPv6 nexthop (no crash)"
	run_cmd "$IP ro del 172.20.20.0/24"
	run_cmd "$IP nexthop del id 20"
}

ipv4_fcnal_runtime()