Skip to content

Commit a5a5990

Browse files
matttbedavem330
authored andcommitted
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: 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]>
1 parent 221e455 commit a5a5990

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ksft_skip=4
1212
timeout_poll=30
1313
timeout_test=$((timeout_poll * 2 + 1))
1414
mptcp_connect=""
15+
iptables="iptables"
16+
ip6tables="ip6tables"
1517

1618
sec=$(date +%s)
1719
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
@@ -25,7 +27,7 @@ add_mark_rules()
2527
local m=$2
2628

2729
local t
28-
for t in iptables ip6tables; do
30+
for t in ${iptables} ${ip6tables}; do
2931
# just to debug: check we have multiple subflows connection requests
3032
ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
3133

@@ -95,14 +97,14 @@ if [ $? -ne 0 ];then
9597
exit $ksft_skip
9698
fi
9799

98-
iptables -V > /dev/null 2>&1
99-
if [ $? -ne 0 ];then
100+
# Use the legacy version if available to support old kernel versions
101+
if iptables-legacy -V &> /dev/null; then
102+
iptables="iptables-legacy"
103+
ip6tables="ip6tables-legacy"
104+
elif ! iptables -V &> /dev/null; then
100105
echo "SKIP: Could not run all tests without iptables tool"
101106
exit $ksft_skip
102-
fi
103-
104-
ip6tables -V > /dev/null 2>&1
105-
if [ $? -ne 0 ];then
107+
elif ! ip6tables -V &> /dev/null; then
106108
echo "SKIP: Could not run all tests without ip6tables tool"
107109
exit $ksft_skip
108110
fi
@@ -112,10 +114,10 @@ check_mark()
112114
local ns=$1
113115
local af=$2
114116

115-
local tables=iptables
117+
local tables=${iptables}
116118

117119
if [ $af -eq 6 ];then
118-
tables=ip6tables
120+
tables=${ip6tables}
119121
fi
120122

121123
local counters values

0 commit comments

Comments
 (0)