pub struct ProgramArray { /* private fields */ }Expand description
A BPF map that stores an array of program indices for tail calling.
§Examples
use aya_ebpf::{macros::map, maps::ProgramArray};
#[map]
static JUMP_TABLE: ProgramArray = ProgramArray::with_max_entries(16, 0);
let index: u32 = 13;
unsafe {
JUMP_TABLE.tail_call(ctx, index);
}Implementations§
Source§impl ProgramArray
impl ProgramArray
pub const fn with_max_entries(max_entries: u32, flags: u32) -> Self
pub const fn pinned(max_entries: u32, flags: u32) -> Self
Sourcepub unsafe fn tail_call<C: EbpfContext>(&self, ctx: &C, index: u32)
pub unsafe fn tail_call<C: EbpfContext>(&self, ctx: &C, index: u32)
Performs a tail call into a program indexed by this map.
§Safety
This function is inherently unsafe, since it causes control flow to jump into another eBPF program. This can have side effects, such as drop methods not being called. Note that tail calling into an eBPF program is not the same thing as a function call – control flow never returns to the caller.
§Return Value
On success, this function does not return into the original program.
On failure, control returns to the caller. The kernel’s
bpf_tail_call helper is declared with ret_type = RET_VOID and
does not write R0 on failure, so callers cannot distinguish
between the three failure modes (out-of-bounds index, empty slot,
or MAX_TAIL_CALL_CNT exceeded).