From: Lorenz Bauer <lmb@cloudflare.com>
To: ast@kernel.org, yhs@fb.com, daniel@iogearbox.net,
jakub@cloudflare.com, john.fastabend@gmail.com
Cc: bpf@vger.kernel.org, kernel-team@cloudflare.com,
Lorenz Bauer <lmb@cloudflare.com>
Subject: [PATCH bpf-next v3 2/6] net: sockmap: Remove unnecessary sk_fullsock checks
Date: Fri, 4 Sep 2020 10:59:00 +0100 [thread overview]
Message-ID: <20200904095904.612390-3-lmb@cloudflare.com> (raw)
In-Reply-To: <20200904095904.612390-1-lmb@cloudflare.com>
The lookup paths for sockmap and sockhash currently include a check
that returns NULL if the socket we just found is not a full socket.
However, this check is not necessary. On insertion we ensure that
we have a full socket (caveat around sock_ops), so request sockets
are not a problem. Time-wait sockets are allocated separate from
the original socket and then fed into the hashdance. They don't
affect the sockets already stored in the sockmap.
Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
net/core/sock_map.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 078386d7d9a2..82494810d0ee 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -382,7 +382,7 @@ static void *sock_map_lookup(struct bpf_map *map, void *key)
struct sock *sk;
sk = __sock_map_lookup_elem(map, *(u32 *)key);
- if (!sk || !sk_fullsock(sk))
+ if (!sk)
return NULL;
if (sk_is_refcounted(sk) && !refcount_inc_not_zero(&sk->sk_refcnt))
return NULL;
@@ -1110,7 +1110,7 @@ static void *sock_hash_lookup(struct bpf_map *map, void *key)
struct sock *sk;
sk = __sock_hash_lookup_elem(map, key);
- if (!sk || !sk_fullsock(sk))
+ if (!sk)
return NULL;
if (sk_is_refcounted(sk) && !refcount_inc_not_zero(&sk->sk_refcnt))
return NULL;
--
2.25.1
next prev parent reply other threads:[~2020-09-04 9:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 9:58 [PATCH bpf-next v3 0/6] Sockmap iterator Lorenz Bauer
2020-09-04 9:58 ` [PATCH bpf-next v3 1/6] bpf: Allow passing BTF pointers as PTR_TO_SOCKET Lorenz Bauer
2020-09-06 22:40 ` Martin KaFai Lau
2020-09-07 8:57 ` Lorenz Bauer
2020-09-08 19:52 ` Martin KaFai Lau
2020-09-09 9:16 ` Lorenz Bauer
2020-09-09 15:42 ` Lorenz Bauer
2020-09-09 16:40 ` Martin KaFai Lau
2020-09-04 9:59 ` Lorenz Bauer [this message]
2020-09-04 9:59 ` [PATCH bpf-next v3 3/6] net: Allow iterating sockmap and sockhash Lorenz Bauer
2020-09-04 9:59 ` [PATCH bpf-next v3 4/6] selftests: bpf: Ensure that BTF sockets cannot be released Lorenz Bauer
2020-09-04 9:59 ` [PATCH bpf-next v3 5/6] selftests: bpf: Add helper to compare socket cookies Lorenz Bauer
2020-09-04 9:59 ` [PATCH bpf-next v3 6/6] 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=20200904095904.612390-3-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=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