From: Florian Westphal Date: Mon, 9 Sep 2024 15:13:46 +0000 (+0200) Subject: tests: shell: extend vmap test with updates X-Git-Tag: v1.1.1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db80037c0279acfba9da1dbfd0bd0868b61e836c;p=thirdparty%2Fnftables.git tests: shell: extend vmap test with updates It won't validate that the update is actually effective, but it will trigger relevant update logic in kernel. This means the updated test works even if the kernel doesn't support updates. A dedicated test will be added to check timeout updates work. Signed-off-by: Florian Westphal --- diff --git a/tests/shell/testcases/maps/vmap_timeout b/tests/shell/testcases/maps/vmap_timeout index 0cd965f7..3f0563af 100755 --- a/tests/shell/testcases/maps/vmap_timeout +++ b/tests/shell/testcases/maps/vmap_timeout @@ -11,18 +11,52 @@ port=23 for i in $(seq 1 100) ; do timeout=$((RANDOM%5)) timeout=$((timeout+1)) + expire=$((RANDOM%timeout)) j=1 batched="{ $port timeout 3s : jump other_input " - batched_addr="{ 10.0.$((i%256)).$j . $port timeout ${timeout}s : jump other_input " + ubatched="$batched" + + timeout_str="timeout ${timeout}s" + expire_str="" + if [ "$expire" -gt 0 ]; then + expire_str="expires ${expire}s" + fi + + batched_addr="{ 10.0.$((i%256)).$j . $port ${timeout_str} ${expire_str} : jump other_input " + ubatched_addr="$batched_addr" + port=$((port + 1)) for j in $(seq 2 400); do timeout=$((RANDOM%5)) timeout=$((timeout+1)) + expire=$((RANDOM%timeout)) + utimeout=$((RANDOM%5)) + utimeout=$((timeout+1)) + + timeout_str="timeout ${timeout}s" + expire_str="" + if [ "$expire" -gt 0 ]; then + expire_str="expires ${expire}s" + fi - batched="$batched, $port timeout ${timeout}s : jump other_input " - batched_addr="$batched_addr, 10.0.$((i%256)).$((j%256)) . $port timeout ${timeout}s : jump other_input " + batched="$batched, $port ${timeout_str} ${expire_str} : jump other_input " + batched_addr="$batched_addr, 10.0.$((i%256)).$((j%256)) . $port ${timeout_str} ${expire_str} : jump other_input " port=$((port + 1)) + + timeout_str="timeout ${utimeout}s" + expire=$((RANDOM%utimeout)) + + expire_str="" + if [ "$expires" -gt 0 ]; then + expire_str="expires ${expire}s" + fi + + update=$((RANDOM%2)) + if [ "$update" -ne 0 ]; then + ubatched="$batched, $port ${timeout_str} ${expire_str} : jump other_input " + ubatched_addr="$batched_addr, 10.0.$((i%256)).$((j%256)) . $port ${timeout_str} ${expire_str} : jump other_input " + fi done fail_addr="$batched_addr, 1.2.3.4 . 23 timeout 5m : jump other_input, @@ -40,6 +74,14 @@ for i in $(seq 1 100) ; do $NFT add element inet filter portmap "$batched" $NFT add element inet filter portaddrmap "$batched_addr" + + update=$((RANDOM%2)) + if [ "$update" -ne 0 ]; then + ubatched="$ubatched }" + ubatched_addr="$ubatched_addr }" + $NFT add element inet filter portmap "$ubatched" + $NFT add element inet filter portaddrmap "$ubatched_addr" + fi done if [ "$NFT_TEST_HAVE_catchall_element" = n ] ; then