bpf: Allow skb_ancestor_cgroup_id helper in cgroup skb
authorAndrey Ignatov <rdna@fb.com>
Thu, 14 May 2020 20:03:46 +0000 (13:03 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 May 2020 01:41:07 +0000 (18:41 -0700)
cgroup skb programs already can use bpf_skb_cgroup_id. Allow
bpf_skb_ancestor_cgroup_id as well so that container policies can be
implemented for a container that can have sub-cgroups dynamically
created, but policies should still be implemented based on cgroup id of
container itself not on an id of a sub-cgroup.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/8874194d6041eba190356453ea9f6071edf5f658.1589486450.git.rdna@fb.com
net/core/filter.c

index 9c3eada5c86cf00e54df350d565056a6ac3b24ee..a47dc5b9dad4fbd74bc86654ab9e10ffa3a37627 100644 (file)
@@ -6157,6 +6157,8 @@ cg_skb_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 #ifdef CONFIG_SOCK_CGROUP_DATA
        case BPF_FUNC_skb_cgroup_id:
                return &bpf_skb_cgroup_id_proto;
+       case BPF_FUNC_skb_ancestor_cgroup_id:
+               return &bpf_skb_ancestor_cgroup_id_proto;
 #endif
 #ifdef CONFIG_INET
        case BPF_FUNC_sk_lookup_tcp: