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.
Minimum kernel version
The minimum kernel version required to use this feature is 4.2.
Examples
use aya::maps::ProgramArray;
use aya::programs::{CgroupSkb, ProgramFd};
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").unwrap().try_into()?;
let prog_1: &CgroupSkb = bpf.program("example_prog_1").unwrap().try_into()?;
let prog_2: &CgroupSkb = bpf.program("example_prog_2").unwrap().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
sourceimpl<T: Deref<Target = Map>> ProgramArray<T>
impl<T: Deref<Target = Map>> ProgramArray<T>
sourceimpl<T: Deref<Target = Map> + DerefMut<Target = Map>> ProgramArray<T>
impl<T: Deref<Target = Map> + DerefMut<Target = Map>> ProgramArray<T>
Trait Implementations
sourceimpl TryFrom<MapRef> for ProgramArray<MapRef>
impl TryFrom<MapRef> for ProgramArray<MapRef>
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,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more