From nobody Fri May 3 20:36:48 2024 Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DD0B4682 for ; Sun, 25 Sep 2022 23:26:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1664148371; cv=none; d=zohomail.eu; s=zohoarc; b=ZCy/dPfWPNcvefJO4kaRmf14rV1MtiY+QH3Uiqilcka9F60Uqs9YaYXkoB6I8DeXjanI6vulhoYe6LRhLCL9HGk5jzEF5+1usoIjt6qtt3ZHV4/EooudI21dZyu0Gb89bosTF/+rfZae2dE6F8+Eew6Vre3/gyzH5ipjmzqqXDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1664148371; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=+gI5I5olr5+iXgM3I5tUNUeHJnYUQ+eC+S96KmqxXIg=; b=EqdgEP3ct8HD9TZT7IViFPmJ9R5NaLpQr2yeX/IrMWPQTFwBIfMik4CFW+4cibt7GGPE2ou31NHx3xglrY3TGs5jM1sSoILkHt+i5yw8Ry1PP+OAlAwQJ32XDmOLe7rJO5qQm74AS4JM+67YLM5iBG2aQg1pYCF3Ih2t991GDvo= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=shytyi.net; spf=pass smtp.mailfrom=dmytro@shytyi.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1664148371; s=hs; d=shytyi.net; i=dmytro@shytyi.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=+gI5I5olr5+iXgM3I5tUNUeHJnYUQ+eC+S96KmqxXIg=; b=ehf/QT7wObQ97AIrg1y15JhamAFI3Qmqyp3DGKV/moCTormcEz9TJ2rDJbxD60e+ giz6EgQjglC0fQ+pC4aB8vCL4hHZKBZpld2RxN5T50ByZkWepgRfYCPJE0e03BywX+L WvRw3SKQ+wRFZyvmrbKswMMNsh4ldYkY7kkLfeUA= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1664148368893720.3573427483719; Mon, 26 Sep 2022 01:26:08 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220925232601.25252-2-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v11 1/4] mptcp: add mptcp_setsockopt_fastopen Date: Mon, 26 Sep 2022 01:25:58 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925232601.25252-1-dmytro@shytyi.net> References: <20220925232601.25252-1-dmytro@shytyi.net> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Add set MPTFO socket option for MPTCP. This option is needed for the listen socket to accept MPTFO. Signed-off-by: Dmytro Shytyi --- net/mptcp/Makefile | 2 +- net/mptcp/fastopen.c | 37 +++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 5 +++++ net/mptcp/sockopt.c | 3 +++ 4 files changed, 46 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) +=3D mptcp.o =20 mptcp-y :=3D protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o d= iag.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 =20 obj-$(CONFIG_SYN_COOKIES) +=3D syncookies.o obj-$(CONFIG_INET_MPTCP_DIAG) +=3D mptcp_diag.o diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c new file mode 100644 index 000000000000..086cbad49979 --- /dev/null +++ b/net/mptcp/fastopen.c @@ -0,0 +1,37 @@ +/* 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 op= tval, + unsigned int optlen) +{ + struct sock *sk =3D (struct sock *)msk; + struct net *net =3D sock_net(sk); + struct socket *ssock; + struct sock *ssk; + int val; + int ret; + + ret =3D 0; + + if (copy_from_sockptr(&val, optval, sizeof(val))) + return -EFAULT; + + ssock =3D __mptcp_nmpc_socket(msk); + ssk =3D ssock->sk; + net =3D sock_net(ssk); + lock_sock(ssk); + + if (val >=3D 0 && ((1 << ssk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { + tcp_fastopen_init_key_once(net); + fastopen_queue_tune(ssk, val); + } else { + ret =3D -EINVAL; + } + + release_sock(ssk); + + 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); =20 +// Fast Open Mechanism functions begin +int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t op= tval, + 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 optn= ame) case TCP_NOTSENT_LOWAT: case TCP_TX_DELAY: case TCP_INQ: + case TCP_FASTOPEN: return true; } =20 @@ -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); } =20 return -EOPNOTSUPP; --=20 2.25.1 From nobody Fri May 3 20:36:48 2024 Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7098C4684 for ; Sun, 25 Sep 2022 23:26:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1664148370; cv=none; d=zohomail.eu; s=zohoarc; b=ZjtaGueAHAuj/ZxVJvJSImUbkaIEYWSXBGS+oQiN6Mit1saT945IQ8H+VqiQ+eps/WD9qV/vnB6KejSbzJ/ELECKRPd42VBOvffiuBEXWzq+V+CrJniLKuZ5n5Mn0IQpwkdwn00l0s/kYiFSaj89mREHysheRwWZh6XKLNerNlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1664148370; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=m5ozyr2RckgQ5NrtzpjNAamU9T+wocXkWjxuI7mu1x8=; b=Cwi73t9gjwxrZnxT02NIwDSbfFkUjrwx7mdSjUd6qf5tlFKBhSRb1D9uMMLq+UVb5oBmQQBXuRDUqK860olom6Ja7DEiQiOj1rrcTLFyp927yDy5a9umvB2YtXGx4aMoneprtjtUxy74y+X5DfoBVxTquJT0kRGDaY32BpX5DYg= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=shytyi.net; spf=pass smtp.mailfrom=dmytro@shytyi.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1664148370; s=hs; d=shytyi.net; i=dmytro@shytyi.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=m5ozyr2RckgQ5NrtzpjNAamU9T+wocXkWjxuI7mu1x8=; b=UVKK2taxEptzJeNjgwn9PNwvRJDmB62UVnWT59DezYzHy5zNvOeGyEQijkxulgl5 xWyvkRFjGD4DtcVORe9/9pbFiwPbp/+3r+4Yis+PDWgMEAi6WzfHXqno/0tDysQMvgE osrJnaBDWXc2F1LeBo/qdFXOaS5P9ID13yZJvd4k= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1664148369123871.0247626027892; Mon, 26 Sep 2022 01:26:09 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220925232601.25252-3-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v11 2/4] mptcp: add mptcp_stream_connect to *.h Date: Mon, 26 Sep 2022 01:25:59 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925232601.25252-1-dmytro@shytyi.net> References: <20220925232601.25252-1-dmytro@shytyi.net> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" 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 --- include/net/mptcp.h | 8 ++++++++ net/mptcp/protocol.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index c25939b2af68..d9908b839059 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -150,6 +150,7 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr= , struct tcp_sock *tp, struct mptcp_out_options *opts); =20 void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info); +int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, int = addr_len, int flags); =20 /* move the skb extension owership, with the assumption that 'to' is * newly allocated @@ -286,6 +287,13 @@ static inline bool mptcp_skb_can_collapse(const struct= sk_buff *to, =20 static inline void mptcp_space(const struct sock *ssk, int *s, int *fs) { } static inline void mptcp_seq_show(struct seq_file *seq) { } +static inline int mptcp_stream_connect(struct socket *sock, + struct sockaddr *uaddr, + int addr_len, + int flags) +{ + +} =20 static inline int mptcp_subflow_init_cookie_req(struct request_sock *req, const struct sock *sk_listener, 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); } =20 -static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uadd= r, - int addr_len, int flags) +int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, + int addr_len, int flags) { struct mptcp_sock *msk =3D mptcp_sk(sock->sk); struct mptcp_subflow_context *subflow; --=20 2.25.1 From nobody Fri May 3 20:36:48 2024 Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 851114685 for ; Sun, 25 Sep 2022 23:26:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1664148371; cv=none; d=zohomail.eu; s=zohoarc; b=bg9eJRqim7mb5OutGludFX98Tc+12wJuprE+a1BAZTS9o7TpIvD0WM/WlB9QaPaaaHZmCdH+MA4hchkexdt4P5LxSAxpUnQDhAC5hghTTgJKCnZaiMHoatashCZ85wUYly3ZHoyFODlwLDQtf8gr06Qgnk/tpthibjhCnj/PCFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1664148371; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=29/2Wv8ppT+6/XSVyrfjLFk6pFV1hhH3C4UmdC18qPc=; b=VDoR4TKy4EDd8ULNV5nTb1buZdPM8E7Eq+v9ELPGOzAUTVNci2u9vi1Uduq0w9UEISuJ3nntG6wW368k4jSZkf/4H33XVFT15NJkvOxuFSdrQT7mZbAB861q5+JF4NOjM33QA2rnRBR8xR7+wm4/ZAVpgMNs8qndBIO2htQNK/k= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=shytyi.net; spf=pass smtp.mailfrom=dmytro@shytyi.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1664148371; s=hs; d=shytyi.net; i=dmytro@shytyi.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=29/2Wv8ppT+6/XSVyrfjLFk6pFV1hhH3C4UmdC18qPc=; b=HmOZpHI2LDRMTZSTKqYGaFG2hm1vhAnDaX8tQKKyAPLAR/OJMn/9bdyIAIDzeaDG b/Zp1IfTUnjkQn9uOA0YP81S5AMSRxj6gYttmZZ0gE0uzD2Mq65+17BPqzrg3+OEZxt 5ri2TaPNdAY/nsaZ3bWrJ21wfPRjtRe9giqJxA2s= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 16641483695721005.7720995242595; Mon, 26 Sep 2022 01:26:09 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi Message-ID: <20220925232601.25252-4-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v11 3/4] mptcp: add mptcp_subflow_conn_sock() Date: Mon, 26 Sep 2022 01:26:00 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925232601.25252-1-dmytro@shytyi.net> References: <20220925232601.25252-1-dmytro@shytyi.net> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" In the following patches we will call mptcp_subflow_conn_sock() from=20 tcp_sendmsg_fastopen() in file "net/ipv4/tcp.c", thus make such symbol visible. Signed-off-by: Dmytro Shytyi --- include/net/mptcp.h | 1 + net/ipv4/tcp.c | 15 +++++++++++++-- net/mptcp/protocol.c | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index d9908b839059..ccf2b42837a1 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -151,6 +151,7 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr= , struct tcp_sock *tp, =20 void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info); int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, int = addr_len, int flags); +struct sock *mptcp_subflow_conn_sock(struct sock *sk); =20 /* move the skb extension owership, with the assumption that 'to' is * newly allocated diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 5702ca9b952d..a22c8044de17 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1197,8 +1197,19 @@ static int tcp_sendmsg_fastopen(struct sock *sk, str= uct msghdr *msg, } } flags =3D (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0; - err =3D __inet_stream_connect(sk->sk_socket, uaddr, - msg->msg_namelen, flags, 1); + if (!sk_is_mptcp(sk)) { + err =3D __inet_stream_connect(sk->sk_socket, uaddr, + msg->msg_namelen, flags, 1); + } else { + struct sock *parent =3D mptcp_subflow_conn_sock(sk); + + release_sock(sk); + release_sock(parent); + err =3D mptcp_stream_connect(sk->sk_socket, uaddr, + msg->msg_namelen, msg->msg_flags); + lock_sock(parent); + 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..fb08e1f458c0 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -58,6 +58,12 @@ static void __mptcp_check_send_data_fin(struct sock *sk); DEFINE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions); static struct net_device mptcp_napi_dev; =20 +struct sock * +mptcp_subflow_conn_sock(struct sock *sk) +{ + return ((mptcp_subflow_ctx(sk))->conn); +} + /* If msk has an initial subflow socket, and the MP_CAPABLE handshake has = not * completed yet or has failed, return the subflow socket. * Otherwise return NULL. --=20 2.25.1 From nobody Fri May 3 20:36:48 2024 Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF7E24682 for ; Sun, 25 Sep 2022 23:27:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1664148431; cv=none; d=zohomail.eu; s=zohoarc; b=UDjw2VvgNsR03Ry+D137KF0Cdz20jlMllvXTG1UQIbdXZr55/uzsqbk/dumMQwsg+z5tDdDaLgraylABFanlILVvCeHWXy9a/dv6W391d7AdvWhMwbIqfXmhoWoN4HVmh06ZyIpo+1q/0C3v5P7QvDT48cZmq0dAHBfrDUPP8nA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1664148431; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=80Ksk8Qlj9QydeBYveFPQAA9IxDN0PgU6HvxcL4LlC0=; b=i8/pU1sae6tvAeAK/2Mpj0C9kxFbqwp1S/Sr4F1K9x6zawb/JDfstL0vghreMjbvFJru+0oRnwBQ3ECAQasf3C997GjZlIiVPgEffkfgZxiigqoq/aqlWM54pK/lcRHhlMjsAKDJcZO3yUH/DHFE0T87mFh8sY4ZtvpAGtnCGE8= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=shytyi.net; spf=pass smtp.mailfrom=dmytro@shytyi.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1664148431; s=hs; d=shytyi.net; i=dmytro@shytyi.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=80Ksk8Qlj9QydeBYveFPQAA9IxDN0PgU6HvxcL4LlC0=; b=Y+nis/+5AXEIp++OPuaeoCgAKAmXp/4ZdA9thfWLqi6waS0U5lgOwdbX00iioUW+ vyQAPOQ8t2+VtUETLIogXTvloeBX/ozIS1pBvEjTrrwHxXWF1vmZaHJFlN6yGJk8RFm SUrtDsRqdIEb/AFXToeF9wxnVNGufq54IvU5yxT0= Received: from doris.localdomain (243.34.22.93.rev.sfr.net [93.22.34.243]) by mx.zoho.eu with SMTPS id 1664148369818729.127890630177; Mon, 26 Sep 2022 01:26:09 +0200 (CEST) From: Dmytro Shytyi To: mptcp@lists.linux.dev Cc: Dmytro Shytyi , Benjamin Hesmans Message-ID: <20220925232601.25252-5-dmytro@shytyi.net> Subject: [RFC PATCH mptcp-next v11 4/4] mptcp: reuse tcp_sendmsg_fastopen() Date: Mon, 26 Sep 2022 01:26:01 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220925232601.25252-1-dmytro@shytyi.net> References: <20220925232601.25252-1-dmytro@shytyi.net> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" In the following patches we will reuse modified tcp_sendmsg_fastopen(). We call it from mptcp_sendmsg(). Signed-of-by: Benjamin Hesmans Signed-off-by: Dmytro Shytyi --- 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) } } =20 -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 =3D tcp_sk(sk); struct inet_sock *inet =3D 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 msg= hdr *msg, size_t len) long timeo; =20 /* 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; =20 + lock_sock(sk); + + ssock =3D __mptcp_nmpc_socket(msk); + ssk =3D ssock->sk; + + lock_sock(ssk); + + if (ssock) { + int copied_syn_fastopen =3D 0; + + ret =3D tcp_sendmsg_fastopen(ssk, msg, &copied_syn_fastopen, len, NULL); + copied +=3D 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 &=3D MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL; =20 --=20 2.25.1