Skip to main content

Module bpf

Module bpf 

Source
Expand description

Self-contained eBPF XSK redirect driver and map loader.

Provides a zero-dependency Linux eBPF/XDP driver using direct bpf(2) syscalls to direct incoming tunnel UDP datagrams straight into AF_XDP rings (BPF_MAP_TYPE_XSKMAP) at the NIC driver layer, bypassing sk_buff allocations.

All raw syscalls and pointer manipulations are quarantined within this module, with explicit // SAFETY: justifications on every unsafe block.

Structs§

BpfInsn
8-byte eBPF instruction binary layout matching Linux kernel ABI (struct bpf_insn).
BpfLinkCreateAttr
BpfMapCreateAttr
BpfMapElemAttr
BpfProgLoadAttr
XdpRedirectFilter
RAII container for loaded eBPF redirect map and XDP program.

Enums§

BpfFilterStatus
Operational status of the opportunistic eBPF XDP filter attachment.

Constants§

BPF_ADD
BPF_ALU64
BPF_AND
BPF_B
BPF_CALL
BPF_DW
BPF_EXIT
BPF_FUNC_REDIRECT_MAP
BPF_H
BPF_IMM
BPF_JA
BPF_JEQ
BPF_JGT
BPF_JMP
BPF_JNE
BPF_K
BPF_LD
BPF_LDX
BPF_LINK_CREATE
BPF_LSH
BPF_MAP_CREATE
BPF_MAP_TYPE_XSKMAP
BPF_MAP_UPDATE_ELEM
BPF_MEM
BPF_MOV
BPF_PROG_LOAD
BPF_PROG_TYPE_XDP
BPF_PSEUDO_MAP_FD
BPF_W
BPF_X
BPF_XDP
R0
R1
R2
R3
R4
R5
R6
XDP_PASS

Functions§

bpf_attach_xdp
Attaches an XDP program to the network interface specified by ifindex.
bpf_map_create_xsk
Creates a BPF_MAP_TYPE_XSKMAP map holding up to max_entries AF_XDP socket descriptors.
bpf_map_update_xsk
Updates an entry in an XSK map mapping queue_id to xsk_fd.
bpf_prog_assemble_xdp
Assembles the dual-stack outer UDP eBPF XDP filter bytecode.
bpf_prog_load_xdp
Compiles and loads an eBPF XDP filter redirecting dual-stack UDP traffic for listen_port to xsk_map_fd.
sys_bpf⚠
Raw syscall wrapper for Linux bpf(2).

Unions§

BpfAttr
Linux union bpf_attr representation, 152 bytes.