public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, davem@davemloft.net
Cc: netdev@vger.kernel.org, john.fastabend@gmail.com
Subject: [net-next PATCH 7/9] bpf: sockmap indicate sock events to listeners
Date: Mon, 28 Aug 2017 07:12:01 -0700	[thread overview]
Message-ID: <20170828141201.14143.84669.stgit@john-Precision-Tower-5810> (raw)
In-Reply-To: <20170828140850.14143.83953.stgit@john-Precision-Tower-5810>

After userspace pushes sockets into a sockmap it may not be receiving
data (assuming stream_{parser|verdict} programs are attached). But, it
may still want to manage the socks. A common pattern is to poll/select
for a POLLRDHUP event so we can close the sock.

This patch adds the logic to wake up these listeners.

Also add TCP_SYN_SENT to the list of events to handle. We don't want
to break the connection just because we happen to be in this state.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 kernel/bpf/sockmap.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index 38bf4e4..bcc326a 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -162,6 +162,7 @@ static void smap_state_change(struct sock *sk)
 {
 	struct smap_psock_map_entry *e, *tmp;
 	struct smap_psock *psock;
+	struct socket_wq *wq;
 	struct sock *osk;
 
 	rcu_read_lock();
@@ -171,6 +172,7 @@ static void smap_state_change(struct sock *sk)
 	 * is established.
 	 */
 	switch (sk->sk_state) {
+	case TCP_SYN_SENT:
 	case TCP_SYN_RECV:
 	case TCP_ESTABLISHED:
 		break;
@@ -208,6 +210,10 @@ static void smap_state_change(struct sock *sk)
 		smap_report_sk_error(psock, EPIPE);
 		break;
 	}
+
+	wq = rcu_dereference(sk->sk_wq);
+	if (skwq_has_sleeper(wq))
+		wake_up_interruptible_all(&wq->wait);
 	rcu_read_unlock();
 }
 

  parent reply	other threads:[~2017-08-28 14:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 14:09 [net-next PATCH 0/9] sockmap UAPI updates and fixes John Fastabend
2017-08-28 14:10 ` [net-next PATCH 1/9] bpf: convert sockmap field attach_bpf_fd2 to type John Fastabend
2017-08-28 17:22   ` Alexei Starovoitov
2017-08-28 14:10 ` [net-next PATCH 2/9] bpf: sockmap, remove STRPARSER map_flags and add multi-map support John Fastabend
2017-08-28 17:31   ` Alexei Starovoitov
2017-08-28 14:10 ` [net-next PATCH 3/9] bpf: sockmap add missing rcu_read_(un)lock in smap_data_ready John Fastabend
2017-08-28 14:11 ` [net-next PATCH 4/9] bpf: additional sockmap self tests John Fastabend
2017-08-28 17:36   ` Alexei Starovoitov
2017-08-28 14:11 ` [net-next PATCH 5/9] bpf: more SK_SKB selftests John Fastabend
2017-08-28 17:38   ` Alexei Starovoitov
2017-08-28 14:11 ` [net-next PATCH 6/9] bpf: harden sockmap program attach to ensure correct map type John Fastabend
2017-08-28 17:33   ` Alexei Starovoitov
2017-08-28 14:12 ` John Fastabend [this message]
2017-08-28 14:12 ` [net-next PATCH 8/9] bpf: sockmap requires STREAM_PARSER add Kconfig entry John Fastabend
2017-08-28 17:34   ` Alexei Starovoitov
2017-08-28 14:12 ` [net-next PATCH 9/9] bpf: test_maps add sockmap stress test John Fastabend
2017-08-28 18:13 ` [net-next PATCH 0/9] sockmap UAPI updates and fixes David Miller

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=20170828141201.14143.84669.stgit@john-Precision-Tower-5810 \
    --to=john.fastabend@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --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