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-- 654 bytes
Makefile -rw-r--r-- 241 bytes
af_smc.c -rw-r--r-- 53.3 KB
smc.h -rw-r--r-- 7.9 KB
smc_cdc.c -rw-r--r-- 13.5 KB
smc_cdc.h -rw-r--r-- 8.3 KB
smc_clc.c -rw-r--r-- 18.2 KB
smc_clc.h -rw-r--r-- 7.2 KB
smc_close.c -rw-r--r-- 12.2 KB
smc_close.h -rw-r--r-- 759 bytes
smc_core.c -rw-r--r-- 51.9 KB
smc_core.h -rw-r--r-- 13.0 KB
smc_diag.c -rw-r--r-- 7.4 KB
smc_ib.c -rw-r--r-- 17.3 KB
smc_ib.h -rw-r--r-- 3.2 KB
smc_ism.c -rw-r--r-- 9.8 KB
smc_ism.h -rw-r--r-- 1.5 KB
smc_llc.c -rw-r--r-- 51.5 KB
smc_llc.h -rw-r--r-- 3.6 KB
smc_netns.h -rw-r--r-- 342 bytes
smc_pnet.c -rw-r--r-- 25.7 KB
smc_pnet.h -rw-r--r-- 1.3 KB
smc_rx.c -rw-r--r-- 11.6 KB
smc_rx.h -rw-r--r-- 715 bytes
smc_tx.c -rw-r--r-- 18.6 KB
smc_tx.h -rw-r--r-- 1.1 KB
smc_wr.c -rw-r--r-- 20.0 KB
smc_wr.h -rw-r--r-- 3.5 KB

back to top