pub struct SkLookup { /* private fields */ }
Expand description
A program used to redirect incoming packets to a local socket.
SkLookup
programs are attached to network namespaces to provide programmable
socket lookup for TCP/UDP when a packet is to be delievered locally.
You may attach multiple programs to the same namespace and they are executed in the order they were attached.
Minimum kernel version
The minimum kernel version required to use this feature is 5.9.
Examples
use std::fs::File;
use std::convert::TryInto;
use aya::programs::SkLookup;
let file = File::open("/var/run/netns/test")?;
let program: &mut SkLookup = bpf.program_mut("sk_lookup").unwrap().try_into()?;
program.load()?;
program.attach(file)?;
Implementations
sourceimpl SkLookup
impl SkLookup
sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
sourcepub fn attach<T: AsRawFd>(
&mut self,
netns: T
) -> Result<SkLookupLinkId, ProgramError>
pub fn attach<T: AsRawFd>(
&mut self,
netns: T
) -> Result<SkLookupLinkId, ProgramError>
Attaches the program to the given network namespace.
The returned value can be used to detach, see SkLookup::detach.
sourcepub fn take_link(
&mut self,
link_id: SkLookupLinkId
) -> Result<OwnedLink<SkLookupLink>, ProgramError>
pub fn take_link(
&mut self,
link_id: SkLookupLinkId
) -> Result<OwnedLink<SkLookupLink>, ProgramError>
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.
sourcepub fn detach(&mut self, link_id: SkLookupLinkId) -> Result<(), ProgramError>
pub fn detach(&mut self, link_id: SkLookupLinkId) -> Result<(), ProgramError>
Detaches the program.
See SkLookup::attach.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for SkLookup
impl Send for SkLookup
impl Sync for SkLookup
impl Unpin for SkLookup
impl UnwindSafe for SkLookup
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more