Skip to content

Libbpf userspace function bpf_program__attach_netfilter

1.3.0

Attach a BPF_PROG_TYPE_NETFILTER program to a netfilter hook.

Definition

struct bpf_link * bpf_program__attach_netfilter(const struct bpf_program *prog, const struct bpf_netfilter_opts *opts);

Parameters

  • prog: BPF program to attach
  • opts: netfilter options

Return

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

struct bpf_netfilter_opts

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

    __u32 pf;
    __u32 hooknum;
    __s32 priority;
    __u32 flags;
};

pf

The protocol family of the hook.

hooknum

The hook number.

priority

The priority of the hook.

flags

The flags of the hook.

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