]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: fix __dev_kfree_skb_any() vs drop monitor
authorEric Dumazet <edumazet@google.com>
Thu, 23 Feb 2023 08:38:45 +0000 (08:38 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:26:52 +0000 (16:26 +0100)
[ Upstream commit ac3ad19584b26fae9ac86e4faebe790becc74491 ]

dev_kfree_skb() is aliased to consume_skb().

When a driver is dropping a packet by calling dev_kfree_skb_any()
we should propagate the drop reason instead of pretending
the packet was consumed.

Note: Now we have enum skb_drop_reason we could remove
enum skb_free_reason (for linux-6.4)

v2: added an unlikely(), suggested by Yunsheng Lin.

Fixes: e6247027e517 ("net: introduce dev_consume_skb_any()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/dev.c

index 4741c239af170bd97c18ee67db6d77f4c856f77b..86f762a1cf7ac0aa943efa84d58c1f8c12216165 100644 (file)
@@ -2525,8 +2525,10 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
 {
        if (in_irq() || irqs_disabled())
                __dev_kfree_skb_irq(skb, reason);
+       else if (unlikely(reason == SKB_REASON_DROPPED))
+               kfree_skb(skb);
        else
-               dev_kfree_skb(skb);
+               consume_skb(skb);
 }
 EXPORT_SYMBOL(__dev_kfree_skb_any);