Trait rxdp::MapLike [−][src]
This trait exposes the functionality of update/lookup/delete of underlying eBPF maps.
Required methods
fn map_fd(&self) -> i32
[src]
File descriptor for this map.
fn map_type(&self) -> MapType
[src]
fn max_entries(&self) -> u32
[src]
The maximum number of entries the map supports
fn items(&self) -> XDPResult<Vec<KeyValue<K, MapValue<V>>>>
[src]
Returns all items in the map. Note that for Array type maps, this will always
return max_entries
number of items.
Provided methods
fn lookup(&self, key: &K) -> XDPResult<MapValue<V>>
[src]
Lookup an element from the underlying eBPF map.
fn update(&self, key: &K, value: &V, flags: MapFlags) -> XDPResult<()>
[src]
Update an element in the underlying eBPF map.
fn delete(&self, key: &K) -> XDPResult<()>
[src]
Delete an element from the underlying eBPF map.
fn update_batch(
&self,
keys: &mut Vec<K>,
values: &mut Vec<V>,
flags: MapFlags
) -> XDPResult<u32>
[src]
&self,
keys: &mut Vec<K>,
values: &mut Vec<V>,
flags: MapFlags
) -> XDPResult<u32>
Update a batch of elements in the underlying eBPF map. If the kernel supports it, this
will use the BPF_MAP_UPDATE_BATCH
syscall to update all elements in 1 call. Otherwise,
it is equivalent to calling update()
in a loop for every element.
fn lookup_batch(
&self,
batch_size: u32,
next_key: Option<u32>
) -> XDPResult<BatchResult<K, MapValue<V>>>
[src]
&self,
batch_size: u32,
next_key: Option<u32>
) -> XDPResult<BatchResult<K, MapValue<V>>>
Lookup a batch of elements from the underlying eBPF map. Returns a
BatchResult
that includes the next key to pass in to
continue looking up elements:
use rxdp::MapLike; let mut next_key = None; loop { let r = m.lookup_batch(10u32, next_key).unwrap(); // do something with `r.items`... if r.next_key.is_none() { break; } next_key = r.next_key; }
NOTE: By design of the bpf kernel code, this may return anywhere from 0 - batch_size
elements, particularly when the batch_size
is small. If the number of elements returned
is frequently less than the requested batch_size
, increasing the batch_size
will help.
NOTE: This function will return an error if the kernel doesn’t support batching or the map type is PerCPUArray.
fn lookup_and_delete_batch(
&self,
batch_size: u32,
next_key: Option<u32>
) -> XDPResult<BatchResult<K, MapValue<V>>>
[src]
&self,
batch_size: u32,
next_key: Option<u32>
) -> XDPResult<BatchResult<K, MapValue<V>>>
Lookup and delete a batch of elements from the underlying eBPF map. Returns a
BatchResult
that includes the next key to pass in to
continue looking up elements:
use rxdp::MapLike; let mut next_key = None; loop { let r = m.lookup_and_delete_batch(10u32, next_key).unwrap(); // do something with `r.items`... if r.next_key.is_none() { break; } next_key = r.next_key; }
NOTE: By design of the bpf kernel code, this may return anywhere from 0 - batch_size
elements, particularly when the batch_size
is small. If the number of elements returned
is frequently less than the requested batch_size
, increasing the batch_size
will help.
NOTE: This function will return an error if the kernel doesn’t support batching or the map type is PerCPUArray.
Implementors
impl<K: Default + Copy, V: ByteAligned> MapLike<K, V> for PerCpuMap<K, V>
[src]
fn update_batching_not_supported(&self) -> bool
[src]
fn map_fd(&self) -> i32
[src]
fn map_type(&self) -> MapType
[src]
fn max_entries(&self) -> u32
[src]
fn update(&self, key: &K, value: &V, flags: MapFlags) -> XDPResult<()>
[src]
fn lookup(&self, key: &K) -> XDPResult<MapValue<V>>
[src]
fn update_batch_impl(
&self,
keys: &mut Vec<K>,
values: &mut Vec<V>,
opts: &bpf_map_batch_opts
) -> (i32, u32)
[src]
&self,
keys: &mut Vec<K>,
values: &mut Vec<V>,
opts: &bpf_map_batch_opts
) -> (i32, u32)
fn lookup_batch_impl(
&self,
batch_size: u32,
next_key: Option<u32>,
delete: bool
) -> XDPResult<BatchResult<K, MapValue<V>>>
[src]
&self,
batch_size: u32,
next_key: Option<u32>,
delete: bool
) -> XDPResult<BatchResult<K, MapValue<V>>>
fn _items(&self) -> XDPResult<Vec<KeyValue<K, MapValue<V>>>>
[src]
fn items(&self) -> XDPResult<Vec<KeyValue<K, MapValue<V>>>>
[src]
impl<K: Default + Copy, V: Default> MapLike<K, V> for Map<K, V>
[src]
fn update_batching_not_supported(&self) -> bool
[src]
fn map_fd(&self) -> i32
[src]
fn map_type(&self) -> MapType
[src]
fn max_entries(&self) -> u32
[src]
fn lookup_batch_impl(
&self,
batch_size: u32,
next_key: Option<u32>,
delete: bool
) -> XDPResult<BatchResult<K, MapValue<V>>>
[src]
&self,
batch_size: u32,
next_key: Option<u32>,
delete: bool
) -> XDPResult<BatchResult<K, MapValue<V>>>