From: Daniel Borkmann <daniel@iogearbox.net>
To: Stanislav Fomichev <sdf@google.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: davem@davemloft.net, ast@kernel.org,
Martin KaFai Lau <kafai@fb.com>, Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH bpf-next v4 0/4] bpf: support cloning sk storage on accept()
Date: Sat, 17 Aug 2019 23:32:41 +0200 [thread overview]
Message-ID: <21c14e84-472b-74ec-eec6-0117d40e54d2@iogearbox.net> (raw)
In-Reply-To: <20190814173751.31806-1-sdf@google.com>
On 8/14/19 7:37 PM, Stanislav Fomichev wrote:
> Currently there is no way to propagate sk storage from the listener
> socket to a newly accepted one. Consider the following use case:
>
> fd = socket();
> setsockopt(fd, SOL_IP, IP_TOS,...);
> /* ^^^ setsockopt BPF program triggers here and saves something
> * into sk storage of the listener.
> */
> listen(fd, ...);
> while (client = accept(fd)) {
> /* At this point all association between listener
> * socket and newly accepted one is gone. New
> * socket will not have any sk storage attached.
> */
> }
>
> Let's add new BPF_F_CLONE flag that can be specified when creating
> a socket storage map. This new flag indicates that map contents
> should be cloned when the socket is cloned.
>
> v4:
> * drop 'goto err' in bpf_sk_storage_clone (Yonghong Song)
> * add comment about race with bpf_sk_storage_map_free to the
> bpf_sk_storage_clone side as well (Daniel Borkmann)
>
> v3:
> * make sure BPF_F_NO_PREALLOC is always present when creating
> a map (Martin KaFai Lau)
> * don't call bpf_sk_storage_free explicitly, rely on
> sk_free_unlock_clone to do the cleanup (Martin KaFai Lau)
>
> v2:
> * remove spinlocks around selem_link_map/sk (Martin KaFai Lau)
> * BPF_F_CLONE on a map, not selem (Martin KaFai Lau)
> * hold a map while cloning (Martin KaFai Lau)
> * use BTF maps in selftests (Yonghong Song)
> * do proper cleanup selftests; don't call close(-1) (Yonghong Song)
> * export bpf_map_inc_not_zero
>
> Cc: Martin KaFai Lau <kafai@fb.com>
> Cc: Yonghong Song <yhs@fb.com>
>
> Stanislav Fomichev (4):
> bpf: export bpf_map_inc_not_zero
> bpf: support cloning sk storage on accept()
> bpf: sync bpf.h to tools/
> selftests/bpf: add sockopt clone/inheritance test
>
> include/linux/bpf.h | 2 +
> include/net/bpf_sk_storage.h | 10 +
> include/uapi/linux/bpf.h | 3 +
> kernel/bpf/syscall.c | 16 +-
> net/core/bpf_sk_storage.c | 104 ++++++-
> net/core/sock.c | 9 +-
> tools/include/uapi/linux/bpf.h | 3 +
> tools/testing/selftests/bpf/.gitignore | 1 +
> tools/testing/selftests/bpf/Makefile | 3 +-
> .../selftests/bpf/progs/sockopt_inherit.c | 97 +++++++
> .../selftests/bpf/test_sockopt_inherit.c | 253 ++++++++++++++++++
> 11 files changed, 491 insertions(+), 10 deletions(-)
> create mode 100644 tools/testing/selftests/bpf/progs/sockopt_inherit.c
> create mode 100644 tools/testing/selftests/bpf/test_sockopt_inherit.c
>
Applied, thanks!
prev parent reply other threads:[~2019-08-17 21:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-14 17:37 [PATCH bpf-next v4 0/4] bpf: support cloning sk storage on accept() Stanislav Fomichev
2019-08-14 17:37 ` [PATCH bpf-next v4 1/4] bpf: export bpf_map_inc_not_zero Stanislav Fomichev
2019-08-14 17:37 ` [PATCH bpf-next v4 2/4] bpf: support cloning sk storage on accept() Stanislav Fomichev
2019-08-14 17:37 ` [PATCH bpf-next v4 3/4] bpf: sync bpf.h to tools/ Stanislav Fomichev
2019-08-14 17:37 ` [PATCH bpf-next v4 4/4] selftests/bpf: add sockopt clone/inheritance test Stanislav Fomichev
2019-08-17 21:32 ` Daniel Borkmann [this message]
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=21c14e84-472b-74ec-eec6-0117d40e54d2@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=yhs@fb.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).