]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Add BPF_CGROUP_INET_SOCK_RELEASE hook
authorStanislav Fomichev <sdf@google.com>
Mon, 6 Jul 2020 23:01:25 +0000 (16:01 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 7 Jul 2020 23:03:31 +0000 (01:03 +0200)
commit3c469420fc3d56570c59ca446d90b324c0d203f8
tree44335764c2ebba2099ba8bf26267bdfac7c36ed1
parentdf19dcb7b3f6052a46a7fd8c84122d2c3aab6acf
bpf: Add BPF_CGROUP_INET_SOCK_RELEASE hook

Sometimes it's handy to know when the socket gets freed. In
particular, we'd like to try to use a smarter allocation of
ports for bpf_bind and explore the possibility of limiting
the number of SOCK_DGRAM sockets the process can have.

Implement BPF_CGROUP_INET_SOCK_RELEASE hook that triggers on
inet socket release. It triggers only for userspace sockets
(not in-kernel ones) and therefore has the same semantics as
the existing BPF_CGROUP_INET_SOCK_CREATE.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200706230128.4073544-2-sdf@google.com
include/linux/bpf-cgroup.h
include/uapi/linux/bpf.h
kernel/bpf/syscall.c
net/core/filter.c
net/ipv4/af_inet.c