Skip to main content

ProgramArray

Struct ProgramArray 

Source
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

Source

pub const fn with_max_entries(max_entries: u32, flags: u32) -> Self

Source

pub const fn pinned(max_entries: u32, flags: u32) -> Self

Source

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).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.