Libbpf userspace function bpf_prog_attach_opts
Low level wrapper around the BPF_PROG_ATTACH
syscall command.
Definition
int bpf_prog_attach_opts(int prog_fd, int target, enum bpf_attach_type type, const struct bpf_prog_attach_opts *opts);
Parameters
prog_fd
: BPF program file descriptortarget
: attach location file descriptor or ifindextype
: attach type for the BPF programopts
: options for configuring the attachment
struct bpf_prog_attach_opts
struct bpf_prog_attach_opts {
size_t sz; /* size of this struct for forward/backward compatibility */
__u32 flags;
union {
int replace_prog_fd;
int replace_fd;
};
int relative_fd;
__u32 relative_id;
__u64 expected_revision;
size_t :0;
};
flags
replace_prog_fd
replace_fd
relative_fd
relative_id
expected_revision
Return
0
, on success; negative error code, otherwise (errno
is also set to the error code)
Usage
Attaches the BPF program corresponding to prog_fd
to a target
which can represent a file descriptor or netdevice ifindex.
This function should only be used for specific program types that need to be attached via the BPF_PROG_ATTACH
syscall command and you need specific control over this process. In most cases, the bpf_program__attach
or specific bpf_program__attach_*
functions should be used instead.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome