Skip to content

Libbpf userspace function bpf_map_get_fd_by_id

0.0.1

Low level wrapper around the BPF_MAP_GET_FD_BY_ID syscall command.

Definition

int bpf_map_get_fd_by_id(__u32 id);

Parameters

  • id: BPF map ID

Return

File descriptor of the BPF map with the given id, on success; negative error code, otherwise

Usage

This function returns the file descriptor of the BPF map with the given id. This causes the current process to hold a reference to the map, preventing the kernel from unloading it. The file descriptor should be closed with close when it is no longer needed.

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome