mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 18:08:36 +00:00
25 lines
546 B
Python
25 lines
546 B
Python
# Ported from Linux tools/testing/selftests/bpf/progs/priv_prog.c
|
|
#
|
|
# An XDP program that drops everything. Upstream loads it from an
|
|
# unprivileged process to check the CAP_BPF/CAP_NET_ADMIN gating; the
|
|
# program itself is the smallest privileged-type program there is.
|
|
|
|
from pythonbpf import bpf, section, bpfglobal, compile
|
|
from vmlinux import XDP_DROP
|
|
from ctypes import c_void_p, c_int64
|
|
|
|
|
|
@bpf
|
|
@section("xdp")
|
|
def xdp_prog1(xdp: c_void_p) -> c_int64:
|
|
return XDP_DROP
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|