diff options
author | Andrey Ignatov <rdna@fb.com> | 2020-05-14 13:03:47 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-05-14 18:41:07 -0700 |
commit | f307fa2cb4c935f7f1ff0aeb880c7b44fb9a642b (patch) | |
tree | dce575da97bf84e2fc907274202d228f8aa1a6c6 /tools/testing/selftests/bpf/network_helpers.h | |
parent | 06d3e4c9f11afc849dc201ecf9ef7a43eeb1dddd (diff) | |
download | linux-f307fa2cb4c935f7f1ff0aeb880c7b44fb9a642b.tar.bz2 |
bpf: Introduce bpf_sk_{, ancestor_}cgroup_id helpers
With having ability to lookup sockets in cgroup skb programs it becomes
useful to access cgroup id of retrieved sockets so that policies can be
implemented based on origin cgroup of such socket.
For example, a container running in a cgroup can have cgroup skb ingress
program that can lookup peer socket that is sending packets to a process
inside the container and decide whether those packets should be allowed
or denied based on cgroup id of the peer.
More specifically such ingress program can implement intra-host policy
"allow incoming packets only from this same container and not from any
other container on same host" w/o relying on source IP addresses since
quite often it can be the case that containers share same IP address on
the host.
Introduce two new helpers for this use-case: bpf_sk_cgroup_id() and
bpf_sk_ancestor_cgroup_id().
These helpers are similar to existing bpf_skb_{,ancestor_}cgroup_id
helpers with the only difference that sk is used to get cgroup id
instead of skb, and share code with them.
See documentation in UAPI for more details.
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/f5884981249ce911f63e9b57ecd5d7d19154ff39.1589486450.git.rdna@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/network_helpers.h')
0 files changed, 0 insertions, 0 deletions