Skip to contentSkip to conversation

selftests: drv-net: improve zerocopy tests

PATCH Applied Jakub Kicinski 5 participants 19 messages Aug 11, 2025 – Aug 13, 2025

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover selftests: drv-net: improve zerocopy tests

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/[email protected]
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(-)
Signature · 1 line
2.50.1
author maintainer
#1 lore raw

PATCH 1/5 selftests: drv-net: add configs for zerocopy Rx

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.

---
 tools/testing/selftests/drivers/net/hw/config | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/drivers/net/hw/config +2 -0
index 88ae719e6f8f..e8a06aa1471c 100644
@@ -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
Signature · 1 line
2.50.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH net-next 1/5] selftests: drv-net: add configs for zerocopy Rx

Quoted 14 lines · Jakub Kicinski

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.

---
 tools/testing/selftests/drivers/net/hw/config | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/drivers/net/hw/config +0 -0
index 88ae719e6f8f..e8a06aa1471c 100644

tools/testing/selftests/drivers/net/hw/config line 7

Quoted 7 lines
tools/testing/selftests/drivers/net/hw/config +2 -0
@@ -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 on v1 1/5
#3 lore raw

Re: [PATCH net-next 1/5] selftests: drv-net: add configs for zerocopy Rx

In reply to Jakub Kicinski
Quoted 6 lines · Jakub Kicinski

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.

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.

Signature · 2 lines
Thanks,
Mina
author maintainer
#4 lore raw

PATCH 2/5 selftests: drv-net: devmem: remove sudo from system() calls

In reply to Jakub Kicinski

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.

---
 tools/testing/selftests/drivers/net/hw/ncdevmem.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tools/testing/selftests/drivers/net/hw/ncdevmem.c +7 -7
index 72f828021f83..be937542b4c0 100644
@@ -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,
Signature · 1 line
2.50.1
Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH net-next 2/5] selftests: drv-net: devmem: remove sudo from system() calls

Quoted 4 lines · Jakub Kicinski

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:

author maintainer
#6 lore raw

Re: [PATCH net-next 2/5] selftests: drv-net: devmem: remove sudo from system() calls

Quoted 9 lines · On Mon, 11 Aug 2025 16:55:56 -0700 Joe Damato wrote:
Quoted 4 lines · Jakub Kicinski

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..

Reviewed-by on v1 2/5
#7 lore raw

Re: [PATCH net-next 2/5] selftests: drv-net: devmem: remove sudo from system() calls

In reply to Jakub Kicinski
Quoted 7 lines · Jakub Kicinski

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.

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

Signature · 2 lines
Thanks,
Mina
author maintainer
#8 lore raw

PATCH 3/5 selftests: drv-net: devmem: add / correct the IPv6 support

In reply to Jakub Kicinski

We need to use bracketed IPv6 addresses for socat.

---
 tools/testing/selftests/drivers/net/hw/devmem.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/drivers/net/hw/devmem.py +1 -1
index baa2f24240ba..0a2533a3d6d6 100755
@@ -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:
Signature · 1 line
2.50.1
Reviewed-by on v1 3/5
#9 lore raw

Re: [PATCH net-next 3/5] selftests: drv-net: devmem: add / correct the IPv6 support

Quoted 12 lines · Jakub Kicinski

We need to use bracketed IPv6 addresses for socat.

---
 tools/testing/selftests/drivers/net/hw/devmem.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/drivers/net/hw/devmem.py +0 -0
index baa2f24240ba..0a2533a3d6d6 100755

tools/testing/selftests/drivers/net/hw/devmem.py from lib.py import ksft_disruptive · line 27

Quoted 5 lines
tools/testing/selftests/drivers/net/hw/devmem.py +1 -1
@@ -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.

author maintainer
#11 lore raw

PATCH 4/5 selftests: net: terminate bkg() commands on exception

In reply to Jakub Kicinski

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.

---
 tools/testing/selftests/net/lib/py/utils.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/net/lib/py/utils.py +4 -1
index f395c90fb0f1..4ac9249c85ab 100644
@@ -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 = []
Signature · 1 line
2.50.1
Reviewed-by on v1 4/5
#12 lore raw

Re: [PATCH net-next 4/5] selftests: net: terminate bkg() commands on exception

Quoted 8 lines · Jakub Kicinski

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.

Quoted 7 lines

A specific example where this happens is the devmem Tx tests.

---
 tools/testing/selftests/net/lib/py/utils.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
#13 lore raw

Re: [PATCH net-next 4/5] selftests: net: terminate bkg() commands on exception

In reply to Jakub Kicinski
Quoted 12 lines · Jakub Kicinski

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.

Signature · 3 lines
Thanks,
Mina
Acked-by: Mina Almasry <[email protected]>
author maintainer
#14 lore raw

PATCH 5/5 selftests: drv-net: devmem: flip the direction of Tx tests

In reply to Jakub Kicinski

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.

---
 tools/testing/selftests/drivers/net/hw/devmem.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/drivers/net/hw/devmem.py +6 -6
index 0a2533a3d6d6..45c2d49d55b6 100755
@@ -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")
 
Signature · 1 line
2.50.1
Reviewed-by on v1 5/5
#15 lore raw

Re: [PATCH net-next 5/5] selftests: drv-net: devmem: flip the direction of Tx tests

Quoted 31 lines · Jakub Kicinski

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.

---
 tools/testing/selftests/drivers/net/hw/devmem.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/drivers/net/hw/devmem.py +3 -3
index 0a2533a3d6d6..45c2d49d55b6 100755
@@ -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()

tools/testing/selftests/drivers/net/hw/devmem.py from lib.py import ksft_disruptive · line 63

Quoted 10 lines
tools/testing/selftests/drivers/net/hw/devmem.py +3 -3
     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 on v1 5/5
#16 lore raw

Re: [PATCH net-next 5/5] selftests: drv-net: devmem: flip the direction of Tx tests

In reply to Jakub Kicinski
Quoted 9 lines · Jakub Kicinski

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.

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:

and I guess when I have a chance to test I'll either give Tested-by or a fix on top.

Signature · 2 lines
Thanks,
Mina
Acked-by on the v1 series
#17 lore raw
In reply to Jakub Kicinski
Quoted 14 lines · Jakub Kicinski

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

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

#18 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 14 lines · 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/[email protected]
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
Quoted 1 line

[...]

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!

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