* [PATCH 6.6.y 1/4] selftests/net: synchronize udpgro tests' tx and rx connection
2024-05-29 15:15 [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Po-Hsu Lin
@ 2024-05-29 15:16 ` Po-Hsu Lin
2024-05-29 15:16 ` [PATCH 6.6.y 2/4] selftests: net: Remove executable bits from library scripts Po-Hsu Lin
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Po-Hsu Lin @ 2024-05-29 15:16 UTC (permalink / raw)
To: stable; +Cc: gregkh, po-hsu.lin
From: Lucas Karpinski <lkarpins@redhat.com>
commit 3bdd9fd29cb0f136b307559a19c107210ad5c314 upstream.
The sockets used by udpgso_bench_tx aren't always ready when
udpgso_bench_tx transmits packets. This issue is more prevalent in -rt
kernels, but can occur in both. Replace the hacky sleep calls with a
function that checks whether the ports in the namespace are ready for
use.
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[PHLin: context adjustment for the differences in BPF_FILE]
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
tools/testing/selftests/net/net_helper.sh | 22 ++++++++++++++++++++++
tools/testing/selftests/net/udpgro.sh | 13 ++++++-------
tools/testing/selftests/net/udpgro_bench.sh | 5 +++--
tools/testing/selftests/net/udpgro_frglist.sh | 5 +++--
4 files changed, 34 insertions(+), 11 deletions(-)
create mode 100755 tools/testing/selftests/net/net_helper.sh
diff --git a/tools/testing/selftests/net/net_helper.sh b/tools/testing/selftests/net/net_helper.sh
new file mode 100755
index 00000000..4fe0bef
--- /dev/null
+++ b/tools/testing/selftests/net/net_helper.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Helper functions
+
+wait_local_port_listen()
+{
+ local listener_ns="${1}"
+ local port="${2}"
+ local protocol="${3}"
+ local port_hex
+ local i
+
+ port_hex="$(printf "%04X" "${port}")"
+ for i in $(seq 10); do
+ if ip netns exec "${listener_ns}" cat /proc/net/"${protocol}"* | \
+ grep -q "${port_hex}"; then
+ break
+ fi
+ sleep 0.1
+ done
+}
diff --git a/tools/testing/selftests/net/udpgro.sh b/tools/testing/selftests/net/udpgro.sh
index 3f09ac78..8802604 100755
--- a/tools/testing/selftests/net/udpgro.sh
+++ b/tools/testing/selftests/net/udpgro.sh
@@ -3,6 +3,8 @@
#
# Run a series of udpgro functional tests.
+source net_helper.sh
+
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
BPF_FILE="xdp_dummy.o"
@@ -51,8 +53,7 @@ run_one() {
echo "ok" || \
echo "failed" &
- # Hack: let bg programs complete the startup
- sleep 0.2
+ wait_local_port_listen ${PEER_NS} 8000 udp
./udpgso_bench_tx ${tx_args}
ret=$?
wait $(jobs -p)
@@ -97,7 +98,7 @@ run_one_nat() {
echo "ok" || \
echo "failed"&
- sleep 0.1
+ wait_local_port_listen "${PEER_NS}" 8000 udp
./udpgso_bench_tx ${tx_args}
ret=$?
kill -INT $pid
@@ -118,11 +119,9 @@ run_one_2sock() {
echo "ok" || \
echo "failed" &
- # Hack: let bg programs complete the startup
- sleep 0.2
+ wait_local_port_listen "${PEER_NS}" 12345 udp
./udpgso_bench_tx ${tx_args} -p 12345
- sleep 0.1
- # first UDP GSO socket should be closed at this point
+ wait_local_port_listen "${PEER_NS}" 8000 udp
./udpgso_bench_tx ${tx_args}
ret=$?
wait $(jobs -p)
diff --git a/tools/testing/selftests/net/udpgro_bench.sh b/tools/testing/selftests/net/udpgro_bench.sh
index 65ff1d4..7080eae 100755
--- a/tools/testing/selftests/net/udpgro_bench.sh
+++ b/tools/testing/selftests/net/udpgro_bench.sh
@@ -3,6 +3,8 @@
#
# Run a series of udpgro benchmarks
+source net_helper.sh
+
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
BPF_FILE="xdp_dummy.o"
@@ -40,8 +42,7 @@ run_one() {
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
- # Hack: let bg programs complete the startup
- sleep 0.2
+ wait_local_port_listen "${PEER_NS}" 8000 udp
./udpgso_bench_tx ${tx_args}
}
diff --git a/tools/testing/selftests/net/udpgro_frglist.sh b/tools/testing/selftests/net/udpgro_frglist.sh
index bd51d38..e1ff645 100755
--- a/tools/testing/selftests/net/udpgro_frglist.sh
+++ b/tools/testing/selftests/net/udpgro_frglist.sh
@@ -3,6 +3,8 @@
#
# Run a series of udpgro benchmarks
+source net_helper.sh
+
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
BPF_FILE="xdp_dummy.o"
@@ -45,8 +47,7 @@ run_one() {
echo ${rx_args}
ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
- # Hack: let bg programs complete the startup
- sleep 0.2
+ wait_local_port_listen "${PEER_NS}" 8000 udp
./udpgso_bench_tx ${tx_args}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 6.6.y 2/4] selftests: net: Remove executable bits from library scripts
2024-05-29 15:15 [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Po-Hsu Lin
2024-05-29 15:16 ` [PATCH 6.6.y 1/4] selftests/net: synchronize udpgro tests' tx and rx connection Po-Hsu Lin
@ 2024-05-29 15:16 ` Po-Hsu Lin
2024-05-29 15:16 ` [PATCH 6.6.y 3/4] selftests: net: included needed helper in the install targets Po-Hsu Lin
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Po-Hsu Lin @ 2024-05-29 15:16 UTC (permalink / raw)
To: stable; +Cc: gregkh, po-hsu.lin
From: Benjamin Poirier <bpoirier@nvidia.com>
commit 9d851dd4dab63e95c1911a2fa847796d1ec5d58d upstream.
setup_loopback.sh and net_helper.sh are meant to be sourced from other
scripts, not executed directly. Therefore, remove the executable bits from
those files' permissions.
This change is similar to commit 49078c1b80b6 ("selftests: forwarding:
Remove executable bits from lib.sh")
Fixes: 7d1575014a63 ("selftests/net: GRO coalesce test")
Fixes: 3bdd9fd29cb0 ("selftests/net: synchronize udpgro tests' tx and rx connection")
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Link: https://lore.kernel.org/r/20240131140848.360618-4-bpoirier@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
tools/testing/selftests/net/net_helper.sh | 0
tools/testing/selftests/net/setup_loopback.sh | 0
2 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 tools/testing/selftests/net/net_helper.sh
mode change 100755 => 100644 tools/testing/selftests/net/setup_loopback.sh
diff --git a/tools/testing/selftests/net/net_helper.sh b/tools/testing/selftests/net/net_helper.sh
old mode 100755
new mode 100644
diff --git a/tools/testing/selftests/net/setup_loopback.sh b/tools/testing/selftests/net/setup_loopback.sh
old mode 100755
new mode 100644
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 6.6.y 3/4] selftests: net: included needed helper in the install targets
2024-05-29 15:15 [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Po-Hsu Lin
2024-05-29 15:16 ` [PATCH 6.6.y 1/4] selftests/net: synchronize udpgro tests' tx and rx connection Po-Hsu Lin
2024-05-29 15:16 ` [PATCH 6.6.y 2/4] selftests: net: Remove executable bits from library scripts Po-Hsu Lin
@ 2024-05-29 15:16 ` Po-Hsu Lin
2024-05-29 15:16 ` [PATCH 6.6.y 4/4] selftests: net: List helper scripts in TEST_FILES Makefile variable Po-Hsu Lin
2024-06-12 13:44 ` [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Greg KH
4 siblings, 0 replies; 6+ messages in thread
From: Po-Hsu Lin @ 2024-05-29 15:16 UTC (permalink / raw)
To: stable; +Cc: gregkh, po-hsu.lin
From: Paolo Abeni <pabeni@redhat.com>
commit f5173fe3e13b2cbd25d0d73f40acd923d75add55 upstream.
The blamed commit below introduce a dependency in some net self-tests
towards a newly introduce helper script.
Such script is currently not included into the TEST_PROGS_EXTENDED list
and thus is not installed, causing failure for the relevant tests when
executed from the install dir.
Fix the issue updating the install targets.
Fixes: 3bdd9fd29cb0 ("selftests/net: synchronize udpgro tests' tx and rx connection")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/076e8758e21ff2061cc9f81640e7858df775f0a9.1706131762.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[PHLin: ignore the non-existing lib.sh]
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
tools/testing/selftests/net/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index de4506e..6fbebf8 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -55,6 +55,7 @@ TEST_PROGS += rps_default_mask.sh
TEST_PROGS += big_tcp.sh
TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh
TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh
+TEST_PROGS_EXTENDED += net_helper.sh
TEST_GEN_FILES = socket nettest
TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 6.6.y 4/4] selftests: net: List helper scripts in TEST_FILES Makefile variable
2024-05-29 15:15 [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Po-Hsu Lin
` (2 preceding siblings ...)
2024-05-29 15:16 ` [PATCH 6.6.y 3/4] selftests: net: included needed helper in the install targets Po-Hsu Lin
@ 2024-05-29 15:16 ` Po-Hsu Lin
2024-06-12 13:44 ` [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Greg KH
4 siblings, 0 replies; 6+ messages in thread
From: Po-Hsu Lin @ 2024-05-29 15:16 UTC (permalink / raw)
To: stable; +Cc: gregkh, po-hsu.lin
From: Benjamin Poirier <bpoirier@nvidia.com>
commit 06efafd8608dac0c3a480539acc66ee41d2fb430 upstream.
Some scripts are not tests themselves; they contain utility functions used
by other tests. According to Documentation/dev-tools/kselftest.rst, such
files should be listed in TEST_FILES. Move those utility scripts to
TEST_FILES.
Fixes: 1751eb42ddb5 ("selftests: net: use TEST_PROGS_EXTENDED")
Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
Fixes: b99ac1841147 ("kselftests/net: add missed setup_loopback.sh/setup_veth.sh to Makefile")
Fixes: f5173fe3e13b ("selftests: net: included needed helper in the install targets")
Suggested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Link: https://lore.kernel.org/r/20240131140848.360618-5-bpoirier@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[PHLin: ignore the non-existing lib.sh]
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
tools/testing/selftests/net/Makefile | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 6fbebf8..3412b29 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -53,9 +53,7 @@ TEST_PROGS += bind_bhash.sh
TEST_PROGS += ip_local_port_range.sh
TEST_PROGS += rps_default_mask.sh
TEST_PROGS += big_tcp.sh
-TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh
-TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh
-TEST_PROGS_EXTENDED += net_helper.sh
+TEST_PROGS_EXTENDED := toeplitz_client.sh toeplitz.sh
TEST_GEN_FILES = socket nettest
TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite
@@ -94,6 +92,7 @@ TEST_PROGS += test_vxlan_nolocalbypass.sh
TEST_PROGS += test_bridge_backup_port.sh
TEST_FILES := settings
+TEST_FILES += in_netns.sh net_helper.sh setup_loopback.sh setup_veth.sh
include ../lib.mk
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test
2024-05-29 15:15 [PATCH 6.6.y 0/4] Fix missing net_helper.sh for net/udpgro_fwd.sh test Po-Hsu Lin
` (3 preceding siblings ...)
2024-05-29 15:16 ` [PATCH 6.6.y 4/4] selftests: net: List helper scripts in TEST_FILES Makefile variable Po-Hsu Lin
@ 2024-06-12 13:44 ` Greg KH
4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2024-06-12 13:44 UTC (permalink / raw)
To: Po-Hsu Lin; +Cc: stable
On Wed, May 29, 2024 at 11:15:59PM +0800, Po-Hsu Lin wrote:
> Since upstream commit 4acffb66 "selftests: net: explicitly wait for
> listener ready", the net_helper.sh from commit 3bdd9fd2 "selftests/net:
> synchronize udpgro tests' tx and rx connection" will be needed.
>
> Otherwise selftests/net/udpgro_fwd.sh will complain about:
> $ sudo ./udpgro_fwd.sh
> ./udpgro_fwd.sh: line 4: net_helper.sh: No such file or directory
> IPv4
> No GRO ./udpgro_fwd.sh: line 134: wait_local_port_listen: command not found
>
> Patch "selftests/net: synchronize udpgro tests' tx and rx connection" adds
> the missing net_helper.sh. Context adjustment is needed for applying this
> patch, as the BPF_FILE is different in 6.6.y
>
> Patch "selftests: net: Remove executable bits from library scripts" fixes
> the script permission.
>
> Patch "selftests: net: included needed helper in the install targets" and
> "selftests: net: List helper scripts in TEST_FILES Makefile variable" will
> add this helper to the Makefile and fix the installation, lib.sh needs to
> be ignored for them.
All now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread