On Thu, Apr 17, 2025 at 06:46:15AM -0700, Jakub Kicinski wrote:
On Thu, 17 Apr 2025 01:32:42 +0000 Joe Damato wrote:
Test that the SO_INCOMING_NAPI_ID of a network file descriptor is non-zero. This ensures that either the core networking stack or, in some cases like netdevsim, the driver correctly sets the NAPI ID.
Signed-off-by: Joe Damato jdamato@fastly.com
.../testing/selftests/drivers/net/.gitignore | 1 + tools/testing/selftests/drivers/net/Makefile | 6 +- .../testing/selftests/drivers/net/napi_id.py | 24 ++++++ .../selftests/drivers/net/napi_id_helper.c | 83 +++++++++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/drivers/net/napi_id.py create mode 100644 tools/testing/selftests/drivers/net/napi_id_helper.c
diff --git a/tools/testing/selftests/drivers/net/.gitignore b/tools/testing/selftests/drivers/net/.gitignore index ec746f374e85..71bd7d651233 100644 --- a/tools/testing/selftests/drivers/net/.gitignore +++ b/tools/testing/selftests/drivers/net/.gitignore @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only xdp_helper +napi_id_helper
sort alphabetically, pls
Thanks, fixed.
diff --git a/tools/testing/selftests/drivers/net/napi_id.py b/tools/testing/selftests/drivers/net/napi_id.py new file mode 100755 index 000000000000..aee6f90be49b --- /dev/null +++ b/tools/testing/selftests/drivers/net/napi_id.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0
+from lib.py import ksft_run, ksft_exit +from lib.py import ksft_eq, NetDrvEpEnv +from lib.py import bkg, cmd, rand_port, NetNSEnter
+def test_napi_id(cfg) -> None:
- port = rand_port()
- listen_cmd = f'{cfg.test_dir / "napi_id_helper"} {cfg.addr_v['4']} {port}'
you need to deploy, in case test is running with a real remote machine and the binary has to be copied over:
bin_remote = cfg.remote.deploy(cfg.test_dir / "napi_id_helper") listen_cmd = f'{bin_remote} {cfg.addr_v['4']} {port}'
Thanks, fixed.
- with bkg(listen_cmd, ksft_wait=3) as server:
with NetNSEnter('net', '/proc/self/ns/'):
cmd(f"echo a | socat - TCP:{cfg.addr_v['4']}:{port}", host=cfg.remote, shell=True)
Like Xiao Liang said, just host=cfg.remote should work.
You are both correct; sorry about the noise. I thought I tried this last night and it was failing, but clearly I was wrong/something else was broken.
I've fixed this locally and dropped patch 3 which is now unnecessary.
I think the main outstanding thing is Paolo's feedback which maybe (?) is due to a Python version difference? If you have any guidance on how to proceed on that, I'd appreciate it [1].
My guess is that I could rewrite that line to concat the strings instead of interpolate and it would work both on Paolo's system and mine. Would that be the right way to go?
[1]: https://lore.kernel.org/netdev/aAEtSppgCFNd8vr4@LQ3V64L9R2/