selftests: mptcp: sockopt: use 'iptables-legacy' if available
IPTables commands using 'iptables-nft' fail on old kernels, at least
on v5.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: dc65fe82fb
("selftests: mptcp: add packet mark test case")
Cc: stable@vger.kernel.org
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
221e455045
commit
a5a5990c09
1 changed files with 11 additions and 9 deletions
|
@ -12,6 +12,8 @@ ksft_skip=4
|
||||||
timeout_poll=30
|
timeout_poll=30
|
||||||
timeout_test=$((timeout_poll * 2 + 1))
|
timeout_test=$((timeout_poll * 2 + 1))
|
||||||
mptcp_connect=""
|
mptcp_connect=""
|
||||||
|
iptables="iptables"
|
||||||
|
ip6tables="ip6tables"
|
||||||
|
|
||||||
sec=$(date +%s)
|
sec=$(date +%s)
|
||||||
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
|
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
|
||||||
|
@ -25,7 +27,7 @@ add_mark_rules()
|
||||||
local m=$2
|
local m=$2
|
||||||
|
|
||||||
local t
|
local t
|
||||||
for t in iptables ip6tables; do
|
for t in ${iptables} ${ip6tables}; do
|
||||||
# just to debug: check we have multiple subflows connection requests
|
# just to debug: check we have multiple subflows connection requests
|
||||||
ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
|
ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
|
||||||
|
|
||||||
|
@ -95,14 +97,14 @@ if [ $? -ne 0 ];then
|
||||||
exit $ksft_skip
|
exit $ksft_skip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
iptables -V > /dev/null 2>&1
|
# Use the legacy version if available to support old kernel versions
|
||||||
if [ $? -ne 0 ];then
|
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
|
elif ! ip6tables -V &> /dev/null; then
|
||||||
|
|
||||||
ip6tables -V > /dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ];then
|
|
||||||
echo "SKIP: Could not run all tests without ip6tables tool"
|
echo "SKIP: Could not run all tests without ip6tables tool"
|
||||||
exit $ksft_skip
|
exit $ksft_skip
|
||||||
fi
|
fi
|
||||||
|
@ -112,10 +114,10 @@ check_mark()
|
||||||
local ns=$1
|
local ns=$1
|
||||||
local af=$2
|
local af=$2
|
||||||
|
|
||||||
local tables=iptables
|
local tables=${iptables}
|
||||||
|
|
||||||
if [ $af -eq 6 ];then
|
if [ $af -eq 6 ];then
|
||||||
tables=ip6tables
|
tables=${ip6tables}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local counters values
|
local counters values
|
||||||
|
|
Loading…
Add table
Reference in a new issue