Skip to contentSkip to conversation

net: also flag accepted sockets supporting msghdr originated zerocopy

PATCH In review Stefan Metzmacher 2 participants 2 messages Oct 25, 2022 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 net: also flag accepted sockets supporting msghdr originated zerocopy

Without this only the client initiated tcp sockets have SOCK_SUPPORT_ZC. The listening socket on the server also has it, but the accepted connections didn't, which meant IORING_OP_SEND[MSG]_ZC will always fails with -EOPNOTSUPP.

Fixes e993ffe3da4b ("net: flag sockets supporting msghdr originated zerocopy")
CC Pavel Begunkov <[email protected]>
Cc Jakub Kicinski <[email protected]>
CC Jens Axboe <[email protected]>
---
 net/ipv4/af_inet.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/af_inet.c +2 -0
index 3dd02396517d..4728087c42a5 100644
@@ -754,6 +754,8 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags,
 		  (TCPF_ESTABLISHED | TCPF_SYN_RECV |
 		  TCPF_CLOSE_WAIT | TCPF_CLOSE)));
 
+	if (test_bit(SOCK_SUPPORT_ZC, &sock->flags))
+		set_bit(SOCK_SUPPORT_ZC, &newsock->flags);
 	sock_graft(sk2, newsock);
 
 	newsock->state = SS_CONNECTED;
Signature · 1 line
2.34.1
#2 lore raw
Quoted 4 lines · Stefan Metzmacher

Without this only the client initiated tcp sockets have SOCK_SUPPORT_ZC. The listening socket on the server also has it, but the accepted connections didn't, which meant IORING_OP_SEND[MSG]_ZC will always fails with -EOPNOTSUPP.

Jakub pointed out a bunch of places yesterday that we have to consider. I'll pick it up and resend with the rest. Thanks

Quoted 24 lines
Fixes e993ffe3da4b ("net: flag sockets supporting msghdr originated zerocopy")
CC Pavel Begunkov <[email protected]>
Cc Jakub Kicinski <[email protected]>
CC Jens Axboe <[email protected]>
---
  net/ipv4/af_inet.c | 2 ++
  1 file changed, 2 insertions(+)
net/ipv4/af_inet.c +2 -0
index 3dd02396517d..4728087c42a5 100644
@@ -754,6 +754,8 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags,
  		  (TCPF_ESTABLISHED | TCPF_SYN_RECV |
  		  TCPF_CLOSE_WAIT | TCPF_CLOSE)));
 
+	if (test_bit(SOCK_SUPPORT_ZC, &sock->flags))
+		set_bit(SOCK_SUPPORT_ZC, &newsock->flags);
  	sock_graft(sk2, newsock);
 
  	newsock->state = SS_CONNECTED;
Signature · 1 line
Pavel Begunkov