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
impl ProgramArray
pub const fn with_max_entries(max_entries: u32, flags: u32) -> ProgramArray
pub const fn pinned(max_entries: u32, flags: u32) -> ProgramArray
Sourcepub unsafe fn tail_call<C: EbpfContext>(
&self,
ctx: &C,
index: u32,
) -> Result<!, c_long>
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§
impl Sync for ProgramArray
Auto Trait Implementations§
impl !Freeze for ProgramArray
impl !RefUnwindSafe for ProgramArray
impl Send for ProgramArray
impl Unpin for ProgramArray
impl UnwindSafe for ProgramArray
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more