correct error size calculation for arrays

This commit is contained in:
2025-10-18 22:13:59 +05:30
parent 1b4272b408
commit dc1b243e82
3 changed files with 43 additions and 22 deletions

View File

@ -1,22 +1,20 @@
from pythonbpf import bpf, map, section, bpfglobal, compile_to_ir, compile
from pythonbpf.maps import HashMap
from pythonbpf.helper import XDP_PASS
from pythonbpf import bpf, section, bpfglobal, compile_to_ir, compile
from vmlinux import TASK_COMM_LEN # noqa: F401
from vmlinux import struct_xdp_md
from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
from ctypes import c_int64
# Instructions to how to run this program
# 1. Install PythonBPF: pip install pythonbpf
# 2. Run the program: python examples/xdp_pass.py
# 3. Run the program with sudo: sudo tools/check.sh run examples/xdp_pass.o
# 4. Attach object file to any network device with something like ./check.sh xdp examples/xdp_pass.o tailscale0
# 5. send traffic through the device and observe effects
@bpf
@section("xdp")
def hello_world(ctx: struct_xdp_md) -> c_int64:
return XDP_PASS
@section("tracepoint/syscalls/sys_enter_execve")
def hello_world(ctx: struct_trace_event_raw_sys_enter) -> c_int64:
print("Hello, World!")
return c_int64(0)
@bpf