pub struct Xdp { /* private fields */ }
Expand description
An XDP program.
eXpress Data Path (XDP) programs can be attached to the very early stages of network processing, where they can apply custom packet processing logic. When supported by the underlying network driver, XDP programs can execute directly on network cards, greatly reducing CPU load.
Minimum kernel version
The minimum kernel version required to use this feature is 4.8.
Examples
use aya::{Bpf, programs::{Xdp, XdpFlags}};
use std::convert::TryInto;
let program: &mut Xdp = bpf.program_mut("intercept_packets").unwrap().try_into()?;
program.attach("eth0", XdpFlags::default())?;
Implementations
sourceimpl Xdp
impl Xdp
sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
See also Program::load
.
sourcepub fn attach(
&mut self,
interface: &str,
flags: XdpFlags
) -> Result<LinkRef, ProgramError>
pub fn attach(
&mut self,
interface: &str,
flags: XdpFlags
) -> Result<LinkRef, ProgramError>
Attaches the program to the given interface
.
Errors
If the given interface
does not exist
ProgramError::UnknownInterface
is returned.
When attaching fails, ProgramError::SyscallError
is returned for
kernels >= 5.9.0
, and instead
XdpError::NetlinkError
is returned for older
kernels.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Xdp
impl !Send for Xdp
impl !Sync for Xdp
impl Unpin for Xdp
impl !UnwindSafe for Xdp
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