History

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.

Stanislav Fomichev committed 6 years ago

Commit f5836741 parent 4e489785 files · +12 −0Browse files

Showing the changes to include/uapi/linux (1 of 5 files). Show all

Unified · Split

include/uapi/linux/bpf.h+1−0
@@ -226,6 +226,7 @@ enum bpf_attach_type { · 225 unmodified lines
226226 BPF_CGROUP_INET4_GETSOCKNAME,
227227 BPF_CGROUP_INET6_GETSOCKNAME,
228228 BPF_XDP_DEVMAP,
229+ BPF_CGROUP_INET_SOCK_RELEASE,
229230 __MAX_BPF_ATTACH_TYPE
230231 };
231232