Skip to contentSkip to conversation

Squash to "implement mptcp read_sock" v8

PATCH Superseded Geliang Tang 2 participants 5 messages Jul 10, 2025

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

cover Squash to "implement mptcp read_sock" v8

From: Geliang Tang <[email protected]>

Drop "shutdown" parameter of mptcp_recv_should_stop.

Based-on: <[email protected]>

Geliang Tang (2):
Squash to "mptcp: add recv_should_stop helper"
Squash to "mptcp: implement .splice_read"

 net/mptcp/protocol.c | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)
Signature · 1 line
2.48.1
author reviewer
#1 lore raw

PATCH 1/2 Squash to "mptcp: add recv_should_stop helper"

From: Geliang Tang <[email protected]>

Drop "shutdown" parameter.

---
 net/mptcp/protocol.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
net/mptcp/protocol.c +14 -15
index 6b3be1d0668d..73359a61ec80 100644
@@ -2090,20 +2090,13 @@ static unsigned int mptcp_inq_hint(const struct sock *sk)
 	return 0;
 }
 
-static int mptcp_recv_should_stop(struct sock *sk, long timeo, int *shutdown)
+static int mptcp_recv_should_stop(struct sock *sk, long timeo)
 {
 	if (sk->sk_err)
 		return sock_error(sk);
 
-	if (sk->sk_shutdown & RCV_SHUTDOWN) {
-		*shutdown = 1;
-		/* race breaker: the shutdown could be after the
-		 * previous receive queue check
-		 */
-		if (__mptcp_move_skbs(sk))
-			*shutdown = 0;
-		return 0;
-	}
+	if (sk->sk_shutdown & RCV_SHUTDOWN)
+		return -ESHUTDOWN;
 
 	if (sk->sk_state == TCP_CLOSE)
 		return -ENOTCONN;
@@ -2123,7 +2116,6 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 	struct mptcp_sock *msk = mptcp_sk(sk);
 	struct scm_timestamping_internal tss;
 	int copied = 0, cmsg_flags = 0;
-	int shutdown = -1;
 	int target;
 	long timeo;
 
@@ -2174,11 +2166,18 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 			    signal_pending(current))
 				break;
 		} else {
-			copied = mptcp_recv_should_stop(sk, timeo, &shutdown);
-			if (copied < 0 || shutdown == 1)
+			copied = mptcp_recv_should_stop(sk, timeo);
+			if (copied == -ESHUTDOWN) {
+				copied = 0;
+				/* race breaker: the shutdown could be after the
+				 * previous receive queue check
+				 */
+				if (__mptcp_move_skbs(sk))
+					continue;
 				break;
-			if (shutdown == 0)
-				continue;
+			} else if (copied < 0) {
+				break;
+			}
 		}
 
 		pr_debug("block timeout %ld\n", timeo);
Signature · 1 line
2.48.1
author reviewer
#2 lore raw

PATCH 2/2 Squash to "mptcp: implement .splice_read"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Update the parameter of mptcp_recv_should_stop.

---
 net/mptcp/protocol.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
net/mptcp/protocol.c +8 -5
index 73359a61ec80..a3eb39a45403 100644
@@ -4060,7 +4060,6 @@ static ssize_t mptcp_splice_read(struct socket *sock, loff_t *ppos,
 		.flags = flags,
 	};
 	struct sock *sk = sock->sk;
-	int shutdown = -1;
 	ssize_t spliced;
 	long timeo;
 	int ret;
@@ -4086,11 +4085,15 @@ static ssize_t mptcp_splice_read(struct socket *sock, loff_t *ppos,
 				break;
 			if (sock_flag(sk, SOCK_DONE))
 				break;
-			ret = mptcp_recv_should_stop(sk, timeo, &shutdown);
-			if (ret < 0 || shutdown == 1)
+			ret = mptcp_recv_should_stop(sk, timeo);
+			if (ret == -ESHUTDOWN) {
+				ret = 0;
+				if (__mptcp_move_skbs(sk))
+					continue;
 				break;
-			if (shutdown == 0)
-				continue;
+			} else if (ret < 0) {
+				break;
+			}
 			/* if __mptcp_splice_read() got nothing while we have
 			 * an skb in receive queue, we do not want to loop.
 			 * This might happen with URG data.
Signature · 1 line
2.48.1
#3 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

But sadly, our CI spotted some issues with it when trying to build it.

You can find more details there:

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/16189539590

Status: failure
Initiator: Matthieu Baerts (NGI0)
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/768ce545975a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=980877

Feel free to reply to this email if you cannot access logs, if you need some support to fix the error, if this doesn't seem to be caused by your modifications or if the error is a false positive one.

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

#4 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Unstable: 1 failed test(s): selftest_mptcp_connect 🔴
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/16189539607

Initiator: Matthieu Baerts (NGI0)
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/768ce545975a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=980877

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)