Skip to content

Libbpf userspace function bpf_program__attach

0.0.7

This is a generic function for attaching a BPF program based on auto-detection of program type, attach type, and extra parameters, where applicable.

Definition

struct bpf_link * bpf_program__attach(const struct bpf_program *prog);

Parameters

  • prog: BPF program to attach

Return

Reference to the newly created BPF link; or NULL is returned on error, error code is stored in errno

Usage

This is supported for: - kprobe/kretprobe (depends on SEC definition) - uprobe/uretprobe (depends on SEC definition) - tracepoint - raw tracepoint - tracing programs (typed raw TP/fentry/fexit/fmod_ret)

Example

Docs could be improved

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