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)) {