OSDN Git Service

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)
commitcb20b08ead401fd17627a36f035c0bf5bfee5567
treec54c33ebf505b934a4f0f4dd6502da47245c6364
parent09772d92cd5ad998b0d5f6f46cd1658f8cb698cf
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