Skip to contentSkip to conversation

selftests: drv-net: devmem: set reuseaddr on the sender's source port

PATCH Applied Jakub Kicinski 2 participants 2 messages Sep 12 – Sep 15

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v2 1/1 selftests: drv-net: devmem: set reuseaddr on the sender's source port

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.

---
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/[email protected]

---
 tools/testing/selftests/drivers/net/hw/devmem_lib.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/hw/devmem_lib.py +2 -2
index 3554954a6691..71b916c16196 100644
@@ -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):
Signature · 1 line
2.55.0
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

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

Quoted 8 lines · On Sat, 12 Sep 2026 13:31:01 -0700 you wrote:

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

[...]

Here is the summary with links:
- [net-next,v2] selftests: drv-net: devmem: set reuseaddr on the sender's source port

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

You are awesome, thank you!

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