From 55fb6d6b9a42947a01917f762a28528ba12a7473 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Fri, 25 Sep 2026 01:25:35 +0530 Subject: [PATCH] Core: Export every XDP action from pythonbpf.helper helpers.py defined all five and return_utils mapped them, but only XDP_DROP and XDP_PASS were exported, so the xdp_tx port had to import XDP_TX from vmlinux and live under vmlinux/, skipped on any host without a generated module. It imports from pythonbpf.helper and lives under xdp/ now, returning XDP_TX bare like its siblings and the C original, which is the shape the return fast path resolves without vmlinux. Co-Authored-By: Claude Fable 5.1 --- pythonbpf/helper/__init__.py | 6 ++++++ tests/kernel_selftest_equivalent/xdp/xdp_tx.py | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pythonbpf/helper/__init__.py b/pythonbpf/helper/__init__.py index bd4fe17..129de1d 100644 --- a/pythonbpf/helper/__init__.py +++ b/pythonbpf/helper/__init__.py @@ -18,8 +18,11 @@ from .helpers import ( skb_store_bytes, get_current_cgroup_id, get_stack, + XDP_ABORTED, XDP_DROP, XDP_PASS, + XDP_TX, + XDP_REDIRECT, ) @@ -86,6 +89,9 @@ __all__ = [ "uid", "skb_store_bytes", "get_stack", + "XDP_ABORTED", "XDP_DROP", "XDP_PASS", + "XDP_TX", + "XDP_REDIRECT", ] diff --git a/tests/kernel_selftest_equivalent/xdp/xdp_tx.py b/tests/kernel_selftest_equivalent/xdp/xdp_tx.py index 8d40ffe..128f438 100644 --- a/tests/kernel_selftest_equivalent/xdp/xdp_tx.py +++ b/tests/kernel_selftest_equivalent/xdp/xdp_tx.py @@ -3,18 +3,15 @@ # Bounce every packet back out of the interface it arrived on. Upstream is # the transmit side of the veth XDP tests. # -# XDP_TX comes from vmlinux because pythonbpf.helper exports only XDP_PASS -# and XDP_DROP; that is why this lives under vmlinux/. - from pythonbpf import bpf, section, bpfglobal, compile -from vmlinux import XDP_TX +from pythonbpf.helper import XDP_TX from ctypes import c_void_p, c_int64 @bpf @section("xdp") def xdp_tx(xdp: c_void_p) -> c_int64: - return c_int64(XDP_TX) + return XDP_TX # bare, like the C: resolved by the return fast path @bpf