]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh
authorAlessandro Carminati (Red Hat) <alessandro.carminati@gmail.com>
Thu, 14 Mar 2024 10:59:11 +0000 (10:59 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 19 Mar 2024 23:16:09 +0000 (16:16 -0700)
commitf803bcf9208a2540acb4c32bdc3616673169f490
treea90cb445d6fa8d01e4d2e739c5d7d48a78a33a29
parent437ffcb0bf97361e5c4062043309832f4724d1a8
selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh

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
tools/testing/selftests/bpf/test_tc_tunnel.sh