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

selftests: router_mpath_nh: Test 16-bit next hop weights

Add tests that exercise full 16 bits of NH weight.

To test the 255:65535, it is necessary to run more packets than for the
other tests. On a debug kernel, the test can take up to a minute, therefore
avoid the test when KSFT_MACHINE_SLOW.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/c0c257c00ad30b07afc3fa5e2afd135925405544.1723036486.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Petr Machata and committed by
Jakub Kicinski
bb89fdac 110d3ffe

+50 -8
+7
tools/testing/selftests/net/forwarding/lib.sh
··· 509 509 fi 510 510 } 511 511 512 + omit_on_slow() 513 + { 514 + if [[ $KSFT_MACHINE_SLOW != yes ]]; then 515 + "$@" 516 + fi 517 + } 518 + 512 519 xfail_on_veth() 513 520 { 514 521 local dev=$1; shift
+30 -8
tools/testing/selftests/net/forwarding/router_mpath_nh.sh
··· 40 40 ping_ipv4 41 41 ping_ipv6 42 42 multipath_test 43 + multipath16_test 43 44 ping_ipv4_blackhole 44 45 ping_ipv6_blackhole 45 46 nh_stats_test_v4 ··· 227 226 228 227 multipath4_test() 229 228 { 230 - local desc="$1" 231 - local weight_rp12=$2 232 - local weight_rp13=$3 229 + local desc=$1; shift 230 + local weight_rp12=$1; shift 231 + local weight_rp13=$1; shift 232 + local ports=${1-sp=1024,dp=0-32768}; shift 233 + 233 234 local t0_rp12 t0_rp13 t1_rp12 t1_rp13 234 235 local packets_rp12 packets_rp13 235 236 ··· 245 242 t0_rp13=$(link_stats_tx_packets_get $rp13) 246 243 247 244 ip vrf exec vrf-h1 $MZ $h1 -q -p 64 -A 192.0.2.2 -B 198.51.100.2 \ 248 - -d $MZ_DELAY -t udp "sp=1024,dp=0-32768" 245 + -d $MZ_DELAY -t udp "$ports" 249 246 sleep 1 250 247 251 248 t1_rp12=$(link_stats_tx_packets_get $rp12) ··· 262 259 263 260 multipath6_test() 264 261 { 265 - local desc="$1" 266 - local weight_rp12=$2 267 - local weight_rp13=$3 262 + local desc=$1; shift 263 + local weight_rp12=$1; shift 264 + local weight_rp13=$1; shift 265 + local ports=${1-sp=1024,dp=0-32768}; shift 266 + 268 267 local t0_rp12 t0_rp13 t1_rp12 t1_rp13 269 268 local packets_rp12 packets_rp13 270 269 ··· 281 276 t0_rp13=$(link_stats_tx_packets_get $rp13) 282 277 283 278 $MZ $h1 -6 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:2::2 \ 284 - -d $MZ_DELAY -t udp "sp=1024,dp=0-32768" 279 + -d $MZ_DELAY -t udp "$ports" 285 280 sleep 1 286 281 287 282 t1_rp12=$(link_stats_tx_packets_get $rp12) ··· 318 313 multipath6_test "ECMP" 1 1 319 314 multipath6_test "Weighted MP 2:1" 2 1 320 315 multipath6_test "Weighted MP 11:45" 11 45 316 + } 317 + 318 + multipath16_test() 319 + { 320 + check_nhgw16 104 || return 321 + 322 + log_info "Running 16-bit IPv4 multipath tests" 323 + multipath4_test "65535:65535" 65535 65535 324 + multipath4_test "128:512" 128 512 325 + omit_on_slow \ 326 + multipath4_test "255:65535" 255 65535 sp=1024-1026,dp=0-65535 327 + 328 + log_info "Running 16-bit IPv6 multipath tests" 329 + multipath6_test "65535:65535" 65535 65535 330 + multipath6_test "128:512" 128 512 331 + omit_on_slow \ 332 + multipath6_test "255:65535" 255 65535 sp=1024-1026,dp=0-65535 321 333 } 322 334 323 335 ping_ipv4_blackhole()
+13
tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh
··· 117 117 $MZ -6 $h1 -A 2001:db8:1::2 -B 2001:db8:2::2 118 118 sysctl_restore net.ipv6.fib_multipath_hash_policy 119 119 } 120 + 121 + check_nhgw16() 122 + { 123 + local nhid=$1; shift 124 + 125 + ip nexthop replace id 9999 group "$nhid,65535" &>/dev/null 126 + if (( $? )); then 127 + log_test_skip "16-bit multipath tests" \ 128 + "iproute2 or the kernel do not support 16-bit next hop weights" 129 + return 1 130 + fi 131 + ip nexthop del id 9999 ||: 132 + }