Skip to contentSkip to conversation

udp:allow UDP cmsghdrs through io_uring

PATCH In review Victor Stewart 3 participants 6 messages Dec 16, 2020 – Feb 17, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 udp:allow UDP cmsghdrs through io_uring

This patch adds PROTO_CMSG_DATA_ONLY to inet_dgram_ops and inet6_dgram_ops so that UDP_SEGMENT (GSO) and UDP_GRO can be used through io_uring.

GSO and GRO are vital to bring QUIC servers on par with TCP throughputs, and together offer a higher throughput gain than io_uring alone (rate of data transit
considering), thus io_uring is presently the lesser performance choice.

RE http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-paper-DRAFT-1.pdf,
GSO is about +~63% and GRO +~82%.

this patch closes that loophole.

---
 net/ipv4/af_inet.c  | 1 +
 net/ipv6/af_inet6.c | 1 +
 net/socket.c        | 8 +++++---
 3 files changed, 7 insertions(+), 3 deletions(-)
net/ipv4/af_inet.c +1 -0
index b7260c8cef2e..c9fd5e7cfd6e 100644
@@ -1052,6 +1052,7 @@ EXPORT_SYMBOL(inet_stream_ops);
 
 const struct proto_ops inet_dgram_ops = {
 	.family		   = PF_INET,
+	.flags		   = PROTO_CMSG_DATA_ONLY,
 	.owner		   = THIS_MODULE,
 	.release	   = inet_release,
 	.bind		   = inet_bind,
net/ipv6/af_inet6.c +1 -0
index e648fbebb167..560f45009d06 100644
@@ -695,6 +695,7 @@ const struct proto_ops inet6_stream_ops = {
 
 const struct proto_ops inet6_dgram_ops = {
 	.family		   = PF_INET6,
+	.flags		   = PROTO_CMSG_DATA_ONLY,
 	.owner		   = THIS_MODULE,
 	.release	   = inet6_release,
 	.bind		   = inet6_bind,
net/socket.c +5 -3
index 6e6cccc2104f..6995835d6355 100644
@@ -2416,9 +2416,11 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
 long __sys_sendmsg_sock(struct socket *sock, struct msghdr *msg,
 			unsigned int flags)
 {
-	/* disallow ancillary data requests from this path */
-	if (msg->msg_control || msg->msg_controllen)
-		return -EINVAL;
+	if (msg->msg_control || msg->msg_controllen) {
+		/* disallow ancillary data reqs unless cmsg is plain data */
+		if (!(sock->ops->flags & PROTO_CMSG_DATA_ONLY))
+			return -EINVAL;
+	}
 
 	return ____sys_sendmsg(sock, msg, flags, NULL, 0);
 }
Signature · 1 line
2.26.2
Acked-by on v5 1/1
#1 lore raw
Quoted 7 lines · Victor Stewart

This patch adds PROTO_CMSG_DATA_ONLY to inet_dgram_ops and inet6_dgram_ops so that UDP_SEGMENT (GSO) and UDP_GRO can be used through io_uring.

GSO and GRO are vital to bring QUIC servers on par with TCP throughputs, and together offer a higher throughput gain than io_uring alone (rate of data transit
considering), thus io_uring is presently the lesser performance choice.

Quoted 6 lines

RE http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-paper-DRAFT-1.pdf,
GSO is about +~63% and GRO +~82%.

this patch closes that loophole.

Thanks for adding this! I audied the code and couldn't find an escalation path. +Jann could you please double check?

Quoted 52 lines
---
 net/ipv4/af_inet.c  | 1 +
 net/ipv6/af_inet6.c | 1 +
 net/socket.c        | 8 +++++---
 3 files changed, 7 insertions(+), 3 deletions(-)
net/ipv4/af_inet.c +1 -0
index b7260c8cef2e..c9fd5e7cfd6e 100644
@@ -1052,6 +1052,7 @@ EXPORT_SYMBOL(inet_stream_ops);
 
 const struct proto_ops inet_dgram_ops = {
        .family            = PF_INET,
+       .flags             = PROTO_CMSG_DATA_ONLY,
        .owner             = THIS_MODULE,
        .release           = inet_release,
        .bind              = inet_bind,
net/ipv6/af_inet6.c +1 -0
index e648fbebb167..560f45009d06 100644
@@ -695,6 +695,7 @@ const struct proto_ops inet6_stream_ops = {
 
 const struct proto_ops inet6_dgram_ops = {
        .family            = PF_INET6,
+       .flags             = PROTO_CMSG_DATA_ONLY,
        .owner             = THIS_MODULE,
        .release           = inet6_release,
        .bind              = inet6_bind,
net/socket.c +5 -4
index 6e6cccc2104f..6995835d6355 100644
@@ -2416,9 +2416,11 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
 long __sys_sendmsg_sock(struct socket *sock, struct msghdr *msg,
                        unsigned int flags)
 {
-       /* disallow ancillary data requests from this path */
-       if (msg->msg_control || msg->msg_controllen)
-               return -EINVAL;
+       if (msg->msg_control || msg->msg_controllen) {
+               /* disallow ancillary data reqs unless cmsg is plain data */
+               if (!(sock->ops->flags & PROTO_CMSG_DATA_ONLY))
+                       return -EINVAL;
+       }
 
        return ____sys_sendmsg(sock, msg, flags, NULL, 0);
 }
--

2.26.2

maintainer Acked-by on v5 1/1
#2 lore raw
In reply to Victor Stewart
Quoted 10 lines · Victor Stewart

This patch adds PROTO_CMSG_DATA_ONLY to inet_dgram_ops and inet6_dgram_ops so that UDP_SEGMENT (GSO) and UDP_GRO can be used through io_uring.

GSO and GRO are vital to bring QUIC servers on par with TCP throughputs, and together offer a higher throughput gain than io_uring alone (rate of data transit
considering), thus io_uring is presently the lesser performance choice.

RE http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-paper-DRAFT-1.pdf,
GSO is about +~63% and GRO +~82%.

this patch closes that loophole.

LGTM

Signature · 1 line
Jens Axboe
#3 lore raw

might this still make it into 5.11?

Quoted 20 lines · Jens Axboe
Quoted 10 lines · Victor Stewart

This patch adds PROTO_CMSG_DATA_ONLY to inet_dgram_ops and inet6_dgram_ops so that UDP_SEGMENT (GSO) and UDP_GRO can be used through io_uring.

GSO and GRO are vital to bring QUIC servers on par with TCP throughputs, and together offer a higher throughput gain than io_uring alone (rate of data transit
considering), thus io_uring is presently the lesser performance choice.

RE http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-paper-DRAFT-1.pdf,
GSO is about +~63% and GRO +~82%.

this patch closes that loophole.

LGTM

--
Jens Axboe

maintainer
#4 lore raw
Quoted 1 line · Victor Stewart

might this still make it into 5.11?

Doesn't meet the criteria to go in at this point. I sometimes make exceptions, but generally speaking, something going into 5.11 should have been completed at least a week ago.

So I'd feel more comfortable pushing this to 5.12.

Signature · 1 line
Jens Axboe
#5 lore raw
Quoted 9 lines · Jens Axboe
Quoted 1 line · Victor Stewart

might this still make it into 5.11?

Doesn't meet the criteria to go in at this point. I sometimes make exceptions, but generally speaking, something going into 5.11 should have been completed at least a week ago.

So I'd feel more comfortable pushing this to 5.12.

ping. are we still looking at 5.12 for this?

Quoted 4 lines

--
Jens Axboe