pub struct SockOps { /* private fields */ }
Expand description
A program used to work with sockets.
SockOps
programs can access or set socket options, connection
parameters, watch connection state changes and more. They are attached to
cgroups.
Minimum kernel version
The minimum kernel version required to use this feature is 4.13.
Examples
use std::fs::File;
use std::convert::TryInto;
use aya::programs::SockOps;
let file = File::open("/sys/fs/cgroup/unified")?;
let prog: &mut SockOps = bpf.program_mut("intercept_active_sockets").unwrap().try_into()?;
prog.load()?;
prog.attach(file)?;
Implementations
sourceimpl SockOps
impl SockOps
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,
cgroup: T
) -> Result<SockOpsLinkId, ProgramError>
pub fn attach<T: AsRawFd>(
&mut self,
cgroup: T
) -> Result<SockOpsLinkId, ProgramError>
Attaches the program to the given cgroup.
The returned value can be used to detach, see SockOps::detach.
sourcepub fn detach(&mut self, link_id: SockOpsLinkId) -> Result<(), ProgramError>
pub fn detach(&mut self, link_id: SockOpsLinkId) -> Result<(), ProgramError>
Detaches the program.
See SockOps::attach.
sourcepub fn take_link(
&mut self,
link_id: SockOpsLinkId
) -> Result<OwnedLink<SockOpsLink>, ProgramError>
pub fn take_link(
&mut self,
link_id: SockOpsLinkId
) -> Result<OwnedLink<SockOpsLink>, 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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for SockOps
impl Send for SockOps
impl Sync for SockOps
impl Unpin for SockOps
impl UnwindSafe for SockOps
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