]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
udp: gro behind static key
authorWillem de Bruijn <willemb@google.com>
Fri, 5 Oct 2018 15:31:40 +0000 (11:31 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Oct 2018 18:52:38 +0000 (11:52 -0700)
Avoid the socket lookup cost in udp_gro_receive if no socket has a
udp tunnel callback configured.

udp_sk(sk)->gro_receive requires a registration with
setup_udp_tunnel_sock, which enables the static key.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/udp.h
net/ipv4/udp.c
net/ipv4/udp_offload.c
net/ipv6/udp.c
net/ipv6/udp_offload.c

index 8482a990b0bb8e781883d3e09ea84a6f345863ed..9e82cb391dea2b64fec14f8e6323c22d4c7b5c53 100644 (file)
@@ -443,8 +443,10 @@ int udpv4_offload_init(void);
 
 void udp_init(void);
 
+DECLARE_STATIC_KEY_FALSE(udp_encap_needed_key);
 void udp_encap_enable(void);
 #if IS_ENABLED(CONFIG_IPV6)
+DECLARE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
 void udpv6_encap_enable(void);
 #endif
 
index 5fc4beb1c3361497f8fac0b124edc98d8a566b3b..1bec2203d558392c479e31d234b041f34daab86e 100644 (file)
@@ -1889,7 +1889,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
        return 0;
 }
 
-static DEFINE_STATIC_KEY_FALSE(udp_encap_needed_key);
+DEFINE_STATIC_KEY_FALSE(udp_encap_needed_key);
 void udp_encap_enable(void)
 {
        static_branch_enable(&udp_encap_needed_key);
index 0c0522b79b43f09785ce8fd5f0dc9461a93f0e98..802f2bc00d69751a40856a6f4f82b32bd244617d 100644 (file)
@@ -405,7 +405,7 @@ static struct sk_buff *udp4_gro_receive(struct list_head *head,
 {
        struct udphdr *uh = udp_gro_udphdr(skb);
 
-       if (unlikely(!uh))
+       if (unlikely(!uh) || !static_branch_unlikely(&udp_encap_needed_key))
                goto flush;
 
        /* Don't bother verifying checksum if we're going to flush anyway. */
index 28c4aa5078fcb34b773875d28790e367a5c98ad6..374e7d302f26c4506bb3269c2208bad41a023374 100644 (file)
@@ -548,7 +548,7 @@ static __inline__ void udpv6_err(struct sk_buff *skb,
        __udp6_lib_err(skb, opt, type, code, offset, info, &udp_table);
 }
 
-static DEFINE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
+DEFINE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
 void udpv6_encap_enable(void)
 {
        static_branch_enable(&udpv6_encap_needed_key);
index 95dee9ca8d22186486b09ef7514ec69e0985ff3a..1b8e161ac527dd1c2f594680ef532cd7cf453378 100644 (file)
@@ -119,7 +119,7 @@ static struct sk_buff *udp6_gro_receive(struct list_head *head,
 {
        struct udphdr *uh = udp_gro_udphdr(skb);
 
-       if (unlikely(!uh))
+       if (unlikely(!uh) || !static_branch_unlikely(&udpv6_encap_needed_key))
                goto flush;
 
        /* Don't bother verifying checksum if we're going to flush anyway. */