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

Matthieu Baerts
2026-01-30T10:50:54Z

Hi Geliang,

On 30/01/2026 11:43, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Check the return value of splice().

Thank you for looking at that.

> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index ff1a298d3469..aaa2248ac76e 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -947,14 +947,16 @@ static int do_splice(const int infd, const int outfd, const size_t len,
> 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);
> + bytes = splice(pipefd[0], NULL, outfd, NULL, bytes,
> + SPLICE_F_MOVE | SPLICE_F_MORE);
> + if (bytes <= 0)
> + break;

Please check [1]: that's not enough: it is important to print the error
to be able to find out what went wrong in case of error. Also, the two
splice() should return the same value, and if "bytes" is 0 here, that's
not normal.

[1]
https://lore.kernel.org/mptcp/20260130-mptcp-sft-no-ignore-splice-err-v1-1-af0a458b6ec8@kernel.org

> }
>
> close(pipefd[0]);
> close(pipefd[1]);
>
> - return 0;
> + return bytes < 0 ? bytes : 0;

The returned value is supposed to be positive (that's the exit returned
value). Also, I don't think you are supposed to have bytes > 0 here, no?

> }
>
> static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,

Cheers,
Matt
--