selftests/net: add _find_bpf_obj() to search hw/ for BPF objects
Add _find_bpf_obj() helper to NetDrvContEnv that searches the test directory first, then falls back to the hw/ subdirectory. This allows tests outside drivers/net/hw/ (e.g. psp.py in drivers/net/) to find BPF objects built in the hw/ directory. Update _attach_bpf() and _attach_primary_rx_redirect_bpf() to use _find_bpf_obj() for BPF object discovery. Signed-off-by: Wei Wang <weibunny@fb.com> Link: https://patch.msgid.link/20260608233118.2694144-6-weibunny.kernel@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
1 parent
89ed478a6c
commit
b9d51f2e13
1 file changed
+15
-6
@@ -512,10 +512,19 @@ class NetDrvContEnv(NetDrvEpEnv):
|
||||
return map_id
|
||||
raise Exception(f"Failed to find .bss map for prog {prog_id}")
|
||||
|
||||
def _find_bpf_obj(self, name):
|
||||
bpf_obj = self.test_dir / name
|
||||
if bpf_obj.exists():
|
||||
return bpf_obj
|
||||
bpf_obj = self.test_dir / "hw" / name
|
||||
if bpf_obj.exists():
|
||||
return bpf_obj
|
||||
return None
|
||||
|
||||
def _attach_bpf(self):
|
||||
bpf_obj = self.test_dir / "nk_forward.bpf.o"
|
||||
if not bpf_obj.exists():
|
||||
raise KsftSkipEx("BPF prog not found")
|
||||
bpf_obj = self._find_bpf_obj("nk_forward.bpf.o")
|
||||
if not bpf_obj:
|
||||
raise KsftSkipEx("BPF prog nk_forward.bpf.o not found")
|
||||
|
||||
if self._tc_ensure_clsact():
|
||||
self._tc_clsact_added = True
|
||||
@@ -535,9 +544,9 @@ class NetDrvContEnv(NetDrvEpEnv):
|
||||
|
||||
def _attach_primary_rx_redirect_bpf(self):
|
||||
"""Attach BPF redirect program on the primary netkit ingress."""
|
||||
bpf_obj = self.test_dir / "nk_primary_rx_redirect.bpf.o"
|
||||
if not bpf_obj.exists():
|
||||
raise KsftSkipEx("Primary RX redirect BPF prog not found")
|
||||
bpf_obj = self._find_bpf_obj("nk_primary_rx_redirect.bpf.o")
|
||||
if not bpf_obj:
|
||||
raise KsftSkipEx("nk_primary_rx_redirect.bpf.o not found")
|
||||
|
||||
if self._tc_ensure_clsact(self._nk_host_ifname):
|
||||
self._primary_rx_redirect_clsact_added = True
|
||||
|
||||
Reference in new issue
Block a user