From patchwork Mon Sep 26 23:27:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 12989592 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9481C6FA82 for ; Mon, 26 Sep 2022 23:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbiIZX1u (ORCPT ); Mon, 26 Sep 2022 19:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiIZX1q (ORCPT ); Mon, 26 Sep 2022 19:27:46 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F88F6EF29 for ; Mon, 26 Sep 2022 16:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664234865; x=1695770865; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dTdNtwOMsNbFRYHs8fkMG5KM7mukDSfJKHtWQRWdNQ8=; b=ho38uD6CROEELp1goaOA9rVWAz27gENRRVNWLnqLoqZZtTQjw6INpS26 SYhLsNGGUlApq7h2ItaogJpqZ+GhE49QYZiuvsC1zQwwlAJVDcmdhzDGx 07H3ZVyhd5HzZzVm9Lo/dHjly0OiOX5+bGQWjZH8jYCZhyLdeQWImeU0k EnD3Si4whJk7sDQZiFr/Oo2GRjcG9QvBeSbsxwE0/0Q7L50DgSRtvZZiu +4nKNH2TQ6vPKzq7gOmEnqQG3UZsrlhhW5Y86Ni8hZmJX2qHizJSrifiT xalQoBypP5ZWXwzkkqgVWtSi1kvxPIr9027Bw/JFLwyuWqmihATHuP3Pq g==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="280890867" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="280890867" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:44 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="572424285" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="572424285" Received: from sankarka-mobl1.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.3.132]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:43 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Benjamin Hesmans , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, dmytro@shytyi.net, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net-next 1/4] mptcp: add TCP_FASTOPEN_CONNECT socket option Date: Mon, 26 Sep 2022 16:27:36 -0700 Message-Id: <20220926232739.76317-2-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> References: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Benjamin Hesmans Set the option for the first subflow only. For the other subflows TFO can't be used because a mapping would be needed to cover the data in the SYN. Acked-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Benjamin Hesmans Signed-off-by: Mat Martineau --- net/mptcp/sockopt.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 423d3826ca1e..c7cb68c725b2 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_CONNECT: return true; } @@ -567,7 +568,7 @@ static bool mptcp_supported_sockopt(int level, int optname) /* TCP_REPAIR, TCP_REPAIR_QUEUE, TCP_QUEUE_SEQ, TCP_REPAIR_OPTIONS, * TCP_REPAIR_WINDOW are not supported, better avoid this mess */ - /* TCP_FASTOPEN_KEY, TCP_FASTOPEN TCP_FASTOPEN_CONNECT, TCP_FASTOPEN_NO_COOKIE, + /* TCP_FASTOPEN_KEY, TCP_FASTOPEN, TCP_FASTOPEN_NO_COOKIE, * are not supported fastopen is currently unsupported */ } @@ -768,6 +769,19 @@ static int mptcp_setsockopt_sol_tcp_defer(struct mptcp_sock *msk, sockptr_t optv return tcp_setsockopt(listener->sk, SOL_TCP, TCP_DEFER_ACCEPT, optval, optlen); } +static int mptcp_setsockopt_sol_tcp_fastopen_connect(struct mptcp_sock *msk, sockptr_t optval, + unsigned int optlen) +{ + struct socket *sock; + + /* Limit to first subflow */ + sock = __mptcp_nmpc_socket(msk); + if (!sock) + return -EINVAL; + + return tcp_setsockopt(sock->sk, SOL_TCP, TCP_FASTOPEN_CONNECT, optval, optlen); +} + static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, sockptr_t optval, unsigned int optlen) { @@ -796,6 +810,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_CONNECT: + return mptcp_setsockopt_sol_tcp_fastopen_connect(msk, optval, optlen); } return -EOPNOTSUPP; @@ -1157,6 +1173,7 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname, case TCP_INFO: case TCP_CC_INFO: case TCP_DEFER_ACCEPT: + case TCP_FASTOPEN_CONNECT: return mptcp_getsockopt_first_sf_only(msk, SOL_TCP, optname, optval, optlen); case TCP_INQ: From patchwork Mon Sep 26 23:27:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 12989591 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A41C6FA82 for ; Mon, 26 Sep 2022 23:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbiIZX1t (ORCPT ); Mon, 26 Sep 2022 19:27:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbiIZX1q (ORCPT ); Mon, 26 Sep 2022 19:27:46 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57E526EF2B for ; Mon, 26 Sep 2022 16:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664234865; x=1695770865; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pFuL3oGB1skylBc+oR2zLed0XO1DUoAGU+z8uS8xsQU=; b=gWoRUDB5flTUFTRBgO8MGGy3udfKC+Nz7jfMntsphdureHFyQgVka/8b qj/0k2wd7fuvzwx71++Pd+ySlzcpK6tMpdr6JQ0vhG5R1229m7dH1JLBs /6Ox+HFPdmH91SiIMAytDpkvBOxyoV4ZEcPXqbpiBunvWq4Kj+d229OIN qqfDkzY1fJdo3x8bf+Zg97+Q0N162w0Y0l80fPfzFq+pQR1TaKe7sXGJC Cuiu3FcC0dnOdW40k+QZ/uSd0hbP8yOM664BSQbif/BzN2ejqpQ6FndNc 9Au4uLzA2RRe9MHhdY2Ii4CJlPeeQjmZ+uQZTjLS1yg2VPliqqMQtOGiR Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="280890870" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="280890870" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:44 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="572424286" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="572424286" Received: from sankarka-mobl1.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.3.132]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:43 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Benjamin Hesmans , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, dmytro@shytyi.net, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net-next 2/4] tcp: export tcp_sendmsg_fastopen Date: Mon, 26 Sep 2022 16:27:37 -0700 Message-Id: <20220926232739.76317-3-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> References: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Benjamin Hesmans It will be used to support TCP FastOpen with MPTCP in the following commit. Acked-by: Paolo Abeni Reviewed-by: Matthieu Baerts Co-developed-by: Dmytro Shytyi Signed-off-by: Dmytro Shytyi Signed-off-by: Benjamin Hesmans Signed-off-by: Mat Martineau --- include/net/tcp.h | 2 ++ net/ipv4/tcp.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 27e8d378c70a..4f71cc15ff8e 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -327,6 +327,8 @@ void tcp_remove_empty_skb(struct sock *sk); int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size); +int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *copied, + size_t size, struct ubuf_info *uarg); int tcp_sendpage(struct sock *sk, struct page *page, int offset, size_t size, int flags); int tcp_sendpage_locked(struct sock *sk, struct page *page, int offset, diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 5702ca9b952d..5237a3f08c94 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1162,9 +1162,8 @@ 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); From patchwork Mon Sep 26 23:27:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 12989594 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 114F3C32771 for ; Mon, 26 Sep 2022 23:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbiIZX2N (ORCPT ); Mon, 26 Sep 2022 19:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiIZX1t (ORCPT ); Mon, 26 Sep 2022 19:27:49 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 691526EF2A for ; Mon, 26 Sep 2022 16:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664234866; x=1695770866; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9am/bieXiysWtUx7w/8/1msQI6g+HrLkELye1uXSmPM=; b=dnTHYwqhusnhP82sHhQ1A8Dn06oazH+0mhOTQPW/uGnEpTQGUSFYq2eE qoIfIjEjGXj1iW/VOjW6Zqa4G+rWzDdIpxIRbGJLYbvcy2pVLovqcihcR qC2h440CuMg1nQoYcAvVsQ41mPA00LVWbb0i9DgP3THs5hnHVRlB3leyh MK63pZML06F4i0WU4Y8jGKaBto+FVDvmYH1oW14/xUP+Nvio9XU84vDlF OF29t8TzHx+et+0CEsgAvOHK98Ora4DOLsGo1iiniChV7qjxKF6h4AkJC wgswTD+hrBjg293maAdthPzbcWGNVwAU8bxUzPBTOC6VOFMjc7nv/jnla g==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="280890873" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="280890873" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:44 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="572424287" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="572424287" Received: from sankarka-mobl1.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.3.132]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:44 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Dmytro Shytyi , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, benjamin.hesmans@tessares.net, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net-next 3/4] mptcp: handle defer connect in mptcp_sendmsg Date: Mon, 26 Sep 2022 16:27:38 -0700 Message-Id: <20220926232739.76317-4-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> References: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Dmytro Shytyi When TCP_FASTOPEN_CONNECT has been set on the socket before a connect, the defer flag is set and must be handled when sendmsg is called. This is similar to what is done in tcp_sendmsg_locked(). Acked-by: Paolo Abeni Reviewed-by: Matthieu Baerts Co-developed-by: Benjamin Hesmans Signed-off-by: Benjamin Hesmans Signed-off-by: Dmytro Shytyi Signed-off-by: Mat Martineau --- net/mptcp/protocol.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 866dfad3cde6..fc753896caa0 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1677,6 +1677,7 @@ 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; @@ -1690,6 +1691,27 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) lock_sock(sk); + ssock = __mptcp_nmpc_socket(msk); + if (unlikely(ssock && inet_sk(ssock->sk)->defer_connect)) { + struct sock *ssk = ssock->sk; + int copied_syn = 0; + + lock_sock(ssk); + + ret = tcp_sendmsg_fastopen(ssk, msg, &copied_syn, len, NULL); + copied += copied_syn; + if (ret == -EINPROGRESS && copied_syn > 0) { + /* reflect the new state on the MPTCP socket */ + inet_sk_state_store(sk, inet_sk_state_load(ssk)); + release_sock(ssk); + goto out; + } else if (ret) { + release_sock(ssk); + goto out; + } + release_sock(ssk); + } + timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); if ((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) { From patchwork Mon Sep 26 23:27:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 12989593 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D88D6C32771 for ; Mon, 26 Sep 2022 23:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbiIZX17 (ORCPT ); Mon, 26 Sep 2022 19:27:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbiIZX1t (ORCPT ); Mon, 26 Sep 2022 19:27:49 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3CC6EF30 for ; Mon, 26 Sep 2022 16:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664234866; x=1695770866; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3eEN83FGptLBGWVNuc+N6UdQMdtD/faMYXdyfUdW2Ss=; b=m34chFg/DTH3bxYBJm1UUnNlRjfBMFeuZCSh+nRvxB5NdZxBJDpK3Mqo IeHlMtBLMDmadV3NTleVTqI2Hq4wyeZTggREYtGUXvVHN9AjFbdHtVmRT FJ+0Dv7+XIWPZLItqTYia4QotZX1N0d6Sp82IBKo4Hkflf7W83pQ4rcbp QwfQb3qfrMUbBeyRNX+RwjTfli2zkUezy8IU8pb0f/ec74eWhT9cwbXHh CpXEjeIqihPsl24Bho7lwVbbil2PnoOUN+f+njrk08RgxL5vYM/SUaFrM 3AT47ao6A53+wk+p+hPM/H3WAuMLfe3ITOic76wOAYvjMRPIVVY+AWI/e w==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="280890877" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="280890877" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:44 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="572424288" X-IronPort-AV: E=Sophos;i="5.93,347,1654585200"; d="scan'208";a="572424288" Received: from sankarka-mobl1.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.209.3.132]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 16:27:44 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Benjamin Hesmans , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, dmytro@shytyi.net, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net-next 4/4] mptcp: poll allow write call before actual connect Date: Mon, 26 Sep 2022 16:27:39 -0700 Message-Id: <20220926232739.76317-5-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> References: <20220926232739.76317-1-mathew.j.martineau@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Benjamin Hesmans If fastopen is used, poll must allow a first write that will trigger the SYN+data Similar to what is done in tcp_poll(). Acked-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Benjamin Hesmans Signed-off-by: Mat Martineau --- net/mptcp/protocol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index fc753896caa0..16c3a6fc347f 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3548,6 +3548,7 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, do_connect: err = ssock->ops->connect(ssock, uaddr, addr_len, flags); + inet_sk(sock->sk)->defer_connect = inet_sk(ssock->sk)->defer_connect; sock->state = ssock->state; /* on successful connect, the msk state will be moved to established by @@ -3698,6 +3699,9 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, if (state != TCP_SYN_SENT && state != TCP_SYN_RECV) { mask |= mptcp_check_readable(msk); mask |= mptcp_check_writeable(msk); + } else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) { + /* cf tcp_poll() note about TFO */ + mask |= EPOLLOUT | EPOLLWRNORM; } if (sk->sk_shutdown == SHUTDOWN_MASK || state == TCP_CLOSE) mask |= EPOLLHUP;