Skip to content

bpf: add BPF_CGROUP_INET_SOCK_RELEASE hook

Stanislav Fomichev bpf netdev 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 8 repliesIn review
  2. v34 patches 2 repliesSuperseded
  3. v24 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches5 repliesSuperseded

Changes in v4 from the cover letter

* initialize global BPF vars (Andrii Nakryiko)
* simplify error handling (Andrii Nakryiko)

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4bpf: add BPF_CGROUP_INET_SOCK_RELEASE hookinclude/linux/bpf-cgroup.h include/uapi/linux/bpf.h kernel/bpf/syscall.c +2 more+12 -05 replies
2/4libbpf: add support for BPF_CGROUP_INET_SOCK_RELEASEtools/include/uapi/linux/bpf.h tools/lib/bpf/libbpf.c+5 -00 replies
3/4bpftool: add support for BPF_CGROUP_INET_SOCK_RELEASEtools/bpf/bpftool/common.c+1 -00 replies
4/4selftests/bpf: test BPF_CGROUP_INET_SOCK_RELEASEtools/testing/selftests/bpf/prog_tests/udp_limit.c tools/testing/selftests/bpf/progs/udp_limit.c+117 -03 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchAndrii Nakryiko
1/4A-b
2/4A-b
3/4A-b
4/4A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH bpf-next v4 0/4] 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.

There is already existing BPF_CGROUP_INET_SOCK_CREATE hook that triggers upon socket creation; let's add new hook (BPF_CGROUP_INET_SOCK_RELEASE) that triggers on socket release.

v4:
* initialize global BPF vars (Andrii Nakryiko)
* simplify error handling (Andrii Nakryiko)

v3:
* s/CHECK_FAIL/CHECK/ (Andrii Nakryiko)
* s/bpf_prog_attach/bpf_program__attach_cgroup/ (Andrii Nakryiko)
* fix &in_use in BPF program (Andrii Nakryiko)

v2:
* fix compile issue with CONFIG_CGROUP_BPF=n (kernel test robot)

Stanislav Fomichev (4):
bpf: add BPF_CGROUP_INET_SOCK_RELEASE hook
libbpf: add support for BPF_CGROUP_INET_SOCK_RELEASE
bpftool: add support for BPF_CGROUP_INET_SOCK_RELEASE selftests/bpf: test BPF_CGROUP_INET_SOCK_RELEASE

 include/linux/bpf-cgroup.h                    |  4 +
 include/uapi/linux/bpf.h                      |  1 +
 kernel/bpf/syscall.c                          |  3 +
 net/core/filter.c                             |  1 +
 net/ipv4/af_inet.c                            |  3 +
 tools/bpf/bpftool/common.c                    |  1 +
 tools/include/uapi/linux/bpf.h                |  1 +
 tools/lib/bpf/libbpf.c                        |  4 +
 .../selftests/bpf/prog_tests/udp_limit.c      | 75 +++++++++++++++++++
 tools/testing/selftests/bpf/progs/udp_limit.c | 42 +++++++++++
 10 files changed, 135 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/udp_limit.c
 create mode 100644 tools/testing/selftests/bpf/progs/udp_limit.c
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog