A few tweaks to the devmem test to make it more "NIPA-compatible". We still need a fix to make sure that the test sets hds threshold to 0. Taehee is presumably already/still working on that: https://lore.kernel.org/20250702104249.1665034-1-ap420073@gmail.com so I'm not including my version.
# ./tools/testing/selftests/drivers/net/hw/devmem.py TAP version 13 1..3 ok 1 devmem.check_rx ok 2 devmem.check_tx ok 3 devmem.check_tx_chunks # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0
Jakub Kicinski (5): selftests: drv-net: add configs for zerocopy Rx selftests: drv-net: devmem: remove sudo from system() calls selftests: drv-net: devmem: add / correct the IPv6 support selftests: net: terminate bkg() commands on exception selftests: drv-net: devmem: flip the direction of Tx tests
tools/testing/selftests/drivers/net/hw/ncdevmem.c | 14 +++++++------- tools/testing/selftests/drivers/net/hw/config | 2 ++ tools/testing/selftests/drivers/net/hw/devmem.py | 14 +++++++------- tools/testing/selftests/net/lib/py/utils.py | 5 ++++- 4 files changed, 20 insertions(+), 15 deletions(-)
Looks like neither IO_URING nor UDMABUF are enabled even tho iou-zcrx.py and devmem.py (respectively) need those. IO_URING gets enabled by default but UDMABUF is missing.
Signed-off-by: Jakub Kicinski kuba@kernel.org --- tools/testing/selftests/drivers/net/hw/config | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/config b/tools/testing/selftests/drivers/net/hw/config index 88ae719e6f8f..e8a06aa1471c 100644 --- a/tools/testing/selftests/drivers/net/hw/config +++ b/tools/testing/selftests/drivers/net/hw/config @@ -1,5 +1,7 @@ +CONFIG_IO_URING=y CONFIG_IPV6=y CONFIG_IPV6_GRE=y CONFIG_NET_IPGRE=y CONFIG_NET_IPGRE_DEMUX=y +CONFIG_UDMABUF=y CONFIG_VXLAN=y
On Mon, Aug 11, 2025 at 04:13:30PM -0700, Jakub Kicinski wrote:
Looks like neither IO_URING nor UDMABUF are enabled even tho iou-zcrx.py and devmem.py (respectively) need those. IO_URING gets enabled by default but UDMABUF is missing.
Signed-off-by: Jakub Kicinski kuba@kernel.org
tools/testing/selftests/drivers/net/hw/config | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/config b/tools/testing/selftests/drivers/net/hw/config index 88ae719e6f8f..e8a06aa1471c 100644 --- a/tools/testing/selftests/drivers/net/hw/config +++ b/tools/testing/selftests/drivers/net/hw/config @@ -1,5 +1,7 @@ +CONFIG_IO_URING=y CONFIG_IPV6=y CONFIG_IPV6_GRE=y CONFIG_NET_IPGRE=y CONFIG_NET_IPGRE_DEMUX=y +CONFIG_UDMABUF=y CONFIG_VXLAN=y
Reviewed-by: Joe Damato joe@dama.to
On Mon, Aug 11, 2025 at 4:13 PM Jakub Kicinski kuba@kernel.org wrote:
Looks like neither IO_URING nor UDMABUF are enabled even tho iou-zcrx.py and devmem.py (respectively) need those. IO_URING gets enabled by default but UDMABUF is missing.
Signed-off-by: Jakub Kicinski kuba@kernel.org
At first glance I thought CONFIG_NET_DEVMEM=y could also be added, but that is def_bool y, so it's very unnecessary to add it.
Reviewed-by: Mina Almasry almasrymina@google.com
The general expectations for network HW selftests is that they will be run as root. sudo doesn't seem to work on NIPA VMs. While it's probably something solvable in the setup I think we should remove the sudos. devmem is the only networking test using sudo.
Signed-off-by: Jakub Kicinski kuba@kernel.org --- tools/testing/selftests/drivers/net/hw/ncdevmem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/ncdevmem.c b/tools/testing/selftests/drivers/net/hw/ncdevmem.c index 72f828021f83..be937542b4c0 100644 --- a/tools/testing/selftests/drivers/net/hw/ncdevmem.c +++ b/tools/testing/selftests/drivers/net/hw/ncdevmem.c @@ -287,10 +287,10 @@ static int reset_flow_steering(void) * the exit status. */
- run_command("sudo ethtool -K %s ntuple off >&2", ifname); - run_command("sudo ethtool -K %s ntuple on >&2", ifname); + run_command("ethtool -K %s ntuple off >&2", ifname); + run_command("ethtool -K %s ntuple on >&2", ifname); run_command( - "sudo ethtool -n %s | grep 'Filter:' | awk '{print $2}' | xargs -n1 ethtool -N %s delete >&2", + "ethtool -n %s | grep 'Filter:' | awk '{print $2}' | xargs -n1 ethtool -N %s delete >&2", ifname, ifname); return 0; } @@ -351,12 +351,12 @@ static int configure_headersplit(bool on)
static int configure_rss(void) { - return run_command("sudo ethtool -X %s equal %d >&2", ifname, start_queue); + return run_command("ethtool -X %s equal %d >&2", ifname, start_queue); }
static int configure_channels(unsigned int rx, unsigned int tx) { - return run_command("sudo ethtool -L %s rx %u tx %u", ifname, rx, tx); + return run_command("ethtool -L %s rx %u tx %u", ifname, rx, tx); }
static int configure_flow_steering(struct sockaddr_in6 *server_sin) @@ -374,7 +374,7 @@ static int configure_flow_steering(struct sockaddr_in6 *server_sin) }
/* Try configure 5-tuple */ - if (run_command("sudo ethtool -N %s flow-type %s %s %s dst-ip %s %s %s dst-port %s queue %d >&2", + if (run_command("ethtool -N %s flow-type %s %s %s dst-ip %s %s %s dst-port %s queue %d >&2", ifname, type, client_ip ? "src-ip" : "", @@ -384,7 +384,7 @@ static int configure_flow_steering(struct sockaddr_in6 *server_sin) client_ip ? port : "", port, start_queue)) /* If that fails, try configure 3-tuple */ - if (run_command("sudo ethtool -N %s flow-type %s dst-ip %s dst-port %s queue %d >&2", + if (run_command("ethtool -N %s flow-type %s dst-ip %s dst-port %s queue %d >&2", ifname, type, server_addr,
On Mon, Aug 11, 2025 at 04:13:31PM -0700, Jakub Kicinski wrote:
The general expectations for network HW selftests is that they will be run as root. sudo doesn't seem to work on NIPA VMs. While it's probably something solvable in the setup I think we should remove the sudos. devmem is the only networking test using sudo.
FWIW, it looks like:
virtio_net/virtio_net_common.sh
is also using sudo... that said in general I agree on removing the sudos, so:
Reviewed-by: Joe Damato joe@dama.to
On Mon, 11 Aug 2025 16:55:56 -0700 Joe Damato wrote:
On Mon, Aug 11, 2025 at 04:13:31PM -0700, Jakub Kicinski wrote:
The general expectations for network HW selftests is that they will be run as root. sudo doesn't seem to work on NIPA VMs. While it's probably something solvable in the setup I think we should remove the sudos. devmem is the only networking test using sudo.
FWIW, it looks like:
virtio_net/virtio_net_common.sh
I think there were two tests that had sudo in code comments. But not the actual code. I may have misread..
On Mon, Aug 11, 2025 at 4:13 PM Jakub Kicinski kuba@kernel.org wrote:
The general expectations for network HW selftests is that they will be run as root. sudo doesn't seem to work on NIPA VMs. While it's probably something solvable in the setup I think we should remove the sudos. devmem is the only networking test using sudo.
Signed-off-by: Jakub Kicinski kuba@kernel.org
I suspect this breaks my test setup, but I can probably figure out how to run our tests as sudo. I can't argue with consistency with the rest of the tests which don't sudo anyway :D
Reviewed-by: Mina Almasry almasrymina@google.com
We need to use bracketed IPv6 addresses for socat.
Signed-off-by: Jakub Kicinski kuba@kernel.org --- 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 baa2f24240ba..0a2533a3d6d6 100755 --- a/tools/testing/selftests/drivers/net/hw/devmem.py +++ b/tools/testing/selftests/drivers/net/hw/devmem.py @@ -24,7 +24,7 @@ from lib.py import ksft_disruptive 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:
On Mon, Aug 11, 2025 at 04:13:32PM -0700, Jakub Kicinski wrote:
We need to use bracketed IPv6 addresses for socat.
Signed-off-by: Jakub Kicinski kuba@kernel.org
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 baa2f24240ba..0a2533a3d6d6 100755 --- a/tools/testing/selftests/drivers/net/hw/devmem.py +++ b/tools/testing/selftests/drivers/net/hw/devmem.py @@ -24,7 +24,7 @@ from lib.py import ksft_disruptive 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}"
FWIW I had no idea socat supports bracketed v4 addresses (just to make sure this change won't break anything). A quick test I did locally shows it does.
Reviewed-by: Joe Damato joe@dama.to
On Mon, Aug 11, 2025 at 4:13 PM Jakub Kicinski kuba@kernel.org wrote:
We need to use bracketed IPv6 addresses for socat.
Signed-off-by: Jakub Kicinski kuba@kernel.org
Reviewed-by: Mina Almasry almasrymina@google.com
There is a number of:
with bkg("socat ..LISTEN..", exit_wait=True)
uses in the tests. If whatever is supposed to send the traffic fails we will get stuck in the bkg(). Try to kill the process in case of exception, to avoid the long wait.
A specific example where this happens is the devmem Tx tests.
Signed-off-by: Jakub Kicinski kuba@kernel.org --- tools/testing/selftests/net/lib/py/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py index f395c90fb0f1..4ac9249c85ab 100644 --- a/tools/testing/selftests/net/lib/py/utils.py +++ b/tools/testing/selftests/net/lib/py/utils.py @@ -117,6 +117,7 @@ import time shell=shell, fail=fail, ns=ns, host=host, ksft_wait=ksft_wait) self.terminate = not exit_wait and not ksft_wait + self._exit_wait = exit_wait self.check_fail = fail
if shell and self.terminate: @@ -127,7 +128,9 @@ import time return self
def __exit__(self, ex_type, ex_value, ex_tb): - return self.process(terminate=self.terminate, fail=self.check_fail) + # Force termination on exception + terminate = self.terminate or (self._exit_wait and ex_type) + return self.process(terminate=terminate, fail=self.check_fail)
global_defer_queue = []
On Mon, Aug 11, 2025 at 04:13:33PM -0700, Jakub Kicinski wrote:
There is a number of:
with bkg("socat ..LISTEN..", exit_wait=True)
uses in the tests. If whatever is supposed to send the traffic fails we will get stuck in the bkg(). Try to kill the process in case of exception, to avoid the long wait.
A specific example where this happens is the devmem Tx tests.
Signed-off-by: Jakub Kicinski kuba@kernel.org
tools/testing/selftests/net/lib/py/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Reviewed-by: Joe Damato joe@dama.to
On Mon, Aug 11, 2025 at 4:13 PM Jakub Kicinski kuba@kernel.org wrote:
There is a number of:
with bkg("socat ..LISTEN..", exit_wait=True)
uses in the tests. If whatever is supposed to send the traffic fails we will get stuck in the bkg(). Try to kill the process in case of exception, to avoid the long wait.
A specific example where this happens is the devmem Tx tests.
Signed-off-by: Jakub Kicinski kuba@kernel.org
The Device Under Test should always be the local system. While the Rx test gets this right the Tx test is sending from remote to local. So Tx of DMABUF memory happens on remote.
These tests never run in NIPA since we don't have a compatible device so we haven't caught this.
Signed-off-by: Jakub Kicinski kuba@kernel.org --- tools/testing/selftests/drivers/net/hw/devmem.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py index 0a2533a3d6d6..45c2d49d55b6 100755 --- a/tools/testing/selftests/drivers/net/hw/devmem.py +++ b/tools/testing/selftests/drivers/net/hw/devmem.py @@ -42,9 +42,9 @@ from lib.py import ksft_disruptive port = rand_port() listen_cmd = f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
- with bkg(listen_cmd) as socat: - wait_port_listen(port) - cmd(f"echo -e "hello\nworld"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port}", host=cfg.remote, shell=True) + with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat: + wait_port_listen(port, host=cfg.remote) + cmd(f"echo -e "hello\nworld"| {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port}", shell=True)
ksft_eq(socat.stdout.strip(), "hello\nworld")
@@ -56,9 +56,9 @@ from lib.py import ksft_disruptive port = rand_port() listen_cmd = f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
- with bkg(listen_cmd, exit_wait=True) as socat: - wait_port_listen(port) - cmd(f"echo -e "hello\nworld"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port} -z 3", host=cfg.remote, shell=True) + with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat: + wait_port_listen(port, host=cfg.remote) + cmd(f"echo -e "hello\nworld"| {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port} -z 3", shell=True)
ksft_eq(socat.stdout.strip(), "hello\nworld")
On Mon, Aug 11, 2025 at 04:13:34PM -0700, Jakub Kicinski wrote:
The Device Under Test should always be the local system. While the Rx test gets this right the Tx test is sending from remote to local. So Tx of DMABUF memory happens on remote.
These tests never run in NIPA since we don't have a compatible device so we haven't caught this.
Signed-off-by: Jakub Kicinski kuba@kernel.org
tools/testing/selftests/drivers/net/hw/devmem.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py index 0a2533a3d6d6..45c2d49d55b6 100755 --- a/tools/testing/selftests/drivers/net/hw/devmem.py +++ b/tools/testing/selftests/drivers/net/hw/devmem.py @@ -42,9 +42,9 @@ from lib.py import ksft_disruptive port = rand_port() listen_cmd = f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
- with bkg(listen_cmd) as socat:
wait_port_listen(port)
cmd(f"echo -e \"hello\\nworld\"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port}", host=cfg.remote, shell=True)
- with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat:
wait_port_listen(port, host=cfg.remote)
cmd(f"echo -e \"hello\\nworld\"| {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port}", shell=True)
ksft_eq(socat.stdout.strip(), "hello\nworld") @@ -56,9 +56,9 @@ from lib.py import ksft_disruptive port = rand_port() listen_cmd = f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
- with bkg(listen_cmd, exit_wait=True) as socat:
wait_port_listen(port)
cmd(f"echo -e \"hello\\nworld\"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port} -z 3", host=cfg.remote, shell=True)
- with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat:
wait_port_listen(port, host=cfg.remote)
cmd(f"echo -e \"hello\\nworld\"| {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port} -z 3", shell=True)
ksft_eq(socat.stdout.strip(), "hello\nworld")
FWIW: I don't have one of these devices to test this on, but the change seems reasonable to me, so:
Reviewed-by: Joe Damato joe@dama.to
On Mon, Aug 11, 2025 at 4:13 PM Jakub Kicinski kuba@kernel.org wrote:
The Device Under Test should always be the local system. While the Rx test gets this right the Tx test is sending from remote to local. So Tx of DMABUF memory happens on remote.
These tests never run in NIPA since we don't have a compatible device so we haven't caught this.
Signed-off-by: Jakub Kicinski kuba@kernel.org
Changes look reasonable, and to my eye the rx and tx commands are just switched with no changes. I would have liked to test this first but I'm not sure I'll get the chance today. So:
Reviewed-by: Mina Almasry almasrymina@google.com
and I guess when I have a chance to test I'll either give Tested-by or a fix on top.
On 08/11, Jakub Kicinski wrote:
A few tweaks to the devmem test to make it more "NIPA-compatible". We still need a fix to make sure that the test sets hds threshold to 0. Taehee is presumably already/still working on that: https://lore.kernel.org/20250702104249.1665034-1-ap420073@gmail.com so I'm not including my version.
# ./tools/testing/selftests/drivers/net/hw/devmem.py TAP version 13 1..3 ok 1 devmem.check_rx ok 2 devmem.check_tx ok 3 devmem.check_tx_chunks # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0
Jakub Kicinski (5): selftests: drv-net: add configs for zerocopy Rx selftests: drv-net: devmem: remove sudo from system() calls selftests: drv-net: devmem: add / correct the IPv6 support selftests: net: terminate bkg() commands on exception selftests: drv-net: devmem: flip the direction of Tx tests
Acked-by: Stanislav Fomichev sdf@fomichev.me
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski kuba@kernel.org:
On Mon, 11 Aug 2025 16:13:29 -0700 you wrote:
A few tweaks to the devmem test to make it more "NIPA-compatible". We still need a fix to make sure that the test sets hds threshold to 0. Taehee is presumably already/still working on that: https://lore.kernel.org/20250702104249.1665034-1-ap420073@gmail.com so I'm not including my version.
# ./tools/testing/selftests/drivers/net/hw/devmem.py TAP version 13 1..3 ok 1 devmem.check_rx ok 2 devmem.check_tx ok 3 devmem.check_tx_chunks # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0
[...]
Here is the summary with links: - [net-next,1/5] selftests: drv-net: add configs for zerocopy Rx https://git.kernel.org/netdev/net-next/c/27e5b560a86e - [net-next,2/5] selftests: drv-net: devmem: remove sudo from system() calls https://git.kernel.org/netdev/net-next/c/a94e9cf79cee - [net-next,3/5] selftests: drv-net: devmem: add / correct the IPv6 support https://git.kernel.org/netdev/net-next/c/424e96de3023 - [net-next,4/5] selftests: net: terminate bkg() commands on exception https://git.kernel.org/netdev/net-next/c/6e9a12f85a75 - [net-next,5/5] selftests: drv-net: devmem: flip the direction of Tx tests https://git.kernel.org/netdev/net-next/c/c378c497f3fe
You are awesome, thank you!
linux-kselftest-mirror@lists.linaro.org