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