udp: gro behind static key
Subsystems (3)
Willem de Bruijn
maintainerPATCH 1/1 udp: gro behind static key
From: Willem de Bruijn <[email protected]>
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.
--- include/net/udp.h | 2 ++ net/ipv4/udp.c | 2 +- net/ipv4/udp_offload.c | 2 +- net/ipv6/udp.c | 2 +- net/ipv6/udp_offload.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-)
include/net/udp.h +2 -0
@@ -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
net/ipv4/udp.c +1 -1
@@ -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);
net/ipv4/udp_offload.c +1 -1
@@ -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. */
net/ipv6/udp.c +1 -1
@@ -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);
net/ipv6/udp_offload.c +1 -1
@@ -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. */
Signature · 1 line
2.19.0.605.g01d371f741-goog
Quoted 76 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
Avoid the socket lookup cost in
udp_gro_receiveif 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 <[email protected]>--- include/net/udp.h | 2 ++ net/ipv4/udp.c | 2 +- net/ipv4/udp_offload.c | 2 +- net/ipv6/udp.c | 2 +- net/ipv6/udp_offload.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-)include/net/udp.h +2
-0@@ -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 net/ipv4/udp.c +1
-1@@ -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);net/ipv4/udp_offload.c +1
-1@@ -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. */ net/ipv6/udp.c +1
-1@@ -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);net/ipv6/udp_offload.c +0
-0
net/ipv6/udp_offload.c static struct sk_buff *udp6_gro_receive(struct list_head *head, · line 125
Quoted 8 lines
net/ipv6/udp_offload.c +1
-1@@ -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. */
From: Willem de Bruijn <[email protected]>
Date: Fri, 5 Oct 2018 11:31:40 -0400
Quoted 9 lines
From: Willem de Bruijn <[email protected]>
Avoid the socket lookup cost in
udp_gro_receiveif 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 <[email protected]>
Applied, thanks.