Skip to content

Commit 0ab95d5

Browse files
matttbegregkh
authored andcommitted
selftests: mptcp: sockopt: use 'iptables-legacy' if available
commit a5a5990 upstream. 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: multipath-tcp/mptcp_net-next#368 Fixes: dc65fe8 ("selftests: mptcp: add packet mark test case") Cc: [email protected] Acked-by: Paolo Abeni <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bd2deca commit 0ab95d5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ timeout_poll=30
1313
timeout_test=$((timeout_poll * 2 + 1))
1414
mptcp_connect=""
1515
do_all_tests=1
16+
iptables="iptables"
17+
ip6tables="ip6tables"
1618

1719
add_mark_rules()
1820
{
1921
local ns=$1
2022
local m=$2
2123

22-
for t in iptables ip6tables; do
24+
for t in ${iptables} ${ip6tables}; do
2325
# just to debug: check we have multiple subflows connection requests
2426
ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
2527

@@ -92,14 +94,14 @@ if [ $? -ne 0 ];then
9294
exit $ksft_skip
9395
fi
9496

95-
iptables -V > /dev/null 2>&1
96-
if [ $? -ne 0 ];then
97+
# Use the legacy version if available to support old kernel versions
98+
if iptables-legacy -V &> /dev/null; then
99+
iptables="iptables-legacy"
100+
ip6tables="ip6tables-legacy"
101+
elif ! iptables -V &> /dev/null; then
97102
echo "SKIP: Could not run all tests without iptables tool"
98103
exit $ksft_skip
99-
fi
100-
101-
ip6tables -V > /dev/null 2>&1
102-
if [ $? -ne 0 ];then
104+
elif ! ip6tables -V &> /dev/null; then
103105
echo "SKIP: Could not run all tests without ip6tables tool"
104106
exit $ksft_skip
105107
fi
@@ -109,10 +111,10 @@ check_mark()
109111
local ns=$1
110112
local af=$2
111113

112-
tables=iptables
114+
tables=${iptables}
113115

114116
if [ $af -eq 6 ];then
115-
tables=ip6tables
117+
tables=${ip6tables}
116118
fi
117119

118120
counters=$(ip netns exec $ns $tables -v -L OUTPUT | grep DROP)
@@ -314,8 +316,8 @@ do_tcpinq_tests()
314316
{
315317
local lret=0
316318

317-
ip netns exec "$ns1" iptables -F
318-
ip netns exec "$ns1" ip6tables -F
319+
ip netns exec "$ns1" ${iptables} -F
320+
ip netns exec "$ns1" ${ip6tables} -F
319321

320322
if ! mptcp_lib_kallsyms_has "mptcp_ioctl$"; then
321323
echo "INFO: TCP_INQ not supported: SKIP"

0 commit comments

Comments
 (0)