mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +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
38 lines
758 B
Python
38 lines
758 B
Python
# Ported from Linux tools/testing/selftests/bpf/progs/test_signed_loader_data.c
|
|
#
|
|
# The signed-loader fixture with one initialised global, so the object has a
|
|
# .data map that the loader must seed. Upstream checks that a signed loader
|
|
# keeps the attested initial value:
|
|
#
|
|
# __u64 magic = 0x5eed1234abad1deaULL;
|
|
#
|
|
# SEC("socket")
|
|
# int probe(void *ctx)
|
|
# {
|
|
# return (int)magic;
|
|
# }
|
|
|
|
from pythonbpf import bpf, section, bpfglobal, compile
|
|
from ctypes import c_void_p, c_int32, c_uint64
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def magic() -> c_uint64:
|
|
return c_uint64(0x5EED1234ABAD1DEA)
|
|
|
|
|
|
@bpf
|
|
@section("socket")
|
|
def probe(ctx: c_void_p) -> c_int32:
|
|
return c_int32(magic)
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|