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, cty::c_long};

#[map]
static JUMP_TABLE: ProgramArray = ProgramArray::with_max_entries(16, 0);

let index: u32 = 13;

if let Err(e) = JUMP_TABLE.tail_call(ctx, index) {
    return Err(e);
}

}

Implementations§

Source§

impl ProgramArray

Source

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

Source

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

Source

pub unsafe fn tail_call<C: EbpfContext>( &self, ctx: &C, index: u32, ) -> Result<!, c_long>

Perform 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, a negative error is returned, wrapped in Err().

Trait Implementations§

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.