Skip to content

Libbpf userspace function bpf_btf_load

0.7.0

Low level wrapper around the BPF_BTF_LOAD syscall command.

Definition

int bpf_btf_load(const void *btf_data, size_t btf_size, struct bpf_btf_load_opts *opts);

Parameters

  • btf_data: pointer to the BTF data to load
  • btf_size: size of the BTF data
  • opts: options for the BTF load

struct bpf_btf_load_opts

struct bpf_btf_load_opts {
    size_t sz; /* size of this struct for forward/backward compatibility */

    /* kernel log options */
    char *log_buf;
    __u32 log_level;
    __u32 log_size;
    /* output: actual total log contents size (including terminating zero).
     * It could be both larger than original log_size (if log was
     * truncated), or smaller (if log buffer wasn't filled completely).
     * If kernel doesn't support this feature, log_size is left unchanged.
     */
    __u32 log_true_size;

    __u32 btf_flags;
    __u32 token_fd;
    size_t :0;
};

log_buf

0.7.0

log_level

0.7.0

log_size

0.7.0

log_true_size

1.2.0

btf_flags

1.4.0

token_fd

1.4.0

Usage

This function should only be used if you need precise control over the BTF loading process. For most cases, program should be loaded via bpf_object__load or similar high level APIs instead.

Example

Docs could be improved

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