[PATCH mptcp-next v4 3/4] mptcp: set .splice_read

Geliang Tang posted 4 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH mptcp-next v4 3/4] mptcp: set .splice_read
Posted by Geliang Tang 2 months, 3 weeks ago
From: Geliang Tang <tanggeliang@kylinos.cn>

This patch sets .splice_read interface of mptcp struct proto_ops as
tcp_splice_read. And invoke .read_sock in __tcp_splice_read().

v2:
 - use INDIRECT_CALL_INET_1.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/ipv4/tcp.c       | 4 +++-
 net/mptcp/protocol.c | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c18682c3fa33..97175b75796b 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -774,13 +774,15 @@ static int tcp_splice_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
 
 static int __tcp_splice_read(struct sock *sk, struct tcp_splice_state *tss)
 {
+	const struct proto_ops *ops = READ_ONCE(sk->sk_socket->ops);
 	/* Store TCP splice context information in read_descriptor_t. */
 	read_descriptor_t rd_desc = {
 		.arg.data = tss,
 		.count	  = tss->len,
 	};
 
-	return tcp_read_sock(sk, &rd_desc, tcp_splice_data_recv);
+	return INDIRECT_CALL_INET_1(ops->read_sock, tcp_read_sock,
+				    sk, &rd_desc, tcp_splice_data_recv);
 }
 
 /**
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 10cc8756877e..33608404b871 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -4039,6 +4039,7 @@ static const struct proto_ops mptcp_stream_ops = {
 	.mmap		   = sock_no_mmap,
 	.set_rcvlowat	   = mptcp_set_rcvlowat,
 	.read_sock	   = mptcp_read_sock,
+	.splice_read	   = tcp_splice_read,
 };
 
 static struct inet_protosw mptcp_protosw = {
@@ -4144,6 +4145,7 @@ static const struct proto_ops mptcp_v6_stream_ops = {
 #endif
 	.set_rcvlowat	   = mptcp_set_rcvlowat,
 	.read_sock	   = mptcp_read_sock,
+	.splice_read	   = tcp_splice_read,
 };
 
 static struct proto mptcp_v6_prot;
-- 
2.48.1
Re: [PATCH mptcp-next v4 3/4] mptcp: set .splice_read
Posted by Paolo Abeni 2 months, 2 weeks ago
Hi,

On 6/27/25 5:59 PM, Geliang Tang wrote:
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 10cc8756877e..33608404b871 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -4039,6 +4039,7 @@ static const struct proto_ops mptcp_stream_ops = {
>  	.mmap		   = sock_no_mmap,
>  	.set_rcvlowat	   = mptcp_set_rcvlowat,
>  	.read_sock	   = mptcp_read_sock,
> +	.splice_read	   = tcp_splice_read,

This is potentially a bit problematic. i.e. if some day
tcp_splice_read() will be modified to actually touch tcp specific fields
into the `sk` argument, it will silently break mptcp.

I don't have a good solution, but possibly it will make sense to have an
mptcp specific splice_read.

Note that most of checks area already coded in mptcp_recvmsg(), so
mptcp_splice_read() and mptcp_recvmsg() could use a shared helper and
not much new code should be needed.

/P