Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp826587ybg; Tue, 9 Jun 2020 13:59:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoQnG2bR4gfNPVfoR6LgMGW4FahXioE4cmoG3E+Q7xQblwPEHsOM7IGkyKuBnqggBTNyEL X-Received: by 2002:aa7:c6d1:: with SMTP id b17mr30187330eds.39.1591736355679; Tue, 09 Jun 2020 13:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591736355; cv=none; d=google.com; s=arc-20160816; b=H9i77Q5AmcwX0aZWIbF0bITiYSX6BgARB6X1STduDTNYCH6quCMY4CYaZNuCD6IQCB F20Rbioa1OXlxXfuqfHZ1H6TbAJCPldOgc/5L99immL0sMmgaMmDPdXL6tce0tZh6suW HlnI3yN9Y7iawX81APeoQk38hxy9y96pM0mM0vY2BxyOuQsCt545z8oAKqRbS9oxVAGo eBMosX5JO0g3eCssO4HhmBKU3psmrfmu6rdO1erMJPs32ze2GxIkFSRTB7hnkErnSVoR GzGdTDbNSxlI78zJi2dfOoZPlu0aPjmXiUw1IgY9+jRrA3Lylnt6UxswfdJnWrDRPDoQ ai0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tgHk7Nwvgr9gPAf0hXkJmLMrunxy5Pg7q0WU1UwN7+4=; b=Z3Dup2SyBZNrxqW1LHTLUdOFDrQzDoRGX5lDCAU0y/awsl7z4BMzPkQsx/N4g8ShL+ b4JbJICGPvh8Sl3riWD1AVOpmKoobsPWtsWp5WfBWjqAsxJVrII7Jk2N3tt3B2+OIGaF Cdt4hCoVH14jCJ0XpT63B31Z8J3ouSEPewNtfmmfdA9HY77DPtuqENxNNrhIhNfojSR2 /Gs+L96tEiKdbiCOmcjEVnSNA8Hkea1GWMBwlRdTgwM6otufZfRW7Wdh0u1/znnes/Aw 8zMZfo5XZXOwNY+RQ6Vr2F8MFYUs51TrobKSseYJqk/ekR5xeV0LPTWaJ2Dm6GOIw0Z1 tJpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0dsKjld7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si11860321ejl.1.2020.06.09.13.58.52; Tue, 09 Jun 2020 13:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0dsKjld7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387486AbgFIR4S (ORCPT + 99 others); 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);