]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 29 Oct 2018 19:31:28 +0000 (12:31 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 30 Oct 2018 22:31:22 +0000 (23:31 +0100)
commit98bf2aaba37adf4e31b34f6a317ee5e732b7512a
treeefc8ca26473eb98d494b0ad3c01af4d5a54050f8
parent3496a4b2c334d3974b1aba2ef0e4d118508ee73a
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.

Fixes: eaf66302e456 ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/ipv4/tcp_bpf.c