public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.1 01/17] selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh
@ 2024-05-27 14:16 Sasha Levin
  2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 02/17] selftests/bpf: Fix flaky test btf_map_in_map/lookup_update Sasha Levin
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: Sasha Levin @ 2024-05-27 14:16 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Alessandro Carminati (Red Hat), Andrii Nakryiko, Sasha Levin, ast,
	daniel, eddyz87, shuah, bpf, linux-kselftest

From: "Alessandro Carminati (Red Hat)" <alessandro.carminati@gmail.com>

[ Upstream commit f803bcf9208a2540acb4c32bdc3616673169f490 ]

In some systems, the netcat server can incur in delay to start listening.
When this happens, the test can randomly fail in various points.
This is an example error message:

   # ip gre none gso
   # encap 192.168.1.1 to 192.168.1.2, type gre, mac none len 2000
   # test basic connectivity
   # Ncat: Connection refused.

The issue stems from a race condition between the netcat client and server.
The test author had addressed this problem by implementing a sleep, which
I have removed in this patch.
This patch introduces a function capable of sleeping for up to two seconds.
However, it can terminate the waiting period early if the port is reported
to be listening.

Signed-off-by: Alessandro Carminati (Red Hat) <alessandro.carminati@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240314105911.213411-1-alessandro.carminati@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/bpf/test_tc_tunnel.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_tc_tunnel.sh b/tools/testing/selftests/bpf/test_tc_tunnel.sh
index 334bdfeab9403..365a2c7a89bad 100755
--- a/tools/testing/selftests/bpf/test_tc_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tc_tunnel.sh
@@ -72,7 +72,6 @@ cleanup() {
 server_listen() {
 	ip netns exec "${ns2}" nc "${netcat_opt}" -l "${port}" > "${outfile}" &
 	server_pid=$!
-	sleep 0.2
 }
 
 client_connect() {
@@ -93,6 +92,16 @@ verify_data() {
 	fi
 }
 
+wait_for_port() {
+	for i in $(seq 20); do
+		if ip netns exec "${ns2}" ss ${2:--4}OHntl | grep -q "$1"; then
+			return 0
+		fi
+		sleep 0.1
+	done
+	return 1
+}
+
 set -e
 
 # no arguments: automated test, run all
@@ -190,6 +199,7 @@ setup
 # basic communication works
 echo "test basic connectivity"
 server_listen
+wait_for_port ${port} ${netcat_opt}
 client_connect
 verify_data
 
@@ -201,6 +211,7 @@ ip netns exec "${ns1}" tc filter add dev veth1 egress \
 	section "encap_${tuntype}_${mac}"
 echo "test bpf encap without decap (expect failure)"
 server_listen
+wait_for_port ${port} ${netcat_opt}
 ! client_connect
 
 if [[ "$tuntype" =~ "udp" ]]; then
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-05-27 14:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27 14:16 [PATCH AUTOSEL 6.1 01/17] selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 02/17] selftests/bpf: Fix flaky test btf_map_in_map/lookup_update Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 03/17] batman-adv: bypass empty buckets in batadv_purge_orig_ref() Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 04/17] wifi: ath9k: work around memset overflow warning Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 05/17] af_packet: avoid a false positive warning in packet_setsockopt() Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 06/17] net: sfp: add quirk for another multigig RollBall transceiver Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 07/17] drop_monitor: replace spin_lock by raw_spin_lock Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 08/17] scsi: qedi: Fix crash while reading debugfs attribute Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 09/17] net/sched: fix false lockdep warning on qdisc root lock Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 10/17] kselftest: arm64: Add a null pointer check Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 11/17] net: dsa: realtek: keep default LED state in rtl8366rb Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 12/17] netpoll: Fix race condition in netpoll_owner_active Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 13/17] wifi: mt76: mt7921s: fix potential hung tasks during chip recovery Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 14/17] HID: Add quirk for Logitech Casa touchpad Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 15/17] HID: asus: fix more n-key report descriptors if n-key quirked Sasha Levin
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 16/17] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Sasha Levin
2024-05-27 14:48   ` Benjamin Tissoires
2024-05-27 14:16 ` [PATCH AUTOSEL 6.1 17/17] Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox