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

selftests: forwarding: Add blackhole nexthops tests

Test that IPv4 and IPv6 ping fail when the route is using a blackhole
nexthop or a group with a blackhole nexthop. Test that ping passes when
the route starts using a valid nexthop.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ido Schimmel and committed by
Jakub Kicinski
1beaff77 24eb2a02

+57 -1
+57 -1
tools/testing/selftests/net/forwarding/router_mpath_nh.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - ALL_TESTS="ping_ipv4 ping_ipv6 multipath_test" 4 + ALL_TESTS=" 5 + ping_ipv4 6 + ping_ipv6 7 + multipath_test 8 + ping_ipv4_blackhole 9 + ping_ipv6_blackhole 10 + " 5 11 NUM_NETIFS=8 6 12 source lib.sh 7 13 ··· 306 300 multipath6_l4_test "ECMP" 1 1 307 301 multipath6_l4_test "Weighted MP 2:1" 2 1 308 302 multipath6_l4_test "Weighted MP 11:45" 11 45 303 + } 304 + 305 + ping_ipv4_blackhole() 306 + { 307 + RET=0 308 + 309 + ip nexthop add id 1001 blackhole 310 + ip nexthop add id 1002 group 1001 311 + 312 + ip route replace 198.51.100.0/24 vrf vrf-r1 nhid 1001 313 + ping_do $h1 198.51.100.2 314 + check_fail $? "ping did not fail when using a blackhole nexthop" 315 + 316 + ip route replace 198.51.100.0/24 vrf vrf-r1 nhid 1002 317 + ping_do $h1 198.51.100.2 318 + check_fail $? "ping did not fail when using a blackhole nexthop group" 319 + 320 + ip route replace 198.51.100.0/24 vrf vrf-r1 nhid 103 321 + ping_do $h1 198.51.100.2 322 + check_err $? "ping failed with a valid nexthop" 323 + 324 + log_test "IPv4 blackhole ping" 325 + 326 + ip nexthop del id 1002 327 + ip nexthop del id 1001 328 + } 329 + 330 + ping_ipv6_blackhole() 331 + { 332 + RET=0 333 + 334 + ip -6 nexthop add id 1001 blackhole 335 + ip nexthop add id 1002 group 1001 336 + 337 + ip route replace 2001:db8:2::/64 vrf vrf-r1 nhid 1001 338 + ping6_do $h1 2001:db8:2::2 339 + check_fail $? "ping did not fail when using a blackhole nexthop" 340 + 341 + ip route replace 2001:db8:2::/64 vrf vrf-r1 nhid 1002 342 + ping6_do $h1 2001:db8:2::2 343 + check_fail $? "ping did not fail when using a blackhole nexthop group" 344 + 345 + ip route replace 2001:db8:2::/64 vrf vrf-r1 nhid 106 346 + ping6_do $h1 2001:db8:2::2 347 + check_err $? "ping failed with a valid nexthop" 348 + 349 + log_test "IPv6 blackhole ping" 350 + 351 + ip nexthop del id 1002 352 + ip -6 nexthop del id 1001 309 353 } 310 354 311 355 setup_prepare()