]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gre: Count GRE packet drops
authorGal Pressman <gal@nvidia.com>
Thu, 9 Apr 2026 09:09:45 +0000 (12:09 +0300)
committerJakub Kicinski <kuba@kernel.org>
Sun, 12 Apr 2026 19:33:33 +0000 (12:33 -0700)
GRE is silently dropping packets without updating statistics.

In case of drop, increment rx_dropped counter to provide visibility into
packet loss. For the case where no GRE protocol handler is registered,
use rx_nohandler.

Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Link: https://patch.msgid.link/20260409090945.1542440-1-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/gre_demux.c
net/ipv4/ip_gre.c
net/ipv6/ip6_gre.c

index dafd68f3436a2c3d294ba701fa57e66c4ccc9a75..96fd7dc6d82dd0b6ff75315857906ee665db7069 100644 (file)
@@ -159,14 +159,18 @@ static int gre_rcv(struct sk_buff *skb)
        rcu_read_lock();
        proto = rcu_dereference(gre_proto[ver]);
        if (!proto || !proto->handler)
-               goto drop_unlock;
+               goto drop_nohandler;
        ret = proto->handler(skb);
        rcu_read_unlock();
        return ret;
 
-drop_unlock:
+drop_nohandler:
        rcu_read_unlock();
+       dev_core_stats_rx_nohandler_inc(skb->dev);
+       kfree_skb(skb);
+       return NET_RX_DROP;
 drop:
+       dev_core_stats_rx_dropped_inc(skb->dev);
        kfree_skb(skb);
        return NET_RX_DROP;
 }
index 35f0baa99d4092fd499a4795f7f52db33a1fe4e2..169e2921a851d55bb67f5a7cf3f005ded1ed2655 100644 (file)
@@ -468,6 +468,7 @@ static int gre_rcv(struct sk_buff *skb)
 out:
        icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
 drop:
+       dev_core_stats_rx_dropped_inc(skb->dev);
        kfree_skb(skb);
        return 0;
 }
index dafcc0dcd77a5394857d6f339d83370826a25109..63fc8556b475e5166f150ed1aff39319f096f758 100644 (file)
@@ -593,6 +593,7 @@ static int gre_rcv(struct sk_buff *skb)
 out:
        icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
 drop:
+       dev_core_stats_rx_dropped_inc(skb->dev);
        kfree_skb(skb);
        return 0;
 }