Skip to content

Commit d46cea0

Browse files
Florian Westphalummakynes
authored andcommitted
selftests: netfilter: switch zone stress to socat
centos9 has nmap-ncat which doesn't like the '-q' option, use socat. While at it, mark test skipped if needed tools are missing. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 962e5a4 commit d46cea0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tools/testing/selftests/netfilter/nft_zones_many.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ cleanup()
1818
ip netns del $ns
1919
}
2020

21-
ip netns add $ns
22-
if [ $? -ne 0 ];then
23-
echo "SKIP: Could not create net namespace $gw"
24-
exit $ksft_skip
25-
fi
21+
checktool (){
22+
if ! $1 > /dev/null 2>&1; then
23+
echo "SKIP: Could not $2"
24+
exit $ksft_skip
25+
fi
26+
}
27+
28+
checktool "nft --version" "run test without nft tool"
29+
checktool "ip -Version" "run test without ip tool"
30+
checktool "socat -V" "run test without socat tool"
31+
checktool "ip netns add $ns" "create net namespace"
2632

2733
trap cleanup EXIT
2834

@@ -71,7 +77,8 @@ EOF
7177
local start=$(date +%s%3N)
7278
i=$((i + 10000))
7379
j=$((j + 1))
74-
dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" nc -w 1 -q 1 -u -p 12345 127.0.0.1 12345 > /dev/null
80+
# nft rule in output places each packet in a different zone.
81+
dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" socat STDIN UDP:127.0.0.1:12345,sourceport=12345
7582
if [ $? -ne 0 ] ;then
7683
ret=1
7784
break

0 commit comments

Comments
 (0)