mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dmytro Shytyi <dmytro@shytyi.net>
To: mptcp@lists.linux.dev
Cc: Dmytro Shytyi <dmytro@shytyi.net>,
	Benjamin Hesmans <benjamin.hesmans@tessares.net>
Subject: [RFC PATCH mptcp-next v11 4/4] mptcp: reuse tcp_sendmsg_fastopen()
Date: Mon, 26 Sep 2022 01:26:01 +0200	[thread overview]
Message-ID: <20220925232601.25252-5-dmytro@shytyi.net> (raw)
In-Reply-To: <20220925232601.25252-1-dmytro@shytyi.net>

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

Signed-of-by: Benjamin Hesmans <benjamin.hesmans@tessares.net>
Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
 include/net/tcp.h    |  3 +++
 net/ipv4/tcp.c       |  6 +++---
 net/mptcp/protocol.c | 25 +++++++++++++++++++++++--
 3 files changed, 29 insertions(+), 5 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 a22c8044de17..daa611671d9a 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1162,9 +1162,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);
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index fb08e1f458c0..dd2414fdcf04 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1679,9 +1679,30 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	long timeo;
 
 	/* we don't support FASTOPEN yet */
-	if (msg->msg_flags & MSG_FASTOPEN)
-		return -EOPNOTSUPP;
+	if (msg->msg_flags & MSG_FASTOPEN) {
+		struct socket *ssock;
+		struct sock *ssk;
 
+		lock_sock(sk);
+
+		ssock = __mptcp_nmpc_socket(msk);
+		ssk = ssock->sk;
+
+		lock_sock(ssk);
+
+		if (ssock) {
+			int copied_syn_fastopen = 0;
+
+			ret = tcp_sendmsg_fastopen(ssk, msg, &copied_syn_fastopen, len, NULL);
+			copied += copied_syn_fastopen;
+			if (ret) {
+				release_sock(ssk);
+				goto do_error;
+			}
+		}
+		release_sock(ssock->sk);
+		release_sock(sk);
+	}
 	/* silently ignore everything else */
 	msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL;
 
-- 
2.25.1



  parent reply	other threads:[~2022-09-25 23:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 23:25 [RFC PATCH mptcp-next v11 0/4] mptcp: Fast Open: Initiator Dmytro Shytyi
2022-09-25 23:25 ` [RFC PATCH mptcp-next v11 1/4] mptcp: add mptcp_setsockopt_fastopen Dmytro Shytyi
2022-09-26 14:50   ` Paolo Abeni
2022-09-26 15:01     ` Matthieu Baerts
2022-09-27  4:01       ` Dmytro Shytyi
2022-09-27 15:22         ` Matthieu Baerts
2022-09-27 21:56           ` Dmytro Shytyi
2022-09-25 23:25 ` [RFC PATCH mptcp-next v11 2/4] mptcp: add mptcp_stream_connect to *.h Dmytro Shytyi
2022-09-25 23:26 ` [RFC PATCH mptcp-next v11 3/4] mptcp: add mptcp_subflow_conn_sock() Dmytro Shytyi
2022-09-26 17:11   ` Matthieu Baerts
2022-09-27 15:11     ` Dmytro Shytyi
2022-09-25 23:26 ` Dmytro Shytyi [this message]
2022-09-26 14:46   ` [RFC PATCH mptcp-next v11 4/4] mptcp: reuse tcp_sendmsg_fastopen() Paolo Abeni
2022-09-27 15:09     ` Dmytro Shytyi
2022-09-26 14:52 ` [RFC PATCH mptcp-next v11 0/4] mptcp: Fast Open: Initiator Paolo Abeni
2022-09-27  3:22   ` Dmytro Shytyi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220925232601.25252-5-dmytro@shytyi.net \
    --to=dmytro@shytyi.net \
    --cc=benjamin.hesmans@tessares.net \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).