OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes
@ 2026-09-28 19:37 Eva Kurchatova
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 1/3] selftests: drv-net: let NetDrvEnv take nsim_test Eva Kurchatova
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eva Kurchatova @ 2026-09-28 19:37 UTC (permalink / raw)
  To: khorenko; +Cc: devel

Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-139651

Changes in v2:

1/3:
- Fix the Feature tag.

2/3:
- Re-exec only when no real interface is given through NETIF.
- Bring lo up in the new namespace.
- Fix comments and double spaces.

3/3:
- One-line comment.

Link to v1: http://lore.virtuozzo.com/kernel/20260831234411.1649762-1-eva.kurchatova@virtuozzo.com/

Eva Kurchatova (3):
  selftests: drv-net: let NetDrvEnv take nsim_test
  selftests: drv-net: run ping in its own netns
  selftests: drv-net: read the channel count over netlink

 .../selftests/drivers/net/lib/py/__init__.py  |  2 +-
 .../selftests/drivers/net/lib/py/env.py       |  8 +++-
 .../selftests/drivers/net/napi_threaded.py    |  6 ++-
 tools/testing/selftests/drivers/net/ping.py   |  4 ++
 tools/testing/selftests/net/lib/py/utils.py   | 44 +++++++++++++++++++
 5 files changed, 60 insertions(+), 4 deletions(-)

-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Devel] [PATCH hci-8.1 v2 1/3] selftests: drv-net: let NetDrvEnv take nsim_test
  2026-09-28 19:37 [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Eva Kurchatova
@ 2026-09-28 19:37 ` Eva Kurchatova
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 2/3] selftests: drv-net: run ping in its own netns Eva Kurchatova
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eva Kurchatova @ 2026-09-28 19:37 UTC (permalink / raw)
  To: khorenko; +Cc: devel

rss_api.py fails at once:

  TypeError: NetdevSimDev.__init__() got an unexpected
  keyword argument 'nsim_test'

The RHEL10 import brought the test in but not the NetDrvEnv parameter
it uses. Take the env.py part of commit 185646a8a0a8 ("selftests:
drv-net: add tests for napi IRQ affinity notifiers"), which added it.
The test that commit adds needs real hardware and is left out.

https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/drivers/net/lib/py/env.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py
index 987e452d3a45..4677c3df4ec6 100644
--- a/tools/testing/selftests/drivers/net/lib/py/env.py
+++ b/tools/testing/selftests/drivers/net/lib/py/env.py
@@ -38,14 +38,20 @@ class NetDrvEnv:
     """
     Class for a single NIC / host env, with no remote end
     """
-    def __init__(self, src_path, **kwargs):
+    def __init__(self, src_path, nsim_test=None, **kwargs):
         self._ns = None
 
         self.env = _load_env_file(src_path)
 
         if 'NETIF' in self.env:
+            if nsim_test is True:
+                raise KsftXfailEx("Test only works on netdevsim")
+
             self.dev = ip("link show dev " + self.env['NETIF'], json=True)[0]
         else:
+            if nsim_test is False:
+                raise KsftXfailEx("Test does not work on netdevsim")
+
             self._ns = NetdevSimDev(**kwargs)
             self.dev = self._ns.nsims[0].dev
         self.ifname = self.dev['ifname']
-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Devel] [PATCH hci-8.1 v2 2/3] selftests: drv-net: run ping in its own netns
  2026-09-28 19:37 [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Eva Kurchatova
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 1/3] selftests: drv-net: let NetDrvEnv take nsim_test Eva Kurchatova
@ 2026-09-28 19:37 ` Eva Kurchatova
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 3/3] selftests: drv-net: read the channel count over netlink Eva Kurchatova
  2026-09-30 13:41 ` [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Konstantin Khorenko
  3 siblings, 0 replies; 5+ messages in thread
From: Eva Kurchatova @ 2026-09-28 19:37 UTC (permalink / raw)
  To: khorenko; +Cc: devel

In netdevsim mode ping.py sends its traffic to itself through the host
namespace, so a host firewall that drops it fails the test:

  ok 1 ping.test_v4
  ok 2 ping.test_v6
  not ok 3 ping.test_tcp
  # Stopping tests due to KsftTerminate.

Re-exec the test in a namespace of its own, the way nft_audit.sh does
since commit 2e2d9c7d4d37 ("selftests: netfilter: Run nft_audit.sh in
its own netns"). A test given a real interface through NETIF stays
where it is, that interface is not reachable from a new namespace.

https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 .../selftests/drivers/net/lib/py/__init__.py  |  2 +-
 tools/testing/selftests/drivers/net/ping.py   |  4 ++
 tools/testing/selftests/net/lib/py/utils.py   | 44 +++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/drivers/net/lib/py/__init__.py b/tools/testing/selftests/drivers/net/lib/py/__init__.py
index fce5d9218f1d..2d3fdaa81550 100644
--- a/tools/testing/selftests/drivers/net/lib/py/__init__.py
+++ b/tools/testing/selftests/drivers/net/lib/py/__init__.py
@@ -15,7 +15,7 @@ try:
         NlError, RtnlFamily, DevlinkFamily
     from net.lib.py import CmdExitFailure
     from net.lib.py import bkg, cmd, defer, ethtool, fd_read_timeout, ip, \
-        rand_port, tool, wait_port_listen
+        rand_port, rexec_in_netns, tool, wait_port_listen
     from net.lib.py import fd_read_timeout
     from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx
     from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \
diff --git a/tools/testing/selftests/drivers/net/ping.py b/tools/testing/selftests/drivers/net/ping.py
index eb83e7b48797..46da331158ba 100755
--- a/tools/testing/selftests/drivers/net/ping.py
+++ b/tools/testing/selftests/drivers/net/ping.py
@@ -5,6 +5,7 @@ from lib.py import ksft_run, ksft_exit
 from lib.py import ksft_eq
 from lib.py import NetDrvEpEnv
 from lib.py import bkg, cmd, wait_port_listen, rand_port
+from lib.py import rexec_in_netns
 
 
 def test_v4(cfg) -> None:
@@ -42,6 +43,9 @@ def test_tcp(cfg) -> None:
 
 
 def main() -> None:
+    # In netdevsim mode both ends would sit in the host's namespace
+    rexec_in_netns(__file__)
+
     with NetDrvEpEnv(__file__) as cfg:
         ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, ))
     ksft_exit()
diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index afce547bcab0..ab91358cca9c 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -8,6 +8,7 @@ import re
 import select
 import socket
 import subprocess
+import sys
 import time
 
 
@@ -131,6 +132,49 @@ def ethtool(args, json=None, ns=None, host=None):
     return tool('ethtool', args, json=json, ns=ns, host=host)
 
 
+def _netif_configured(path):
+    """
+    Whether a real interface was named, in the environment or net.config.
+    """
+    if os.environ.get("NETIF"):
+        return True
+
+    cfg = os.path.join(os.path.dirname(os.path.abspath(path)), "net.config")
+    try:
+        with open(cfg, 'r') as fp:
+            for line in fp.readlines():
+                pos = line.find("#")
+                if pos >= 0:
+                    line = line[:pos]
+                pair = line.strip().split('=', maxsplit=1)
+                if len(pair) == 2 and pair[0] == "NETIF" and pair[1]:
+                    return True
+    except OSError:
+        pass
+    return False
+
+
+def rexec_in_netns(path):
+    """
+    Re-exec the test in a network namespace of its own, with sysfs
+    mounted again. Does nothing where a real interface is named, or
+    where unshare is not there to move the test.
+    """
+    if os.environ.get("KSFT_IN_NETNS") or _netif_configured(path):
+        return
+
+    os.environ["KSFT_IN_NETNS"] = "1"
+    try:
+        os.execvp("unshare",
+                  ["unshare", "-n", "-m",
+                   "sh", "-c",
+                   'mount -t sysfs sysfs /sys && ip link set lo up && '
+                   'exec "$@"',
+                   "sh", sys.executable, os.path.abspath(path)] + sys.argv[1:])
+    except OSError:
+        del os.environ["KSFT_IN_NETNS"]
+
+
 def rand_port(type=socket.SOCK_STREAM):
     """
     Get a random unprivileged port.
-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Devel] [PATCH hci-8.1 v2 3/3] selftests: drv-net: read the channel count over netlink
  2026-09-28 19:37 [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Eva Kurchatova
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 1/3] selftests: drv-net: let NetDrvEnv take nsim_test Eva Kurchatova
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 2/3] selftests: drv-net: run ping in its own netns Eva Kurchatova
@ 2026-09-28 19:37 ` Eva Kurchatova
  2026-09-30 13:41 ` [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Konstantin Khorenko
  3 siblings, 0 replies; 5+ messages in thread
From: Eva Kurchatova @ 2026-09-28 19:37 UTC (permalink / raw)
  To: khorenko; +Cc: devel

napi_threaded.py asks ethtool for the channel count as JSON, which
ethtool 6.11 cannot print for -l:

  ethtool: bad command line argument(s)
  JSON output not available for this subcommand

  not ok 1 napi_threaded.napi_init

Read the count over ethtool netlink instead, so the test does not
depend on the ethtool version installed.

https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/drivers/net/napi_threaded.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/napi_threaded.py b/tools/testing/selftests/drivers/net/napi_threaded.py
index ed66efa481b0..33cc3f8752d3 100755
--- a/tools/testing/selftests/drivers/net/napi_threaded.py
+++ b/tools/testing/selftests/drivers/net/napi_threaded.py
@@ -7,7 +7,7 @@ Test napi threaded states.
 
 from lib.py import ksft_run, ksft_exit
 from lib.py import ksft_eq, ksft_ne, ksft_ge
-from lib.py import NetDrvEnv, NetdevFamily
+from lib.py import EthtoolFamily, NetDrvEnv, NetdevFamily
 from lib.py import cmd, defer, ethtool
 
 
@@ -28,7 +28,9 @@ def _set_threaded_state(cfg, threaded) -> None:
 
 
 def _setup_deferred_cleanup(cfg) -> None:
-    combined = ethtool(f"-l {cfg.ifname}", json=True)[0].get("combined", 0)
+    # Not every ethtool prints -l as JSON, ask the kernel
+    chan = EthtoolFamily().channels_get({'header': {'dev-index': cfg.ifindex}})
+    combined = chan.get('combined-count', 0)
     ksft_ge(combined, 2)
     defer(ethtool, f"-L {cfg.ifname} combined {combined}")
 
-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes
  2026-09-28 19:37 [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Eva Kurchatova
                   ` (2 preceding siblings ...)
  2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 3/3] selftests: drv-net: read the channel count over netlink Eva Kurchatova
@ 2026-09-30 13:41 ` Konstantin Khorenko
  3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Khorenko @ 2026-09-30 13:41 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On Mon, 28 Sep 2026 22:37:14 +0300, Eva Kurchatova wrote:
> selftests: drv-net: bunch of fixes
> 
> Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-139651
> 
> Changes in v2:
> 
> 1/3:
> - Fix the Feature tag.
> 
> [...]

Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.5.vz10, thanks!

[1/3] selftests: drv-net: let NetDrvEnv take nsim_test
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/2432fb84aad5
[2/3] selftests: drv-net: run ping in its own netns
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/334e41b0a277
[3/3] selftests: drv-net: read the channel count over netlink
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/fcc465f2ccd5

-- 
Konstantin Khorenko <khorenko@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-30 13:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 19:37 [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Eva Kurchatova
2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 1/3] selftests: drv-net: let NetDrvEnv take nsim_test Eva Kurchatova
2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 2/3] selftests: drv-net: run ping in its own netns Eva Kurchatova
2026-09-28 19:37 ` [Devel] [PATCH hci-8.1 v2 3/3] selftests: drv-net: read the channel count over netlink Eva Kurchatova
2026-09-30 13:41 ` [Devel] [PATCH hci-8.1 v2 0/3] selftests: drv-net: bunch of fixes Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox