public inbox for mptcp@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"
@ 2026-01-30 10:17 Matthieu Baerts (NGI0)
  2026-01-30 11:15 ` MPTCP CI
  2026-01-30 13:46 ` Geliang Tang
  0 siblings, 2 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-01-30 10:17 UTC (permalink / raw)
  To: MPTCP Upstream; +Cc: Geliang Tang, Matthieu Baerts (NGI0)

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>


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode"
@ 2026-01-30 10:43 Geliang Tang
  2026-01-30 10:50 ` Matthieu Baerts
  2026-01-30 11:45 ` MPTCP CI
  0 siblings, 2 replies; 8+ messages in thread
From: Geliang Tang @ 2026-01-30 10:43 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-30 18:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-30 10:17 [PATCH mptcp-next] Squash to "selftests: mptcp: add splice io mode" Matthieu Baerts (NGI0)
2026-01-30 11:15 ` MPTCP CI
2026-01-30 13:46 ` Geliang Tang
2026-01-30 18:45   ` Matthieu Baerts
  -- strict thread matches above, loose matches on Subject: below --
2026-01-30 10:43 Geliang Tang
2026-01-30 10:50 ` Matthieu Baerts
2026-01-30 13:56   ` Geliang Tang
2026-01-30 11:45 ` MPTCP CI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox