@@ -97,6 +97,8 @@ static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
extern struct proto udp_prot;
+extern struct static_key udp_encap_needed;
+
extern atomic_long_t udp_memory_allocated;
/* sysctl variables for udp */
@@ -1813,7 +1813,9 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
return 0;
}
-static struct static_key udp_encap_needed __read_mostly;
+struct static_key udp_encap_needed __read_mostly;
+EXPORT_SYMBOL(udp_encap_needed);
+
void udp_encap_enable(void)
{
static_key_enable(&udp_encap_needed);
@@ -261,6 +261,13 @@ static struct sk_buff **udp4_gro_receive(struct sk_buff **head,
{
struct udphdr *uh = udp_gro_udphdr(skb);
+ if (!static_key_false(&udp_encap_needed)) {
+ /* Currently udp_gro_receive only does something if
+ * a UDP encapsulation has been set.
+ */
+ goto flush;
+ }
+
if (unlikely(!uh))
goto flush;
@@ -34,6 +34,13 @@ static struct sk_buff **udp6_gro_receive(struct sk_buff **head,
{
struct udphdr *uh = udp_gro_udphdr(skb);
+ if (!static_key_false(&udp_encap_needed)) {
+ /* Currently udp_gro_receive only does something if
+ * a UDP encapsulation has been set.
+ */
+ goto flush;
+ }
+
if (unlikely(!uh))
goto flush;
Currently, the only support for udp gro is provided by UDP encapsulation protocols. Since they always set udp_encap_needed we can check that in udp_gro_receive functions before performing a socket lookup. Signed-off-by: Tom Herbert <tom@quantonium.net> --- include/net/udp.h | 2 ++ net/ipv4/udp.c | 4 +++- net/ipv4/udp_offload.c | 7 +++++++ net/ipv6/udp_offload.c | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-)