Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp441326rdb; Thu, 8 Feb 2024 10:06:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXKXmz0TGVQsEsv59oXYu35AZVQZ0tB25/CDGqOq1SJKeNray+QZASG6nJNOsPhT/JSsT17QFQ1lcRH1k0IQ/3sasteReduaX7X1bvCuQ== X-Google-Smtp-Source: AGHT+IE4J8DYrzM+edm3H4rC43tB6vqEbbRmHqKCjGwf4CFi/GliyUXNwsECvEcG5Q+bWipXvQbh X-Received: by 2002:a05:6870:7252:b0:218:b6d2:87c3 with SMTP id y18-20020a056870725200b00218b6d287c3mr1764822oaf.23.1707415587111; Thu, 08 Feb 2024 10:06:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415587; cv=pass; d=google.com; s=arc-20160816; b=swgWt/9JsDUtegixdE0mY9iutiXwGvR6AHSCBef/6FiIn6iJLv29CFk+O8qA5Th3ZW 2yl9jLVXRjJIQ/Yu3xr5cl2lkRMZym2+8SO9Xr8Uz2aN1ge3PivijvvkSPBi6k39aAVD yOG3LZfx6LQZbVE4DGeHz4XGV2t9O/FVpPcaUqz7kCJZTgXJlDFGXETngGxX0hVhL3B9 tDfTscYEjRzxJ0BFySj13jZVpk+sntc3zwRKslT5Tosq0eZhxgSRGrnb2Y2y/o2AxBxJ uHRmuIZ6MNmorhxT2C88cyakDnoFy7fqiwsYi1FYzaCbHXjLCj9T4NFMOl2NNKv+Vyje FMrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=MZ9Q8+nkcU3rSMvDK3D+MZUQbR7DGhTtIYBaOYm7j2g=; fh=HySDXBr7lflsSwqWqBkL7ejBF2rJGjMpqiWStjoB4nk=; b=FmxcpfpZacNy1zLtElprRM+tf2yzqh6HY8ZCP5kz0i0/+lZ06ZNm3lEMT2ogSM5GR7 6o6jkQsa3Vm41HPu2r3XiVnl63iuUE8YhK3XNHr0b9sdE18LipAIbUu+7l/IIkeHEIOR eyINy2nY4mH5azh1Z2fPosoHZNd2dh7Q/zkMa6gT/a+A7WNmIq4EUYJKXFsSHGlbtbC/ vO6LkqBsIJ4wFmKYAWJKGiyGrHzJBCO2i4S3IQP2vHDYtrrKw6ibgW8N6mqxltqa1S3p e/YrhIgHxALO7oY6kjaPaTQh/TEJq7i4/UPHx5DdBipORHovV8Fdy5A1jTnHWehcktK/ +p5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XgTGszmx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58508-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58508-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVQpH1ANJ4e9hZ/XV35cLIggZJJQMJqkJ789Zfas7JnImRwl+BJb2pGbl1glPhn2p7J4DHyQGka66yJuPgPHrEqz6mbXKSghIvXOhmOww== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c15-20020a056870b28f00b00214aa267364si35563oao.253.2024.02.08.10.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:06:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58508-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XgTGszmx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58508-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58508-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2FED328CE80 for ; Thu, 8 Feb 2024 18:05:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2ABA127B55; Thu, 8 Feb 2024 18:04:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XgTGszmx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C26AA1272D0; Thu, 8 Feb 2024 18:04:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415473; cv=none; b=DFOTLBnaELzmalUXhQaba24NkPcs2eeu13GpFT30PE0N/EONLX9fbFZqNeuyjVW5g7NDCgwFATyxTWmFNV7P1uTUwS/mTGLTTRj+fG6PdLaCuDC2UT8LuKCyoflar8vGp328En2A2k34ndy/+hFNIXvyZDEy4SzlzivlwJaUz1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415473; c=relaxed/simple; bh=yHJvs4che6WyhYHzxH8wT4v6HXxxwDmE2feB06/a0QY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZjdbcoLH/sI9CqBMT0MHRx50sftmfYjbbWSsZ4ERbd4FOeBd3zznCA8TLmHsWCn8B+VF8O+mbnX2u95CC5IRtXh0gK0rmBpCBV9VTCsqrGiHCOuUM3s2mScRQ5lNr5lneFgWX0l7AQMXmknY0YFbX0Wv3S+dpjpVKQB7RvfY8hs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XgTGszmx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA1A0C43390; Thu, 8 Feb 2024 18:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415473; bh=yHJvs4che6WyhYHzxH8wT4v6HXxxwDmE2feB06/a0QY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XgTGszmxQE3Wk32I7duZggjSPhqW9GNMht/S90Hhce0HOgMMHTmCh5iagf56vS/RQ lsZwnH+UjSh+9IT3ANTzDVZlhgnzBh9zs9XiOoknlEZklSFA7SjGWUOJZZVm6VrhC3 gkSlatMe561yStwVPFXfsmaPDASjbNC3vOtwoaAudkjDLZZi+oME5s5VAYZNn83MCM DkFRtvUtsjld5/Ifxyh0KsqB+UJ5WMgOQJ9hQKAbxNkka6TMaS5xQrL7R1w1pjEfUs ufGPyojuVBURq4kQe5Mzs3oLsIAVxjFFLNdOZ+rxa3oVyfpDdXBAwnnBzffx3Dz4t6 KnGsKJJV74ueQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:51 +0100 Subject: [PATCH net 3/7] mptcp: fix more tx path fields initialization Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-3-f75cc5b97e5a@kernel.org> References: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-0-f75cc5b97e5a@kernel.org> In-Reply-To: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-0-f75cc5b97e5a@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kishen Maloor , Florian Westphal , Peter Krystad , Dmytro Shytyi , Benjamin Hesmans Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Paasch , "Matthieu Baerts (NGI0)" , stable@vger.kernel.org X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2392; i=matttbe@kernel.org; h=from:subject:message-id; bh=BH9JwtYC2RN/3BDjjpe9vHZJy5WVFOfYRfxZhvGrfHM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxRehoTpOkhQagMNL0KqONyCoHfQC3+GgB+o7X hLmr9ahZ5KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXoQAKCRD2t4JPQmmg c6QsD/9+sUDZ1mdnC9h189TtEe7cUCxjSjCf2hgQZ6q5p9UWmq8m/CkIkxsyi0S37ONi2QSE/sq kDVg0zfgcA3HnVdGJYZ219wpOWcSTT5O6TPAot3vre7gzOFtIiiHXK0QfpuhTquTQC697z4IUIh LhBpYK6uoDZH6ezQje3PKwddcA5v3XGtCQgEfUJRfn8+pbhFcZzsUZlyxhHFHRsO1hQJohYZon8 CRfdsk8BXLvyJODr6zpN/A/BzxJYk1eOFfn1TegSKHGVYBJ/QxKT34uxw8l5p5AHojkvp8BP5yW t2ozFgG4qcKOp/28LzMPCmszncJKvXWLluI03czeiu5GefBw7tVkEFZr1NMBZvIPoDDoa5Hw+5S s/p1mQ0EWqp0Dg5d8SrzfwghkRUkyPWMYWTAat2oy7Eo+RF3cqVFmvM5sDl/yY8ILm12GRQoEbd y7LIUzCl1MK0VjhFlsoyY5MBUYSy+20awY7muTWX6mGnO1VP5cmrmC91f2NVeU4douFSbNY2VC6 f0c9FAcFIZawV9V/+42VCGL5bGoEMfjW3a1We+e7mvY4EcK84Vnkku/uJjN7OepjpGXd2PWEO/s xbtAsNle5kH1n0seFi6FOenAvNeAyHS+ob2ee8F9JJNZHvkdemZCbKjJxcoSwyq6NOC16S1NbvC knAdu5d97NpXbfw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni The 'msk->write_seq' and 'msk->snd_nxt' are always updated under the msk socket lock, except at MPC handshake completiont time. Builds-up on the previous commit to move such init under the relevant lock. There are no known problems caused by the potential race, the primary goal is consistency. Fixes: 6d0060f600ad ("mptcp: Write MPTCP DSS headers to outgoing data packets") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 6 ++---- net/mptcp/subflow.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 7632eafb683b..8cb6a873dae9 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3478,10 +3478,8 @@ void mptcp_finish_connect(struct sock *ssk) * accessing the field below */ WRITE_ONCE(msk->local_key, subflow->local_key); - WRITE_ONCE(msk->write_seq, subflow->idsn + 1); - WRITE_ONCE(msk->snd_nxt, msk->write_seq); - WRITE_ONCE(msk->snd_una, msk->write_seq); - WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd); + WRITE_ONCE(msk->snd_una, subflow->idsn + 1); + WRITE_ONCE(msk->wnd_end, subflow->idsn + 1 + tcp_sk(ssk)->snd_wnd); mptcp_pm_new_connection(msk, ssk, 0); } diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 56b2ac2f2f22..c2df34ebcf28 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -421,12 +421,21 @@ static bool subflow_use_different_dport(struct mptcp_sock *msk, const struct soc void __mptcp_sync_state(struct sock *sk, int state) { + struct mptcp_subflow_context *subflow; struct mptcp_sock *msk = mptcp_sk(sk); + struct sock *ssk = msk->first; - __mptcp_propagate_sndbuf(sk, msk->first); + subflow = mptcp_subflow_ctx(ssk); + __mptcp_propagate_sndbuf(sk, ssk); if (!msk->rcvspace_init) - mptcp_rcv_space_init(msk, msk->first); + mptcp_rcv_space_init(msk, ssk); + if (sk->sk_state == TCP_SYN_SENT) { + /* subflow->idsn is always available is TCP_SYN_SENT state, + * even for the FASTOPEN scenarios + */ + WRITE_ONCE(msk->write_seq, subflow->idsn + 1); + WRITE_ONCE(msk->snd_nxt, msk->write_seq); mptcp_set_state(sk, state); sk->sk_state_change(sk); } -- 2.43.0