pub trait BpfMapCommonOps:
Send
+ Sync
+ Debug
+ Any {
Show 18 methods
// Required methods
fn map_mem_usage(&self) -> Result<usize>;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
// Provided methods
fn lookup_elem(&mut self, _key: &[u8]) -> Result<Option<&[u8]>> { ... }
fn update_elem(
&mut self,
_key: &[u8],
_value: &[u8],
_flags: u64,
) -> Result<()> { ... }
fn delete_elem(&mut self, _key: &[u8]) -> Result<()> { ... }
fn for_each_elem(
&mut self,
_cb: BpfCallBackFn,
_ctx: *const u8,
_flags: u64,
) -> Result<u32> { ... }
fn lookup_and_delete_elem(
&mut self,
_key: &[u8],
_value: &mut [u8],
) -> Result<()> { ... }
fn lookup_percpu_elem(
&mut self,
_key: &[u8],
_cpu: u32,
) -> Result<Option<&[u8]>> { ... }
fn get_next_key(
&self,
_key: Option<&[u8]>,
_next_key: &mut [u8],
) -> Result<()> { ... }
fn push_elem(&mut self, _value: &[u8], _flags: u64) -> Result<()> { ... }
fn pop_elem(&mut self, _value: &mut [u8]) -> Result<()> { ... }
fn peek_elem(&self, _value: &mut [u8]) -> Result<()> { ... }
fn freeze(&self) -> Result<()> { ... }
fn map_values_ptr_range(&self) -> Result<Range<usize>> { ... }
fn map_mmap(
&self,
_offset: usize,
_size: usize,
_read: bool,
_write: bool,
) -> Result<Vec<usize>> { ... }
fn readable(&self) -> bool { ... }
fn writable(&self) -> bool { ... }
}Expand description
Common operations for BPF maps.
Required Methods§
Sourcefn map_mem_usage(&self) -> Result<usize>
fn map_mem_usage(&self) -> Result<usize>
Get the memory usage of the map.
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Get a mutable reference to the map as Any.
Provided Methods§
Sourcefn lookup_elem(&mut self, _key: &[u8]) -> Result<Option<&[u8]>>
fn lookup_elem(&mut self, _key: &[u8]) -> Result<Option<&[u8]>>
Lookup an element in the map.
See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_lookup_elem/
Sourcefn update_elem(&mut self, _key: &[u8], _value: &[u8], _flags: u64) -> Result<()>
fn update_elem(&mut self, _key: &[u8], _value: &[u8], _flags: u64) -> Result<()>
Update an element in the map.
See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_update_elem/
Sourcefn delete_elem(&mut self, _key: &[u8]) -> Result<()>
fn delete_elem(&mut self, _key: &[u8]) -> Result<()>
Delete an element from the map.
See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_delete_elem/
Sourcefn for_each_elem(
&mut self,
_cb: BpfCallBackFn,
_ctx: *const u8,
_flags: u64,
) -> Result<u32>
fn for_each_elem( &mut self, _cb: BpfCallBackFn, _ctx: *const u8, _flags: u64, ) -> Result<u32>
For each element in map, call callback_fn function with map, callback_ctx and other map-specific parameters.
See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_for_each_map_elem/
Sourcefn lookup_and_delete_elem(
&mut self,
_key: &[u8],
_value: &mut [u8],
) -> Result<()>
fn lookup_and_delete_elem( &mut self, _key: &[u8], _value: &mut [u8], ) -> Result<()>
Look up an element with the given key in the map referred to by the file descriptor fd, and if found, delete the element.
Sourcefn lookup_percpu_elem(
&mut self,
_key: &[u8],
_cpu: u32,
) -> Result<Option<&[u8]>>
fn lookup_percpu_elem( &mut self, _key: &[u8], _cpu: u32, ) -> Result<Option<&[u8]>>
erform a lookup in percpu map for an entry associated to key on cpu.
Sourcefn get_next_key(&self, _key: Option<&[u8]>, _next_key: &mut [u8]) -> Result<()>
fn get_next_key(&self, _key: Option<&[u8]>, _next_key: &mut [u8]) -> Result<()>
Get the next key in the map. If key is None, get the first key.
Called from syscall
Sourcefn push_elem(&mut self, _value: &[u8], _flags: u64) -> Result<()>
fn push_elem(&mut self, _value: &[u8], _flags: u64) -> Result<()>
Push an element value in map.
Sourcefn map_values_ptr_range(&self) -> Result<Range<usize>>
fn map_values_ptr_range(&self) -> Result<Range<usize>>
Get the first value pointer.
This is used for BPF_PSEUDO_MAP_VALUE.