From: Dmytro Shytyi <dmytro@shytyi.net>
To: mptcp@lists.linux.dev
Cc: Dmytro Shytyi <dmytro@shytyi.net>
Subject: [RFC PATCH mptcp-next v5 04/10] Treat a socket option TCP_FASTOPEN on Lister side. Suggestion @mmartineau(MAY 22): 'Need to use ssk instead of sk in these several lines' (1 AUG): 'Since fastopen is only relevant for the initial subflow (and never with MP_JOIN). __mptcp_nmpc_socket() should give the initial subflow'
Date: Wed, 14 Sep 2022 13:31:45 +0200 [thread overview]
Message-ID: <20220914113151.9898-4-dmytro@shytyi.net> (raw)
In-Reply-To: <20220914113151.9898-1-dmytro@shytyi.net>
Treat a socket option TCP_FASTOPEN on
Lister side. Suggestion @mmartineau(MAY 22): 'Need to use ssk instead of sk
in these several lines' (1 AUG): 'Since fastopen is only relevant for the
initial subflow (and never with MP_JOIN). __mptcp_nmpc_socket() should give
the initial subflow'
Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
net/mptcp/fastopen.c | 31 +++++++++++++++++++++++++++++++
net/mptcp/protocol.c | 4 ++--
net/mptcp/protocol.h | 3 +++
net/mptcp/sockopt.c | 3 +++
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c
index 0e071c988894..2633d5148dcb 100644
--- a/net/mptcp/fastopen.c
+++ b/net/mptcp/fastopen.c
@@ -54,3 +54,34 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
ret = -EFAULT;
return ret;
}
+
+int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t optval,
+ unsigned int optlen)
+{
+ struct sock *ssk = __mptcp_nmpc_socket(msk)->sk;
+ 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);
+ lock_sock(ssk);
+
+ if (val >= 0 && ((1 << ssk->sk_state) & (TCPF_CLOSE |
+ TCPF_LISTEN))) {
+ tcp_fastopen_init_key_once(net);
+ fastopen_queue_tune(ssk, val);
+ } else {
+ ret = -EINVAL;
+ }
+
+ release_sock(ssk);
+ release_sock(sk);
+
+ return ret;
+}
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 6bbf1b86465d..af99a03021c9 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3474,8 +3474,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 ad51910f1cc9..ef8330d5a9b5 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -835,11 +835,14 @@ 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_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
size_t len, struct mptcp_sock *msk,
size_t *copied);
+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)
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
next prev parent reply other threads:[~2022-09-14 11:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 11:31 [RFC PATCH mptcp-next v5 01/10] mptcp: Fast Open Mechanism Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 02/10] Initiator: MSG_FASTOPEN in sendto triggers the mptcp_sendsmg_fastopen. It requests a MPTFO cookie. Suggestion @palbeni(JAN 17): 'split the patch in several small one, clearly documenting in the individual commit message what each patch is doing and why' Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 03/10] Initiator: mptcp_sendmsg_fastopen. Usage of lock_sock() / release_sock() leads to hangup' Dmytro Shytyi
2022-09-14 11:31 ` Dmytro Shytyi [this message]
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 05/10] This fixes the unexpected value of subflow->map_seq for the second packet that leads to packet discard and further retransmit Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 06/10] This commit introduces mptfo variables for msk and options. Also fixes the infinite retransmissions in the end of second session. Suggestion @palbeni (SEP 1) during the meting to 'look at data_ack' Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 07/10] Add the received skb on the listener side to msk and set flag mptfo to 1 to treat some parts only in MPTFO case. This function is called from the functions presented in the next patch Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 08/10] This is temporary modification and will be adressed in the new version of the patch: Remove OPTIONS_TS from the options. See disscusion in the mailing list (JAN 18) [PATCH v2] fastopen with @palbeni Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 09/10] These 2 functions are from protocol.c. Cannot import as not in protocol.h. Should I leave them like this? Or add prototypes in protocol.h and reuse? Dmytro Shytyi
2022-09-14 11:31 ` [RFC PATCH mptcp-next v5 10/10] MPTFO tests: these are examples that probably are going to be integrated to the mptcp_connect.* selftests 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=20220914113151.9898-4-dmytro@shytyi.net \
--to=dmytro@shytyi.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).