Struct libbpf_rs::Xdp

source ·
pub struct Xdp<'fd> { /* private fields */ }
Expand description

Represents a XDP program.

This struct exposes operations to attach, detach and query a XDP program

Implementations§

source§

impl<'fd> Xdp<'fd>

source

pub fn new(fd: BorrowedFd<'fd>) -> Self

Create a new XDP instance with the given file descriptor of the SEC("xdp") Program.

source

pub fn attach(&self, ifindex: i32, flags: XdpFlags) -> Result<()>

Attach the XDP program to the given interface to start processing the packets

§Notes

Once a program is attached, it will outlive the userspace program. Make sure to detach the program if its not desired.

source

pub fn detach(&self, ifindex: i32, flags: XdpFlags) -> Result<()>

Detach the XDP program from the interface

source

pub fn query(&self, ifindex: i32, flags: XdpFlags) -> Result<bpf_xdp_query_opts>

Query to inspect the program

source

pub fn query_id(&self, ifindex: i32, flags: XdpFlags) -> Result<u32>

Query to inspect the program identifier (prog_id)

source

pub fn replace(&self, ifindex: i32, old_prog_fd: BorrowedFd<'_>) -> Result<()>

Replace an existing xdp program (identified by old_prog_fd) with this xdp program

Trait Implementations§

source§

impl<'fd> Debug for Xdp<'fd>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'fd> Freeze for Xdp<'fd>

§

impl<'fd> RefUnwindSafe for Xdp<'fd>

§

impl<'fd> Send for Xdp<'fd>

§

impl<'fd> Sync for Xdp<'fd>

§

impl<'fd> Unpin for Xdp<'fd>

§

impl<'fd> UnwindSafe for Xdp<'fd>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.