netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bpf PATCH] net: tcp_bpf, correctly handle DONT_WAIT flags and timeo == 0
@ 2019-05-14  4:42 John Fastabend
  2019-05-15 23:42 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: John Fastabend @ 2019-05-14  4:42 UTC (permalink / raw)
  To: ast, daniel; +Cc: netdev, bpf, john.fastabend

The tcp_bpf_wait_data() routine needs to check timeo != 0 before
calling sk_wait_event() otherwise we may see unexpected stalls
on receiver.

Arika did all the leg work here I just formaatted, posted and ran
a few tests.

Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
Reported-by: Arika Chen <eaglesora@gmail.com>
Suggested-by: Arika Chen <eaglesora@gmail.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 net/ipv4/tcp_bpf.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 1bb7321a256d..27206b2064db 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -27,7 +27,10 @@ static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock,
 			     int flags, long timeo, int *err)
 {
 	DEFINE_WAIT_FUNC(wait, woken_wake_function);
-	int ret;
+	int ret = 0;
+
+	if (!timeo)
+		return ret;
 
 	add_wait_queue(sk_sleep(sk), &wait);
 	sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [bpf PATCH] net: tcp_bpf, correctly handle DONT_WAIT flags and timeo == 0
  2019-05-14  4:42 [bpf PATCH] net: tcp_bpf, correctly handle DONT_WAIT flags and timeo == 0 John Fastabend
@ 2019-05-15 23:42 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2019-05-15 23:42 UTC (permalink / raw)
  To: John Fastabend, ast; +Cc: netdev, bpf

On 05/14/2019 06:42 AM, John Fastabend wrote:
> The tcp_bpf_wait_data() routine needs to check timeo != 0 before
> calling sk_wait_event() otherwise we may see unexpected stalls
> on receiver.
> 
> Arika did all the leg work here I just formaatted, posted and ran
> a few tests.
> 
> Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
> Reported-by: Arika Chen <eaglesora@gmail.com>
> Suggested-by: Arika Chen <eaglesora@gmail.com>
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-16  1:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14  4:42 [bpf PATCH] net: tcp_bpf, correctly handle DONT_WAIT flags and timeo == 0 John Fastabend
2019-05-15 23:42 ` Daniel Borkmann

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).