mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 09:58:34 +00:00
retype, helper_cond, direct_assign and globals had no xfail entry and have been passing at every level; their NOTE headers describe limits that have since been lifted, so they are rewritten. xdp_pass was an xfail only because it used the old count().lookup() spelling of a map call; in the current syntax it compiles. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
33 lines
677 B
Python
33 lines
677 B
Python
from pythonbpf import bpf, map, section, bpfglobal, compile
|
|
from ctypes import c_void_p, c_int64, c_uint64
|
|
from pythonbpf.maps import HashMap
|
|
|
|
# A map lookup used directly in a comparison: the value is null-checked and
|
|
# dereferenced, and a missing key takes the else branch.
|
|
|
|
|
|
@bpf
|
|
@map
|
|
def last() -> HashMap:
|
|
return HashMap(key=c_uint64, value=c_uint64, max_entries=3)
|
|
|
|
|
|
@bpf
|
|
@section("tracepoint/syscalls/sys_enter_execve")
|
|
def hello_world(ctx: c_void_p) -> c_int64:
|
|
last.update(0, 1)
|
|
if last.lookup(0) > 0:
|
|
print("Hello, World!")
|
|
else:
|
|
print("Goodbye, World!")
|
|
return
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|