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>
impl<'fd> Xdp<'fd>
sourcepub fn new(fd: BorrowedFd<'fd>) -> Self
pub fn new(fd: BorrowedFd<'fd>) -> Self
Create a new XDP instance with the given file descriptor of the
SEC("xdp")
Program
.
sourcepub fn attach(&self, ifindex: i32, flags: XdpFlags) -> Result<()>
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.
sourcepub fn detach(&self, ifindex: i32, flags: XdpFlags) -> Result<()>
pub fn detach(&self, ifindex: i32, flags: XdpFlags) -> Result<()>
Detach the XDP program from the interface
sourcepub fn query(&self, ifindex: i32, flags: XdpFlags) -> Result<bpf_xdp_query_opts>
pub fn query(&self, ifindex: i32, flags: XdpFlags) -> Result<bpf_xdp_query_opts>
Query to inspect the program
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more