Libbpf userspace function bpf_program__attach_tcx
Attach a BPF_PROG_TYPE_SCHED_CLS program to a network interface.
Definition
struct bpf_link * bpf_program__attach_tcx(const struct bpf_program *prog, int ifindex, const struct bpf_tcx_opts *opts);
Parameters
prog: BPF program to attachifindex: index of the network interface to attach the program toopts: options for the TC program
Return
Reference to the newly created BPF link; or NULL is returned on error, error code is stored in errno
struct bpf_tcx_opts
struct bpf_tcx_opts {
    /* size of this struct, for forward/backward compatibility */
    size_t sz;
    __u32 flags;
    __u32 relative_fd;
    __u32 relative_id;
    __u64 expected_revision;
    size_t :0;
};
flags
Flags to modify attachment behavior.
BPF_F_ID - If set, identify a relative object based on the ID in relative_id. Otherwise use the FD in relative_fd.
BPF_F_LINK - If set, the relative_fd/relative_id fields refer to links, not programs.
BPF_F_REPLACE - If set, replace the existing program/link with the relative one.
BPF_F_BEFORE - If set, add the new program/link before the relative one.
BPF_F_AFTER - If set, add the new program/link after the relative one.
relative_fd
File descriptor of the relative object.
relative_id
ID of the relative object.
expected_revision
The current BPF_PROG_QUERY / bpf_prog_query / bpf_prog_query_opts.
Usage
This function attaches a TC program via the BPF link interface. It is referred to as TCX to differentiate it from TC programs attached via bpf_tc_attach. The two methods are mutually exclusive. TCX is the newer and preferred method.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome