From nobody Mon Feb 9 07:23:55 2026 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 DECED31D39F; Thu, 29 Jan 2026 19:23:57 +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=1769714637; cv=none; b=Ba4k/yw1zWIMvSLz6FB7Aq038xazvxHT2bMpA0ehB2vrcxYJ+NDdDL/f1KFMuqHEI4WjMpfD8bxXhL6QA4tPripB471BaqrQ8UQV+jWRG82ZVh4IOfRTB33lTJU8h6a8wfQHgFmrMTNeghOwYflG2QsoZ4yLdod+3UGkhSZvxZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769714637; c=relaxed/simple; bh=eYBDsyJmB6j9pEkaHZ+2ZtIkwz1/CVg+my0AG9MLd4A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uCJXBjMvd7sB7PEgcjDrZH+EsVUyDMaNe/DL+tTIqMktTzX1op4UGpOQyrwowYBl1D0/0xRJw/gj6ZPLdnMtjYq9rxwfP/smICVANa2Jili5BYMUq29OyCrcnDcSoA/nuLZMm1zppIS/ZMOIF56GEOa2r0iQDJETAJopVVcDPng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t6W8I7+2; 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="t6W8I7+2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C15F8C2BC87; Thu, 29 Jan 2026 19:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769714637; bh=eYBDsyJmB6j9pEkaHZ+2ZtIkwz1/CVg+my0AG9MLd4A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=t6W8I7+23Hd3yol/qp7sB7sS0mMdhwDUtJJS3XW6m3BC7iX6/bYPWaLkMYlgOHIgd xrIABM4mm8EMACn+E/utBRh/Dg3yZ827KyqNcl+OoZJ0IlfUMGFMj/muyxsSc+pLwN LEGT8Pwqi7VO2ofswNOJpoafFn1P8zH4Xc1X9BCzI98Dw9Xu38E6ziYStX+Se0mYaq um5e25uJfUaTy99cA4m8e7YnlBM7uHmD5R2VfxNiFN5a5GlxCgB+7UG2FAf/UCuy4t wdvwYpoJuG5CYe86o/7XJswjScissme71NbD+pKvKPb769WJpw2Ar7DoDi/hrOmiIA AOUH7YZFSw+PQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 29 Jan 2026 20:23:35 +0100 Subject: [PATCH net-next 2/6] mptcp: implement .read_sock 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: <20260129-net-next-mptcp-splice-v1-2-994cac40daa0@kernel.org> References: <20260129-net-next-mptcp-splice-v1-0-994cac40daa0@kernel.org> In-Reply-To: <20260129-net-next-mptcp-splice-v1-0-994cac40daa0@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)" , Hannes Reinecke , Geliang Tang X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3705; i=matttbe@kernel.org; h=from:subject:message-id; bh=ZDGtaKUBriS4QMep24PHEfzUNFarX+TBum4YVF044uY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDKrNx8MUjtXfYwtrqymYGbc/ceSzV2LWWZ+nKQeEq9ne eGH2ImujlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIl80WRkmDXva96O95tnelww e35OPupL5ctfJY3LRL7n7rHpmBn57QHDPyOuvyHiFc1VCx70zpufH/rQdI7LHKEX2aeZL97J2Dg /lxkA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Current in-kernel TCP sockets -- i.e. from nvme_tcp_try_recv() -- need to call .read_sock interface of struct proto_ops, but it's not implemented in MPTCP. This patch implements it with reference to __tcp_read_sock() and __mptcp_recvmsg_mskq(). Corresponding to tcp_recv_skb(), a new helper for MPTCP named mptcp_recv_skb() is added to peek a skb from sk->sk_receive_queue. Compared with __mptcp_recvmsg_mskq(), mptcp_read_sock() uses sk->sk_rcvbuf as the max read length. The LISTEN status is checked before the while loop, and mptcp_recv_skb() and mptcp_cleanup_rbuf() are invoked after the loop. In the loop, all flags checks for __mptcp_recvmsg_mskq() are removed. Reviewed-by: Hannes Reinecke Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 82 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 80f37220ef0c..c58e306ec3ef 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4316,6 +4316,86 @@ static __poll_t mptcp_poll(struct file *file, struct= socket *sock, return mask; } =20 +static struct sk_buff *mptcp_recv_skb(struct sock *sk, u32 *off) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct sk_buff *skb; + u32 offset; + + if (!list_empty(&msk->backlog_list)) + mptcp_move_skbs(sk); + + while ((skb =3D skb_peek(&sk->sk_receive_queue)) !=3D NULL) { + offset =3D MPTCP_SKB_CB(skb)->offset; + if (offset < skb->len) { + *off =3D offset; + return skb; + } + mptcp_eat_recv_skb(sk, skb); + } + return NULL; +} + +/* + * Note: + * - It is assumed that the socket was locked by the caller. + */ +static int __mptcp_read_sock(struct sock *sk, read_descriptor_t *desc, + sk_read_actor_t recv_actor, bool noack) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct sk_buff *skb; + int copied =3D 0; + u32 offset; + + msk_owned_by_me(msk); + + if (sk->sk_state =3D=3D TCP_LISTEN) + return -ENOTCONN; + while ((skb =3D mptcp_recv_skb(sk, &offset)) !=3D NULL) { + u32 data_len =3D skb->len - offset; + int count; + u32 size; + + size =3D min_t(size_t, data_len, INT_MAX); + count =3D recv_actor(desc, skb, offset, size); + if (count <=3D 0) { + if (!copied) + copied =3D count; + break; + } + + copied +=3D count; + + msk->bytes_consumed +=3D count; + if (count < data_len) { + MPTCP_SKB_CB(skb)->offset +=3D count; + MPTCP_SKB_CB(skb)->map_seq +=3D count; + break; + } + + mptcp_eat_recv_skb(sk, skb); + } + + if (noack) + goto out; + + mptcp_rcv_space_adjust(msk, copied); + + if (copied > 0) { + mptcp_recv_skb(sk, &offset); + mptcp_cleanup_rbuf(msk, copied); + } +out: + return copied; +} + +static int mptcp_read_sock(struct sock *sk, read_descriptor_t *desc, + sk_read_actor_t recv_actor) +{ + return __mptcp_read_sock(sk, desc, recv_actor, false); +} + static const struct proto_ops mptcp_stream_ops =3D { .family =3D PF_INET, .owner =3D THIS_MODULE, @@ -4336,6 +4416,7 @@ static const struct proto_ops mptcp_stream_ops =3D { .recvmsg =3D inet_recvmsg, .mmap =3D sock_no_mmap, .set_rcvlowat =3D mptcp_set_rcvlowat, + .read_sock =3D mptcp_read_sock, }; =20 static struct inet_protosw mptcp_protosw =3D { @@ -4440,6 +4521,7 @@ static const struct proto_ops mptcp_v6_stream_ops =3D= { .compat_ioctl =3D inet6_compat_ioctl, #endif .set_rcvlowat =3D mptcp_set_rcvlowat, + .read_sock =3D mptcp_read_sock, }; =20 static struct proto mptcp_v6_prot; --=20 2.51.0