pub struct FEntry { /* private fields */ }
Expand description
A program that can be attached to the entry point of (almost) any kernel function.
FEntry
programs are similar to kprobes, but
the difference is that fentry has practically zero overhead to call before
kernel function. Fentry programs can be also attached to other eBPF
programs.
Minimum kernel version
The minimum kernel version required to use this feature is 5.5.
Examples
use aya::{Bpf, programs::FEntry, BtfError, Btf};
use std::convert::TryInto;
let btf = Btf::from_sys_fs()?;
let program: &mut FEntry = bpf.program_mut("filename_lookup").unwrap().try_into()?;
program.load("filename_lookup", &btf)?;
program.attach()?;
Implementations
sourceimpl FEntry
impl FEntry
sourcepub fn load(&mut self, fn_name: &str, btf: &Btf) -> Result<(), ProgramError>
pub fn load(&mut self, fn_name: &str, btf: &Btf) -> Result<(), ProgramError>
Loads the program inside the kernel.
Loads the program so it’s executed when the kernel function fn_name
is entered. The btf
argument must contain the BTF info for the
running kernel.
sourcepub fn attach(&mut self) -> Result<FEntryLinkId, ProgramError>
pub fn attach(&mut self) -> Result<FEntryLinkId, ProgramError>
Attaches the program.
The returned value can be used to detach, see FEntry::detach.
sourcepub fn detach(&mut self, link_id: FEntryLinkId) -> Result<(), ProgramError>
pub fn detach(&mut self, link_id: FEntryLinkId) -> Result<(), ProgramError>
Detaches the program.
See FEntry::attach.
sourcepub fn take_link(
&mut self,
link_id: FEntryLinkId
) -> Result<OwnedLink<FEntryLink>, ProgramError>
pub fn take_link(
&mut self,
link_id: FEntryLinkId
) -> Result<OwnedLink<FEntryLink>, ProgramError>
Takes ownership of the link referenced by the provided link_id.
The link will be detached on Drop
and the caller is now responsible
for managing its lifetime.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for FEntry
impl Send for FEntry
impl Sync for FEntry
impl Unpin for FEntry
impl UnwindSafe for FEntry
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