Libbpf userspace function bpf_map_lookup_and_delete_batch
Allows for batch lookup and deletion of BPF map elements where each element is deleted after being retrieved.
Definition
int bpf_map_lookup_and_delete_batch(int fd, void *in_batch, void *out_batch, void *keys, void *values, __u32 *count, const struct bpf_map_batch_opts *opts);
Parameters
fd: BPF map file descriptorin_batch: address of the first element in batch to read, can passNULLto get address of the first element inout_batch. If notNULL, must be large enough to hold a key. For BPF_MAP_TYPE_{HASH, PERCPU_HASH, LRU_HASH, LRU_PERCPU_HASH}, the memory size must be at least 4 bytes wide regardless of key size.out_batch: output parameter that should be passed to next call asin_batchkeys: pointer to an array ofcountkeysvalues: pointer to an array large enough forcountvaluescount: input and output parameter; on input it's the number of elements in the map to read and delete in batch; on output it represents the number of elements that were successfully read and deleted If a non-EFAULTerror code is returned and if the outputcountvalue is not equal to the inputcountvalue, up tocountelements may have been deleted. ifEFAULTis returned up tocountelements may have been deleted without being returned via thekeysandvaluesoutput parameters.opts: options for configuring the way the batch lookup and delete works
Return
0, on success; negative error code, otherwise (errno is also set to the error code)
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome