Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: fib_nexthops: test stale has_v4 on nexthop replace

Add test cases that exercise the scenario where an IPv6 nexthop is
replaced with an IPv4 nexthop while being part of a group. The group's
has_v4 flag must be updated so that subsequent IPv6 route additions are
properly rejected.

Two cases are covered:
1. Gateway nexthop replaced across families with an existing IPv6
route on the group (rejected by fib6_check_nh_list).
2. Blackhole nexthop replaced across families with no existing IPv6
route on the group (fib6_check_nh_list returns early) — this is
the path that triggers a NULL ptr deref without the kernel fix.

Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20260413114522.147784-2-jiayuan.chen@linux.dev
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Jiayuan Chen and committed by
Paolo Abeni
104f082f 29c95185

+22
+22
tools/testing/selftests/net/fib_nexthops.sh
··· 1209 1209 run_cmd "$IP ro replace 2001:db8:101::1/128 nhid 124" 1210 1210 log_test $? 0 "IPv6 route using a group after replacing v4 gateways" 1211 1211 1212 + # Replacing an IPv6 nexthop with an IPv4 nexthop should update has_v4 1213 + # for all groups using it, preventing IPv6 routes from referencing the 1214 + # group after the replace. 1215 + run_cmd "$IP nexthop add id 89 via 2001:db8:91::2 dev veth1" 1216 + run_cmd "$IP nexthop add id 125 group 89" 1217 + run_cmd "$IP nexthop replace id 89 via 172.16.1.1 dev veth1" 1218 + run_cmd "$IP ro replace 2001:db8:101::1/128 nhid 125" 1219 + log_test $? 2 "IPv6 route can not use group after v6 nexthop replaced by v4" 1220 + 1221 + # Same scenario but with a blackhole nexthop: the group has no IPv6 1222 + # routes yet when the replace happens, so fib6_check_nh_list returns 1223 + # early without checking. has_v4 must still be updated to block 1224 + # subsequent IPv6 route additions. 1225 + run_cmd "$IP nexthop flush >/dev/null 2>&1" 1226 + run_cmd "$IP -6 nexthop add id 90 blackhole" 1227 + run_cmd "$IP nexthop add id 125 group 90" 1228 + run_cmd "$IP nexthop replace id 90 blackhole" 1229 + run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 125" 1230 + log_test $? 2 "IPv6 route reject v6 blackhole replaced by v4 blackhole" 1231 + run_cmd "ip netns exec $me ping -6 2001:db8:101::1 -c1 -w$PING_TIMEOUT" 1232 + log_test $? 2 "Ping unreachable after rejected route" 1233 + 1212 1234 $IP nexthop flush >/dev/null 2>&1 1213 1235 1214 1236 #