libbpf_rs

Struct 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>,

Source§

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>,

Source§

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.