summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorGeliang Tang <tanggeliang@kylinos.cn>2026-04-03 14:29:29 +0300
committerJakub Kicinski <kuba@kernel.org>2026-04-07 05:14:27 +0300
commiteb477fdd68036a54a6678020d4e6ab177dea111c (patch)
treefb905b3dca9d273301f3af2eff05ac53b28faf92 /include/net
parent7fb2f5f964998819dcc8f5d38dcd8999a568c3ef (diff)
downloadlinux-eb477fdd68036a54a6678020d4e6ab177dea111c.tar.xz
tcp: add recv_should_stop helper
Factor out a new helper tcp_recv_should_stop() from tcp_recvmsg_locked() and tcp_splice_read() to check whether to stop receiving. And use this helper in mptcp_recvmsg() and mptcp_splice_read() to reduce redundant code. Suggested-by: Paolo Abeni <pabeni@redhat.com> Acked-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Acked-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260403-net-next-mptcp-msg_eor-misc-v1-3-b0b33bea3fed@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/tcp.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 565943c34b7e..6156d1d068e1 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -3077,4 +3077,12 @@ enum skb_drop_reason tcp_inbound_hash(struct sock *sk,
const void *saddr, const void *daddr,
int family, int dif, int sdif);
+static inline int tcp_recv_should_stop(struct sock *sk)
+{
+ return sk->sk_err ||
+ sk->sk_state == TCP_CLOSE ||
+ (sk->sk_shutdown & RCV_SHUTDOWN) ||
+ signal_pending(current);
+}
+
#endif /* _TCP_H */