mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
veristat_foo (three socket programs) is clean. test_perf_link, test_enable_stats and test_cgroup_link count with __sync_fetch_and_add, which becomes a plain `x += 1` tagged WORKAROUND(atomics) for a mechanical sweep once atomics exist. connect4_dropper compares against bpf_htons(port), written out as shifts on the low 16 bits. All five pass at IR, llc and verifier level, and bring perf_event, raw_tracepoint/sys_enter, cgroup_skb/egress and cgroup/connect4 under test. The porting notes gain the third batch, the atomics tag, the current blocker histogram from the checked-in audit tool, and how to re-run it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DLMW3X7opqAPH6bjmTVkr7
36 lines
708 B
Python
36 lines
708 B
Python
# Ported from Linux tools/testing/selftests/bpf/progs/veristat_foo.c
|
|
#
|
|
# Three empty socket filters. Upstream exists only to exercise veristat's
|
|
# program-name filters, so the bodies are irrelevant and the names are the
|
|
# test. Ported for the same reason: three programs, one section, one object.
|
|
|
|
from pythonbpf import bpf, section, bpfglobal, compile
|
|
from ctypes import c_void_p, c_int64
|
|
|
|
|
|
@bpf
|
|
@section("socket")
|
|
def foo(ctx: c_void_p) -> c_int64:
|
|
return c_int64(0)
|
|
|
|
|
|
@bpf
|
|
@section("socket")
|
|
def bar(ctx: c_void_p) -> c_int64:
|
|
return c_int64(0)
|
|
|
|
|
|
@bpf
|
|
@section("socket")
|
|
def buz(ctx: c_void_p) -> c_int64:
|
|
return c_int64(0)
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|