From nobody Wed Oct 1 22:26:37 2025 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 81AA52D94A8; Sat, 27 Sep 2025 09:41:10 +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=1758966070; cv=none; b=K2MI3tk++5Grou/1gudu7HntThxhe4sVh42/TvIoX7YV5mumJjfqU/jNNm0RbDi+Cb2Mn99hx3hxxWfTKxJJuJbyl3ggZiYF7qwFEHiL8Bv9OlLzDcz/3KbKGbqtg22GJzklPLvnvZmjC/YRFyBXPrFGoBOV8QLTlEKzQlBC9VI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758966070; c=relaxed/simple; bh=DuR/n0MAhNOdVdW7cbtGYlCwhUUWqMCY1IxaSFB1xto=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kEPhy1Z3JqKPdvNnSTbwNczoPRXycZvPLHQoBPwKAegIpBkcsI0fQAVvIpxAwWYElidD3aNs35eh1WHV3wf8VD8wUm+LlZuD7EAjAVqXts4qDT9lL9h3WtAWcbuXzAoujeOMESdrAXxrfmdUVdJhU/BLqqo7xeZYVx26ec7wu4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YID/ekxJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YID/ekxJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9289EC113CF; Sat, 27 Sep 2025 09:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758966070; bh=DuR/n0MAhNOdVdW7cbtGYlCwhUUWqMCY1IxaSFB1xto=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YID/ekxJBq4AuQY5qqMfEo7RMton9JujOB8PjWdEKoZpp2cQ01xM3v6wfesMP+oyE Of1RF/F3pLmZUy8lBuCzjux4/KB6aidg9dIdo2In/leaFmRQImKXumHoF39HsaYw3D UVrqPVZsTwBuu75zWEZFKXrauWQs1B1j1CkUNA7/08PEDLwaJgX0lIHYKnpD/WJm9T 31UnWmLyNfnuC6CoWLcAOOWIjHkYAHztMnuTY40NDP7qtZahlSUBgLXCRAJlYGrQ+n m2Jy5TdZxaPYPKJR4cY66MiQdxOnRCLgGf0oKNSZf5BosV9IA7lMZZux1iSaFz+xf/ drA5gZGJqlC1Q== From: "Matthieu Baerts (NGI0)" Date: Sat, 27 Sep 2025 11:40:40 +0200 Subject: [PATCH net-next 4/8] mptcp: introduce the mptcp_init_skb helper Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250927-net-next-mptcp-rcv-path-imp-v1-4-5da266aa9c1a@kernel.org> References: <20250927-net-next-mptcp-rcv-path-imp-v1-0-5da266aa9c1a@kernel.org> In-Reply-To: <20250927-net-next-mptcp-rcv-path-imp-v1-0-5da266aa9c1a@kernel.org> To: Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Neal Cardwell , Kuniyuki Iwashima , David Ahern , Shuah Khan Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3172; i=matttbe@kernel.org; h=from:subject:message-id; bh=a6n+Svpd0CKjvMgJKQmYqY6PoYH398y5gIFNbgE5hm4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDKub1SY1zE1bs5MHv6bif+tDPgPz9demSHs8fXN8wbdP 2dfdmVc7ihlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZgIzxZGhjezok2M90T9mKdr uTw8TVNhv33NSbnTO/cUF8i5CMjPv8fwv9SUza91y/6XLOv8dksHPTV6qCT0Oq8012n+pI55CYL CrAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni Factor out all the skb initialization step in a new helper and use it. Note that this change moves the MPTCP CB initialization earlier: we can do such step as soon as the skb leaves the subflow socket receive queues. Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Paolo Abeni Reviewed-by: Geliang Tang Tested-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f994e7f45f7b96c280708d7a29c1423a91e4cfee..832782e23740d22acda608966c2= 9516666c9b111 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -326,27 +326,11 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *m= sk, struct sk_buff *skb) mptcp_rcvbuf_grow(sk); } =20 -static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, - struct sk_buff *skb, unsigned int offset, - size_t copy_len) +static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offs= et, + int copy_len) { - struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); - struct sock *sk =3D (struct sock *)msk; - struct sk_buff *tail; - bool has_rxtstamp; - - __skb_unlink(skb, &ssk->sk_receive_queue); - - skb_ext_reset(skb); - skb_orphan(skb); - - /* try to fetch required memory from subflow */ - if (!sk_rmem_schedule(sk, skb, skb->truesize)) { - MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); - goto drop; - } - - has_rxtstamp =3D TCP_SKB_CB(skb)->has_rxtstamp; + const struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); + bool has_rxtstamp =3D TCP_SKB_CB(skb)->has_rxtstamp; =20 /* the skb map_seq accounts for the skb offset: * mptcp_subflow_get_mapped_dsn() is based on the current tp->copied_seq @@ -358,6 +342,24 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, s= truct sock *ssk, MPTCP_SKB_CB(skb)->has_rxtstamp =3D has_rxtstamp; MPTCP_SKB_CB(skb)->cant_coalesce =3D 0; =20 + __skb_unlink(skb, &ssk->sk_receive_queue); + + skb_ext_reset(skb); + skb_dst_drop(skb); +} + +static bool __mptcp_move_skb(struct sock *sk, struct sk_buff *skb) +{ + u64 copy_len =3D MPTCP_SKB_CB(skb)->end_seq - MPTCP_SKB_CB(skb)->map_seq; + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct sk_buff *tail; + + /* try to fetch required memory from subflow */ + if (!sk_rmem_schedule(sk, skb, skb->truesize)) { + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); + goto drop; + } + if (MPTCP_SKB_CB(skb)->map_seq =3D=3D msk->ack_seq) { /* in sequence */ msk->bytes_received +=3D copy_len; @@ -678,7 +680,9 @@ static bool __mptcp_move_skbs_from_subflow(struct mptcp= _sock *msk, if (offset < skb->len) { size_t len =3D skb->len - offset; =20 - ret =3D __mptcp_move_skb(msk, ssk, skb, offset, len) || ret; + mptcp_init_skb(ssk, skb, offset, len); + skb_orphan(skb); + ret =3D __mptcp_move_skb(sk, skb) || ret; seq +=3D len; =20 if (unlikely(map_remaining < len)) { --=20 2.51.0