Trait rxdp::MapLike[][src]

pub trait MapLike<K, V: Default> {
    fn map_fd(&self) -> i32;
fn map_type(&self) -> MapType;
fn max_entries(&self) -> u32;
fn items(&self) -> XDPResult<Vec<KeyValue<K, MapValue<V>>>>; fn lookup(&self, key: &K) -> XDPResult<MapValue<V>> { ... }
fn update(&self, key: &K, value: &V, flags: MapFlags) -> XDPResult<()> { ... }
fn delete(&self, key: &K) -> XDPResult<()> { ... }
fn update_batch(
        &self,
        keys: &mut Vec<K>,
        values: &mut Vec<V>,
        flags: MapFlags
    ) -> XDPResult<u32> { ... }
fn lookup_batch(
        &self,
        batch_size: u32,
        next_key: Option<u32>
    ) -> XDPResult<BatchResult<K, MapValue<V>>> { ... }
fn lookup_and_delete_batch(
        &self,
        batch_size: u32,
        next_key: Option<u32>
    ) -> XDPResult<BatchResult<K, MapValue<V>>> { ... } }

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.

Loading content...

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]

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]

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]

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.

Loading content...

Implementors

impl<K: Default + Copy, V: ByteAligned> MapLike<K, V> for PerCpuMap<K, V>[src]

impl<K: Default + Copy, V: Default> MapLike<K, V> for Map<K, V>[src]

Loading content...