Struct aya::programs::Xdp [−][src]
pub struct Xdp { /* fields omitted */ }
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")?.try_into()?;
program.attach("eth0", XdpFlags::default())?;
Implementations
Loads the program inside the kernel.
See also Program::load
.
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
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.