From: Daniel Borkmann <daniel@iogearbox.net>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Stanislav Fomichev <sdf@google.com>
Cc: Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH bpf-next v4 1/4] bpf: add BPF_CGROUP_INET_SOCK_RELEASE hook
Date: Tue, 7 Jul 2020 23:41:57 +0200 [thread overview]
Message-ID: <073ac0af-5de7-0a61-4e11-e4ca292f6456@iogearbox.net> (raw)
In-Reply-To: <CAEf4Bzb=vHUC2dgxNEE2fvCZrk9+crmZAp+6kb5U1wLF293cHQ@mail.gmail.com>
On 7/7/20 1:42 AM, Andrii Nakryiko wrote:
> On Mon, Jul 6, 2020 at 4:02 PM Stanislav Fomichev <sdf@google.com> wrote:
>>
>> Implement BPF_CGROUP_INET_SOCK_RELEASE hook that triggers
>> on inet socket release. It triggers only for userspace
>> sockets, the same semantics as existing BPF_CGROUP_INET_SOCK_CREATE.
>>
>> The only questionable part here is the sock->sk check
>> in the inet_release. Looking at the places where we
>> do 'sock->sk = NULL', I don't understand how it can race
>> with inet_release and why the check is there (it's been
>> there since the initial git import). Otherwise, the
>> change itself is pretty simple, we add a BPF hook
>> to the inet_release and avoid calling it for kernel
>> sockets.
>>
>> Signed-off-by: Stanislav Fomichev <sdf@google.com>
>> ---
>> 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 +++
>> 5 files changed, 12 insertions(+)
>>
>
> Looks good overall, but I have no idea about sock->sk NULL case.
+1, looks good & very useful hook. For the sock->sk NULL case here's a related
discussion on why it's needed [0].
[0] https://lore.kernel.org/netdev/20190221221356.173485-1-ebiggers@kernel.org/
> Acked-by: Andrii Nakryiko <andriin@fb.com>
>
>> diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
>> index c66c545e161a..2c6f26670acc 100644
>> --- a/include/linux/bpf-cgroup.h
>> +++ b/include/linux/bpf-cgroup.h
>
> [...]
>
next prev parent reply other threads:[~2020-07-07 21:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 23:01 [PATCH bpf-next v4 0/4] bpf: add BPF_CGROUP_INET_SOCK_RELEASE hook Stanislav Fomichev
2020-07-06 23:01 ` [PATCH bpf-next v4 1/4] " Stanislav Fomichev
2020-07-06 23:42 ` Andrii Nakryiko
2020-07-07 21:41 ` Daniel Borkmann [this message]
2020-07-07 23:43 ` Stanislav Fomichev
2020-07-07 23:56 ` Daniel Borkmann
2020-07-07 23:59 ` Stanislav Fomichev
2020-07-06 23:01 ` [PATCH bpf-next v4 2/4] libbpf: add support for BPF_CGROUP_INET_SOCK_RELEASE Stanislav Fomichev
2020-07-06 23:01 ` [PATCH bpf-next v4 3/4] bpftool: " Stanislav Fomichev
2020-07-06 23:01 ` [PATCH bpf-next v4 4/4] selftests/bpf: test BPF_CGROUP_INET_SOCK_RELEASE Stanislav Fomichev
2020-07-06 23:39 ` Andrii Nakryiko
2020-07-07 21:44 ` Daniel Borkmann
2020-07-07 21:58 ` 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=073ac0af-5de7-0a61-4e11-e4ca292f6456@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
/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).