From: John Fastabend <john.fastabend@gmail.com>
To: daniel@iogearbox.net, ast@kernel.org
Cc: john.fastabend@gmail.com, netdev@vger.kernel.org
Subject: [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
Date: Mon, 29 Oct 2018 12:31:28 -0700 [thread overview]
Message-ID: <1540841488-22023-1-git-send-email-john.fastabend@gmail.com> (raw)
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
next reply other threads:[~2018-10-30 4:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 19:31 John Fastabend [this message]
2018-10-29 20:30 ` [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data John Fastabend
2018-10-29 22:13 ` Song Liu
2018-10-30 22:30 ` Daniel Borkmann
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=1540841488-22023-1-git-send-email-john.fastabend@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.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