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

Geliang Tang
2026-01-30T10:43:18Z

From: Geliang Tang <tanggeliang@kylinos.cn>

Check the return value of splice().

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;
}

close(pipefd[0]);
close(pipefd[1]);

- return 0;
+ return bytes < 0 ? bytes : 0;
}

static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,
--
2.51.0