bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: jakub.kicinski@netronome.com, ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, edumazet@google.com,
	john.fastabend@gmail.com, bpf@vger.kernel.org
Subject: [bpf PATCH v2 5/6] bpf: sockmap, only create entry if ulp is not already enabled
Date: Mon, 08 Jul 2019 19:15:01 +0000	[thread overview]
Message-ID: <156261330105.31108.1927837989210591684.stgit@ubuntu3-kvm1> (raw)
In-Reply-To: <156261310104.31108.4569969631798277807.stgit@ubuntu3-kvm1>

Sockmap does not currently support adding sockets after TLS has been
enabled. There never was a real use case for this so it was never
added. But, we lost the test for ULP at some point so add it here
and fail the socket insert if TLS is enabled. Future work could
make sockmap support this use case but fixup the bug here.

Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 net/core/sock_map.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 56bcabe7c2f2..1330a7442e5b 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -334,6 +334,7 @@ static int sock_map_update_common(struct bpf_map *map, u32 idx,
 				  struct sock *sk, u64 flags)
 {
 	struct bpf_stab *stab = container_of(map, struct bpf_stab, map);
+	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct sk_psock_link *link;
 	struct sk_psock *psock;
 	struct sock *osk;
@@ -344,6 +345,8 @@ static int sock_map_update_common(struct bpf_map *map, u32 idx,
 		return -EINVAL;
 	if (unlikely(idx >= map->max_entries))
 		return -E2BIG;
+	if (unlikely(icsk->icsk_ulp_data))
+		return -EINVAL;
 
 	link = sk_psock_init_link();
 	if (!link)


  parent reply	other threads:[~2019-07-08 19:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 19:13 [bpf PATCH v2 0/6] bpf: sockmap/tls fixes John Fastabend
2019-07-08 19:13 ` [bpf PATCH v2 1/6] tls: remove close callback sock unlock/lock and flush_sync John Fastabend
2019-07-08 19:14 ` [bpf PATCH v2 2/6] bpf: tls fix transition through disconnect with close John Fastabend
2019-07-10  2:45   ` Jakub Kicinski
2019-07-10  3:39     ` John Fastabend
2019-07-10 19:34       ` Jakub Kicinski
2019-07-10 20:04         ` Jakub Kicinski
2019-07-11 16:47           ` John Fastabend
2019-07-11 18:32             ` Jakub Kicinski
2019-07-11 21:25               ` John Fastabend
2019-07-12  3:16                 ` Jakub Kicinski
2019-07-15 20:58                   ` John Fastabend
2019-07-11 16:35         ` John Fastabend
2019-07-08 19:14 ` [bpf PATCH v2 3/6] bpf: sockmap, sock_map_delete needs to use xchg John Fastabend
2019-07-08 19:14 ` [bpf PATCH v2 4/6] bpf: sockmap, synchronize_rcu before free'ing map John Fastabend
2019-07-08 19:15 ` John Fastabend [this message]
2019-07-08 19:15 ` [bpf PATCH v2 6/6] bpf: sockmap/tls, close can race with map free John Fastabend
2019-07-10  2:36   ` Jakub Kicinski
2019-07-10  2:38   ` Jakub Kicinski
2019-07-10  3:33     ` John Fastabend
2019-07-10 19:35       ` Jakub Kicinski
2019-07-11 16:39         ` John Fastabend
2019-07-09  6:13 ` [bpf PATCH v2 0/6] bpf: sockmap/tls fixes Jakub Kicinski
2019-07-09 15:40   ` John Fastabend
2019-07-10  0:04     ` Jakub Kicinski
2019-07-10  2:21       ` Jakub Kicinski
2019-07-10  3:28         ` John Fastabend

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=156261330105.31108.1927837989210591684.stgit@ubuntu3-kvm1 \
    --to=john.fastabend@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=edumazet@google.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).