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

Loads the program inside the kernel.

Attaches the program to the given interface.

The returned value can be used to detach, see Xdp::detach.

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.

Detaches the program.

See Xdp::attach.

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.

Unloads the program from the kernel.

Links will be detached before unloading the program. Note that owned links obtained using take_link() will not be detached.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the RawFd of the program if it has been loaded, or None

Returns the RawFd of the program if it has been loaded, or None

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.