pub struct CgroupArray<T> { /* private fields */ }Expand description
An array of cgroups.
eBPF programs can test whether a packet or the current task belongs to a
cgroup by calling bpf_skb_under_cgroup or bpf_current_task_under_cgroup
against this map. You populate it from userspace with the file descriptors
of cgroup directories.
§Minimum kernel version
The minimum kernel version required to use this feature is 4.8.
§Examples
use aya::maps::CgroupArray;
let mut array = CgroupArray::try_from(bpf.map_mut("CGROUPS").unwrap())?;
// cgroup_fd is the RawFd of an open cgroup directory.
array.set(0, cgroup_fd, 0);Implementations§
Source§impl<T: Borrow<MapData>> CgroupArray<T>
impl<T: Borrow<MapData>> CgroupArray<T>
Source§impl<T: BorrowMut<MapData>> CgroupArray<T>
impl<T: BorrowMut<MapData>> CgroupArray<T>
Sourcepub fn set(
&mut self,
index: u32,
cgroup_fd: impl AsRawFd,
flags: u64,
) -> Result<(), MapError>
pub fn set( &mut self, index: u32, cgroup_fd: impl AsRawFd, flags: u64, ) -> Result<(), MapError>
Stores a cgroup file descriptor at the given index.
§Errors
Returns MapError::OutOfBounds if index is out of bounds,
MapError::SyscallError if bpf_map_update_elem fails.
Sourcepub fn unset(&mut self, index: u32) -> Result<(), MapError>
pub fn unset(&mut self, index: u32) -> Result<(), MapError>
Un-sets the cgroup at the given index.
§Errors
Returns MapError::OutOfBounds if index is out of bounds,
MapError::SyscallError if bpf_map_delete_elem fails.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CgroupArray<T>where
T: Freeze,
impl<T> RefUnwindSafe for CgroupArray<T>where
T: RefUnwindSafe,
impl<T> Send for CgroupArray<T>where
T: Send,
impl<T> Sync for CgroupArray<T>where
T: Sync,
impl<T> Unpin for CgroupArray<T>where
T: Unpin,
impl<T> UnsafeUnpin for CgroupArray<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CgroupArray<T>where
T: UnwindSafe,
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