selftests: netfilter: extend flowtable test script for ipsec
'flow offload' expression should not offload flows that will be subject to ipsec, but it does. This results in a connectivity blackhole for the affected flows -- first packets will go through (offload happens after established state is reached), but all remaining ones bypass ipsec encryption and are thus discarded by the peer. This can be worked around by adding "rt ipsec exists accept" before the 'flow offload' rule matches. This test case will fail, support for such flows is added in next patch. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
5e5412c365
commit
0ca1bbb7f4
|
@ -321,4 +321,52 @@ else
|
|||
ip netns exec nsr1 nft list ruleset
|
||||
fi
|
||||
|
||||
KEY_SHA="0x"$(ps -xaf | sha1sum | cut -d " " -f 1)
|
||||
KEY_AES="0x"$(ps -xaf | md5sum | cut -d " " -f 1)
|
||||
SPI1=$RANDOM
|
||||
SPI2=$RANDOM
|
||||
|
||||
if [ $SPI1 -eq $SPI2 ]; then
|
||||
SPI2=$((SPI2+1))
|
||||
fi
|
||||
|
||||
do_esp() {
|
||||
local ns=$1
|
||||
local me=$2
|
||||
local remote=$3
|
||||
local lnet=$4
|
||||
local rnet=$5
|
||||
local spi_out=$6
|
||||
local spi_in=$7
|
||||
|
||||
ip -net $ns xfrm state add src $remote dst $me proto esp spi $spi_in enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $rnet dst $lnet
|
||||
ip -net $ns xfrm state add src $me dst $remote proto esp spi $spi_out enc aes $KEY_AES auth sha1 $KEY_SHA mode tunnel sel src $lnet dst $rnet
|
||||
|
||||
# to encrypt packets as they go out (includes forwarded packets that need encapsulation)
|
||||
ip -net $ns xfrm policy add src $lnet dst $rnet dir out tmpl src $me dst $remote proto esp mode tunnel priority 1 action allow
|
||||
# to fwd decrypted packets after esp processing:
|
||||
ip -net $ns xfrm policy add src $rnet dst $lnet dir fwd tmpl src $remote dst $me proto esp mode tunnel priority 1 action allow
|
||||
|
||||
}
|
||||
|
||||
do_esp nsr1 192.168.10.1 192.168.10.2 10.0.1.0/24 10.0.2.0/24 $SPI1 $SPI2
|
||||
|
||||
do_esp nsr2 192.168.10.2 192.168.10.1 10.0.2.0/24 10.0.1.0/24 $SPI2 $SPI1
|
||||
|
||||
ip netns exec nsr1 nft delete table ip nat
|
||||
|
||||
# restore default routes
|
||||
ip -net ns2 route del 192.168.10.1 via 10.0.2.1
|
||||
ip -net ns2 route add default via 10.0.2.1
|
||||
ip -net ns2 route add default via dead:2::1
|
||||
|
||||
test_tcp_forwarding ns1 ns2
|
||||
if [ $? -eq 0 ] ;then
|
||||
echo "PASS: ipsec tunnel mode for ns1/ns2"
|
||||
else
|
||||
echo "FAIL: ipsec tunnel mode for ns1/ns2"
|
||||
ip netns exec nsr1 nft list ruleset 1>&2
|
||||
ip netns exec nsr1 cat /proc/net/xfrm_stat 1>&2
|
||||
fi
|
||||
|
||||
exit $ret
|
||||
|
|
Loading…
Reference in New Issue