From nobody Thu Nov 27 14:01:12 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 90C813093A7 for ; Thu, 20 Nov 2025 08:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628012; cv=none; b=t9CexT2YKAnqFb7bAC/NBBvaM3XLHriPuqfhVJCVR5VvtwbLSDt/IUBIPmVLg0VZi6yViMwn45wtogsbJvYWSl2CO4g4sRI6VKOYQKPvrA8N3YMg2Bt3EEnbgnZ0T1rBWtybRGhegXo/hqNcCSI++8IYUHBjWuAfXfx11KfQ1kM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628012; c=relaxed/simple; bh=XIySVHr1xGFqLAZzVNJCoceiAPT4qi9Fym6TCpJinf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=Nrn8Oyu3hnTCpHLQT99NJhQrDFHeY4yKjmm34zqncErvkSfn/JwAI5c9rtkAC8c6f1KRrjitoCEXGQhz6GlS7VYJ5hUe5dNn4BYqmVcN0VKqZt4QEkqrmxhhJ/Ni92423Ahm6aYGCd0vT8+XlFc9asycCCagpJe+m235eVEgGJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bb+WvWoy; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bb+WvWoy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763628008; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q5Hjjp4+I4ApWiQR2nRDfv0Ab/gCrFvattRyrPB8cv8=; b=bb+WvWoyFVuXPUQjL1aCvtzyx0zBrlzNflys86zCie95wmH0wniyn/TCD6x7nJdFFeE+br 7XC9Uz9epRRE6igpvY3L+zydfs0dmdZyii9twUGfNXiLoNS/qSMk5vzCz86Ve/QSNImRrt +Y932W17c1JrbywhylN9/2A+pWYMkAw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-IeYrJ-acMrCHTXxapti7WQ-1; Thu, 20 Nov 2025 03:40:03 -0500 X-MC-Unique: IeYrJ-acMrCHTXxapti7WQ-1 X-Mimecast-MFC-AGG-ID: IeYrJ-acMrCHTXxapti7WQ_1763628003 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC5C31801235; Thu, 20 Nov 2025 08:40:02 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.44.33.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CCB9C3001E83; Thu, 20 Nov 2025 08:40:01 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Cc: martineau@kernel.org Subject: [PATCH v7 mptcp-next 3/6] mptcp: fix receive space timestamp initialization. Date: Thu, 20 Nov 2025 09:39:47 +0100 Message-ID: <1ff99337d84cb7827b4aed83d6cfeffce9563d80.1763625391.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: k-0q7QD86uLXYmrhfyjfrISIdZmP2utHxt0ycdg_sXA_1763628003 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" MPTCP initialize the receive buffer stamp in mptcp_rcv_space_init(), using the provided subflow stamp. Such helper is invoked in several places; for passive sockets, space init happened at clone time. In such scenario, MPTCP ends-up accesses the subflow stamp before its initialization, leading to quite randomic timing for the first receive buffer auto-tune event, as the timestamp for newly created subflow is not refreshed there. Fix the issue moving the stamp initialization out of the mentioned helper, at the data transfer start, and always using a fresh timestamp. Fixes: 013e3179dbd2 ("mptcp: fix rcv space initialization") Reviewed-by: Mat Martineau Signed-off-by: Paolo Abeni --- v6 -> v7 - do not remove the mptcp_rcv_space_init() call in mptcp_sk_clone_init(): v5 -> v6 - really remove the stamp init from mptcp_rcv_space_init() v1 -> v2: - factor out only the tstamp change for better reviewability --- net/mptcp/protocol.c | 8 ++++---- net/mptcp/protocol.h | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e31ccc4bbb2d..b25cc8d5c98d 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2083,8 +2083,8 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock = *msk, int copied) =20 msk->rcvq_space.copied +=3D copied; =20 - mstamp =3D div_u64(tcp_clock_ns(), NSEC_PER_USEC); - time =3D tcp_stamp_us_delta(mstamp, msk->rcvq_space.time); + mstamp =3D mptcp_stamp(); + time =3D tcp_stamp_us_delta(mstamp, READ_ONCE(msk->rcvq_space.time)); =20 rtt_us =3D msk->rcvq_space.rtt_us; if (rtt_us && time < (rtt_us >> 3)) @@ -3525,6 +3525,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *s= k, __mptcp_propagate_sndbuf(nsk, ssk); =20 mptcp_rcv_space_init(msk, ssk); + msk->rcvq_space.time =3D mptcp_stamp(); =20 if (mp_opt->suboptions & OPTION_MPTCP_MPC_ACK) __mptcp_subflow_fully_established(msk, subflow, mp_opt); @@ -3542,8 +3543,6 @@ void mptcp_rcv_space_init(struct mptcp_sock *msk, con= st struct sock *ssk) msk->rcvq_space.copied =3D 0; msk->rcvq_space.rtt_us =3D 0; =20 - msk->rcvq_space.time =3D tp->tcp_mstamp; - /* initial rcv_space offering made to peer */ msk->rcvq_space.space =3D min_t(u32, tp->rcv_wnd, TCP_INIT_CWND * tp->advmss); @@ -3739,6 +3738,7 @@ void mptcp_finish_connect(struct sock *ssk) * accessing the field below */ WRITE_ONCE(msk->local_key, subflow->local_key); + WRITE_ONCE(msk->rcvq_space.time, mptcp_stamp()); =20 mptcp_pm_new_connection(msk, ssk, 0); } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 199f28f3dd5e..95c62f2ac705 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -917,6 +917,11 @@ static inline bool mptcp_is_fully_established(struct s= ock *sk) READ_ONCE(mptcp_sk(sk)->fully_established); } =20 +static inline u64 mptcp_stamp(void) +{ + return div_u64(tcp_clock_ns(), NSEC_PER_USEC); +} + void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk); void mptcp_data_ready(struct sock *sk, struct sock *ssk); bool mptcp_finish_join(struct sock *sk); --=20 2.51.1