* [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock"
@ 2025-06-11 9:24 Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 1/2] Squash to "mptcp: implement .read_sock" Geliang Tang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Geliang Tang @ 2025-06-11 9:24 UTC (permalink / raw)
To: mptcp, hare; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Two squash-to patches for "implement mptcp read_sock" v2:
- Use sk->sk_rcvbuf instead of INT_MAX as the max len.
- Close all fds of mptcp_splice.c.
- Add splice io mode for mptcp_connect.
Based-on: <cover.1749286212.git.tanggeliang@kylinos.cn>
Geliang Tang (2):
Squash to "mptcp: implement .read_sock"
Squash to "selftests: mptcp: add splice test"
net/mptcp/protocol.c | 2 +-
.../selftests/net/mptcp/mptcp_connect.c | 61 ++++++++++++++++++-
.../selftests/net/mptcp/mptcp_connect.sh | 10 ++-
.../selftests/net/mptcp/mptcp_splice.c | 43 ++++++++-----
4 files changed, 99 insertions(+), 17 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH mptcp-next 1/2] Squash to "mptcp: implement .read_sock"
2025-06-11 9:24 [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" Geliang Tang
@ 2025-06-11 9:24 ` Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 2/2] Squash to "selftests: mptcp: add splice test" Geliang Tang
2025-06-11 10:44 ` [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" MPTCP CI
2 siblings, 0 replies; 5+ messages in thread
From: Geliang Tang @ 2025-06-11 9:24 UTC (permalink / raw)
To: mptcp, hare; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Use sk->sk_rcvbuf instead of INT_MAX as the max len.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
net/mptcp/protocol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 32d389329262..53057c4f41f0 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3965,8 +3965,8 @@ static int mptcp_read_sock(struct sock *sk, read_descriptor_t *desc,
{
struct mptcp_sock *msk = mptcp_sk(sk);
struct scm_timestamping_internal tss;
+ size_t len = sk->sk_rcvbuf;
struct sk_buff *skb, *tmp;
- size_t len = INT_MAX;
int copied = 0;
if (sk->sk_state == TCP_LISTEN)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH mptcp-next 2/2] Squash to "selftests: mptcp: add splice test"
2025-06-11 9:24 [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 1/2] Squash to "mptcp: implement .read_sock" Geliang Tang
@ 2025-06-11 9:24 ` Geliang Tang
2025-06-11 10:44 ` [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" MPTCP CI
2 siblings, 0 replies; 5+ messages in thread
From: Geliang Tang @ 2025-06-11 9:24 UTC (permalink / raw)
To: mptcp, hare; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Close all fds of mptcp_splice.c.
Add splice io mode for mptcp_connect.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../selftests/net/mptcp/mptcp_connect.c | 61 ++++++++++++++++++-
.../selftests/net/mptcp/mptcp_connect.sh | 10 ++-
.../selftests/net/mptcp/mptcp_splice.c | 43 ++++++++-----
3 files changed, 98 insertions(+), 16 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index ac1349c4b9e5..ce4b4ed9164d 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -51,6 +51,7 @@ enum cfg_mode {
CFG_MODE_POLL,
CFG_MODE_MMAP,
CFG_MODE_SENDFILE,
+ CFG_MODE_SPLICE,
};
enum cfg_peek {
@@ -123,7 +124,7 @@ static void die_usage(void)
fprintf(stderr, "\t-j -- add additional sleep at connection start and tear down "
"-- for MPJ tests\n");
fprintf(stderr, "\t-l -- listens mode, accepts incoming connection\n");
- fprintf(stderr, "\t-m [poll|mmap|sendfile] -- use poll(default)/mmap+write/sendfile\n");
+ fprintf(stderr, "\t-m [poll|mmap|sendfile|splice] -- use poll(default)/mmap+write/sendfile/splice\n");
fprintf(stderr, "\t-M mark -- set socket packet mark\n");
fprintf(stderr, "\t-o option -- test sockopt <option>\n");
fprintf(stderr, "\t-p num -- use port num\n");
@@ -925,6 +926,53 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd,
return err;
}
+static int do_splice(const int infd, const int outfd, const size_t len)
+{
+ int pipefd[2];
+ ssize_t bytes;
+ int err;
+
+ err = pipe(pipefd);
+ if (err)
+ return err;
+
+ while ((bytes = splice(infd, NULL, pipefd[1], NULL, len,
+ SPLICE_F_MOVE | SPLICE_F_MORE)) > 0) {
+ splice(pipefd[0], NULL, outfd, NULL, bytes,
+ SPLICE_F_MOVE | SPLICE_F_MORE);
+ }
+
+ close(pipefd[0]);
+ close(pipefd[1]);
+
+ return 0;
+}
+
+static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,
+ bool *in_closed_after_out, struct wstate *winfo)
+{
+ int err;
+
+ if (listen_mode) {
+ err = do_splice(peerfd, outfd, size);
+ if (err)
+ return err;
+
+ err = do_splice(infd, peerfd, size);
+ } else {
+ err = do_splice(infd, peerfd, size);
+ if (err)
+ return err;
+
+ shut_wr(peerfd);
+
+ err = do_splice(peerfd, outfd, size);
+ *in_closed_after_out = true;
+ }
+
+ return err;
+}
+
static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd, struct wstate *winfo)
{
bool in_closed_after_out = false;
@@ -957,6 +1005,14 @@ static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd, struct
&in_closed_after_out, winfo);
break;
+ case CFG_MODE_SPLICE:
+ file_size = get_infd_size(infd);
+ if (file_size < 0)
+ return file_size;
+ ret = copyfd_io_splice(infd, peerfd, outfd, file_size,
+ &in_closed_after_out, winfo);
+ break;
+
default:
fprintf(stderr, "Invalid mode %d\n", cfg_mode);
@@ -1361,12 +1417,15 @@ int parse_mode(const char *mode)
return CFG_MODE_MMAP;
if (!strcasecmp(mode, "sendfile"))
return CFG_MODE_SENDFILE;
+ if (!strcasecmp(mode, "splice"))
+ return CFG_MODE_SPLICE;
fprintf(stderr, "Unknown test mode: %s\n", mode);
fprintf(stderr, "Supported modes are:\n");
fprintf(stderr, "\t\t\"poll\" - interleaved read/write using poll()\n");
fprintf(stderr, "\t\t\"mmap\" - send entire input file (mmap+write), then read response (-l will read input first)\n");
fprintf(stderr, "\t\t\"sendfile\" - send entire input file (sendfile), then read response (-l will read input first)\n");
+ fprintf(stderr, "\t\t\"splice\" - send entire input file (splice), then read response (-l will read input first)\n");
die_usage();
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 5e3c56253274..0b0ed1df710d 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -339,9 +339,17 @@ do_transfer()
fi
if [ -n "$testmode" ]; then
- extra_args+=" -m $testmode"
+ if [ ${testmode} = "splice" ]; then
+ # only use 'splice' mode for MPTCP tests
+ if [ ${cl_proto} = "MPTCP" ] && [ ${srv_proto} = "MPTCP" ]; then
+ extra_args+=" -m splice"
+ fi
+ else
+ extra_args+=" -m $testmode"
+ fi
fi
+
if [ -n "$extra_args" ] && $options_log; then
mptcp_lib_pr_info "extra options: $extra_args"
fi
diff --git a/tools/testing/selftests/net/mptcp/mptcp_splice.c b/tools/testing/selftests/net/mptcp/mptcp_splice.c
index a04ab7e1448d..a43cbc556ec6 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_splice.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_splice.c
@@ -39,7 +39,7 @@ static int server(char *output)
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT,
&opt, sizeof(opt))) {
perror("setsockopt");
- exit(EXIT_FAILURE);
+ goto close_server;
}
address.sin_family = AF_INET;
@@ -48,12 +48,12 @@ static int server(char *output)
if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0) {
perror("bind failed");
- exit(EXIT_FAILURE);
+ goto close_server;
}
if (listen(server_fd, 3) < 0) {
perror("listen");
- exit(EXIT_FAILURE);
+ goto close_server;
}
printf("Server listening on port %d...\n", port);
@@ -62,20 +62,20 @@ static int server(char *output)
(socklen_t *)&addrlen);
if (client_fd < 0) {
perror("accept");
- exit(EXIT_FAILURE);
+ goto close_client;
}
printf("Client connected. Receiving file...\n");
if (pipe(pipefd)) {
perror("pipe");
- exit(EXIT_FAILURE);
+ goto close_client;
}
out_fd = open(output, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (out_fd < 0) {
perror("open");
- exit(EXIT_FAILURE);
+ goto close_pipe;
}
while ((bytes = splice(client_fd, NULL, pipefd[1], NULL, BUFFER_SIZE,
@@ -83,14 +83,22 @@ static int server(char *output)
splice(pipefd[0], NULL, out_fd, NULL, bytes, SPLICE_F_MOVE | SPLICE_F_MORE);
}
- if (bytes == -1)
+ if (bytes == -1) {
perror("splice");
+ goto close_fd;
+ }
printf("File transfer completed. Received %ld bytes.\n",
lseek(out_fd, 0, SEEK_CUR));
- close(client_fd);
+close_fd:
close(out_fd);
+close_pipe:
+ close(pipefd[0]);
+ close(pipefd[1]);
+close_client:
+ close(client_fd);
+close_server:
close(server_fd);
return 0;
@@ -114,25 +122,25 @@ static int client(char *input)
if (inet_pton(AF_INET, server_ip, &serv_addr.sin_addr) <= 0) {
perror("Invalid address/ Address not supported");
- exit(EXIT_FAILURE);
+ goto close_sock;
}
if (connect(sock_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
perror("Connection Failed");
- exit(EXIT_FAILURE);
+ goto close_sock;
}
printf("Connected to server. Sending file...\n");
if (pipe(pipefd)) {
perror("pipe");
- exit(EXIT_FAILURE);
+ goto close_sock;
}
in_fd = open(input, O_RDONLY);
if (in_fd == -1) {
perror("open");
- exit(EXIT_FAILURE);
+ goto close_pipe;
}
while ((bytes = splice(in_fd, NULL, pipefd[1], NULL, BUFFER_SIZE,
@@ -140,14 +148,21 @@ static int client(char *input)
splice(pipefd[0], NULL, sock_fd, NULL, bytes, SPLICE_F_MOVE | SPLICE_F_MORE);
}
- if (bytes == -1)
+ if (bytes == -1) {
perror("splice");
+ goto close_fd;
+ }
printf("File transfer completed. Sent %ld bytes.\n",
lseek(in_fd, 0, SEEK_CUR));
- shutdown(sock_fd, SHUT_WR);
+close_fd:
close(in_fd);
+close_pipe:
+ close(pipefd[0]);
+ close(pipefd[1]);
+close_sock:
+ shutdown(sock_fd, SHUT_WR);
close(sock_fd);
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock"
2025-06-11 9:24 [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 1/2] Squash to "mptcp: implement .read_sock" Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 2/2] Squash to "selftests: mptcp: add splice test" Geliang Tang
@ 2025-06-11 10:44 ` MPTCP CI
2 siblings, 0 replies; 5+ messages in thread
From: MPTCP CI @ 2025-06-11 10:44 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: 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/15581436214
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/b571299e8f55
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=970730
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)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH mptcp-next 0/2] Squash to "implement mptcp read_sock"
@ 2025-07-03 8:47 Geliang Tang
0 siblings, 0 replies; 5+ messages in thread
From: Geliang Tang @ 2025-07-03 8:47 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Two small cleanups for "implement mptcp read_sock" v5.
Based-on: <cover.1751093346.git.tanggeliang@kylinos.cn>
Geliang Tang (2):
Squash to "mptcp: implement .read_sock"
Squash to "mptcp: set .splice_read"
net/ipv4/tcp.c | 2 ++
net/mptcp/protocol.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
--
2.48.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-03 8:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 9:24 [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 1/2] Squash to "mptcp: implement .read_sock" Geliang Tang
2025-06-11 9:24 ` [PATCH mptcp-next 2/2] Squash to "selftests: mptcp: add splice test" Geliang Tang
2025-06-11 10:44 ` [PATCH mptcp-next 0/2] squash to "implement mptcp read_sock" MPTCP CI
-- strict thread matches above, loose matches on Subject: below --
2025-07-03 8:47 [PATCH mptcp-next 0/2] Squash " Geliang Tang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.