Struct aya::programs::cgroup_sock_addr::CgroupSockAddr
source · [−]pub struct CgroupSockAddr { /* private fields */ }
Expand description
A program that can be used to inspect or modify socket addresses (struct sockaddr
).
CgroupSockAddr
programs can be used to inspect or modify socket addresses passed to
various syscalls within a cgroup. They can be attached to a number of different
places as described in CgroupSockAddrAttachType
.
Minimum kernel version
The minimum kernel version required to use this feature is 4.17.
Examples
use std::fs::File;
use std::convert::TryInto;
use aya::programs::{CgroupSockAddr, CgroupSockAddrAttachType};
let file = File::open("/sys/fs/cgroup/unified")?;
let egress: &mut CgroupSockAddr = bpf.program_mut("connect4").unwrap().try_into()?;
egress.load()?;
egress.attach(file)?;
Implementations
sourceimpl CgroupSockAddr
impl CgroupSockAddr
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<CgroupSockAddrLinkId, ProgramError>
pub fn attach<T: AsRawFd>(
&mut self,
cgroup: T
) -> Result<CgroupSockAddrLinkId, ProgramError>
Attaches the program to the given cgroup.
The returned value can be used to detach, see CgroupSockAddr::detach.
sourcepub fn take_link(
&mut self,
link_id: CgroupSockAddrLinkId
) -> Result<OwnedLink<CgroupSockAddrLink>, ProgramError>
pub fn take_link(
&mut self,
link_id: CgroupSockAddrLinkId
) -> Result<OwnedLink<CgroupSockAddrLink>, 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: CgroupSockAddrLinkId
) -> Result<(), ProgramError>
pub fn detach(
&mut self,
link_id: CgroupSockAddrLinkId
) -> Result<(), ProgramError>
Detaches the program.
sourceimpl CgroupSockAddr
impl CgroupSockAddr
sourcepub fn unload(&mut self) -> Result<(), ProgramError>
pub fn unload(&mut self) -> Result<(), ProgramError>
Unloads the program from the kernel.
Links will be detached before unloading the program. Note
that owned links obtained using take_link()
will not be
detached.
Trait Implementations
sourceimpl Debug for CgroupSockAddr
impl Debug for CgroupSockAddr
sourceimpl ProgramFd for CgroupSockAddr
impl ProgramFd for CgroupSockAddr
sourceimpl ProgramFd for &mut CgroupSockAddr
impl ProgramFd for &mut CgroupSockAddr
sourceimpl<'a> TryFrom<&'a Program> for &'a CgroupSockAddr
impl<'a> TryFrom<&'a Program> for &'a CgroupSockAddr
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
sourcefn try_from(program: &'a Program) -> Result<&'a CgroupSockAddr, ProgramError>
fn try_from(program: &'a Program) -> Result<&'a CgroupSockAddr, ProgramError>
Performs the conversion.
sourceimpl<'a> TryFrom<&'a mut Program> for &'a mut CgroupSockAddr
impl<'a> TryFrom<&'a mut Program> for &'a mut CgroupSockAddr
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
sourcefn try_from(
program: &'a mut Program
) -> Result<&'a mut CgroupSockAddr, ProgramError>
fn try_from(
program: &'a mut Program
) -> Result<&'a mut CgroupSockAddr, ProgramError>
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for CgroupSockAddr
impl Send for CgroupSockAddr
impl Sync for CgroupSockAddr
impl Unpin for CgroupSockAddr
impl UnwindSafe for CgroupSockAddr
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