[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231213213735.434249-3-thinker.li@gmail.com>
Date: Wed, 13 Dec 2023 13:37:35 -0800
From: thinker.li@...il.com
To: netdev@...r.kernel.org,
martin.lau@...ux.dev,
kernel-team@...a.com,
davem@...emloft.net,
kuba@...nel.org,
pabeni@...hat.com,
dsahern@...nel.org,
edumazet@...gle.com
Cc: sinquersw@...il.com,
kuifeng@...a.com,
Kui-Feng Lee <thinker.li@...il.com>,
Hangbin Liu <liuhangbin@...il.com>
Subject: [PATCH net-next v3 2/2] selftests: fib_tests: Add tests for toggling between w/ and w/o expires.
From: Kui-Feng Lee <thinker.li@...il.com>
Make sure that toggling routes between w/ expires and w/o expires works
properly with GC list.
When a route with expires is replaced by a permanent route, the entry
should be removed from the gc list. When a permanent routes is replaced by
a temporary route, the new entry should be added to the gc list. The new
tests check if these basic operators work properly.
Signed-off-by: Kui-Feng Lee <thinker.li@...il.com>
Cc: Hangbin Liu <liuhangbin@...il.com>
---
tools/testing/selftests/net/fib_tests.sh | 82 +++++++++++++++++++++++-
1 file changed, 80 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index 66d0db7a2614..337d0febd796 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -785,6 +785,8 @@ fib6_gc_test()
ret=0
fi
+ log_test $ret 0 "ipv6 route garbage collection"
+
# Permanent routes
for i in $(seq 1 5000); do
$IP -6 route add 2001:30::$i \
@@ -806,9 +808,85 @@ fib6_gc_test()
ret=0
fi
- set +e
+ log_test $ret 0 "ipv6 route garbage collection (with permanent routes)"
- log_test $ret 0 "ipv6 route garbage collection"
+ # Delete permanent routes
+ for i in $(seq 1 5000); do
+ $IP -6 route del 2001:30::$i \
+ via 2001:10::2 dev dummy_10
+ done
+
+ # Permanent routes
+ for i in $(seq 1 100); do
+ # Expire route after $EXPIRE seconds
+ $IP -6 route add 2001:20::$i \
+ via 2001:10::2 dev dummy_10
+ done
+ # Replace with temporary routes
+ for i in $(seq 1 100); do
+ # Expire route after $EXPIRE seconds
+ $IP -6 route replace 2001:20::$i \
+ via 2001:10::2 dev dummy_10 expires $EXPIRE
+ done
+ N_EXP_SLEEP=$($IP -6 route list |grep expires|wc -l)
+ if [ $N_EXP_SLEEP -ne 100 ]; then
+ echo "FAIL: expected 100 routes with expires, got $N_EXP_SLEEP"
+ ret=1
+ else
+ ret=0
+ fi
+
+ if [ $ret -eq 0 ]; then
+ sleep $(($EXPIRE * 2 + 1))
+ N_EXP_SLEEP=$($IP -6 route list |grep expires|wc -l)
+ if [ $N_EXP_SLEEP -ne 0 ]; then
+ echo "FAIL: expected 0 routes with expires," \
+ "got $N_EXP_SLEEP"
+ ret=1
+ else
+ ret=0
+ fi
+ fi
+
+ if [ $ret -eq 0 ]; then
+ PERM_BASE=$($IP -6 route list |grep -v expires|wc -l)
+ # Temporary routes
+ for i in $(seq 1 100); do
+ # Expire route after $EXPIRE seconds
+ $IP -6 route add 2001:20::$i \
+ via 2001:10::2 dev dummy_10 expires $EXPIRE
+ done
+ # Replace with permanent routes
+ for i in $(seq 1 100); do
+ # Expire route after $EXPIRE seconds
+ $IP -6 route replace 2001:20::$i \
+ via 2001:10::2 dev dummy_10
+ done
+ N_EXP_SLEEP=$($IP -6 route list |grep expires|wc -l)
+ if [ $N_EXP_SLEEP -ne 0 ]; then
+ echo "FAIL: expected 0 routes with expires," \
+ "got $N_EXP_SLEEP"
+ ret=1
+ else
+ ret=0
+ fi
+ fi
+ if [ $ret -eq 0 ]; then
+ sleep $(($EXPIRE * 2 + 1))
+ N_EXP_PERM=$($IP -6 route list |grep -v expires|wc -l)
+ N_EXP_PERM=$(($N_EXP_PERM - $PERM_BASE))
+ if [ $N_EXP_PERM -ne 100 ]; then
+ echo "FAIL: expected 100 permanent routes," \
+ "got $N_EXP_PERM"
+ ret=1
+ else
+ ret=0
+ fi
+ fi
+
+ log_test $ret 0 "ipv6 route garbage collection (replace with permanent)"
+
+ set +e
cleanup &> /dev/null
}
--
2.34.1
Powered by blists - more mailing lists