]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: flag sockets supporting msghdr originated zerocopy
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 21 Oct 2022 10:16:39 +0000 (11:16 +0100)
committerJens Axboe <axboe@kernel.dk>
Sat, 22 Oct 2022 14:42:58 +0000 (08:42 -0600)
We need an efficient way in io_uring to check whether a socket supports
zerocopy with msghdr provided ubuf_info. Add a new flag into the struct
socket flags fields.

Cc: <stable@vger.kernel.org> # 6.0
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/3dafafab822b1c66308bb58a0ac738b1e3f53f74.1666346426.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/net.h
net/ipv4/tcp.c
net/ipv4/udp.c

index 711c3593c3b8d34513f80d7cdb42b5ce6e8f3c7e..18d942bbdf6e0977f4efe20e0ce17e4092910bd0 100644 (file)
@@ -41,6 +41,7 @@ struct net;
 #define SOCK_NOSPACE           2
 #define SOCK_PASSCRED          3
 #define SOCK_PASSSEC           4
+#define SOCK_SUPPORT_ZC                5
 
 #ifndef ARCH_HAS_SOCKET_TYPES
 /**
index f8232811a5be17ec7652ff47ffde6341b2a76d1e..ef14efa1fb70eaaecfc7884de32b74c49bb25a39 100644 (file)
@@ -457,6 +457,7 @@ void tcp_init_sock(struct sock *sk)
        WRITE_ONCE(sk->sk_sndbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[1]));
        WRITE_ONCE(sk->sk_rcvbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[1]));
 
+       set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
        sk_sockets_allocated_inc(sk);
 }
 EXPORT_SYMBOL(tcp_init_sock);
index 662d717d512335bcb99f57b829402f61efebbe94..1c646797cc79482c5f7b4ab51e27765d1e3477e9 100644 (file)
@@ -1624,6 +1624,7 @@ int udp_init_sock(struct sock *sk)
 {
        skb_queue_head_init(&udp_sk(sk)->reader_queue);
        sk->sk_destruct = udp_destruct_sock;
+       set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
        return 0;
 }