Libbpf userspace function bpf_prog_get_fd_by_id
Low level wrapper around the BPF_PROG_GET_FD_BY_ID
syscall command.
Definition
int bpf_prog_get_fd_by_id(__u32 id);
Parameters
id
: BPF program ID
Return
>0
, a file descriptor for the BPF program; negative error code, otherwise
Usage
This function returns a file descriptor for a BPF program by its ID. This causes the current process to hold a reference to the BPF program, 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