Skip to content

Commit 5a1b72c

Browse files
sworleysdavem330
authored andcommitted
net: add large ecmp group nexthop tests
Add a couple large ecmp group nexthop selftests to cover the remnant fixed by d69100b. 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 <[email protected]> Reviewed-by: David Ahern <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f99c064 commit 5a1b72c

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

tools/testing/selftests/net/fib_nexthops.sh

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ret=0
1919
ksft_skip=4
2020

2121
# 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"
2424

2525
ALL_TESTS="basic ${IPV4_TESTS} ${IPV6_TESTS}"
2626
TESTS="${ALL_TESTS}"
@@ -254,6 +254,60 @@ check_route6()
254254
check_output "${out}" "${expected}"
255255
}
256256

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"
309+
}
310+
257311
start_ip_monitor()
258312
{
259313
local mtype=$1
@@ -700,6 +754,19 @@ ipv6_fcnal_runtime()
700754
# route with src address and using nexthop - not allowed
701755
}
702756

757+
ipv6_large_grp()
758+
{
759+
local ecmp=32
760+
761+
echo
762+
echo "IPv6 large groups (x$ecmp)"
763+
echo "---------------------"
764+
765+
check_large_grp 6 $ecmp
766+
767+
$IP nexthop flush >/dev/null 2>&1
768+
}
769+
703770
ipv4_fcnal()
704771
{
705772
local rc
@@ -1066,6 +1133,19 @@ ipv4_fcnal_runtime()
10661133
log_test $? 0 "IPv4 route with MPLS encap, v6 gw - check"
10671134
}
10681135

1136+
ipv4_large_grp()
1137+
{
1138+
local ecmp=32
1139+
1140+
echo
1141+
echo "IPv4 large groups (x$ecmp)"
1142+
echo "---------------------"
1143+
1144+
check_large_grp 4 $ecmp
1145+
1146+
$IP nexthop flush >/dev/null 2>&1
1147+
}
1148+
10691149
sysctl_nexthop_compat_mode_check()
10701150
{
10711151
local sysctlname="net.ipv4.nexthop_compat_mode"

0 commit comments

Comments
 (0)