pub struct CgroupSkb { /* private fields */ }
Expand description
A program used to inspect or filter network activity for a given cgroup.
CgroupSkb
programs can be used to inspect or filter network activity
generated on all the sockets belonging to a given cgroup. They can be
attached to both ingress and egress.
Minimum kernel version
The minimum kernel version required to use this feature is 4.10.
Examples
use std::fs::File;
use std::convert::TryInto;
use aya::programs::{CgroupSkb, CgroupSkbAttachType};
let file = File::open("/sys/fs/cgroup/unified")?;
let egress: &mut CgroupSkb = bpf.program_mut("egress_filter").unwrap().try_into()?;
egress.load()?;
egress.attach(file, CgroupSkbAttachType::Egress)?;
Implementations
sourceimpl CgroupSkb
impl CgroupSkb
sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
sourcepub fn expected_attach_type(&self) -> &Option<CgroupSkbAttachType>
pub fn expected_attach_type(&self) -> &Option<CgroupSkbAttachType>
Returns the expected attach type of the program.
CgroupSkb
programs can specify the expected attach type in their ELF
section name, eg cgroup_skb/ingress
or cgroup_skb/egress
. This
method returns None
for programs defined with the generic section
cgroup/skb
.
sourcepub fn attach<T: AsRawFd>(
&mut self,
cgroup: T,
attach_type: CgroupSkbAttachType
) -> Result<CgroupSkbLinkId, ProgramError>
pub fn attach<T: AsRawFd>(
&mut self,
cgroup: T,
attach_type: CgroupSkbAttachType
) -> Result<CgroupSkbLinkId, ProgramError>
Attaches the program to the given cgroup.
The returned value can be used to detach, see CgroupSkb::detach.
sourcepub fn take_link(
&mut self,
link_id: CgroupSkbLinkId
) -> Result<OwnedLink<CgroupSkbLink>, ProgramError>
pub fn take_link(
&mut self,
link_id: CgroupSkbLinkId
) -> Result<OwnedLink<CgroupSkbLink>, 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: CgroupSkbLinkId) -> Result<(), ProgramError>
pub fn detach(&mut self, link_id: CgroupSkbLinkId) -> Result<(), ProgramError>
Detaches the program.
See CgroupSkb::attach.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CgroupSkb
impl Send for CgroupSkb
impl Sync for CgroupSkb
impl Unpin for CgroupSkb
impl UnwindSafe for CgroupSkb
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