mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
selftests/net: Use public NetDrvContEnv API in nk_qlease fixtures
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> Link: https://patch.msgid.link/20260614102607.863838-3-daniel@iogearbox.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
bc5c25c8f6
commit
96fda937b4
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user