mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 09:58:34 +00:00
22 lines
414 B
Python
22 lines
414 B
Python
# The same bounds check written on the fields directly.
|
|
from ctypes import c_int64, c_uint32 # noqa: F401
|
|
from pythonbpf import bpf, section, bpfglobal, compile
|
|
from vmlinux import struct_xdp_md
|
|
|
|
|
|
@bpf
|
|
@section("xdp")
|
|
def prog(ctx: struct_xdp_md) -> c_int64:
|
|
if ctx.data + 14 > ctx.data_end:
|
|
return c_int64(1)
|
|
return c_int64(2)
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|