]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dropreason: add MACVLAN_BROADCAST_BACKLOG and IPVLAN_MULTICAST_BACKLOG
authorEric Dumazet <edumazet@google.com>
Tue, 7 Apr 2026 15:07:10 +0000 (15:07 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 9 Apr 2026 02:19:18 +0000 (19:19 -0700)
ipvlan and macvlan use queues to process broadcast/multicast packets
from a work queue.

Under attack these queues can drop packets.

Add MACVLAN_BROADCAST_BACKLOG drop_reason for macvlan broadcast queue.

Add IPVLAN_MULTICAST_BACKLOG drop_reason for ipvlan multicast queue.

Use different reasons as some deployments use both ipvlan and macvlan.

Also change ipvlan_rcv_frame() to use SKB_DROP_REASON_DEV_READY
when the device is not UP.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260407150710.1640747-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ipvlan/ipvlan_core.c
drivers/net/macvlan.c
include/net/dropreason-core.h

index 835e048351a92f0437b466317d0babba4e00fc50..0b493a8aa33857d531329e8eaef6b25a5c6f572d 100644 (file)
@@ -337,7 +337,7 @@ static int ipvlan_rcv_frame(struct ipvl_addr *addr, struct sk_buff **pskb,
         */
        if (local) {
                if (unlikely(!(dev->flags & IFF_UP))) {
-                       kfree_skb(skb);
+                       kfree_skb_reason(skb, SKB_DROP_REASON_DEV_READY);
                        goto out;
                }
 
@@ -596,7 +596,7 @@ static void ipvlan_multicast_enqueue(struct ipvl_port *port,
        } else {
                spin_unlock(&port->backlog.lock);
                dev_core_stats_rx_dropped_inc(skb->dev);
-               kfree_skb(skb);
+               kfree_skb_reason(skb, SKB_DROP_REASON_IPVLAN_MULTICAST_BACKLOG);
        }
 }
 
index 54c514acacc5e24fcdb88904f41fd1d29b1e34d0..9f90c598649d548ee12b0a9806c825f96a4a4d63 100644 (file)
@@ -386,7 +386,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
        return;
 
 free_nskb:
-       kfree_skb(nskb);
+       kfree_skb_reason(nskb, SKB_DROP_REASON_MACVLAN_BROADCAST_BACKLOG);
 err:
        dev_core_stats_rx_dropped_inc(skb->dev);
 }
index 51855de5d20819bff950e1c5846a6a4f3f8a3b95..e0ca3904ff8e0cffb18b6e3f2a604cc97505cff0 100644 (file)
@@ -69,6 +69,8 @@
        FN(QDISC_DROP)                  \
        FN(QDISC_BURST_DROP)            \
        FN(CPU_BACKLOG)                 \
+       FN(MACVLAN_BROADCAST_BACKLOG)           \
+       FN(IPVLAN_MULTICAST_BACKLOG)            \
        FN(XDP)                         \
        FN(TC_INGRESS)                  \
        FN(UNHANDLED_PROTO)             \
@@ -383,6 +385,16 @@ enum skb_drop_reason {
         * netdev_max_backlog in net.rst) or RPS flow limit
         */
        SKB_DROP_REASON_CPU_BACKLOG,
+       /**
+        * @SKB_DROP_REASON_MACVLAN_BROADCAST_BACKLOG: failed to enqueue the skb
+        * to macvlan broadcast queue.
+        */
+       SKB_DROP_REASON_MACVLAN_BROADCAST_BACKLOG,
+       /**
+        * @SKB_DROP_REASON_IPVLAN_MULTICAST_BACKLOG: failed to enqueue the skb
+        * to ipvlan multicast queue.
+        */
+       SKB_DROP_REASON_IPVLAN_MULTICAST_BACKLOG,
        /** @SKB_DROP_REASON_XDP: dropped by XDP in input path */
        SKB_DROP_REASON_XDP,
        /** @SKB_DROP_REASON_TC_INGRESS: dropped in TC ingress HOOK */