Commit 028591f2 authored by John Fastabend's avatar John Fastabend Committed by Carlos Llamas
Browse files

UPSTREAM: bpf, sockmap: Handle fin correctly



[ Upstream commit 901546fd ]

The sockmap code is returning EAGAIN after a FIN packet is received and no
more data is on the receive queue. Correct behavior is to return 0 to the
user and the user can then close the socket. The EAGAIN causes many apps
to retry which masks the problem. Eventually the socket is evicted from
the sockmap because its released from sockmap sock free handling. The
issue creates a delay and can cause some errors on application side.

To fix this check on sk_msg_recvmsg side if length is zero and FIN flag
is set then set return to zero. A selftest will be added to check this
condition.

Fixes: 04919bed ("tcp: Introduce tcp_read_skb()")
Change-Id: I26d941790b9742534370c0447fd4a92cab55c32e
Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Tested-by: default avatarWilliam Findlay <will@isovalent.com>
Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20230523025618.113937-6-john.fastabend@gmail.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 3a2129eb)
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent e69ad7c8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment