From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
<netfilter-devel@vger.kernel.org>,
pablo@netfilter.org
Subject: [PATCH net-next 7/7] selftests: netfilter: conntrack_vrf.sh: prefer socat, not iperf3
Date: Tue, 23 Apr 2024 15:05:50 +0200 [thread overview]
Message-ID: <20240423130604.7013-8-fw@strlen.de> (raw)
In-Reply-To: <20240423130604.7013-1-fw@strlen.de>
Use socat, like most of the other scripts already do. This also makes
the script complete slightly faster (3s -> 1s).
iperf3 establishes two connections (1 control connection, and 1+x
depending on test), so adjust expected counter values as well.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
.../selftests/net/netfilter/conntrack_vrf.sh | 40 ++++++++++---------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/tools/testing/selftests/net/netfilter/conntrack_vrf.sh b/tools/testing/selftests/net/netfilter/conntrack_vrf.sh
index f7417004ec71..073e8e62d350 100755
--- a/tools/testing/selftests/net/netfilter/conntrack_vrf.sh
+++ b/tools/testing/selftests/net/netfilter/conntrack_vrf.sh
@@ -43,15 +43,9 @@ cleanup()
cleanup_all_ns
}
-if ! nft --version > /dev/null 2>&1;then
- echo "SKIP: Could not run test without nft tool"
- exit $ksft_skip
-fi
-
-if ! conntrack --version > /dev/null 2>&1;then
- echo "SKIP: Could not run test without conntrack tool"
- exit $ksft_skip
-fi
+checktool "nft --version" "run test without nft"
+checktool "conntrack --version" "run test without conntrack"
+checktool "socat -h" "run test without socat"
trap cleanup EXIT
@@ -79,7 +73,15 @@ ip -net "$ns1" li set veth0 up
ip -net "$ns0" addr add $IP0/$PFXL dev veth0
ip -net "$ns1" addr add $IP1/$PFXL dev veth0
-ip netns exec "$ns1" iperf3 -s > /dev/null 2>&1 &
+listener_ready()
+{
+ local ns="$1"
+
+ ss -N "$ns" -l -n -t -o "sport = :55555" | grep -q "55555"
+}
+
+ip netns exec "$ns1" socat -u -4 TCP-LISTEN:55555,reuseaddr,fork STDOUT > /dev/null &
+busywait $BUSYWAIT_TIMEOUT listener_ready "$ns1"
# test vrf ingress handling.
# The incoming connection should be placed in conntrack zone 1,
@@ -160,16 +162,16 @@ table ip nat {
}
}
EOF
- if ! ip netns exec "$ns0" ip vrf exec tvrf iperf3 -t 1 -c $IP1 >/dev/null; then
- echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on vrf device"
+ if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then
+ echo "FAIL: connect failure with masquerade + sport rewrite on vrf device"
ret=1
return
fi
# must also check that nat table was evaluated on second (lower device) iteration.
- ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 2' &&
- if ip netns exec "$ns0" nft list table ip nat |grep -q 'untracked counter packets [1-9]'; then
- echo "PASS: iperf3 connect with masquerade + sport rewrite on vrf device ($qdisc qdisc)"
+ if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 1' &&
+ ip netns exec "$ns0" nft list table ip nat |grep -q 'untracked counter packets [1-9]'; then
+ echo "PASS: connect with masquerade + sport rewrite on vrf device ($qdisc qdisc)"
else
echo "FAIL: vrf rules have unexpected counter value"
ret=1
@@ -195,15 +197,15 @@ table ip nat {
}
}
EOF
- if ! ip netns exec "$ns0" ip vrf exec tvrf iperf3 -t 1 -c $IP1 > /dev/null; then
- echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on veth device"
+ if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then
+ echo "FAIL: connect failure with masquerade + sport rewrite on veth device"
ret=1
return
fi
# must also check that nat table was evaluated on second (lower device) iteration.
- if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 2'; then
- echo "PASS: iperf3 connect with masquerade + sport rewrite on veth device"
+ if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 1'; then
+ echo "PASS: connect with masquerade + sport rewrite on veth device"
else
echo "FAIL: vrf masq rule has unexpected counter value"
ret=1
--
2.43.2
next prev parent reply other threads:[~2024-04-23 11:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 13:05 [PATCH net-next 0/7] selftest: netfilter: additional cleanups Florian Westphal
2024-04-23 13:05 ` [PATCH net-next 1/7] selftests: netfilter: nft_concat_range.sh: move to lib.sh infra Florian Westphal
2024-04-23 13:05 ` [PATCH net-next 2/7] selftests: netfilter: nft_concat_range.sh: drop netcat support Florian Westphal
2024-04-23 13:05 ` [PATCH net-next 3/7] selftests: netfilter: nft_concat_range.sh: shellcheck cleanups Florian Westphal
2024-04-23 13:05 ` [PATCH net-next 4/7] selftests: netfilter: nft_flowtable.sh: re-run with random mtu sizes Florian Westphal
2024-04-23 13:05 ` [PATCH net-next 5/7] selftests: netfilter: nft_flowtable.sh: shellcheck cleanups Florian Westphal
2024-04-23 13:05 ` [PATCH net-next 6/7] selftests: netfilter: skip tests on early errors Florian Westphal
2024-04-23 13:05 ` Florian Westphal [this message]
2024-04-23 16:50 ` [PATCH net-next 0/7] selftest: netfilter: additional cleanups Jakub Kicinski
2024-04-23 19:42 ` Florian Westphal
2024-04-23 20:52 ` Jakub Kicinski
2024-04-30 13:44 ` Florian Westphal
2024-04-25 0:20 ` patchwork-bot+netdevbpf
2024-04-25 19:12 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240423130604.7013-8-fw@strlen.de \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).