From: Daniel Borkmann <daniel@iogearbox.net>
To: kuba@kernel.org
Cc: razor@blackwall.org, bobbyeshleman@meta.com, dw@davidwei.uk,
netdev@vger.kernel.org
Subject: [PATCH net-next v3 2/4] selftests/net: Use public NetDrvContEnv API in nk_qlease fixtures
Date: Sun, 14 Jun 2026 12:26:05 +0200 [thread overview]
Message-ID: <20260614102607.863838-3-daniel@iogearbox.net> (raw)
In-Reply-To: <20260614102607.863838-1-daniel@iogearbox.net>
Expose the netkit host ifname as a public attribute nk_host_ifname
(symmetric with the already-public nk_guest_ifname), rename _attach_bpf
to a public attach_bpf, and add a public detach_bpf helper that
encapsulates the tc-filter teardown bookkeeping. Switch the fixtures
to this public API. No functional change and keeps pylint happy.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
---
tools/testing/selftests/drivers/net/hw/nk_qlease.py | 9 ++-------
tools/testing/selftests/drivers/net/lib/py/env.py | 10 ++++++++--
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/nk_qlease.py b/tools/testing/selftests/drivers/net/hw/nk_qlease.py
index 3723574dcd30..b97663820ccf 100755
--- a/tools/testing/selftests/drivers/net/hw/nk_qlease.py
+++ b/tools/testing/selftests/drivers/net/hw/nk_qlease.py
@@ -38,12 +38,7 @@ def _create_netkit_pair(cfg, rxqueues=2):
cmd(f"ip link del dev {cfg.nk_host_ifname}", fail=False)
cfg.nk_host_ifname = None
cfg.nk_guest_ifname = None
- if getattr(cfg, "_tc_attached", False):
- cmd(
- f"tc filter del dev {cfg.ifname} ingress pref {cfg._bpf_prog_pref}",
- fail=False,
- )
- cfg._tc_attached = False
+ cfg.detach_bpf()
all_links = ip("-d link show", json=True)
old_idxs = {
@@ -102,7 +97,7 @@ def _create_netkit_pair(cfg, rxqueues=2):
ns=cfg.netns,
)
- cfg._attach_bpf()
+ cfg.attach_bpf()
def _setup_lease(cfg, rxqueues=2):
diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py
index b188ee55c76b..e4ab99b905b1 100644
--- a/tools/testing/selftests/drivers/net/lib/py/env.py
+++ b/tools/testing/selftests/drivers/net/lib/py/env.py
@@ -401,7 +401,7 @@ class NetDrvContEnv(NetDrvEpEnv):
self.nk_guest_ifindex = netkit_links[0]['ifindex']
self._setup_ns()
- self._attach_bpf()
+ self.attach_bpf()
if primary_rx_redirect:
self._attach_primary_rx_redirect_bpf()
@@ -524,7 +524,13 @@ class NetDrvContEnv(NetDrvEpEnv):
return bpf_obj
return None
- def _attach_bpf(self):
+ def detach_bpf(self):
+ if self._tc_attached:
+ cmd(f"tc filter del dev {self.ifname} ingress pref "
+ f"{self._bpf_prog_pref}", fail=False)
+ self._tc_attached = False
+
+ def attach_bpf(self):
bpf_obj = self._find_bpf_obj("nk_forward.bpf.o")
if not bpf_obj:
raise KsftSkipEx("BPF prog nk_forward.bpf.o not found")
--
2.43.0
next prev parent reply other threads:[~2026-06-14 10:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 10:26 [PATCH net-next v3 0/4] Extend netkit io_uring ZC selftests Daniel Borkmann
2026-06-14 10:26 ` [PATCH net-next v3 1/4] selftests/net: Move netkit lease hw setup into per-test fixtures Daniel Borkmann
2026-06-14 10:26 ` Daniel Borkmann [this message]
2026-06-14 10:26 ` [PATCH net-next v3 3/4] selftests/net: Add netkit io_uring ZC test for large rx_buf_len Daniel Borkmann
2026-06-14 10:26 ` [PATCH net-next v3 4/4] selftests/net: Add hugepage kernel config dependency for zcrx Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260614102607.863838-3-daniel@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=bobbyeshleman@meta.com \
--cc=dw@davidwei.uk \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox