Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 619ae8e0697a6 ("selftests: netfilter: add test case for conntrack helper assignment")
Signed-off-by: Chen Yi <yiche@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Chen Yi and committed by
Pablo Neira Ayuso
fab336b4 c49243e8

+9 -3
+9 -3
tools/testing/selftests/netfilter/nft_conntrack_helper.sh
··· 94 94 local message=$2 95 95 local port=$3 96 96 97 - ip netns exec ${netns} conntrack -L -p tcp --dport $port 2> /dev/null |grep -q 'helper=ftp' 97 + if echo $message |grep -q 'ipv6';then 98 + local family="ipv6" 99 + else 100 + local family="ipv4" 101 + fi 102 + 103 + ip netns exec ${netns} conntrack -L -f $family -p tcp --dport $port 2> /dev/null |grep -q 'helper=ftp' 98 104 if [ $? -ne 0 ] ; then 99 105 echo "FAIL: ${netns} did not show attached helper $message" 1>&2 100 106 ret=1 ··· 117 111 118 112 sleep 3 | ip netns exec ${ns2} nc -w 2 -l -p $port > /dev/null & 119 113 120 - sleep 1 121 114 sleep 1 | ip netns exec ${ns1} nc -w 2 10.0.1.2 $port > /dev/null & 115 + sleep 1 122 116 123 117 check_for_helper "$ns1" "ip $msg" $port 124 118 check_for_helper "$ns2" "ip $msg" $port ··· 134 128 135 129 sleep 3 | ip netns exec ${ns2} nc -w 2 -6 -l -p $port > /dev/null & 136 130 137 - sleep 1 138 131 sleep 1 | ip netns exec ${ns1} nc -w 2 -6 dead:1::2 $port > /dev/null & 132 + sleep 1 139 133 140 134 check_for_helper "$ns1" "ipv6 $msg" $port 141 135 check_for_helper "$ns2" "ipv6 $msg" $port