MPTCP Linux Development
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: mptcp@lists.linux.dev, hare@kernel.org
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: [PATCH mptcp-next v13 4/8] mptcp: use recv_should_stop helper
Date: Thu, 23 Oct 2025 13:56:47 +0800	[thread overview]
Message-ID: <00529da4ea8b262f82505fc99d717145bc8c2aef.1761198660.git.geliang@kernel.org> (raw)
In-Reply-To: <cover.1761198660.git.geliang@kernel.org>

From: Geliang Tang <tanggeliang@kylinos.cn>

Use the newly added tcp_recv_should_stop() helper in mptcp_recvmsg() to
check whether to stop receiving.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/mptcp/protocol.c | 35 +++++------------------------------
 1 file changed, 5 insertions(+), 30 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 3f29236ce5fc..1955717e7dfc 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2306,36 +2306,11 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		if (copied >= target)
 			break;
 
-		if (copied) {
-			if (sk->sk_err ||
-			    sk->sk_state == TCP_CLOSE ||
-			    (sk->sk_shutdown & RCV_SHUTDOWN) ||
-			    !timeo ||
-			    signal_pending(current))
-				break;
-		} else {
-			if (sk->sk_err) {
-				copied = sock_error(sk);
-				break;
-			}
-
-			if (sk->sk_shutdown & RCV_SHUTDOWN)
-				break;
-
-			if (sk->sk_state == TCP_CLOSE) {
-				copied = -ENOTCONN;
-				break;
-			}
-
-			if (!timeo) {
-				copied = -EAGAIN;
-				break;
-			}
-
-			if (signal_pending(current)) {
-				copied = sock_intr_errno(timeo);
-				break;
-			}
+		err = tcp_recv_should_stop(sk, timeo);
+		if (err < 0) {
+			if (!copied && err != -ESHUTDOWN)
+				copied = err;
+			break;
 		}
 
 		pr_debug("block timeout %ld\n", timeo);
-- 
2.43.0


  parent reply	other threads:[~2025-10-23  5:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  5:56 [PATCH mptcp-next v13 0/8] implement mptcp read_sock Geliang Tang
2025-10-23  5:56 ` [PATCH mptcp-next v13 1/8] mptcp: add eat_recv_skb helper Geliang Tang
2025-10-23  5:56 ` [PATCH mptcp-next v13 2/8] mptcp: implement .read_sock Geliang Tang
2025-10-23  5:56 ` [PATCH mptcp-next v13 3/8] tcp: add recv_should_stop helper Geliang Tang
2025-10-23  5:56 ` Geliang Tang [this message]
2025-10-23  5:56 ` [PATCH mptcp-next v13 5/8] tcp: export tcp_splice_state Geliang Tang
2025-10-23  5:56 ` [PATCH mptcp-next v13 6/8] mptcp: implement .splice_read Geliang Tang
2025-10-23  5:56 ` [PATCH mptcp-next v13 7/8] selftests: mptcp: add splice io mode Geliang Tang
2025-10-23  5:56 ` [PATCH mptcp-next v13 8/8] selftests: mptcp: connect: cover splice mode Geliang Tang
2025-10-23  7:54 ` [PATCH mptcp-next v13 0/8] implement mptcp read_sock MPTCP CI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00529da4ea8b262f82505fc99d717145bc8c2aef.1761198660.git.geliang@kernel.org \
    --to=geliang@kernel.org \
    --cc=hare@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox