Re: [PATCH net-next v5 2/2] selftests: fib_tests: Add a test case for IPv6 garbage collection
From: David Ahern <dsahern@kernel.org>
Date: 2023-08-03 02:06:47
On 8/1/23 6:43 PM, thinker.li@gmail.com wrote: \> @@ -747,6 +750,97 @@ fib_notify_test()
cleanup &> /dev/null
}
+fib6_gc_test()
+{
+ echo
+ echo "Fib6 garbage collection test"
+
+ STRACE=$(which strace)
+ if [ -z "$STRACE" ]; then
+ echo " SKIP: strace not found"
+ ret=$ksft_skip
+ return
+ fi
+
+ EXPIRE=10
+
+ setup
+
+ set -e
+
+ # Check expiration of routes every 3 seconds (GC)
+ $NS_EXEC sysctl -wq net.ipv6.route.gc_interval=300
+
+ $IP link add dummy_10 type dummy
+ $IP link set dev dummy_10 up
+ $IP -6 address add 2001:10::1/64 dev dummy_10
+
+ $NS_EXEC sysctl -wq net.ipv6.route.flush=1
+
+ # Temporary routes
+ for i in $(seq 1 1000); do
+ # Expire route after $EXPIRE seconds
+ $IP -6 route add 2001:20::$i \
+ via 2001:10::2 dev dummy_10 expires $EXPIRE
+ done
+ N_EXP=$($IP -6 route list |grep expires|wc -l)
+ if [ $N_EXP -ne 1000 ]; thenrace condition here ... that you can install all 1000 routes and then run this command before any expire. 10 seconds is normally more than enough time, but on a loaded server it might not be. And really it does not matter. What matters is that you install routes with an expires and they disappear when expected - and I believe the flush below should not be needed to validate they have been removed.