From nobody Thu Nov 27 14:02:39 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 C8794328B48 for ; Tue, 4 Nov 2025 21:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762293129; cv=none; b=YlFR/a0UYlMVno8jB5yiHlHu4fQu0Q2lGikCAVuLMJbCx4Rz3d3Z2WqeBESJISRsd3VIZobHw383UxhEhRto7LA1V2oUouRzZs6B92QlAlsJST6wErRXS60Iu4rjE6+Hx1u+AIC7JDdLndbMC7v5DJlrCHTx1PKyj/S+JOdiWe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762293129; c=relaxed/simple; bh=cO+TiZ7FZwHQ+YXUqBpTfCSDE0dOGIEyLgweNUyUvkQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=hR2P8NTOYrRM42MPltinbguELqlK5FZqbrxFEXoVvuD2/sOC9BuuVxhWpXzjy3ePNgjYA/hoL8JjE2ZgjqcU/COwwvJgULX/+CCfoymIDSS+rVYWnfWU+6smPYZn8TXUGWzj2XniklBFvsl8TRdZBbO4ZVNezG4Z8vGBFFaal3Q= 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=Mo4xYfRc; arc=none smtp.client-ip=170.10.133.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="Mo4xYfRc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762293126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Uy6O4RY7w5qeUehIXfes15xbFEjDVkBTBQiO4BRw+E=; b=Mo4xYfRc90SRim5jp9UCY2HuJ29uCthM3WXZ8FHCZBMi/oVB4DRQ5oaSjbkPeS0TQv/VWr JbdgypmwlTD3reZXJ2ynle6tOf78nvCg6gSL79r313UJy54yGGrQX1vcLmxaNDVnSpFYNB xETRmhAKCG8GLlLgusAyc9PC0RE+eSI= 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-304-DWl7sPWuPLmBGLDFkFfOwg-1; Tue, 04 Nov 2025 16:52:05 -0500 X-MC-Unique: DWl7sPWuPLmBGLDFkFfOwg-1 X-Mimecast-MFC-AGG-ID: DWl7sPWuPLmBGLDFkFfOwg_1762293124 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 8FDE91800365 for ; Tue, 4 Nov 2025 21:52:04 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.32]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7F20B19560A2 for ; Tue, 4 Nov 2025 21:52:03 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 mptcp-next 4/7] mptcp: consolidate rcv space init Date: Tue, 4 Nov 2025 22:51:38 +0100 Message-ID: <501c37105f5645ed4249c9619c1fe3a63ac0bd97.1762292476.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.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 8bd8c8RlmxyHdZtpVvITeux6Kbspo1tNqbKlJZfZejQ_1762293124 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" MPTCP uses several calls of the mptcp_rcv_space_init() helper to initialize the receive space, with a catch-up call in mptcp_rcv_space_adjust(). Drop all the other strictly not needed invocations and move constant fields initialization at socket init/reset time. This removes a bit of complexity and will simplify the following patches. No functional changes intended. Signed-off-by: Paolo Abeni --- v1 -> v2: - split helper consolidation out of v1 patch - additionally move 'copied' and 'rtt_us' initialization out of mptcp_rcv_space_init() --- net/mptcp/protocol.c | 34 +++++++++++++++++----------------- net/mptcp/protocol.h | 1 - net/mptcp/subflow.c | 2 -- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index fd10565d9287..07e1703688ea 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2050,6 +2050,19 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, str= uct msghdr *msg, return copied; } =20 +static void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock= *ssk) +{ + const struct tcp_sock *tp =3D tcp_sk(ssk); + + msk->rcvspace_init =3D 1; + + /* initial rcv_space offering made to peer */ + msk->rcvq_space.space =3D min_t(u32, tp->rcv_wnd, + TCP_INIT_CWND * tp->advmss); + if (msk->rcvq_space.space =3D=3D 0) + msk->rcvq_space.space =3D TCP_INIT_CWND * TCP_MSS_DEFAULT; +} + /* receive buffer autotuning. See tcp_rcv_space_adjust for more informati= on. * * Only difference: Use highest rtt estimate of the subflows in use. @@ -2922,6 +2935,8 @@ static void __mptcp_init_sock(struct sock *sk) msk->timer_ival =3D TCP_RTO_MIN; msk->scaling_ratio =3D TCP_DEFAULT_SCALING_RATIO; msk->backlog_len =3D 0; + msk->rcvq_space.copied =3D 0; + msk->rcvq_space.rtt_us =3D 0; =20 WRITE_ONCE(msk->first, NULL); inet_csk(sk)->icsk_sync_mss =3D mptcp_sync_mss; @@ -3364,6 +3379,8 @@ static int mptcp_disconnect(struct sock *sk, int flag= s) msk->bytes_sent =3D 0; msk->bytes_retrans =3D 0; msk->rcvspace_init =3D 0; + msk->rcvq_space.copied =3D 0; + msk->rcvq_space.rtt_us =3D 0; =20 /* for fallback's sake */ WRITE_ONCE(msk->ack_seq, 0); @@ -3501,23 +3518,6 @@ struct sock *mptcp_sk_clone_init(const struct sock *= sk, return nsk; } =20 -void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk) -{ - const struct tcp_sock *tp =3D tcp_sk(ssk); - - msk->rcvspace_init =3D 1; - msk->rcvq_space.copied =3D 0; - msk->rcvq_space.rtt_us =3D 0; - - 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); - if (msk->rcvq_space.space =3D=3D 0) - msk->rcvq_space.space =3D TCP_INIT_CWND * TCP_MSS_DEFAULT; -} - static void mptcp_destroy(struct sock *sk) { struct mptcp_sock *msk =3D mptcp_sk(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 49f211e427bf..7c9e143c0fb5 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -918,7 +918,6 @@ static inline u64 mptcp_stamp(void) return div_u64(tcp_clock_ns(), NSEC_PER_USEC); } =20 -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); bool mptcp_schedule_work(struct sock *sk); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index ac8616e7521e..b64ab7649908 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -462,8 +462,6 @@ void __mptcp_sync_state(struct sock *sk, int state) =20 subflow =3D mptcp_subflow_ctx(ssk); __mptcp_propagate_sndbuf(sk, ssk); - if (!msk->rcvspace_init) - mptcp_rcv_space_init(msk, ssk); =20 if (sk->sk_state =3D=3D TCP_SYN_SENT) { /* subflow->idsn is always available is TCP_SYN_SENT state, --=20 2.51.0