Commit fab336b4 authored by Chen Yi's avatar Chen Yi Committed by Pablo Neira Ayuso

selftests: netfilter: Pass family parameter "-f" to conntrack tool

Fix nft_conntrack_helper.sh false fail report:

1) Conntrack tool need "-f ipv6" parameter to show out ipv6 traffic items.

2) Sleep 1 second after background nc send packet, to make sure check
is after this statement executed.

False report:
FAIL: ns1-lkjUemYw did not show attached helper ip set via ruleset
PASS: ns1-lkjUemYw connection on port 2121 has ftp helper attached
...

After fix:
PASS: ns1-2hUniwU2 connection on port 2121 has ftp helper attached
PASS: ns2-2hUniwU2 connection on port 2121 has ftp helper attached
...

Fixes: 619ae8e0 ("selftests: netfilter: add test case for conntrack helper assignment")
Signed-off-by: default avatarChen Yi <yiche@redhat.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent c49243e8
...@@ -94,7 +94,13 @@ check_for_helper() ...@@ -94,7 +94,13 @@ check_for_helper()
local message=$2 local message=$2
local port=$3 local port=$3
ip netns exec ${netns} conntrack -L -p tcp --dport $port 2> /dev/null |grep -q 'helper=ftp' if echo $message |grep -q 'ipv6';then
local family="ipv6"
else
local family="ipv4"
fi
ip netns exec ${netns} conntrack -L -f $family -p tcp --dport $port 2> /dev/null |grep -q 'helper=ftp'
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "FAIL: ${netns} did not show attached helper $message" 1>&2 echo "FAIL: ${netns} did not show attached helper $message" 1>&2
ret=1 ret=1
...@@ -111,8 +117,8 @@ test_helper() ...@@ -111,8 +117,8 @@ test_helper()
sleep 3 | ip netns exec ${ns2} nc -w 2 -l -p $port > /dev/null & sleep 3 | ip netns exec ${ns2} nc -w 2 -l -p $port > /dev/null &
sleep 1
sleep 1 | ip netns exec ${ns1} nc -w 2 10.0.1.2 $port > /dev/null & sleep 1 | ip netns exec ${ns1} nc -w 2 10.0.1.2 $port > /dev/null &
sleep 1
check_for_helper "$ns1" "ip $msg" $port check_for_helper "$ns1" "ip $msg" $port
check_for_helper "$ns2" "ip $msg" $port check_for_helper "$ns2" "ip $msg" $port
...@@ -128,8 +134,8 @@ test_helper() ...@@ -128,8 +134,8 @@ test_helper()
sleep 3 | ip netns exec ${ns2} nc -w 2 -6 -l -p $port > /dev/null & sleep 3 | ip netns exec ${ns2} nc -w 2 -6 -l -p $port > /dev/null &
sleep 1
sleep 1 | ip netns exec ${ns1} nc -w 2 -6 dead:1::2 $port > /dev/null & sleep 1 | ip netns exec ${ns1} nc -w 2 -6 dead:1::2 $port > /dev/null &
sleep 1
check_for_helper "$ns1" "ipv6 $msg" $port check_for_helper "$ns1" "ipv6 $msg" $port
check_for_helper "$ns2" "ipv6 $msg" $port check_for_helper "$ns2" "ipv6 $msg" $port
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment