From: Joanne Koong <joannekoong@fb.com>
To: <bpf@vger.kernel.org>
Cc: <kafai@fb.com>, <kpsingh@kernel.org>, <memxor@gmail.com>,
<ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<tj@kernel.org>, <davemarchevsky@fb.com>,
Joanne Koong <joannelkoong@gmail.com>
Subject: [PATCH bpf-next v3 2/2] selftests/bpf: Test for associating multiple elements with the local storage
Date: Thu, 17 Mar 2022 21:55:53 -0700 [thread overview]
Message-ID: <20220318045553.3091807-3-joannekoong@fb.com> (raw)
In-Reply-To: <20220318045553.3091807-1-joannekoong@fb.com>
From: Joanne Koong <joannelkoong@gmail.com>
This patch adds a few calls to the existing local storage selftest to
test that we can associate multiple elements with the local storage.
The sleepable program's call to bpf_sk_storage_get with sk_storage_map2
will lead to an allocation of a new selem under the GFP_KERNEL flag.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
.../selftests/bpf/progs/local_storage.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/local_storage.c b/tools/testing/selftests/bpf/progs/local_storage.c
index 9b1f9b75d5c2..19423ed862e3 100644
--- a/tools/testing/selftests/bpf/progs/local_storage.c
+++ b/tools/testing/selftests/bpf/progs/local_storage.c
@@ -36,6 +36,13 @@ struct {
__type(value, struct local_storage);
} sk_storage_map SEC(".maps");
+struct {
+ __uint(type, BPF_MAP_TYPE_SK_STORAGE);
+ __uint(map_flags, BPF_F_NO_PREALLOC | BPF_F_CLONE);
+ __type(key, int);
+ __type(value, struct local_storage);
+} sk_storage_map2 SEC(".maps");
+
struct {
__uint(type, BPF_MAP_TYPE_TASK_STORAGE);
__uint(map_flags, BPF_F_NO_PREALLOC);
@@ -115,7 +122,19 @@ int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address,
if (storage->value != DUMMY_STORAGE_VALUE)
sk_storage_result = -1;
+ /* This tests that we can associate multiple elements
+ * with the local storage.
+ */
+ storage = bpf_sk_storage_get(&sk_storage_map2, sock->sk, 0,
+ BPF_LOCAL_STORAGE_GET_F_CREATE);
+ if (!storage)
+ return 0;
+
err = bpf_sk_storage_delete(&sk_storage_map, sock->sk);
+ if (err)
+ return 0;
+
+ err = bpf_sk_storage_delete(&sk_storage_map2, sock->sk);
if (!err)
sk_storage_result = err;
--
2.30.2
next prev parent reply other threads:[~2022-03-18 4:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 4:55 [PATCH bpf-next v3 0/2] Enable non-atomic allocations in local storage Joanne Koong
2022-03-18 4:55 ` [PATCH bpf-next v3 1/2] bpf: " Joanne Koong
2022-03-18 4:55 ` Joanne Koong [this message]
2022-03-21 2:00 ` [PATCH bpf-next v3 0/2] " patchwork-bot+netdevbpf
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=20220318045553.3091807-3-joannekoong@fb.com \
--to=joannekoong@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davemarchevsky@fb.com \
--cc=joannelkoong@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=memxor@gmail.com \
--cc=tj@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