selftests: netfilter: Fix skip of wildcard interface test
authorPhil Sutter <phil@nwl.cc>
Tue, 27 May 2025 09:41:17 +0000 (11:41 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Wed, 28 May 2025 07:48:41 +0000 (09:48 +0200)
The script is supposed to skip wildcard interface testing if unsupported
by the host's nft tool. The failing check caused script abort due to
'set -e' though. Fix this by running the potentially failing nft command
inside the if-conditional pipe.

Fixes: 73db1b5dab6f ("selftests: netfilter: Torture nftables netdev hooks")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Link: https://patch.msgid.link/20250527094117.18589-1-phil@nwl.cc
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/testing/selftests/net/netfilter/nft_interface_stress.sh

index 11d82d1..5ff7be9 100755 (executable)
@@ -97,7 +97,8 @@ kill $nft_monitor_pid
 kill $rename_loop_pid
 wait
 
-ip netns exec $nsr nft -f - <<EOF
+wildcard_prep() {
+       ip netns exec $nsr nft -f - <<EOF
 table ip t {
        flowtable ft_wild {
                hook ingress priority 0
@@ -105,7 +106,9 @@ table ip t {
        }
 }
 EOF
-if [[ $? -ne 0 ]]; then
+}
+
+if ! wildcard_prep; then
        echo "SKIP wildcard tests: not supported by host's nft?"
 else
        for ((i = 0; i < 100; i++)); do