From: Stanislav Fomichev <sdf@google.com>
To: netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net,
Stanislav Fomichev <sdf@google.com>
Subject: [PATCH bpf-next v3 0/4] bpf: add BPF_CGROUP_INET_SOCK_RELEASE hook
Date: Wed, 1 Jul 2020 13:13:03 -0700 [thread overview]
Message-ID: <20200701201307.855717-1-sdf@google.com> (raw)
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.
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 | 72 +++++++++++++++++++
tools/testing/selftests/bpf/progs/udp_limit.c | 42 +++++++++++
10 files changed, 132 insertions(+)
create mode 100644 tools/testing/selftests/bpf/prog_tests/udp_limit.c
create mode 100644 tools/testing/selftests/bpf/progs/udp_limit.c
--
2.27.0.212.ge8ba1cc988-goog
next reply other threads:[~2020-07-01 20:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 20:13 Stanislav Fomichev [this message]
2020-07-01 20:13 ` [PATCH bpf-next v3 1/4] bpf: add BPF_CGROUP_INET_SOCK_RELEASE hook Stanislav Fomichev
2020-07-01 20:13 ` [PATCH bpf-next v3 2/4] libbpf: add support for BPF_CGROUP_INET_SOCK_RELEASE Stanislav Fomichev
2020-07-01 20:13 ` [PATCH bpf-next v3 3/4] bpftool: " Stanislav Fomichev
2020-07-01 21:01 ` Andrii Nakryiko
2020-07-01 20:13 ` [PATCH bpf-next v3 4/4] selftests/bpf: test BPF_CGROUP_INET_SOCK_RELEASE Stanislav Fomichev
2020-07-01 21:01 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200701201307.855717-1-sdf@google.com \
--to=sdf@google.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).