bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
Subsystems (4)
John Fastabend
maintainerPATCH 1/1 bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
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.
--- net/ipv4/tcp_bpf.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/tcp_bpf.c +1 -0
@@ -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:
Signature · 1 line
1.9.1
John Fastabend
maintainerQuoted 7 lines · John Fastabend
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,
Quoted 7 lines
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 <[email protected]>---
Add fixes tag.
Song Liu
Acked-byQuoted 7 lines · John Fastabend
Quoted 5 lines · John Fastabend
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.
Quoted 8 lines
Quoted 8 lines
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 <[email protected]>
Quoted 9 lines
Quoted 1 line
---
Add fixes tag.
Fixes 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
Daniel Borkmann
AppliedQuoted 5 lines · John Fastabend
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.
Quoted 8 lines
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 <[email protected]>
Applied to bpf, thanks!