Thread (9 messages) 9 messages, 3 authors, 2023-08-03

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 19:49:32

On 8/2/23 10:09 PM, Kui-Feng Lee wrote:

On 8/2/23 19:06, David Ahern wrote:
quoted
On 8/1/23 6:43 PM, thinker.li@gmail.com wrote:
\> @@ -747,6 +750,97 @@ fib_notify_test()
quoted
      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 ]; then
race 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.
Without the flush below, the result will be very unpredictable or need
to wait longer, at least two gc_interval seconds. We can
shorten gc_interval to 10s, but we need to wait for 20s to make it
certain. It is more predictable with the flush.

About race condition, I will remove the check.  Just like what you said,
it is not necessary.
you do not need to measure how long it takes to remove expired routes in
a selftest; you are only testing that in fact the expired routes are
removed.

EXPIRES=1
install routes
# wait 2x expires time for removal
sleep 2
verify routes are removed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help