Skip to content

Commit d1f3dba

Browse files
Mohsin Bashirkuba-moo
authored andcommitted
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. Signed-off-by: Mohsin Bashir <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8020ca5 commit d1f3dba

File tree

1 file changed

+3
-1
lines changed
  • tools/testing/selftests/drivers/net

1 file changed

+3
-1
lines changed

tools/testing/selftests/drivers/net/xdp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ne, ksft_pr
1515
from lib.py import KsftFailEx, NetDrvEpEnv, EthtoolFamily, NlError
16-
from lib.py import bkg, cmd, rand_port
16+
from lib.py import bkg, cmd, rand_port, wait_port_listen
1717
from lib.py import ip, bpftool, defer
1818

1919

@@ -70,6 +70,7 @@ def _exchg_udp(cfg, port, test_string):
7070
tx_udp_cmd = f"echo -n {test_string} | socat -t 2 -u STDIN UDP:{cfg.baddr}:{port}"
7171

7272
with bkg(rx_udp_cmd, exit_wait=True) as nc:
73+
wait_port_listen(port, proto="udp")
7374
cmd(tx_udp_cmd, host=cfg.remote, shell=True)
7475

7576
return nc.stdout.strip()
@@ -310,6 +311,7 @@ def test_xdp_native_tx_mb(cfg):
310311
tx_udp = f"echo {test_string} | socat -t 2 -u STDIN UDP:{cfg.baddr}:{port}"
311312

312313
with bkg(rx_udp, host=cfg.remote, exit_wait=True) as rnc:
314+
wait_port_listen(port, proto="udp", host=cfg.remote)
313315
cmd(tx_udp, host=cfg.remote, shell=True)
314316

315317
stats = _get_stats(prog_info['maps']['map_xdp_stats'])

0 commit comments

Comments
 (0)