squash to "implement mptcp read_sock"
Subsystems (3)
Geliang Tang
reviewercover squash to "implement mptcp read_sock"
From: Geliang Tang <[email protected]>
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: <[email protected]>
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(-)
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH 1/2 Squash to "mptcp: implement .read_sock"
From: Geliang Tang <[email protected]>
Use sk->sk_rcvbuf instead of INT_MAX as the max len.
--- net/mptcp/protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/protocol.c +1 -1
@@ -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 )
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH 2/2 Squash to "selftests: mptcp: add splice test"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Close all fds of mptcp_splice.c.
Add splice io mode for mptcp_connect.
--- .../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(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +60 -1
@@ -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 ();
tools/testing/selftests/net/mptcp/mptcp_connect.sh +9 -1
@@ -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
tools/testing/selftests/net/mptcp/mptcp_splice.c +29 -14
121 lines not on this page · raw message
Signature · 1 line
2.43.0
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-normalFor 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)