Libbpf userspace function bpf_program__attach_trace_opts
Attach a BPF_PROG_TYPE_TRACING
program. Like bpf_program__attach_trace
, but with additional options.
Definition
struct bpf_link * bpf_program__attach_trace_opts(const struct bpf_program *prog, const struct bpf_trace_opts *opts);
Parameters
prog
: BPF program to attachopts
: Trace options
Return
Reference to the newly created BPF link; or NULL
is returned on error, error code is stored in errno
struct bpf_trace_opts
struct bpf_trace_opts {
/* size of this struct, for forward/backward compatibility */
size_t sz;
/* custom user-provided value fetchable through bpf_get_attach_cookie() */
__u64 cookie;
};
cookie
Custom user-provided value fetchable through bpf_get_attach_cookie
. This allows you to write one program, load it once, and then attach it to multiple perf events with different bpf_cookie
values, allowing the program to detect which event it is attached to.
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome