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

Matthieu Baerts (NGI0)
2026-01-30T10:17:40Z

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>