Skip to content

Commit

Permalink
selftests: mptcp: sockopt: use 'iptables-legacy' if available
Browse files Browse the repository at this point in the history
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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
matttbe authored and gregkh committed Aug 3, 2023
1 parent bd2deca commit 0ab95d5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
mptcp_connect=""
do_all_tests=1
iptables="iptables"
ip6tables="ip6tables"

add_mark_rules()
{
local ns=$1
local m=$2

for t in iptables ip6tables; do
for t in ${iptables} ${ip6tables}; do
# 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

Expand Down Expand Up @@ -92,14 +94,14 @@ if [ $? -ne 0 ];then
exit $ksft_skip
fi

iptables -V > /dev/null 2>&1
if [ $? -ne 0 ];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"
exit $ksft_skip
fi

ip6tables -V > /dev/null 2>&1
if [ $? -ne 0 ];then
elif ! ip6tables -V &> /dev/null; then
echo "SKIP: Could not run all tests without ip6tables tool"
exit $ksft_skip
fi
Expand All @@ -109,10 +111,10 @@ check_mark()
local ns=$1
local af=$2

tables=iptables
tables=${iptables}

if [ $af -eq 6 ];then
tables=ip6tables
tables=${ip6tables}
fi

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

ip netns exec "$ns1" iptables -F
ip netns exec "$ns1" ip6tables -F
ip netns exec "$ns1" ${iptables} -F
ip netns exec "$ns1" ${ip6tables} -F

if ! mptcp_lib_kallsyms_has "mptcp_ioctl$"; then
echo "INFO: TCP_INQ not supported: SKIP"
Expand Down

0 comments on commit 0ab95d5

Please sign in to comment.