From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1515BC433E0 for ; Tue, 9 Jun 2020 17:56:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E206620774 for ; Tue, 9 Jun 2020 17:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725381; bh=jM0oMkokSpwwffYJacSP7JNj/zACzPww+HO/X0xDT+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xqwGbtowsN71KexoObq6BMXM3mkaHr9B2+gYSWUBy/KZyV6a0yEEpzqNcgh82m9/e 67oAjRVY+uZeOEs4p7fWNB4b5ucp7WDXpZVIAW2xZF8jzRZZAo8WuOvpaQEZwhRF1P SSd7ftvIkpwowcBBj6HtZ/ksdKCL6f0Ak7NxF9Cw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387490AbgFIR4S (ORCPT ); Tue, 9 Jun 2020 13:56:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:46582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733131AbgFIRym (ORCPT ); Tue, 9 Jun 2020 13:54:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3662207F9; Tue, 9 Jun 2020 17:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725282; bh=jM0oMkokSpwwffYJacSP7JNj/zACzPww+HO/X0xDT+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0dsKjld7Hhv/k/FsYIDnP6LyWaRrNizMQ7Xf9AulK+gYc3jY1pzwkT4kK0W/1eIXt +wasvdKbE7MnhWM6Mj8rDoML3aXA25OEkbS37JbHwHzSY4ZKRL5IfLHpXVkvcR993G gGbqkZzbEnxX0tcQcxr5GyrLQV2iYGJ4iAsu0Pl0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , "David S. Miller" Subject: [PATCH 5.6 15/41] mptcp: fix unblocking connect() Date: Tue, 9 Jun 2020 19:45:17 +0200 Message-Id: <20200609174113.589926014@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609174112.129412236@linuxfoundation.org> References: <20200609174112.129412236@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 41be81a8d3d09acb9033799938306349328861f9 ] Currently unblocking connect() on MPTCP sockets fails frequently. If mptcp_stream_connect() is invoked to complete a previously attempted unblocking connection, it will still try to create the first subflow via __mptcp_socket_create(). If the 3whs is completed and the 'can_ack' flag is already set, the latter will fail with -EINVAL. This change addresses the issue checking for pending connect and delegating the completion to the first subflow. Additionally do msk addresses and sk_state changes only when needed. Fixes: 2303f994b3e1 ("mptcp: Associate MPTCP context with TCP socket") Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/mptcp/protocol.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -920,6 +920,14 @@ static int mptcp_stream_connect(struct s int err; lock_sock(sock->sk); + if (sock->state != SS_UNCONNECTED && msk->subflow) { + /* pending connection or invalid state, let existing subflow + * cope with that + */ + ssock = msk->subflow; + goto do_connect; + } + ssock = __mptcp_socket_create(msk, TCP_SYN_SENT); if (IS_ERR(ssock)) { err = PTR_ERR(ssock); @@ -934,9 +942,17 @@ static int mptcp_stream_connect(struct s mptcp_subflow_ctx(ssock->sk)->request_mptcp = 0; #endif +do_connect: err = ssock->ops->connect(ssock, uaddr, addr_len, flags); - inet_sk_state_store(sock->sk, inet_sk_state_load(ssock->sk)); - mptcp_copy_inaddrs(sock->sk, ssock->sk); + sock->state = ssock->state; + + /* on successful connect, the msk state will be moved to established by + * subflow_finish_connect() + */ + if (!err || err == EINPROGRESS) + mptcp_copy_inaddrs(sock->sk, ssock->sk); + else + inet_sk_state_store(sock->sk, inet_sk_state_load(ssock->sk)); unlock: release_sock(sock->sk);