From nobody Thu Nov 27 14:01:09 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 3D9D33002D6 for ; Wed, 19 Nov 2025 21:54:35 +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=1763589277; cv=none; b=G8vUVTjua5gFFJq2RbMZnuGhn8Q+7i977lbJiW4aA64mDhuYoj4aaWpCwbUPLjZ/ol5bl6WjiHAfw2YVJWlsv86Mfe42DVwuu/+00T/RJoY7/AxdCENHq555dM0q3LBK/58RQ8y/VM6y7skGCWHmgDFoBariSxEHVsy5gLdKrk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763589277; c=relaxed/simple; bh=PdayE6EmgxNaInJNbKO98vucGv/vB+l2r4wmbQmD+Mk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=KrubrgfhR9hQ4M+SPj7BFJ5hrlOx2jMPTvUPjN9m0DtScBtCJoQ1wsAnACyLaQPAelBwKvpaDacJVlmhpZDTxATz7XdFcYKaK9TYsKYkKtjBUgmYdzpS59pYbkxSfqgMsdslmWMjLAD3Vw+H5f3tlWO9v2ldOf45JpHyfzfVJ3c= 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=gbDeZqG+; 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="gbDeZqG+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763589275; 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=2jzQmXOwwYh0MDj+JEbfYJZDZFWE8zZpArcIShBQbyI=; b=gbDeZqG+nirECSjGu7SWhtYvZp9ARety0NL5Y9gplhqpBx0fBt8MTD6cPQ9m1JBNLL34eG SeX2K0TNeRvZA07kPV/G8HIUaI9/GDHOFUjKJmpLdvGV+rQoZ+wnQqOh1qYNItmDzoxUHK kg9jxW2L1UEpyL2NaC40z9OUlpgakQU= Received: from mx-prod-mc-08.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-639-wp7v8sYpPGCegc4w_vpYxA-1; Wed, 19 Nov 2025 16:54:34 -0500 X-MC-Unique: wp7v8sYpPGCegc4w_vpYxA-1 X-Mimecast-MFC-AGG-ID: wp7v8sYpPGCegc4w_vpYxA_1763589273 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4DCE3180034F; Wed, 19 Nov 2025 21:54:33 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.44.33.89]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2E7EE180049F; Wed, 19 Nov 2025 21:54:31 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Cc: martineau@kernel.org Subject: [PATCH mptcp-next v6 2/4] mptcp: fix receive space timestamp initialization. Date: Wed, 19 Nov 2025 22:54:21 +0100 Message-ID: <811d8cc6f0b9bfa6080bd108805cabc021b3e9a5.1763588352.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.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WbSNSLOgIhfLbUD7Qor5h9NTr_D9kS9TWT5uC6K5lc4_1763589273 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 --- 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 | 9 ++++----- net/mptcp/protocol.h | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 64f592a7897c..d6d2d9d1849a 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2089,8 +2089,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)) @@ -3530,7 +3530,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *s= k, mptcp_copy_inaddrs(nsk, ssk); __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); @@ -3548,8 +3548,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); @@ -3745,6 +3743,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