History

net: flag sockets supporting msghdr originated zerocopy

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.

Pavel Begunkov committed 4 years ago

Commit e993ffe1 parent 996d3ef3 files · +3 −0Browse files

Unified · Split

3 files
  1. include/linux/net.h +1 −0
  2. net/ipv4/tcp.c +1 −0
  3. net/ipv4/udp.c +1 −0
include/linux/net.h+1−0
@@ -41,6 +41,7 @@ struct net; · 40 unmodified lines
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 /**
net/ipv4/tcp.c+1−0
@@ -457,6 +457,7 @@ void tcp_init_sock(struct sock *sk) · 456 unmodified lines
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+1−0
@@ -1624,6 +1624,7 @@ int udp_init_sock(struct sock *sk) · 1623 unmodified lines
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