* [PATCH v2 net] net: fix __dev_kfree_skb_any() vs drop monitor
@ 2023-02-23 8:38 Eric Dumazet
2023-02-23 9:19 ` Yunsheng Lin
2023-02-24 19:41 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2023-02-23 8:38 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, eric.dumazet, Eric Dumazet, Yunsheng Lin
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>
---
net/core/dev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 18dc8d75ead9795163ace74e8e86fe35cb9b7552..253584777101f2e6af3fc30107516f1e1197f8d3 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3134,8 +3134,10 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
{
if (in_hardirq() || 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);
--
2.39.2.637.g21b0678d19-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 net] net: fix __dev_kfree_skb_any() vs drop monitor
2023-02-23 8:38 [PATCH v2 net] net: fix __dev_kfree_skb_any() vs drop monitor Eric Dumazet
@ 2023-02-23 9:19 ` Yunsheng Lin
2023-02-24 19:41 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Yunsheng Lin @ 2023-02-23 9:19 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, eric.dumazet
On 2023/2/23 16:38, Eric Dumazet wrote:
> 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)
LGTM.
Reviewed-by: Yunsheng Lin <linyunsheng@huawei.com>
>
> 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>
> ---
> net/core/dev.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 18dc8d75ead9795163ace74e8e86fe35cb9b7552..253584777101f2e6af3fc30107516f1e1197f8d3 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3134,8 +3134,10 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
> {
> if (in_hardirq() || 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);
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2 net] net: fix __dev_kfree_skb_any() vs drop monitor
2023-02-23 8:38 [PATCH v2 net] net: fix __dev_kfree_skb_any() vs drop monitor Eric Dumazet
2023-02-23 9:19 ` Yunsheng Lin
@ 2023-02-24 19:41 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-02-24 19:41 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Paolo Abeni, netdev, eric.dumazet, Yunsheng Lin
On Thu, 23 Feb 2023 08:38:45 +0000 Eric Dumazet wrote:
> 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.
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-24 19:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-23 8:38 [PATCH v2 net] net: fix __dev_kfree_skb_any() vs drop monitor Eric Dumazet
2023-02-23 9:19 ` Yunsheng Lin
2023-02-24 19:41 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).