Commit c50a42b8 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

kselftests: netfilter: fix leftover net/net-next merge conflict

In nf-next, I had extended this script to also cover NAT support for the
inet family.

In nf, I extended it to cover a regression with 'fully-random' masquerade.

Make this script work again by resolving the conflicts as needed.

Fixes: 8b448365 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ee8a2b95
...@@ -8,6 +8,11 @@ ksft_skip=4 ...@@ -8,6 +8,11 @@ ksft_skip=4
ret=0 ret=0
test_inet_nat=true test_inet_nat=true
cleanup()
{
for i in 0 1 2; do ip netns del ns$i;done
}
nft --version > /dev/null 2>&1 nft --version > /dev/null 2>&1
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
echo "SKIP: Could not run test without nft tool" echo "SKIP: Could not run test without nft tool"
...@@ -21,6 +26,13 @@ if [ $? -ne 0 ];then ...@@ -21,6 +26,13 @@ if [ $? -ne 0 ];then
fi fi
ip netns add ns0 ip netns add ns0
if [ $? -ne 0 ];then
echo "SKIP: Could not create net namespace"
exit $ksft_skip
fi
trap cleanup EXIT
ip netns add ns1 ip netns add ns1
ip netns add ns2 ip netns add ns2
...@@ -347,7 +359,7 @@ EOF ...@@ -347,7 +359,7 @@ EOF
test_masquerade6() test_masquerade6()
{ {
local family=$1 local family=$1
local natflags=$1 local natflags=$2
local lret=0 local lret=0
ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
...@@ -392,18 +404,13 @@ EOF ...@@ -392,18 +404,13 @@ EOF
ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
<<<<<<< HEAD echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
echo "ERROR: cannot ping ns1 from ns2 with active $family masquerading"
=======
echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags"
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
lret=1 lret=1
fi fi
# ns1 should have seen packets from ns0, due to masquerade # ns1 should have seen packets from ns0, due to masquerade
expect="packets 1 bytes 104" expect="packets 1 bytes 104"
for dir in "in6" "out6" ; do for dir in "in6" "out6" ; do
cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect") cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
bad_counter ns1 ns0$dir "$expect" bad_counter ns1 ns0$dir "$expect"
...@@ -433,38 +440,27 @@ EOF ...@@ -433,38 +440,27 @@ EOF
fi fi
done done
<<<<<<< HEAD
ip netns exec ns0 nft flush chain $family nat postrouting
=======
ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1 ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)" echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)"
lret=1 lret=1
fi fi
ip netns exec ns0 nft flush chain ip6 nat postrouting ip netns exec ns0 nft flush chain $family nat postrouting
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR: Could not flush $family nat postrouting" 1>&2 echo "ERROR: Could not flush $family nat postrouting" 1>&2
lret=1 lret=1
fi fi
<<<<<<< HEAD test $lret -eq 0 && echo "PASS: $family IPv6 masquerade $natflags for ns2"
test $lret -eq 0 && echo "PASS: $family IPv6 masquerade for ns2"
=======
test $lret -eq 0 && echo "PASS: IPv6 masquerade $natflags for ns2"
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
return $lret return $lret
} }
test_masquerade() test_masquerade()
{ {
<<<<<<< HEAD
local family=$1 local family=$1
======= local natflags=$2
local natflags=$1
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
local lret=0 local lret=0
ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
...@@ -509,11 +505,7 @@ EOF ...@@ -509,11 +505,7 @@ EOF
ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
<<<<<<< HEAD echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
echo "ERROR: cannot ping ns1 from ns2 with active $family masquerading"
=======
echo "ERROR: cannot ping ns1 from ns2 with active ip masquere $natflags"
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
lret=1 lret=1
fi fi
...@@ -549,27 +541,19 @@ EOF ...@@ -549,27 +541,19 @@ EOF
fi fi
done done
<<<<<<< HEAD
ip netns exec ns0 nft flush chain $family nat postrouting
=======
ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1 ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)" echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)"
lret=1 lret=1
fi fi
ip netns exec ns0 nft flush chain ip nat postrouting ip netns exec ns0 nft flush chain $family nat postrouting
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR: Could not flush $family nat postrouting" 1>&2 echo "ERROR: Could not flush $family nat postrouting" 1>&2
lret=1 lret=1
fi fi
<<<<<<< HEAD test $lret -eq 0 && echo "PASS: $family IP masquerade $natflags for ns2"
test $lret -eq 0 && echo "PASS: $family IP masquerade for ns2"
=======
test $lret -eq 0 && echo "PASS: IP masquerade $natflags for ns2"
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
return $lret return $lret
} }
...@@ -842,21 +826,14 @@ reset_counters ...@@ -842,21 +826,14 @@ reset_counters
$test_inet_nat && test_local_dnat inet $test_inet_nat && test_local_dnat inet
$test_inet_nat && test_local_dnat6 inet $test_inet_nat && test_local_dnat6 inet
for flags in "" "fully-random"; do
reset_counters reset_counters
<<<<<<< HEAD test_masquerade ip $flags
test_masquerade ip test_masquerade6 ip6 $flags
test_masquerade6 ip6
reset_counters reset_counters
$test_inet_nat && test_masquerade inet $test_inet_nat && test_masquerade inet $flags
$test_inet_nat && test_masquerade6 inet $test_inet_nat && test_masquerade6 inet $flags
======= done
test_masquerade ""
test_masquerade6 ""
reset_counters
test_masquerade "fully-random"
test_masquerade6 "fully-random"
>>>>>>> cd8dead0c39457e58ec1d36db93aedca811d48f1
reset_counters reset_counters
test_redirect ip test_redirect ip
...@@ -865,6 +842,4 @@ reset_counters ...@@ -865,6 +842,4 @@ reset_counters
$test_inet_nat && test_redirect inet $test_inet_nat && test_redirect inet
$test_inet_nat && test_redirect6 inet $test_inet_nat && test_redirect6 inet
for i in 0 1 2; do ip netns del ns$i;done
exit $ret exit $ret
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