Commit 4af9a0be authored by Kui-Feng Lee's avatar Kui-Feng Lee Committed by Jakub Kicinski
Browse files

selftests/net: fix waiting time for ipv6_gc test in fib_tests.sh.



ipv6_gc fails occasionally. According to the study, fib6_run_gc() using
jiffies_round() to round the GC interval could increase the waiting time up
to 750ms (3/4 seconds). The timer has a granularity of 512ms at the range
4s to 32s. That means a route with an expiration time E seconds can wait
for more than E * 2 + 1 seconds if the GC interval is also E seconds.

E * 2 + 2 seconds should be enough for waiting for removing routes.

Also remove a check immediately after replacing 5 routes since it is very
likely to remove some of routes before completing the last route with a
slow environment.

Signed-off-by: default avatarKui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240305183949.258473-1-thinker.li@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8edbd396
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -789,6 +789,7 @@ fib6_gc_test()
	set -e

	EXPIRE=5
	GC_WAIT_TIME=$((EXPIRE * 2 + 2))

	# Check expiration of routes every $EXPIRE seconds (GC)
	$NS_EXEC sysctl -wq net.ipv6.route.gc_interval=$EXPIRE
@@ -805,7 +806,7 @@ fib6_gc_test()
	    $IP -6 route add 2001:20::$i \
		via 2001:10::2 dev dummy_10 expires $EXPIRE
	done
	sleep $(($EXPIRE * 2 + 1))
	sleep $GC_WAIT_TIME
	$NS_EXEC sysctl -wq net.ipv6.route.flush=1
	check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
	log_test $ret 0 "ipv6 route garbage collection"
@@ -823,7 +824,8 @@ fib6_gc_test()
	    $IP -6 route add 2001:20::$i \
		via 2001:10::2 dev dummy_10 expires $EXPIRE
	done
	sleep $(($EXPIRE * 2 + 1))
	# Wait for GC
	sleep $GC_WAIT_TIME
	check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
	log_test $ret 0 "ipv6 route garbage collection (with permanent routes)"

@@ -840,10 +842,8 @@ fib6_gc_test()
	    $IP -6 route replace 2001:20::$i \
		via 2001:10::2 dev dummy_10 expires $EXPIRE
	done
	check_rt_num_clean 5 $($IP -6 route list |grep expires|wc -l) || return
	# Wait for GC
	sleep $(($EXPIRE * 2 + 1))
	$NS_EXEC sysctl -wq net.ipv6.route.flush=1
	sleep $GC_WAIT_TIME
	check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
	log_test $ret 0 "ipv6 route garbage collection (replace with expires)"

@@ -863,8 +863,7 @@ fib6_gc_test()
	check_rt_num_clean 0 $($IP -6 route list |grep expires|wc -l) || return

	# Wait for GC
	sleep $(($EXPIRE * 2 + 1))

	sleep $GC_WAIT_TIME
	check_rt_num 5 $($IP -6 route list |grep -v expires|grep 2001:20::|wc -l)
	log_test $ret 0 "ipv6 route garbage collection (replace with permanent)"

@@ -901,9 +900,7 @@ fib6_gc_test()
	check_rt_num_clean 1 $($IP -6 route list|grep expires|wc -l) || return

	# Wait for GC
	sleep $(($EXPIRE * 2 + 1))

	$NS_EXEC sysctl -wq net.ipv6.route.flush=1
	sleep $GC_WAIT_TIME
	check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
	log_test $ret 0 "ipv6 route garbage collection (RA message)"