Skip to content

Libbpf userspace function bpf_token_create

1.4.0

Creates a new instance of BPF token derived from specified BPF file system mount point. A wrapper around the BPF_TOKEN_CREATE syscall command.

Definition

int bpf_token_create(int bpffs_fd, struct bpf_token_create_opts *opts);

Parameters

  • bpffs_fd: FD for BPF FS instance from which to derive a BPF token instance.
  • opts: optional BPF token creation options, can be NULL

Return

BPF token FD > 0, on success; negative error code, otherwise (errno is also set to the error code)

struct bpf_token_create_opts

struct bpf_token_create_opts {
    size_t sz; /* size of this struct for forward/backward compatibility */
    __u32 flags;
    size_t :0;
};

Usage

BPF token created with this API can be passed to BPF syscall for commands like BPF_PROG_LOAD, BPF_MAP_CREATE, etc.

Example

Docs could be improved

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