mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 18:08:36 +00:00
Every program on the selftest audit's Tier 1 and Tier 2 lists that the compiler can express today: xdp_dummy, priv_prog, test_xdp_link, xdp_tx, tc_dummy, test_tc_bpf, cgroup_mprog, cgroup_skb_direct_packet_access, test_signed_loader, test_signed_loader_data, test_netfilter_link_attach, kprobe_multi_empty, uprobe_multi_bench, uprobe_multi_usdt, test_link_pinning and test_xdp_devmap_helpers. Fifteen pass at every level, bringing tc, tcx, cgroup/getsockopt, cgroup_skb, socket, netfilter, kprobe.multi, uprobe.multi, usdt and tp_btf program types under test for the first time. test_xdp_devmap_helpers is a negative fixture upstream: reading egress_ifindex is only legal with expected_attach_type = BPF_XDP_DEVMAP and the driver asserts the plain load fails. It is a strict verifier-level xfail here for the same reason, until expected_attach_type can be expressed. The porting notes record the batch and why each remaining program on the two lists is still out of reach. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DLMW3X7opqAPH6bjmTVkr7
40 lines
804 B
Python
40 lines
804 B
Python
# Ported from Linux tools/testing/selftests/bpf/progs/uprobe_multi_bench.c
|
|
#
|
|
# Count how many times the multi-uprobe fires. Upstream attaches it to
|
|
# thousands of uprobe_multi_func_* symbols and reads `count` back:
|
|
#
|
|
# int count;
|
|
#
|
|
# SEC("uprobe.multi/./uprobe_multi:uprobe_multi_func_*")
|
|
# int uprobe_bench(struct pt_regs *ctx)
|
|
# {
|
|
# count++;
|
|
# return 0;
|
|
# }
|
|
|
|
from pythonbpf import bpf, section, bpfglobal, compile
|
|
from ctypes import c_void_p, c_int64, c_int32
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def count() -> c_int32:
|
|
return c_int32(0)
|
|
|
|
|
|
@bpf
|
|
@section("uprobe.multi/./uprobe_multi:uprobe_multi_func_*")
|
|
def uprobe_bench(ctx: c_void_p) -> c_int64:
|
|
global count
|
|
count += 1
|
|
return c_int64(0)
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|