summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNikolay Aleksandrov <razor@blackwall.org>2022-04-01 10:33:43 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 13:23:59 +0300
commit7ca14c5f24dbc74253a7e14988d7ab63f0bb71a7 (patch)
tree1c1ef021077da524d5cd47a00317ed9aa6f2ceb0 /tools
parentf09ac62f0e3f1b4a490d9922a3ac95f554297828 (diff)
downloadlinux-7ca14c5f24dbc74253a7e14988d7ab63f0bb71a7.tar.xz
selftests: net: add delete nexthop route warning test
[ Upstream commit 392baa339c6a42a2cb088e5e5df2b59b8f89be24 ] Add a test which causes a WARNING on kernels which treat a nexthop route like a normal route when comparing for deletion and a device is specified. That is, a route is found but we hit a warning while matching it. The warning is from fib_info_nh() in include/net/nexthop.h because we run it on a fib_info with nexthop object. The call chain is: inet_rtm_delroute -> fib_table_delete -> fib_nh_match (called with a nexthop fib_info and also with fc_oif set thus calling fib_info_nh on the fib_info and triggering the warning). Repro steps: $ ip nexthop add id 12 via 172.16.1.3 dev veth1 $ ip route add 172.16.101.1/32 nhid 12 $ ip route delete 172.16.101.1/32 dev veth1 Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Stable-dep-of: d5082d386eee ("ipv4: Fix route deletion when nexthop info is not specified") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/selftests/net/fib_nexthops.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
index 4c7d33618437..8cca92c969b6 100755
--- a/tools/testing/selftests/net/fib_nexthops.sh
+++ b/tools/testing/selftests/net/fib_nexthops.sh
@@ -931,6 +931,20 @@ ipv4_fcnal()
set +e
check_nexthop "dev veth1" ""
log_test $? 0 "Nexthops removed on admin down"
+
+ # nexthop route delete warning: route add with nhid and delete
+ # using device
+ run_cmd "$IP li set dev veth1 up"
+ run_cmd "$IP nexthop add id 12 via 172.16.1.3 dev veth1"
+ out1=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l`
+ run_cmd "$IP route add 172.16.101.1/32 nhid 12"
+ run_cmd "$IP route delete 172.16.101.1/32 dev veth1"
+ out2=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l`
+ [ $out1 -eq $out2 ]
+ rc=$?
+ log_test $rc 0 "Delete nexthop route warning"
+ run_cmd "$IP ip route delete 172.16.101.1/32 nhid 12"
+ run_cmd "$IP ip nexthop del id 12"
}
ipv4_grp_fcnal()