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.
Unified · Split
| @@ -41,6 +41,7 @@ struct net; · 40 unmodified lines | ||
| 41 | 41 | #define SOCK_NOSPACE 2 |
| 42 | 42 | #define SOCK_PASSCRED 3 |
| 43 | 43 | #define SOCK_PASSSEC 4 |
| 44 | +#define SOCK_SUPPORT_ZC 5 | |
| 44 | 45 | |
| 45 | 46 | #ifndef ARCH_HAS_SOCKET_TYPES |
| 46 | 47 | /** |
| @@ -457,6 +457,7 @@ void tcp_init_sock(struct sock *sk) · 456 unmodified lines | ||
| 457 | 457 | WRITE_ONCE(sk->sk_sndbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[1])); |
| 458 | 458 | WRITE_ONCE(sk->sk_rcvbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[1])); |
| 459 | 459 | |
| 460 | + set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags); | |
| 460 | 461 | sk_sockets_allocated_inc(sk); |
| 461 | 462 | } |
| 462 | 463 | EXPORT_SYMBOL(tcp_init_sock); |
| @@ -1624,6 +1624,7 @@ int udp_init_sock(struct sock *sk) · 1623 unmodified lines | ||
| 1624 | 1624 | { |
| 1625 | 1625 | skb_queue_head_init(&udp_sk(sk)->reader_queue); |
| 1626 | 1626 | sk->sk_destruct = udp_destruct_sock; |
| 1627 | + set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags); | |
| 1627 | 1628 | return 0; |
| 1628 | 1629 | } |
| 1629 | 1630 | |