Struct aya::maps::array::ProgramArray [−][src]
Expand description
An array of eBPF program file descriptors used as a jump table.
eBPF programs can jump to other programs calling bpf_tail_call(ctx, prog_array, index)
. You can use ProgramArray
to configure which
programs correspond to which jump indexes.
Examples
use aya::maps::ProgramArray; use aya::programs::CgroupSkb; use std::convert::{TryFrom, TryInto}; let mut prog_array = ProgramArray::try_from(bpf.map_mut("JUMP_TABLE")?)?; let prog_0: &CgroupSkb = bpf.program("example_prog_0")?.try_into()?; let prog_1: &CgroupSkb = bpf.program("example_prog_1")?.try_into()?; let prog_2: &CgroupSkb = bpf.program("example_prog_2")?.try_into()?; let flags = 0; // bpf_tail_call(ctx, JUMP_TABLE, 0) will jump to prog_0 prog_array.set(0, prog_0, flags); // bpf_tail_call(ctx, JUMP_TABLE, 1) will jump to prog_1 prog_array.set(1, prog_1, flags); // bpf_tail_call(ctx, JUMP_TABLE, 2) will jump to prog_2 prog_array.set(2, prog_2, flags);
Implementations
Sets the target program file descriptor for the given index in the jump table.
When an eBPF program calls bpf_tail_call(ctx, prog_array, index)
, control
flow will jump to program
.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for ProgramArray<T> where
T: RefUnwindSafe,
impl<T> Send for ProgramArray<T> where
T: Send,
impl<T> Sync for ProgramArray<T> where
T: Sync,
impl<T> Unpin for ProgramArray<T> where
T: Unpin,
impl<T> UnwindSafe for ProgramArray<T> where
T: UnwindSafe,