https://github.com/torvalds/linux
Revision 2c7269b231194aae23fb90ab65842573a91acbc9 authored by Sabrina Dubroca on 10 June 2020, 10:19:43 UTC, committed by Alexei Starovoitov on 12 June 2020, 22:10:12 UTC
If the peer is closed, we will never get more data, so
tcp_bpf_wait_data will get stuck forever. In case we passed
MSG_DONTWAIT to recv(), we get EAGAIN but we should actually get
0.

>From man 2 recv:

    RETURN VALUE

    When a stream socket peer has performed an orderly shutdown, the
    return value will be 0 (the traditional "end-of-file" return).

This patch makes tcp_bpf_wait_data always return 1 when the peer
socket has been shutdown. Either we have data available, and it would
have returned 1 anyway, or there isn't, in which case we'll call
tcp_recvmsg which does the right thing in this situation.

Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/26038a28c21fea5d04d4bd4744c5686d3f2e5504.1591784177.git.sd@queasysnail.net
1 parent 2c4779e
History
Tip revision: 2c7269b231194aae23fb90ab65842573a91acbc9 authored by Sabrina Dubroca on 10 June 2020, 10:19:43 UTC
bpf: tcp: Recv() should return 0 when the peer socket is closed
Tip revision: 2c7269b
File Mode Size
Kconfig -rw-r--r-- 3.9 KB
Makefile -rw-r--r-- 775 bytes
dsa.c -rw-r--r-- 10.6 KB
dsa2.c -rw-r--r-- 18.7 KB
dsa_priv.h -rw-r--r-- 6.0 KB
master.c -rw-r--r-- 9.5 KB
port.c -rw-r--r-- 18.3 KB
slave.c -rw-r--r-- 51.7 KB
switch.c -rw-r--r-- 10.0 KB
tag_8021q.c -rw-r--r-- 14.7 KB
tag_ar9331.c -rw-r--r-- 2.4 KB
tag_brcm.c -rw-r--r-- 6.6 KB
tag_dsa.c -rw-r--r-- 3.7 KB
tag_edsa.c -rw-r--r-- 4.3 KB
tag_gswip.c -rw-r--r-- 2.8 KB
tag_ksz.c -rw-r--r-- 6.6 KB
tag_lan9303.c -rw-r--r-- 4.2 KB
tag_mtk.c -rw-r--r-- 3.4 KB
tag_ocelot.c -rw-r--r-- 10.7 KB
tag_qca.c -rw-r--r-- 2.9 KB
tag_sja1105.c -rw-r--r-- 9.8 KB
tag_trailer.c -rw-r--r-- 2.1 KB

back to top