bpf: Add classid helper only based on skb->sk
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 30 Sep 2020 15:18:15 +0000 (17:18 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 30 Sep 2020 18:50:34 +0000 (11:50 -0700)
commitb426ce83baa7dff947fb354118d3133f2953aac8
tree7d64f878329748f97202001f7b9a53f0a43f234c
parent963ec27a10fa6dc700c0465e95965c0bf696a606
bpf: Add classid helper only based on skb->sk

Similarly to 5a52ae4e32a6 ("bpf: Allow to retrieve cgroup v1 classid
from v2 hooks"), add a helper to retrieve cgroup v1 classid solely
based on the skb->sk, so it can be used as key as part of BPF map
lookups out of tc from host ns, in particular given the skb->sk is
retained these days when crossing net ns thanks to 9c4c325252c5
("skbuff: preserve sock reference when scrubbing the skb."). This
is similar to bpf_skb_cgroup_id() which implements the same for v2.
Kubernetes ecosystem is still operating on v1 however, hence net_cls
needs to be used there until this can be dropped in with the v2
helper of bpf_skb_cgroup_id().

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/ed633cf27a1c620e901c5aa99ebdefb028dce600.1601477936.git.daniel@iogearbox.net
include/uapi/linux/bpf.h
net/core/filter.c
tools/include/uapi/linux/bpf.h