aya: add StackTraceMap::remove()

pull/649/merge
Alessandro Decina 10 months ago committed by Michal Rostecki
parent 057f27dc20
commit 92b1947885

@ -1,11 +1,17 @@
//! A hash map of kernel or user space stack traces. //! A hash map of kernel or user space stack traces.
//! //!
//! See [`StackTraceMap`] for documentation and examples. //! See [`StackTraceMap`] for documentation and examples.
use std::{borrow::Borrow, fs, io, mem, os::fd::AsFd as _, path::Path, str::FromStr}; use std::{
borrow::{Borrow, BorrowMut},
fs, io, mem,
os::fd::AsFd as _,
path::Path,
str::FromStr,
};
use crate::{ use crate::{
maps::{IterableMap, MapData, MapError, MapIter, MapKeys}, maps::{IterableMap, MapData, MapError, MapIter, MapKeys},
sys::{bpf_map_lookup_elem_ptr, SyscallError}, sys::{bpf_map_delete_elem, bpf_map_lookup_elem_ptr, SyscallError},
}; };
/// A hash map of kernel or user space stack traces. /// A hash map of kernel or user space stack traces.
@ -157,6 +163,22 @@ impl<'a, T: Borrow<MapData>> IntoIterator for &'a StackTraceMap<T> {
} }
} }
impl<T: BorrowMut<MapData>> StackTraceMap<T> {
/// Removes the stack trace with the given stack_id.
pub fn remove(&mut self, stack_id: &u32) -> Result<(), MapError> {
let fd = self.inner.borrow().fd().as_fd();
bpf_map_delete_elem(fd, stack_id)
.map(|_| ())
.map_err(|(_, io_error)| {
SyscallError {
call: "bpf_map_delete_elem",
io_error,
}
.into()
})
}
}
/// A kernel or user space stack trace. /// A kernel or user space stack trace.
/// ///
/// See the [`StackTraceMap`] documentation for examples. /// See the [`StackTraceMap`] documentation for examples.

@ -849,6 +849,8 @@ pub fn aya::maps::stack_trace::StackTraceMap<T>::iter(&self) -> aya::maps::MapIt
pub fn aya::maps::stack_trace::StackTraceMap<T>::stack_ids(&self) -> aya::maps::MapKeys<'_, u32> pub fn aya::maps::stack_trace::StackTraceMap<T>::stack_ids(&self) -> aya::maps::MapKeys<'_, u32>
impl<T: core::borrow::Borrow<aya::maps::MapData>> aya::maps::stack_trace::StackTraceMap<T> impl<T: core::borrow::Borrow<aya::maps::MapData>> aya::maps::stack_trace::StackTraceMap<T>
pub fn aya::maps::stack_trace::StackTraceMap<T>::pin<P: core::convert::AsRef<std::path::Path>>(self, path: P) -> core::result::Result<(), aya::pin::PinError> pub fn aya::maps::stack_trace::StackTraceMap<T>::pin<P: core::convert::AsRef<std::path::Path>>(self, path: P) -> core::result::Result<(), aya::pin::PinError>
impl<T: core::borrow::BorrowMut<aya::maps::MapData>> aya::maps::stack_trace::StackTraceMap<T>
pub fn aya::maps::stack_trace::StackTraceMap<T>::remove(&mut self, stack_id: &u32) -> core::result::Result<(), aya::maps::MapError>
impl core::convert::TryFrom<aya::maps::Map> for aya::maps::stack_trace::StackTraceMap<aya::maps::MapData> impl core::convert::TryFrom<aya::maps::Map> for aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>
pub type aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::Error = aya::maps::MapError pub type aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::Error = aya::maps::MapError
pub fn aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::try_from(map: aya::maps::Map) -> core::result::Result<Self, Self::Error> pub fn aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::try_from(map: aya::maps::Map) -> core::result::Result<Self, Self::Error>
@ -2231,6 +2233,8 @@ pub fn aya::maps::stack_trace::StackTraceMap<T>::iter(&self) -> aya::maps::MapIt
pub fn aya::maps::stack_trace::StackTraceMap<T>::stack_ids(&self) -> aya::maps::MapKeys<'_, u32> pub fn aya::maps::stack_trace::StackTraceMap<T>::stack_ids(&self) -> aya::maps::MapKeys<'_, u32>
impl<T: core::borrow::Borrow<aya::maps::MapData>> aya::maps::stack_trace::StackTraceMap<T> impl<T: core::borrow::Borrow<aya::maps::MapData>> aya::maps::stack_trace::StackTraceMap<T>
pub fn aya::maps::stack_trace::StackTraceMap<T>::pin<P: core::convert::AsRef<std::path::Path>>(self, path: P) -> core::result::Result<(), aya::pin::PinError> pub fn aya::maps::stack_trace::StackTraceMap<T>::pin<P: core::convert::AsRef<std::path::Path>>(self, path: P) -> core::result::Result<(), aya::pin::PinError>
impl<T: core::borrow::BorrowMut<aya::maps::MapData>> aya::maps::stack_trace::StackTraceMap<T>
pub fn aya::maps::stack_trace::StackTraceMap<T>::remove(&mut self, stack_id: &u32) -> core::result::Result<(), aya::maps::MapError>
impl core::convert::TryFrom<aya::maps::Map> for aya::maps::stack_trace::StackTraceMap<aya::maps::MapData> impl core::convert::TryFrom<aya::maps::Map> for aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>
pub type aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::Error = aya::maps::MapError pub type aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::Error = aya::maps::MapError
pub fn aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::try_from(map: aya::maps::Map) -> core::result::Result<Self, Self::Error> pub fn aya::maps::stack_trace::StackTraceMap<aya::maps::MapData>::try_from(map: aya::maps::Map) -> core::result::Result<Self, Self::Error>

Loading…
Cancel
Save