geneve: avoid indirect calls in GRO path, when possible
authorPaolo Abeni <pabeni@redhat.com>
Wed, 13 Apr 2022 08:44:40 +0000 (10:44 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Apr 2022 09:52:29 +0000 (10:52 +0100)
In the most common setups, the geneve tunnels use an inner
ethernet encapsulation. In the GRO path, when such condition is
true, we can call directly the relevant GRO helper and avoid
a few indirect calls.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/geneve.c

index 7db6c135ac6cfa198f7f595098fd36e6cf57b73d..2495a5719e1c112aefcabae29144cde3951b3811 100644 (file)
@@ -533,14 +533,16 @@ static struct sk_buff *geneve_gro_receive(struct sock *sk,
                }
        }
 
+       skb_gro_pull(skb, gh_len);
+       skb_gro_postpull_rcsum(skb, gh, gh_len);
        type = gh->proto_type;
+       if (likely(type == htons(ETH_P_TEB)))
+               return call_gro_receive(eth_gro_receive, head, skb);
 
        ptype = gro_find_receive_by_type(type);
        if (!ptype)
                goto out;
 
-       skb_gro_pull(skb, gh_len);
-       skb_gro_postpull_rcsum(skb, gh, gh_len);
        pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb);
        flush = 0;
 
@@ -563,6 +565,10 @@ static int geneve_gro_complete(struct sock *sk, struct sk_buff *skb,
        gh_len = geneve_hlen(gh);
        type = gh->proto_type;
 
+       /* since skb->encapsulation is set, eth_gro_complete() sets the inner mac header */
+       if (likely(type == htons(ETH_P_TEB)))
+               return eth_gro_complete(skb, nhoff + gh_len);
+
        ptype = gro_find_complete_by_type(type);
        if (ptype)
                err = ptype->callbacks.gro_complete(skb, nhoff + gh_len);