mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism:
@ 2022-09-23  0:15 Dmytro Shytyi
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 1/3] mptcp: add mptcp_setsockopt_fastopen Dmytro Shytyi
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Dmytro Shytyi @ 2022-09-23  0:15 UTC (permalink / raw)
  To: mptcp; +Cc: Dmytro Shytyi

Compared to the previous patches, these focus on the sender side.

Dmytro Shytyi (3):
  mptcp: add mptcp_setsockopt_fastopen
  mptcp: add mptcp_stream_connect to *.h
  mptcp: reuse tcp_sendmsg_fastopen()

 include/net/tcp.h    |  3 +++
 net/ipv4/tcp.c       | 23 ++++++++++++++++++-----
 net/mptcp/Makefile   |  2 +-
 net/mptcp/fastopen.c | 32 ++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c | 22 ++++++++++++++++++----
 net/mptcp/protocol.h |  6 ++++++
 net/mptcp/sockopt.c  |  3 +++
 7 files changed, 81 insertions(+), 10 deletions(-)
 create mode 100644 net/mptcp/fastopen.c

-- 
2.25.1



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

* [RFC PATCH mptcp-next v10 1/3] mptcp: add mptcp_setsockopt_fastopen
  2022-09-23  0:15 [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
@ 2022-09-23  0:15 ` Dmytro Shytyi
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 2/3] mptcp: add mptcp_stream_connect to *.h Dmytro Shytyi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Dmytro Shytyi @ 2022-09-23  0:15 UTC (permalink / raw)
  To: mptcp; +Cc: Dmytro Shytyi

Add set MPTFO socket option for MPTCP. This option is needed for
the listen socket to accept MPTFO.

Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
 net/mptcp/Makefile   |  2 +-
 net/mptcp/fastopen.c | 32 ++++++++++++++++++++++++++++++++
 net/mptcp/protocol.h |  5 +++++
 net/mptcp/sockopt.c  |  3 +++
 4 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 net/mptcp/fastopen.c

diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile
index 8a7f68efa35f..c42ad8609876 100644
--- a/net/mptcp/Makefile
+++ b/net/mptcp/Makefile
@@ -2,7 +2,7 @@
 obj-$(CONFIG_MPTCP) += mptcp.o
 
 mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \
-	   mib.o pm_netlink.o sockopt.o pm_userspace.o sched.o
+	   mib.o pm_netlink.o sockopt.o pm_userspace.o sched.o fastopen.o
 
 obj-$(CONFIG_SYN_COOKIES) += syncookies.o
 obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o
diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c
new file mode 100644
index 000000000000..9ef49a2d2ea2
--- /dev/null
+++ b/net/mptcp/fastopen.c
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0
+ * MPTCP Fast Open Mechanism. Copyright (c) 2021-2022, Dmytro SHYTYI
+ */
+
+#include "protocol.h"
+
+int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t optval,
+				      unsigned int optlen)
+{
+	struct sock *sk = (struct sock *)msk;
+	struct net *net = sock_net(sk);
+	int val;
+	int ret;
+
+	ret = 0;
+
+	if (copy_from_sockptr(&val, optval, sizeof(val)))
+		return -EFAULT;
+
+	lock_sock(sk);
+
+	if (val >= 0 && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) {
+		tcp_fastopen_init_key_once(net);
+		fastopen_queue_tune(sk, val);
+	} else {
+		ret = -EINVAL;
+	}
+
+	release_sock(sk);
+
+	return ret;
+}
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 93c535440a5c..522647804aed 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -838,6 +838,11 @@ void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_
 void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id);
 bool mptcp_userspace_pm_active(const struct mptcp_sock *msk);
 
+// Fast Open Mechanism functions begin
+int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t optval,
+				      unsigned int optlen);
+// Fast Open Mechanism functions end
+
 static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
 {
 	return READ_ONCE(msk->pm.addr_signal) &
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 423d3826ca1e..f62f0d63b8e6 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -559,6 +559,7 @@ static bool mptcp_supported_sockopt(int level, int optname)
 		case TCP_NOTSENT_LOWAT:
 		case TCP_TX_DELAY:
 		case TCP_INQ:
+		case TCP_FASTOPEN:
 			return true;
 		}
 
@@ -796,6 +797,8 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
 		return mptcp_setsockopt_sol_tcp_nodelay(msk, optval, optlen);
 	case TCP_DEFER_ACCEPT:
 		return mptcp_setsockopt_sol_tcp_defer(msk, optval, optlen);
+	case TCP_FASTOPEN:
+		return mptcp_setsockopt_sol_tcp_fastopen(msk, optval, optlen);
 	}
 
 	return -EOPNOTSUPP;
-- 
2.25.1



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

* [RFC PATCH mptcp-next v10 2/3] mptcp: add mptcp_stream_connect to *.h
  2022-09-23  0:15 [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 1/3] mptcp: add mptcp_setsockopt_fastopen Dmytro Shytyi
@ 2022-09-23  0:15 ` Dmytro Shytyi
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 3/3] mptcp: reuse tcp_sendmsg_fastopen() Dmytro Shytyi
  2022-09-23  2:26 ` [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
  3 siblings, 0 replies; 7+ messages in thread
From: Dmytro Shytyi @ 2022-09-23  0:15 UTC (permalink / raw)
  To: mptcp; +Cc: Dmytro Shytyi

In the following patches we will call mptcp_stream_connect() from
function tcp_sendmsg_fastopen() in file "net/ipv4/tcp.c", thus make
such symbol visible.

Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
 net/mptcp/protocol.c | 4 ++--
 net/mptcp/protocol.h | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7d4e197ec567..c39ed726c1c0 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3543,8 +3543,8 @@ static void mptcp_subflow_early_fallback(struct mptcp_sock *msk,
 	__mptcp_do_fallback(msk);
 }
 
-static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
-				int addr_len, int flags)
+int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr,
+			 int addr_len, int flags)
 {
 	struct mptcp_sock *msk = mptcp_sk(sock->sk);
 	struct mptcp_subflow_context *subflow;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 522647804aed..57596cdfb1f9 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -837,6 +837,7 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
 void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_info *info);
 void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id);
 bool mptcp_userspace_pm_active(const struct mptcp_sock *msk);
+int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, int addr_len, int flags);
 
 // Fast Open Mechanism functions begin
 int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t optval,
-- 
2.25.1



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

* [RFC PATCH mptcp-next v10 3/3] mptcp: reuse tcp_sendmsg_fastopen()
  2022-09-23  0:15 [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 1/3] mptcp: add mptcp_setsockopt_fastopen Dmytro Shytyi
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 2/3] mptcp: add mptcp_stream_connect to *.h Dmytro Shytyi
@ 2022-09-23  0:15 ` Dmytro Shytyi
  2022-09-23  0:44   ` mptcp: reuse tcp_sendmsg_fastopen(): Build Failure MPTCP CI
  2022-09-23  1:49   ` mptcp: reuse tcp_sendmsg_fastopen(): Tests Results MPTCP CI
  2022-09-23  2:26 ` [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
  3 siblings, 2 replies; 7+ messages in thread
From: Dmytro Shytyi @ 2022-09-23  0:15 UTC (permalink / raw)
  To: mptcp; +Cc: Dmytro Shytyi

In the following patches we will reuse modified tcp_sendmsg_fastopen().
We call it from mptcp_sendmsg(). 

Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
 include/net/tcp.h    |  3 +++
 net/ipv4/tcp.c       | 23 ++++++++++++++++++-----
 net/mptcp/protocol.c | 18 ++++++++++++++++--
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 27e8d378c70a..97cb014ddcab 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1755,6 +1755,9 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
 			      struct request_sock *req,
 			      struct tcp_fastopen_cookie *foc,
 			      const struct dst_entry *dst);
+int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
+			 int *copied, size_t size,
+			 struct ubuf_info *uarg);
 void tcp_fastopen_init_key_once(struct net *net);
 bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
 			     struct tcp_fastopen_cookie *cookie);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5702ca9b952d..e86925b3814a 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -280,6 +280,8 @@
 #include <asm/ioctls.h>
 #include <net/busy_poll.h>
 
+#include "../mptcp/protocol.h"
+
 /* Track pending CMSGs. */
 enum {
 	TCP_CMSG_INQ = 1,
@@ -1162,9 +1164,9 @@ void tcp_free_fastopen_req(struct tcp_sock *tp)
 	}
 }
 
-static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
-				int *copied, size_t size,
-				struct ubuf_info *uarg)
+int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
+			 int *copied, size_t size,
+			 struct ubuf_info *uarg)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct inet_sock *inet = inet_sk(sk);
@@ -1197,8 +1199,19 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
 		}
 	}
 	flags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0;
-	err = __inet_stream_connect(sk->sk_socket, uaddr,
-				    msg->msg_namelen, flags, 1);
+	if (!sk_is_mptcp(sk)) {
+		err = __inet_stream_connect(sk->sk_socket, uaddr,
+					    msg->msg_namelen, flags, 1);
+	} else {
+		struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
+
+		release_sock(sk);
+		release_sock(subflow->conn);
+		err = mptcp_stream_connect(sk->sk_socket, uaddr,
+					   msg->msg_namelen, msg->msg_flags);
+		lock_sock(subflow->conn);
+		lock_sock(sk);
+	}
 	/* fastopen_req could already be freed in __inet_stream_connect
 	 * if the connection times out or gets rst
 	 */
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index c39ed726c1c0..8a5f79de3ab9 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1668,14 +1668,28 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
 	struct page_frag *pfrag;
+	struct socket *ssock;
 	size_t copied = 0;
 	int ret = 0;
 	long timeo;
 
 	/* we don't support FASTOPEN yet */
-	if (msg->msg_flags & MSG_FASTOPEN)
-		return -EOPNOTSUPP;
+	if (msg->msg_flags & MSG_FASTOPEN) {
+		lock_sock(sk);
+
+		ssock = __mptcp_nmpc_socket(msk);
+
+		lock_sock(ssock->sk);
 
+		if (ssock) {
+			int copied_syn_fastopen = 0;
+
+			ret = tcp_sendmsg_fastopen(ssock->sk, msg, &copied_syn_fastopen, len, NULL);
+			copied += copied_syn_fastopen;
+		}
+		release_sock(ssock->sk);
+		release_sock(sk);
+	}
 	/* silently ignore everything else */
 	msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL;
 
-- 
2.25.1



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

* Re: mptcp: reuse tcp_sendmsg_fastopen(): Build Failure
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 3/3] mptcp: reuse tcp_sendmsg_fastopen() Dmytro Shytyi
@ 2022-09-23  0:44   ` MPTCP CI
  2022-09-23  1:49   ` mptcp: reuse tcp_sendmsg_fastopen(): Tests Results MPTCP CI
  1 sibling, 0 replies; 7+ messages in thread
From: MPTCP CI @ 2022-09-23  0:44 UTC (permalink / raw)
  To: Dmytro Shytyi; +Cc: mptcp

Hi Dmytro,

Thank you for your modifications, that's great!

But sadly, our CI spotted some issues with it when trying to build it.

You can find more details there:

  https://patchwork.kernel.org/project/mptcp/patch/20220923001530.9722-4-dmytro@shytyi.net/
  https://github.com/multipath-tcp/mptcp_net-next/actions/runs/3109657443

Status: failure
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/d6a6496543d4

Feel free to reply to this email if you cannot access logs, if you need
some support to fix the error, if this doesn't seem to be caused by your
modifications or if the error is a false positive one.

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)

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

* Re: mptcp: reuse tcp_sendmsg_fastopen(): Tests Results
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 3/3] mptcp: reuse tcp_sendmsg_fastopen() Dmytro Shytyi
  2022-09-23  0:44   ` mptcp: reuse tcp_sendmsg_fastopen(): Build Failure MPTCP CI
@ 2022-09-23  1:49   ` MPTCP CI
  1 sibling, 0 replies; 7+ messages in thread
From: MPTCP CI @ 2022-09-23  1:49 UTC (permalink / raw)
  To: Dmytro Shytyi; +Cc: mptcp

Hi Dmytro,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/4837384788377600
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/4837384788377600/summary/summary.txt

- KVM Validation: debug:
  - Unstable: 2 failed test(s): packetdrill_add_addr selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/5963284695220224
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5963284695220224/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/d6a6496543d4


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-debug

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 (Tessares)

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

* Re: [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism:
  2022-09-23  0:15 [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
                   ` (2 preceding siblings ...)
  2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 3/3] mptcp: reuse tcp_sendmsg_fastopen() Dmytro Shytyi
@ 2022-09-23  2:26 ` Dmytro Shytyi
  3 siblings, 0 replies; 7+ messages in thread
From: Dmytro Shytyi @ 2022-09-23  2:26 UTC (permalink / raw)
  To: mptcp

Hello all,


Do you grant a permission to submit v11 in less then 24h period?

I have 2 things to do:
1. I have one line to modify in tcp.c and build will be successful (I 
think).
2. Change the name of the patch (add "sender" in the topic) as somehow 
it wasn't applied.

Best regards,
Dmytro SHYTYI

On 9/23/2022 2:15 AM, Dmytro Shytyi wrote:
> Compared to the previous patches, these focus on the sender side.
>
> Dmytro Shytyi (3):
>    mptcp: add mptcp_setsockopt_fastopen
>    mptcp: add mptcp_stream_connect to *.h
>    mptcp: reuse tcp_sendmsg_fastopen()
>
>   include/net/tcp.h    |  3 +++
>   net/ipv4/tcp.c       | 23 ++++++++++++++++++-----
>   net/mptcp/Makefile   |  2 +-
>   net/mptcp/fastopen.c | 32 ++++++++++++++++++++++++++++++++
>   net/mptcp/protocol.c | 22 ++++++++++++++++++----
>   net/mptcp/protocol.h |  6 ++++++
>   net/mptcp/sockopt.c  |  3 +++
>   7 files changed, 81 insertions(+), 10 deletions(-)
>   create mode 100644 net/mptcp/fastopen.c
>

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

end of thread, other threads:[~2022-09-23  2:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23  0:15 [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi
2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 1/3] mptcp: add mptcp_setsockopt_fastopen Dmytro Shytyi
2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 2/3] mptcp: add mptcp_stream_connect to *.h Dmytro Shytyi
2022-09-23  0:15 ` [RFC PATCH mptcp-next v10 3/3] mptcp: reuse tcp_sendmsg_fastopen() Dmytro Shytyi
2022-09-23  0:44   ` mptcp: reuse tcp_sendmsg_fastopen(): Build Failure MPTCP CI
2022-09-23  1:49   ` mptcp: reuse tcp_sendmsg_fastopen(): Tests Results MPTCP CI
2022-09-23  2:26 ` [RFC PATCH mptcp-next v10 0/3] mptcp: Fast Open Mechanism: Dmytro Shytyi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).