[PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"

Matthieu Baerts (NGI0) posted 1 patch 1 week, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20260130-mptcp-sft-no-ignore-splice-err-v1-1-af0a458b6ec8@kernel.org
There is a newer version of this series
tools/testing/selftests/net/mptcp/mptcp_connect.c | 34 +++++++++++++++++------
1 file changed, 25 insertions(+), 9 deletions(-)
[PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"
Posted by Matthieu Baerts (NGI0) 1 week, 2 days ago
NIPA review assistant rightly spotted errors with splice() are simply...
ignored! Technically, mptcp_connect.sh will check the integrity of the
transfer, but still, that's clearly not a good practice!

The different possible errors are now caught, printed, and reported to
the caller.

Link: https://netdev-ai.bots.linux.dev/ai-review.html?id=93466fc9-574b-45fc-996e-13a19a1490a9
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 34 +++++++++++++++++------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index ff1a298d3469..34d8efe429a4 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -937,24 +937,40 @@ static int do_splice(const int infd, const int outfd, const size_t len,
 		     struct wstate *winfo)
 {
 	int pipefd[2];
-	ssize_t bytes;
+	ssize_t in_bytes, out_bytes;
 	int err;
 
 	err = pipe(pipefd);
-	if (err)
-		return err;
+	if (err) {
+		perror("pipe");
+		return 2;
+	}
 
-	while ((bytes = splice(infd, NULL, pipefd[1], NULL,
-			       len - winfo->total_len,
-			       SPLICE_F_MOVE | SPLICE_F_MORE)) > 0) {
-		splice(pipefd[0], NULL, outfd, NULL, bytes,
-		       SPLICE_F_MOVE | SPLICE_F_MORE);
+again:
+	in_bytes = splice(infd, NULL, pipefd[1], NULL, len - winfo->total_len,
+			  SPLICE_F_MOVE | SPLICE_F_MORE);
+	if (in_bytes < 0) {
+		perror("splice in");
+		err = 3;
+	} else if (in_bytes > 0) {
+		out_bytes = splice(pipefd[0], NULL, outfd, NULL, in_bytes,
+				   SPLICE_F_MOVE | SPLICE_F_MORE);
+		if (out_bytes < 0) {
+			perror("splice out");
+			err = 4;
+		} else if (in_bytes != out_bytes) {
+			fprintf(stderr, "Unexpected transfer: %zu vs %zu\n",
+				in_bytes, out_bytes);
+			err = 5;
+		} else {
+			goto again;
+		}
 	}
 
 	close(pipefd[0]);
 	close(pipefd[1]);
 
-	return 0;
+	return err;
 }
 
 static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,

---
base-commit: 7d56f2ba4d372e9660633de02a01236209c9df8f
change-id: 20260130-mptcp-sft-no-ignore-splice-err-a35a97c217db

Best regards,
-- 
Matthieu Baerts (NGI0) <matttbe@kernel.org>
Re: [PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"
Posted by Geliang Tang 1 week, 2 days ago
Hi Matt,

Thanks for this fix.

On Fri, 2026-01-30 at 11:17 +0100, Matthieu Baerts (NGI0) wrote:
> NIPA review assistant rightly spotted errors with splice() are
> simply...
> ignored! Technically, mptcp_connect.sh will check the integrity of
> the
> transfer, but still, that's clearly not a good practice!
> 
> The different possible errors are now caught, printed, and reported
> to
> the caller.
> 
> Link:
> https://netdev-ai.bots.linux.dev/ai-review.html?id=93466fc9-574b-45fc-996e-13a19a1490a9
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

Looks good to me!

Reviewed-by: Geliang Tang <geliang@kernel.org>

> ---
>  tools/testing/selftests/net/mptcp/mptcp_connect.c | 34
> +++++++++++++++++------
>  1 file changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index ff1a298d3469..34d8efe429a4 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -937,24 +937,40 @@ static int do_splice(const int infd, const int
> outfd, const size_t len,
>  		     struct wstate *winfo)
>  {
>  	int pipefd[2];
> -	ssize_t bytes;
> +	ssize_t in_bytes, out_bytes;

This line is longer than the previous one; their positions could be
swapped.

-Geliang

>  	int err;
>  
>  	err = pipe(pipefd);
> -	if (err)
> -		return err;
> +	if (err) {
> +		perror("pipe");
> +		return 2;
> +	}
>  
> -	while ((bytes = splice(infd, NULL, pipefd[1], NULL,
> -			       len - winfo->total_len,
> -			       SPLICE_F_MOVE | SPLICE_F_MORE)) > 0)
> {
> -		splice(pipefd[0], NULL, outfd, NULL, bytes,
> -		       SPLICE_F_MOVE | SPLICE_F_MORE);
> +again:
> +	in_bytes = splice(infd, NULL, pipefd[1], NULL, len - winfo-
> >total_len,
> +			  SPLICE_F_MOVE | SPLICE_F_MORE);
> +	if (in_bytes < 0) {
> +		perror("splice in");
> +		err = 3;
> +	} else if (in_bytes > 0) {
> +		out_bytes = splice(pipefd[0], NULL, outfd, NULL,
> in_bytes,
> +				   SPLICE_F_MOVE | SPLICE_F_MORE);
> +		if (out_bytes < 0) {
> +			perror("splice out");
> +			err = 4;
> +		} else if (in_bytes != out_bytes) {
> +			fprintf(stderr, "Unexpected transfer: %zu vs
> %zu\n",
> +				in_bytes, out_bytes);
> +			err = 5;
> +		} else {
> +			goto again;
> +		}
>  	}
>  
>  	close(pipefd[0]);
>  	close(pipefd[1]);
>  
> -	return 0;
> +	return err;
>  }
>  
>  static int copyfd_io_splice(int infd, int peerfd, int outfd,
> unsigned int size,
> 
> ---
> base-commit: 7d56f2ba4d372e9660633de02a01236209c9df8f
> change-id: 20260130-mptcp-sft-no-ignore-splice-err-a35a97c217db
> 
> Best regards,
Re: [PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"
Posted by Matthieu Baerts 1 week, 2 days ago
Hi Geliang,

On 30/01/2026 14:46, Geliang Tang wrote:
> Hi Matt,
> 
> Thanks for this fix.
> 
> On Fri, 2026-01-30 at 11:17 +0100, Matthieu Baerts (NGI0) wrote:
>> NIPA review assistant rightly spotted errors with splice() are
>> simply...
>> ignored! Technically, mptcp_connect.sh will check the integrity of
>> the
>> transfer, but still, that's clearly not a good practice!
>>
>> The different possible errors are now caught, printed, and reported
>> to
>> the caller.
>>
>> Link:
>> https://netdev-ai.bots.linux.dev/ai-review.html?id=93466fc9-574b-45fc-996e-13a19a1490a9
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> 
> Looks good to me!
> 
> Reviewed-by: Geliang Tang <geliang@kernel.org>
> 
>> ---
>>  tools/testing/selftests/net/mptcp/mptcp_connect.c | 34
>> +++++++++++++++++------
>>  1 file changed, 25 insertions(+), 9 deletions(-)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c
>> b/tools/testing/selftests/net/mptcp/mptcp_connect.c
>> index ff1a298d3469..34d8efe429a4 100644
>> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
>> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
>> @@ -937,24 +937,40 @@ static int do_splice(const int infd, const int
>> outfd, const size_t len,
>>  		     struct wstate *winfo)
>>  {
>>  	int pipefd[2];
>> -	ssize_t bytes;
>> +	ssize_t in_bytes, out_bytes;
> 
> This line is longer than the previous one; their positions could be
> swapped.

Good point, I missed that. I just fixed that when applying the patch.

New patches for t/upstream:
- f09f3f41e540: Squash to "selftests: mptcp: add splice io mode"
- Results: 50e7f60d4f2a..6f5b41319f11 (export)

Tests are now in progress:

- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/e34e5e3567f9b0fc679d6e6778c749684db62186/checks

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.

Re: [PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"
Posted by MPTCP CI 1 week, 2 days ago
Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_sockopts 🔴
- KVM Validation: debug (only selftest_mptcp_join): 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/21512533499

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/6384e7649754
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1048919


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)