selftests: mptcp: join: use 'iptables-legacy' if available
IPTables commands using 'iptables-nft' fail on old kernels, at least
5.15 because it doesn't see the default IPTables chains:
$ iptables -L
iptables/1.8.2 Failed to initialize nft: Protocol not supported
As a first step before switching to NFTables, we can use iptables-legacy
if available.
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: 8d014eaa92
("selftests: mptcp: add ADD_ADDR timeout test case")
Cc: stable@vger.kernel.org
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
b1a6a38ab8
commit
0c4cd3f86a
1 changed files with 12 additions and 6 deletions
|
@ -25,6 +25,8 @@ capout=""
|
||||||
ns1=""
|
ns1=""
|
||||||
ns2=""
|
ns2=""
|
||||||
ksft_skip=4
|
ksft_skip=4
|
||||||
|
iptables="iptables"
|
||||||
|
ip6tables="ip6tables"
|
||||||
timeout_poll=30
|
timeout_poll=30
|
||||||
timeout_test=$((timeout_poll * 2 + 1))
|
timeout_test=$((timeout_poll * 2 + 1))
|
||||||
capture=0
|
capture=0
|
||||||
|
@ -146,7 +148,11 @@ check_tools()
|
||||||
exit $ksft_skip
|
exit $ksft_skip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! iptables -V &> /dev/null; then
|
# Use the legacy version if available to support old kernel versions
|
||||||
|
if iptables-legacy -V &> /dev/null; then
|
||||||
|
iptables="iptables-legacy"
|
||||||
|
ip6tables="ip6tables-legacy"
|
||||||
|
elif ! iptables -V &> /dev/null; then
|
||||||
echo "SKIP: Could not run all tests without iptables tool"
|
echo "SKIP: Could not run all tests without iptables tool"
|
||||||
exit $ksft_skip
|
exit $ksft_skip
|
||||||
fi
|
fi
|
||||||
|
@ -247,9 +253,9 @@ reset_with_add_addr_timeout()
|
||||||
|
|
||||||
reset "${1}" || return 1
|
reset "${1}" || return 1
|
||||||
|
|
||||||
tables="iptables"
|
tables="${iptables}"
|
||||||
if [ $ip -eq 6 ]; then
|
if [ $ip -eq 6 ]; then
|
||||||
tables="ip6tables"
|
tables="${ip6tables}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
|
ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
|
||||||
|
@ -314,9 +320,9 @@ reset_with_fail()
|
||||||
local ip="${3:-4}"
|
local ip="${3:-4}"
|
||||||
local tables
|
local tables
|
||||||
|
|
||||||
tables="iptables"
|
tables="${iptables}"
|
||||||
if [ $ip -eq 6 ]; then
|
if [ $ip -eq 6 ]; then
|
||||||
tables="ip6tables"
|
tables="${ip6tables}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ip netns exec $ns2 $tables \
|
ip netns exec $ns2 $tables \
|
||||||
|
@ -704,7 +710,7 @@ filter_tcp_from()
|
||||||
local src="${2}"
|
local src="${2}"
|
||||||
local target="${3}"
|
local target="${3}"
|
||||||
|
|
||||||
ip netns exec "${ns}" iptables -A INPUT -s "${src}" -p tcp -j "${target}"
|
ip netns exec "${ns}" ${iptables} -A INPUT -s "${src}" -p tcp -j "${target}"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_transfer()
|
do_transfer()
|
||||||
|
|
Loading…
Add table
Reference in a new issue