From: Lorenz Bauer <lmb@cloudflare.com>
To: ast@kernel.org, yhs@fb.com, daniel@iogearbox.net,
jakub@cloudflare.com, john.fastabend@gmail.com, kafai@fb.com
Cc: bpf@vger.kernel.org, kernel-team@cloudflare.com,
Lorenz Bauer <lmb@cloudflare.com>
Subject: [PATCH bpf-next v4 0/7] Sockmap iterator
Date: Mon, 7 Sep 2020 15:46:54 +0100 [thread overview]
Message-ID: <20200907144701.44867-1-lmb@cloudflare.com> (raw)
Martin pointed out that a struct sock pointer may not be a full socket.
It's therefore invalid to accept such a pointer in lieu of PTR_TO_SOCKET.
Instead, we can allow passing it instead of PTR_TO_SOCK_COMMON. The sockmap
helpers are then adjusted to accept PTR_TO_SOCK_COMMON. This requires no
changes to the sockmap code itself since it already checks for fullsocks.
Changes in v4:
- Alias struct sock* to PTR_TO_SOCK_COMMON instead of PTR_TO_SOCKET (Martin)
Changes in v3:
- Use PTR_TO_BTF_ID in iterator context (Yonghong, Martin)
- Use rcu_dereference instead of rcu_dereference_raw (Jakub)
- Fix various test nits (Jakub, Andrii)
Changes in v2:
- Remove unnecessary sk_fullsock checks (Jakub)
- Nits for test output (Jakub)
- Increase number of sockets in tests to 64 (Jakub)
- Handle ENOENT in tests (Jakub)
- Actually test SOCKHASH iteration (myself)
- Fix SOCKHASH iterator initialization (myself)
v1: https://lore.kernel.org/bpf/20200828094834.23290-1-lmb@cloudflare.com/
v2: https://lore.kernel.org/bpf/20200901103210.54607-1-lmb@cloudflare.com/
Lorenz Bauer (7):
bpf: Allow passing BTF pointers as PTR_TO_SOCK_COMMON
net: sockmap: Remove unnecessary sk_fullsock checks
net: Allow iterating sockmap and sockhash
bpf: sockmap: accept sock_common pointer when updating
selftests: bpf: Ensure that BTF sockets cannot be released
selftests: bpf: Add helper to compare socket cookies
selftests: bpf: Test copying a sockmap via bpf_iter
kernel/bpf/verifier.c | 63 ++--
net/core/sock_map.c | 284 +++++++++++++++++-
.../bpf/prog_tests/reference_tracking.c | 20 +-
.../selftests/bpf/prog_tests/sockmap_basic.c | 138 ++++++++-
tools/testing/selftests/bpf/progs/bpf_iter.h | 9 +
.../selftests/bpf/progs/bpf_iter_sockmap.c | 57 ++++
.../selftests/bpf/progs/bpf_iter_sockmap.h | 3 +
.../bpf/progs/test_sk_ref_track_invalid.c | 20 ++
8 files changed, 549 insertions(+), 45 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_sockmap.c
create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_sockmap.h
create mode 100644 tools/testing/selftests/bpf/progs/test_sk_ref_track_invalid.c
--
2.25.1
next reply other threads:[~2020-09-07 16:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 14:46 Lorenz Bauer [this message]
2020-09-07 14:46 ` [PATCH bpf-next v4 1/7] bpf: Allow passing BTF pointers as PTR_TO_SOCK_COMMON Lorenz Bauer
2020-09-09 5:07 ` Martin KaFai Lau
2020-09-07 14:46 ` [PATCH bpf-next v4 2/7] net: sockmap: Remove unnecessary sk_fullsock checks Lorenz Bauer
2020-09-07 14:46 ` [PATCH bpf-next v4 3/7] net: Allow iterating sockmap and sockhash Lorenz Bauer
2020-09-07 14:46 ` [PATCH bpf-next v4 4/7] bpf: sockmap: accept sock_common pointer when updating Lorenz Bauer
2020-09-07 14:46 ` [PATCH bpf-next v4 5/7] selftests: bpf: Ensure that BTF sockets cannot be released Lorenz Bauer
2020-09-07 14:47 ` [PATCH bpf-next v4 6/7] selftests: bpf: Add helper to compare socket cookies Lorenz Bauer
2020-09-07 14:47 ` [PATCH bpf-next v4 7/7] selftests: bpf: Test copying a sockmap via bpf_iter Lorenz Bauer
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=20200907144701.44867-1-lmb@cloudflare.com \
--to=lmb@cloudflare.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kernel-team@cloudflare.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