Skip to contentSkip to conversation

selftests: drv-net: Wait for bkg socat to start

PATCH Applied Mohsin Bashir 2 participants 2 messages Jul 24, 2025 – Jul 25, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: drv-net: Wait for bkg socat to start

Currently, UDP exchange is prone to failure when cmd attempt to send data while socat in bkg is not ready. Since, the behavior is probabilistic, this can result in flakiness for XDP tests. While testing test_xdp_native_tx_mb() on netdevsim, a failure rate of around 1% in 500 500 iterations was observed.

Use wait_port_listen() to ensure that the bkg socat is started and ready to receive before cmd start sending. With proposed changes, a re-run of the same test passed 100% of time.

---
 tools/testing/selftests/drivers/net/xdp.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/xdp.py +3 -1
index 887d662ad128..1dd8bf3bf6c9 100755
@@ -13,7 +13,7 @@ from enum import Enum
 
 from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ne, ksft_pr
 from lib.py import KsftFailEx, NetDrvEpEnv, EthtoolFamily, NlError
-from lib.py import bkg, cmd, rand_port
+from lib.py import bkg, cmd, rand_port, wait_port_listen
 from lib.py import ip, bpftool, defer
 
 
@@ -70,6 +70,7 @@ def _exchg_udp(cfg, port, test_string):
     tx_udp_cmd = f"echo -n {test_string} | socat -t 2 -u STDIN UDP:{cfg.baddr}:{port}"
 
     with bkg(rx_udp_cmd, exit_wait=True) as nc:
+        wait_port_listen(port, proto="udp")
         cmd(tx_udp_cmd, host=cfg.remote, shell=True)
 
     return nc.stdout.strip()
@@ -310,6 +311,7 @@ def test_xdp_native_tx_mb(cfg):
     tx_udp = f"echo {test_string} | socat -t 2 -u STDIN UDP:{cfg.baddr}:{port}"
 
     with bkg(rx_udp, host=cfg.remote, exit_wait=True) as rnc:
+        wait_port_listen(port, proto="udp", host=cfg.remote)
         cmd(tx_udp, host=cfg.remote, shell=True)
 
     stats = _get_stats(prog_info['maps']['map_xdp_stats'])
Signature · 1 line
2.47.3
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Thu, 24 Jul 2025 16:51:40 -0700 you wrote:

Currently, UDP exchange is prone to failure when cmd attempt to send data while socat in bkg is not ready. Since, the behavior is probabilistic, this can result in flakiness for XDP tests. While testing test_xdp_native_tx_mb() on netdevsim, a failure rate of around 1% in 500 500 iterations was observed.

Use wait_port_listen() to ensure that the bkg socat is started and ready to receive before cmd start sending. With proposed changes, a re-run of the same test passed 100% of time.

[...]

Here is the summary with links:
- [net-next] selftests: drv-net: Wait for bkg socat to start

    https://git.kernel.org/netdev/net-next/c/d1f3dbad6f0d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html