Skip to content

Libbpf userspace function bpf_prog_detach_opts

1.3.0

Detaches the BPF program corresponding to prog_fd from a target which can represent a file descriptor or netdevice ifindex.

Definition

int bpf_prog_detach_opts(int prog_fd, int target, enum bpf_attach_type type, const struct bpf_prog_detach_opts *opts);

Parameters

  • prog_fd: BPF program file descriptor
  • target: detach location file descriptor or ifindex
  • type: detach type for the BPF program
  • opts: options for configuring the detachment

struct bpf_prog_detach_opts

struct bpf_prog_detach_opts {
    size_t sz; /* size of this struct for forward/backward compatibility */
    __u32 flags;
    int relative_fd;
    __u32 relative_id;
    __u64 expected_revision;
    size_t :0;
};

flags

1.3.0

relative_fd

1.3.0

relative_id

1.3.0

expected_revision

1.3.0

Return

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

Usage

This function should only be used for specific program types that need to be detached via the BPF_PROG_DETACH syscall command and you need specific control over this process. In most cases, the bpf_link__detach or bpf_link__destroy function should be used.

Example

Docs could be improved

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