Skip to content

Libbpf userspace function bpf_program__attach_tracepoint_opts

0.5.0

Attach a BPF_PROG_TYPE_TRACEPOINT program. Like bpf_program__attach_tracepoint, but with additional options.

Definition

struct bpf_link * bpf_program__attach_tracepoint_opts(const struct bpf_program *prog, const char *tp_category, const char *tp_name, const struct bpf_tracepoint_opts *opts);

Parameters

  • prog: BPF program to attach
  • tp_category: Tracepoint category
  • tp_name: Tracepoint name
  • opts: Tracepoint options

Return

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

struct bpf_tracepoint_opts

struct bpf_tracepoint_opts {
    /* size of this struct, for forward/backward compatibility */
    size_t sz;
    /* custom user-provided value fetchable through bpf_get_attach_cookie() */
    __u64 bpf_cookie;
};

0.5.0

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