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.
Showing the changes to include/uapi/linux (1 of 5 files). Show all
Unified · Split
| @@ -226,6 +226,7 @@ enum bpf_attach_type { · 225 unmodified lines | |||
| 226 | BPF_CGROUP_INET4_GETSOCKNAME, | 226 | BPF_CGROUP_INET4_GETSOCKNAME, |
| 227 | BPF_CGROUP_INET6_GETSOCKNAME, | 227 | BPF_CGROUP_INET6_GETSOCKNAME, |
| 228 | BPF_XDP_DEVMAP, | 228 | BPF_XDP_DEVMAP, |
| 229 | BPF_CGROUP_INET_SOCK_RELEASE, | ||
| 229 | __MAX_BPF_ATTACH_TYPE | 230 | __MAX_BPF_ATTACH_TYPE |
| 230 | }; | 231 | }; |
| 231 | 232 | ||