Libbpf userspace function bpf_map__get_next_key
allows to iterate BPF map keys by fetching next key that follows current key.
Definition
int bpf_map__get_next_key(const struct bpf_map *map, const void *cur_key, void *next_key, size_t key_sz);
Parameters
map
: BPF map to fetch next key fromcur_key
: pointer to memory containing bytes of current key orNULL
to fetch the first keynext_key
: pointer to memory to write next key intokey_sz
: size in bytes of key data, needs to match BPF map definition'skey_size
Return
0
, on success; -ENOENT
if cur_key
is the last key in BPF map; negative error, otherwise
Usage
bpf_map__get_next_key()
is high-level equivalent of bpf_map_get_next_key()
API with added check for key size.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome