All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
@ 2018-10-29 19:31 John Fastabend
  2018-10-29 20:30 ` John Fastabend
  2018-10-30 22:30 ` Daniel Borkmann
  0 siblings, 2 replies; 4+ messages in thread
From: John Fastabend @ 2018-10-29 19:31 UTC (permalink / raw)
  To: daniel, ast; +Cc: john.fastabend, netdev

We return 0 in the case of a nonblocking socket that has no data
available. However, this is incorrect and may confuse applications.
After this patch we do the correct thing and return the error
EAGAIN.

Quoting return codes from recvmsg manpage,

EAGAIN or EWOULDBLOCK
 The socket is marked nonblocking and the receive operation would
 block, or a receive timeout had been set and the timeout expired
 before data was received.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 net/ipv4/tcp_bpf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index b7918d4..3b45fe5 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -145,6 +145,7 @@ int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 			ret = err;
 			goto out;
 		}
+		copied = -EAGAIN;
 	}
 	ret = copied;
 out:
-- 
1.9.1

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

* Re: [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
  2018-10-29 19:31 [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data John Fastabend
@ 2018-10-29 20:30 ` John Fastabend
  2018-10-29 22:13   ` Song Liu
  2018-10-30 22:30 ` Daniel Borkmann
  1 sibling, 1 reply; 4+ messages in thread
From: John Fastabend @ 2018-10-29 20:30 UTC (permalink / raw)
  To: daniel, ast; +Cc: netdev

On 10/29/2018 12:31 PM, John Fastabend wrote:
> We return 0 in the case of a nonblocking socket that has no data
> available. However, this is incorrect and may confuse applications.
> After this patch we do the correct thing and return the error
> EAGAIN.
> 
> Quoting return codes from recvmsg manpage,
> 
> EAGAIN or EWOULDBLOCK
>  The socket is marked nonblocking and the receive operation would
>  block, or a receive timeout had been set and the timeout expired
>  before data was received.
> 
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
> ---

Add fixes tag.

Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")

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

* Re: [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
  2018-10-29 20:30 ` John Fastabend
@ 2018-10-29 22:13   ` Song Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Song Liu @ 2018-10-29 22:13 UTC (permalink / raw)
  To: John Fastabend; +Cc: Daniel Borkmann, Alexei Starovoitov, Networking

On Mon, Oct 29, 2018 at 1:32 PM John Fastabend <john.fastabend@gmail.com> wrote:
>
> On 10/29/2018 12:31 PM, John Fastabend wrote:
> > We return 0 in the case of a nonblocking socket that has no data
> > available. However, this is incorrect and may confuse applications.
> > After this patch we do the correct thing and return the error
> > EAGAIN.
> >
> > Quoting return codes from recvmsg manpage,
> >
> > EAGAIN or EWOULDBLOCK
> >  The socket is marked nonblocking and the receive operation would
> >  block, or a receive timeout had been set and the timeout expired
> >  before data was received.
> >
> > Signed-off-by: John Fastabend <john.fastabend@gmail.com>

Acked-by: Song Liu <songliubraving@fb.com>

> > ---
>
> Add fixes tag.
>
> Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
>
>
>
>

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

* Re: [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
  2018-10-29 19:31 [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data John Fastabend
  2018-10-29 20:30 ` John Fastabend
@ 2018-10-30 22:30 ` Daniel Borkmann
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2018-10-30 22:30 UTC (permalink / raw)
  To: John Fastabend, ast; +Cc: netdev

On 10/29/2018 08:31 PM, John Fastabend wrote:
> We return 0 in the case of a nonblocking socket that has no data
> available. However, this is incorrect and may confuse applications.
> After this patch we do the correct thing and return the error
> EAGAIN.
> 
> Quoting return codes from recvmsg manpage,
> 
> EAGAIN or EWOULDBLOCK
>  The socket is marked nonblocking and the receive operation would
>  block, or a receive timeout had been set and the timeout expired
>  before data was received.
> 
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>

Applied to bpf, thanks!

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

end of thread, other threads:[~2018-10-31  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-29 19:31 [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data John Fastabend
2018-10-29 20:30 ` John Fastabend
2018-10-29 22:13   ` Song Liu
2018-10-30 22:30 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.