From: Jakub Kicinski kuba@kernel.org
[ Upstream commit 424e96de30230aac2061f941961be645cf0070d5 ]
We need to use bracketed IPv6 addresses for socat.
Reviewed-by: Joe Damato joe@dama.to Reviewed-by: Mina Almasry almasrymina@google.com Acked-by: Stanislav Fomichev sdf@fomichev.me Link: https://patch.msgid.link/20250811231334.561137-4-kuba@kernel.org Signed-off-by: Jakub Kicinski kuba@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes: socat requires bracketed IPv6 literals; without brackets, IPv6 addresses containing colons are parsed incorrectly, causing the devmem selftest RX path to fail on IPv6 setups. - Exact change: In `tools/testing/selftests/drivers/net/hw/devmem.py:27`, the destination and bind addresses in the socat pipeline switch from `cfg.addr`/`cfg.remote_addr` to `cfg.baddr`/`cfg.remote_baddr`, i.e.: - From: `TCP{cfg.addr_ipver}:{cfg.addr}:{port},bind={cfg.remote_addr}: {port}` - To: `TCP{cfg.addr_ipver}:{cfg.baddr}:{port},bind={cfg.remote_baddr}: {port}` - Why this is correct: The environment already provides bracketed- address variants specifically for commands that need `[]` around IPv6: - `tools/testing/selftests/drivers/net/lib/py/env.py:154-156` defines `cfg.baddr` and `cfg.remote_baddr` as `[v6]` when IPv6 is configured, or plain v4 otherwise. - Consistency with other selftests: Other net selftests already use bracketed forms with socat (e.g., `tools/testing/selftests/drivers/net/ping.py:42` and `tools/testing/selftests/drivers/net/ping.py:50`). - Minimal scope: Single-line functional change in a selftest only; no kernel code or interfaces are touched. - No architectural changes: The testing flow and ncdevmem invocation remain unchanged; only socat’s address formatting is corrected. - IPv4 unaffected: For IPv4-only environments, `cfg.baddr` resolves to the plain IPv4 address, preserving existing behavior. - Correct handling for ncdevmem: The ncdevmem tool parses unbracketed literals with `inet_pton` and remains passed unbracketed strings in `listen_cmd` (e.g., `devmem.py:28`), which is required (see `tools/testing/selftests/drivers/net/hw/ncdevmem.c:~560` parse_address()). - User impact: Fixes IPv6 test failures and false negatives in the devmem RX test, improving test reliability for stable trees. - Regression risk: Very low. The change aligns with established patterns in the same selftest suite, doesn’t alter APIs, and is gated by existing cfg fields already present in stable. - Stable policy fit: This is a small, contained test fix, not a feature; it improves correctness and is safe to backport even late in the cycle. - No mention of stable Cc is not blocking: Selftest fixes are commonly backported when they fix real failures.
Conclusion: This is a straightforward, low-risk correctness fix for the selftests that resolves IPv6 misparsing in socat. It should be backported.
tools/testing/selftests/drivers/net/hw/devmem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py index baa2f24240ba5..0a2533a3d6d60 100755 --- a/tools/testing/selftests/drivers/net/hw/devmem.py +++ b/tools/testing/selftests/drivers/net/hw/devmem.py @@ -24,7 +24,7 @@ def check_rx(cfg) -> None: require_devmem(cfg)
port = rand_port() - socat = f"socat -u - TCP{cfg.addr_ipver}:{cfg.addr}:{port},bind={cfg.remote_addr}:{port}" + socat = f"socat -u - TCP{cfg.addr_ipver}:{cfg.baddr}:{port},bind={cfg.remote_baddr}:{port}" listen_cmd = f"{cfg.bin_local} -l -f {cfg.ifname} -s {cfg.addr} -p {port} -c {cfg.remote_addr} -v 7"
with bkg(listen_cmd, exit_wait=True) as ncdevmem: