Skip to main content

BpfMapCommonOps

Trait BpfMapCommonOps 

Source
pub trait BpfMapCommonOps:
    Send
    + Sync
    + Debug
    + Any {
Show 18 methods // Required methods fn map_mem_usage(&self) -> LinuxResult<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]) -> LinuxResult<Option<&[u8]>> { ... } fn update_elem( &mut self, _key: &[u8], _value: &[u8], _flags: u64, ) -> LinuxResult<()> { ... } fn delete_elem(&mut self, _key: &[u8]) -> LinuxResult<()> { ... } fn for_each_elem( &mut self, _cb: BpfCallBackFn, _ctx: *const u8, _flags: u64, ) -> LinuxResult<u32> { ... } fn lookup_and_delete_elem( &mut self, _key: &[u8], _value: &mut [u8], ) -> LinuxResult<()> { ... } fn lookup_percpu_elem( &mut self, _key: &[u8], _cpu: u32, ) -> LinuxResult<Option<&[u8]>> { ... } fn get_next_key( &self, _key: Option<&[u8]>, _next_key: &mut [u8], ) -> LinuxResult<()> { ... } fn push_elem(&mut self, _value: &[u8], _flags: u64) -> LinuxResult<()> { ... } fn pop_elem(&mut self, _value: &mut [u8]) -> LinuxResult<()> { ... } fn peek_elem(&self, _value: &mut [u8]) -> LinuxResult<()> { ... } fn freeze(&self) -> LinuxResult<()> { ... } fn map_values_ptr_range(&self) -> LinuxResult<Range<usize>> { ... } fn map_mmap( &self, offset: usize, size: usize, read: bool, write: bool, ) -> LinuxResult<Vec<usize>> { ... } fn readable(&self) -> bool { ... } fn writable(&self) -> bool { ... }
}
Expand description

Common operations for BPF maps.

Required Methods§

Source

fn map_mem_usage(&self) -> LinuxResult<usize>

Get the memory usage of the map.

Source

fn as_any(&self) -> &dyn Any

Get a reference to the map as Any.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Get a mutable reference to the map as Any.

Provided Methods§

Source

fn lookup_elem(&mut self, _key: &[u8]) -> LinuxResult<Option<&[u8]>>

Source

fn update_elem( &mut self, _key: &[u8], _value: &[u8], _flags: u64, ) -> LinuxResult<()>

Source

fn delete_elem(&mut self, _key: &[u8]) -> LinuxResult<()>

Source

fn for_each_elem( &mut self, _cb: BpfCallBackFn, _ctx: *const u8, _flags: u64, ) -> LinuxResult<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/

Source

fn lookup_and_delete_elem( &mut self, _key: &[u8], _value: &mut [u8], ) -> LinuxResult<()>

Look up an element with the given key in the map referred to by the file descriptor fd, and if found, delete the element.

Source

fn lookup_percpu_elem( &mut self, _key: &[u8], _cpu: u32, ) -> LinuxResult<Option<&[u8]>>

erform a lookup in percpu map for an entry associated to key on cpu.

Source

fn get_next_key( &self, _key: Option<&[u8]>, _next_key: &mut [u8], ) -> LinuxResult<()>

Get the next key in the map. If key is None, get the first key.

Called from syscall

Source

fn push_elem(&mut self, _value: &[u8], _flags: u64) -> LinuxResult<()>

Push an element value in map.

Source

fn pop_elem(&mut self, _value: &mut [u8]) -> LinuxResult<()>

Pop an element value from map.

Source

fn peek_elem(&self, _value: &mut [u8]) -> LinuxResult<()>

Peek an element value from map.

Source

fn freeze(&self) -> LinuxResult<()>

Freeze the map.

It’s useful for .rodata maps.

Source

fn map_values_ptr_range(&self) -> LinuxResult<Range<usize>>

Get the first value pointer.

This is used for BPF_PSEUDO_MAP_VALUE.

Source

fn map_mmap( &self, offset: usize, size: usize, read: bool, write: bool, ) -> LinuxResult<Vec<usize>>

Memory map the map into user space. Return the physical address.

Source

fn readable(&self) -> bool

Whether the map is readable.

Source

fn writable(&self) -> bool

Whether the map is writable.

Implementors§

Source§

impl<T: SpecialMap> BpfMapCommonOps for T