Skip to content

Commit 942e01a

Browse files
committed
Merge tag 'io_uring-6.1-2022-10-22' of git://git.kernel.dk/linux
Pull io_uring follow-up from Jens Axboe: "Currently the zero-copy has automatic fallback to normal transmit, and it was decided that it'd be cleaner to return an error instead if the socket type doesn't support it. Zero-copy does work with UDP and TCP, it's more of a future proofing kind of thing (eg for samba)" * tag 'io_uring-6.1-2022-10-22' of git://git.kernel.dk/linux: io_uring/net: fail zc sendmsg when unsupported by socket io_uring/net: fail zc send when unsupported by socket net: flag sockets supporting msghdr originated zerocopy
2 parents d47136c + cc767e7 commit 942e01a

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

include/linux/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct net;
4141
#define SOCK_NOSPACE 2
4242
#define SOCK_PASSCRED 3
4343
#define SOCK_PASSSEC 4
44+
#define SOCK_SUPPORT_ZC 5
4445

4546
#ifndef ARCH_HAS_SOCKET_TYPES
4647
/**

io_uring/net.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,8 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
10561056
sock = sock_from_file(req->file);
10571057
if (unlikely(!sock))
10581058
return -ENOTSOCK;
1059+
if (!test_bit(SOCK_SUPPORT_ZC, &sock->flags))
1060+
return -EOPNOTSUPP;
10591061

10601062
msg.msg_name = NULL;
10611063
msg.msg_control = NULL;
@@ -1151,6 +1153,8 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
11511153
sock = sock_from_file(req->file);
11521154
if (unlikely(!sock))
11531155
return -ENOTSOCK;
1156+
if (!test_bit(SOCK_SUPPORT_ZC, &sock->flags))
1157+
return -EOPNOTSUPP;
11541158

11551159
if (req_has_async_data(req)) {
11561160
kmsg = req->async_data;

net/ipv4/tcp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ void tcp_init_sock(struct sock *sk)
457457
WRITE_ONCE(sk->sk_sndbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[1]));
458458
WRITE_ONCE(sk->sk_rcvbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[1]));
459459

460+
set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
460461
sk_sockets_allocated_inc(sk);
461462
}
462463
EXPORT_SYMBOL(tcp_init_sock);

net/ipv4/udp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,7 @@ int udp_init_sock(struct sock *sk)
16241624
{
16251625
skb_queue_head_init(&udp_sk(sk)->reader_queue);
16261626
sk->sk_destruct = udp_destruct_sock;
1627+
set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
16271628
return 0;
16281629
}
16291630

0 commit comments

Comments
 (0)