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: 604326b41a ("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>
This commit is contained in:
John Fastabend 2018-10-29 12:31:28 -07:00 committed by Daniel Borkmann
parent b31d30d9be
commit 27b31e68bc
1 changed files with 1 additions and 0 deletions

View File

@ -145,6 +145,7 @@ msg_bytes_ready:
ret = err;
goto out;
}
copied = -EAGAIN;
}
ret = copied;
out: