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

net: add large ecmp group nexthop tests

Add a couple large ecmp group nexthop selftests to cover
the remnant fixed by d69100b8eee27c2d60ee52df76e0b80a8d492d34.

The tests create 100 x32 ecmp groups of ipv4 and ipv6 and then
dump them. On kernels without the fix, they will fail due
to data remnant during the dump.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Stephen Worley and committed by
David S. Miller
5a1b72ce f99c0646

+82 -2
+82 -2
tools/testing/selftests/net/fib_nexthops.sh
··· 19 19 ksft_skip=4 20 20 21 21 # all tests in this script. Can be overridden with -t option 22 - IPV4_TESTS="ipv4_fcnal ipv4_grp_fcnal ipv4_withv6_fcnal ipv4_fcnal_runtime ipv4_compat_mode ipv4_fdb_grp_fcnal" 23 - IPV6_TESTS="ipv6_fcnal ipv6_grp_fcnal ipv6_fcnal_runtime ipv6_compat_mode ipv6_fdb_grp_fcnal" 22 + IPV4_TESTS="ipv4_fcnal ipv4_grp_fcnal ipv4_withv6_fcnal ipv4_fcnal_runtime ipv4_large_grp ipv4_compat_mode ipv4_fdb_grp_fcnal" 23 + IPV6_TESTS="ipv6_fcnal ipv6_grp_fcnal ipv6_fcnal_runtime ipv6_large_grp ipv6_compat_mode ipv6_fdb_grp_fcnal" 24 24 25 25 ALL_TESTS="basic ${IPV4_TESTS} ${IPV6_TESTS}" 26 26 TESTS="${ALL_TESTS}" ··· 252 252 out=$($IP -6 route ls match ${pfx} 2>/dev/null | sed -e 's/pref medium//') 253 253 254 254 check_output "${out}" "${expected}" 255 + } 256 + 257 + check_large_grp() 258 + { 259 + local ipv=$1 260 + local ecmp=$2 261 + local grpnum=100 262 + local nhidstart=100 263 + local grpidstart=1000 264 + local iter=0 265 + local nhidstr="" 266 + local grpidstr="" 267 + local grpstr="" 268 + local ipstr="" 269 + 270 + if [ $ipv -eq 4 ]; then 271 + ipstr="172.16.1." 272 + else 273 + ipstr="2001:db8:91::" 274 + fi 275 + 276 + # 277 + # Create $grpnum groups with specified $ecmp and dump them 278 + # 279 + 280 + # create nexthops with different gateways 281 + iter=2 282 + while [ $iter -le $(($ecmp + 1)) ] 283 + do 284 + nhidstr="$(($nhidstart + $iter))" 285 + run_cmd "$IP nexthop add id $nhidstr via $ipstr$iter dev veth1" 286 + check_nexthop "id $nhidstr" "id $nhidstr via $ipstr$iter dev veth1 scope link" 287 + 288 + if [ $iter -le $ecmp ]; then 289 + grpstr+="$nhidstr/" 290 + else 291 + grpstr+="$nhidstr" 292 + fi 293 + ((iter++)) 294 + done 295 + 296 + # create duplicate large ecmp groups 297 + iter=0 298 + while [ $iter -le $grpnum ] 299 + do 300 + grpidstr="$(($grpidstart + $iter))" 301 + run_cmd "$IP nexthop add id $grpidstr group $grpstr" 302 + check_nexthop "id $grpidstr" "id $grpidstr group $grpstr" 303 + ((iter++)) 304 + done 305 + 306 + # dump large groups 307 + run_cmd "$IP nexthop list" 308 + log_test $? 0 "Dump large (x$ecmp) ecmp groups" 255 309 } 256 310 257 311 start_ip_monitor() ··· 754 700 # route with src address and using nexthop - not allowed 755 701 } 756 702 703 + ipv6_large_grp() 704 + { 705 + local ecmp=32 706 + 707 + echo 708 + echo "IPv6 large groups (x$ecmp)" 709 + echo "---------------------" 710 + 711 + check_large_grp 6 $ecmp 712 + 713 + $IP nexthop flush >/dev/null 2>&1 714 + } 715 + 757 716 ipv4_fcnal() 758 717 { 759 718 local rc ··· 1131 1064 log_test $? 0 "IPv4 route with MPLS encap and v6 gateway" 1132 1065 check_nexthop "id 52" "id 52 encap mpls 102 via 2001:db8:91::2 dev veth1 scope link" 1133 1066 log_test $? 0 "IPv4 route with MPLS encap, v6 gw - check" 1067 + } 1068 + 1069 + ipv4_large_grp() 1070 + { 1071 + local ecmp=32 1072 + 1073 + echo 1074 + echo "IPv4 large groups (x$ecmp)" 1075 + echo "---------------------" 1076 + 1077 + check_large_grp 4 $ecmp 1078 + 1079 + $IP nexthop flush >/dev/null 2>&1 1134 1080 } 1135 1081 1136 1082 sysctl_nexthop_compat_mode_check()