Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH net-next v2] selftests: drv-net: devmem: set reuseaddr on the sender's source port
@ 2026-09-12 20:31 Jakub Kicinski
  2026-09-15 13:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2026-09-12 20:31 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
	Breno Leitao, Bobby Eshleman, shuah, sdf, razor, linux-kselftest

devmem.py fails on the HW runners with:

  CMD[remote]: dd if=/dev/zero bs=512 count=1 2>/dev/null | socat -b 512 \
    -u - TCP6:[fd00:2::1]:50051,bind=[fd00:2::2]:50051,nodelay
    STDERR: socat[41018] W bind(5, {AF=10 [fd00:2::2]:50051}, 28): \
            Address already in use

ncdevmem installs a 5-tuple flow rule which matches the source port, so
socat has to bind it explicitly. The port comes from rand_port(), which
checks availability on the DUT - but we bind on the remote...
That said the failure rate seems to high to be random collisions
(~2% per sub-test). It's probably TIME_WAIT sockets on the remote,
run_rx_hds() alone creates 12 of them.

Set reuseaddr so a TIME_WAIT socket does not fail the bind. Collisions
with a live socket are still possible, we'll see if they are frequent
enough to care.

Reviewed-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
 - also add reuseaddr in socat_listen()
 - keeping the subject unchanged to help PW, even tho we now
   also cover receiver sockets
v1: https://lore.kernel.org/178897895866.219967.293435162679292319@kernel.org

CC: shuah@kernel.org
CC: bobbyeshleman@meta.com
CC: sdf@fomichev.me
CC: leitao@debian.org
CC: razor@blackwall.org
CC: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/drivers/net/hw/devmem_lib.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/hw/devmem_lib.py b/tools/testing/selftests/drivers/net/hw/devmem_lib.py
index 3554954a6691..71b916c16196 100644
--- a/tools/testing/selftests/drivers/net/hw/devmem_lib.py
+++ b/tools/testing/selftests/drivers/net/hw/devmem_lib.py
@@ -201,7 +201,7 @@ def ncdevmem_rx(cfg, port, verify=True, fail_on_linear=False, flow_steer=False,
     else:
         addr = cfg.baddr
 
-    suffix = f",bind={cfg.remote_baddr}:{port}"
+    suffix = f",bind={cfg.remote_baddr}:{port},reuseaddr"
 
     buf = ""
     if buf_size:
@@ -213,7 +213,7 @@ def ncdevmem_rx(cfg, port, verify=True, fail_on_linear=False, flow_steer=False,
 
 def socat_listen(cfg, port):
     """Socat listen command for TX tests."""
-    return f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
+    return f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port},reuseaddr"
 
 
 def setup_test(cfg, bin_local):
-- 
2.55.0


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

end of thread, other threads:[~2026-09-15 13:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-12 20:31 [PATCH net-next v2] selftests: drv-net: devmem: set reuseaddr on the sender's source port Jakub Kicinski
2026-09-15 13:20 ` patchwork-bot+netdevbpf

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