Patch "selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     selftests-bpf-prevent-client-connect-before-server-b.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d7b19d64eb7c8b9c24d45b4bab4c631c86b073e0
Author: Alessandro Carminati (Red Hat) <alessandro.carminati@xxxxxxxxx>
Date:   Thu Mar 14 10:59:11 2024 +0000

    selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh
    
    [ 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@xxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20240314105911.213411-1-alessandro.carminati@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/bpf/test_tc_tunnel.sh b/tools/testing/selftests/bpf/test_tc_tunnel.sh
index 7c76b841b17bb..21bde60c95230 100755
--- a/tools/testing/selftests/bpf/test_tc_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tc_tunnel.sh
@@ -71,7 +71,6 @@ cleanup() {
 server_listen() {
 	ip netns exec "${ns2}" nc "${netcat_opt}" -l -p "${port}" > "${outfile}" &
 	server_pid=$!
-	sleep 0.2
 }
 
 client_connect() {
@@ -92,6 +91,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
@@ -183,6 +192,7 @@ setup
 # basic communication works
 echo "test basic connectivity"
 server_listen
+wait_for_port ${port} ${netcat_opt}
 client_connect
 verify_data
 
@@ -194,6 +204,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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux