Helper function bpf_get_cgroup_classid
Definition
Copyright (c) 2015 The Libbpf Authors. All rights reserved.
Retrieve the classid for the current task, i.e. for the net_cls cgroup to which skb belongs.
This helper can be used on TC egress path, but not on ingress.
The net_cls cgroup provides an interface to tag network packets based on a user-provided identifier for all traffic coming from the tasks belonging to the related cgroup. See also the related kernel documentation, available from the Linux sources in file Documentation/admin-guide/cgroup-v1/net_cls.rst.
The Linux kernel has two versions for cgroups: there are cgroups v1 and cgroups v2. Both are available to users, who can use a mixture of them, but note that the net_cls cgroup is for cgroup v1 only. This makes it incompatible with BPF programs run on cgroups, which is a cgroup-v2-only feature (a socket can only hold data for one version of cgroups at a time).
This helper is only available is the kernel was compiled with the CONFIG_CGROUP_NET_CLASSID configuration option set to "y" or to "m".
Returns
The classid, or 0 for the default unconfigured classid.
static __u32 (* const bpf_get_cgroup_classid)(struct __sk_buff *skb) = (void *) 17;
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Program types
This helper call can be used in the following program types:
BPF_PROG_TYPE_CGROUP_DEVICEv6.16BPF_PROG_TYPE_CGROUP_SKBv6.16BPF_PROG_TYPE_CGROUP_SOCKBPF_PROG_TYPE_CGROUP_SOCKOPTv6.16BPF_PROG_TYPE_CGROUP_SOCK_ADDRBPF_PROG_TYPE_CGROUP_SYSCTLv6.16BPF_PROG_TYPE_FLOW_DISSECTORv6.16BPF_PROG_TYPE_KPROBEv6.16BPF_PROG_TYPE_LSMv6.16BPF_PROG_TYPE_LWT_INBPF_PROG_TYPE_LWT_OUTBPF_PROG_TYPE_LWT_SEG6LOCALBPF_PROG_TYPE_LWT_XMITBPF_PROG_TYPE_NETFILTERv6.16BPF_PROG_TYPE_PERF_EVENTv6.16BPF_PROG_TYPE_RAW_TRACEPOINTv6.16BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLEv6.16BPF_PROG_TYPE_SCHED_ACTBPF_PROG_TYPE_SCHED_CLSBPF_PROG_TYPE_SK_LOOKUPv6.16BPF_PROG_TYPE_SK_MSGBPF_PROG_TYPE_SK_REUSEPORTv6.16BPF_PROG_TYPE_SK_SKBv6.16BPF_PROG_TYPE_SOCKET_FILTERv6.16BPF_PROG_TYPE_SOCK_OPSv6.16BPF_PROG_TYPE_STRUCT_OPSv6.16BPF_PROG_TYPE_SYSCALLv6.16BPF_PROG_TYPE_TRACEPOINTv6.16BPF_PROG_TYPE_TRACINGv6.16BPF_PROG_TYPE_XDPv6.16
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome