]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: add bpf_skb_cgroup_id helper
authorDaniel Borkmann <daniel@iogearbox.net>
Sat, 2 Jun 2018 21:06:36 +0000 (23:06 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 3 Jun 2018 14:46:54 +0000 (07:46 -0700)
commit4281f15aa14bfc20108eeef6b74669195dd4c4bb
treec54c33ebf505b934a4f0f4dd6502da47245c6364
parent1f61e31bd6ab27913ad87c522b0f0691e6333091
bpf: add bpf_skb_cgroup_id helper

Add a new bpf_skb_cgroup_id() helper that allows to retrieve the
cgroup id from the skb's socket. This is useful in particular to
enable bpf_get_cgroup_classid()-like behavior for cgroup v1 in
cgroup v2 by allowing ID based matching on egress. This can in
particular be used in combination with applying policy e.g. from
map lookups, and also complements the older bpf_skb_under_cgroup()
interface. In user space the cgroup id for a given path can be
retrieved through the f_handle as demonstrated in [0] recently.

  [0] https://lkml.org/lkml/2018/5/22/1190

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
net/core/filter.c