* [PATCH net v2] net: don't touch dev->stats in BPF redirect paths
@ 2026-01-30 3:38 Jakub Kicinski
2026-01-30 18:54 ` Eric Dumazet
2026-01-31 21:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-01-30 3:38 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
Martin KaFai Lau, Daniel Borkmann, Gal Pressman, ast, eddyz87,
song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
dsahern, bpf
Gal reports that BPF redirect increments dev->stats.tx_errors
on failure. This is not correct, most modern drivers completely
ignore dev->stats so these drops will be invisible to the user.
Core code should use the dedicated core stats which are folded
into device stats in dev_get_stats().
Note that we're switching from tx_errors to tx_dropped.
Core only has tx_dropped, hence presumably users already expect
that counter to increment for "stack" Tx issues.
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Reported-by: Gal Pressman <gal@nvidia.com>
Link: https://lore.kernel.org/c5df3b60-246a-4030-9c9a-0a35cd1ca924@nvidia.com
Fixes: b4ab31414970 ("bpf: Add redirect_neigh helper as redirect drop-in")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- add note on tx_dropped to the commit msg
v1: https://lore.kernel.org/20260128161030.39870-1-kuba@kernel.org
CC: ast@kernel.org
CC: eddyz87@gmail.com
CC: song@kernel.org
CC: yonghong.song@linux.dev
CC: john.fastabend@gmail.com
CC: kpsingh@kernel.org
CC: sdf@fomichev.me
CC: haoluo@google.com
CC: jolsa@kernel.org
CC: dsahern@gmail.com
CC: bpf@vger.kernel.org
---
net/core/filter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 616e0520a0bb..2c21735798a5 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2289,12 +2289,12 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev,
err = bpf_out_neigh_v6(net, skb, dev, nh);
if (unlikely(net_xmit_eval(err)))
- DEV_STATS_INC(dev, tx_errors);
+ dev_core_stats_tx_dropped_inc(dev);
else
ret = NET_XMIT_SUCCESS;
goto out_xmit;
out_drop:
- DEV_STATS_INC(dev, tx_errors);
+ dev_core_stats_tx_dropped_inc(dev);
kfree_skb(skb);
out_xmit:
return ret;
@@ -2396,12 +2396,12 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,
err = bpf_out_neigh_v4(net, skb, dev, nh);
if (unlikely(net_xmit_eval(err)))
- DEV_STATS_INC(dev, tx_errors);
+ dev_core_stats_tx_dropped_inc(dev);
else
ret = NET_XMIT_SUCCESS;
goto out_xmit;
out_drop:
- DEV_STATS_INC(dev, tx_errors);
+ dev_core_stats_tx_dropped_inc(dev);
kfree_skb(skb);
out_xmit:
return ret;
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net v2] net: don't touch dev->stats in BPF redirect paths
2026-01-30 3:38 [PATCH net v2] net: don't touch dev->stats in BPF redirect paths Jakub Kicinski
@ 2026-01-30 18:54 ` Eric Dumazet
2026-01-31 21:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-01-30 18:54 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, pabeni, andrew+netdev, horms, Martin KaFai Lau,
Daniel Borkmann, Gal Pressman, ast, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, dsahern, bpf
On Fri, Jan 30, 2026 at 4:38 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Gal reports that BPF redirect increments dev->stats.tx_errors
> on failure. This is not correct, most modern drivers completely
> ignore dev->stats so these drops will be invisible to the user.
> Core code should use the dedicated core stats which are folded
> into device stats in dev_get_stats().
>
> Note that we're switching from tx_errors to tx_dropped.
> Core only has tx_dropped, hence presumably users already expect
> that counter to increment for "stack" Tx issues.
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] net: don't touch dev->stats in BPF redirect paths
2026-01-30 3:38 [PATCH net v2] net: don't touch dev->stats in BPF redirect paths Jakub Kicinski
2026-01-30 18:54 ` Eric Dumazet
@ 2026-01-31 21:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-31 21:20 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, martin.lau,
daniel, gal, ast, eddyz87, song, yonghong.song, john.fastabend,
kpsingh, sdf, haoluo, jolsa, dsahern, bpf
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 29 Jan 2026 19:38:27 -0800 you wrote:
> Gal reports that BPF redirect increments dev->stats.tx_errors
> on failure. This is not correct, most modern drivers completely
> ignore dev->stats so these drops will be invisible to the user.
> Core code should use the dedicated core stats which are folded
> into device stats in dev_get_stats().
>
> Note that we're switching from tx_errors to tx_dropped.
> Core only has tx_dropped, hence presumably users already expect
> that counter to increment for "stack" Tx issues.
>
> [...]
Here is the summary with links:
- [net,v2] net: don't touch dev->stats in BPF redirect paths
https://git.kernel.org/netdev/net/c/fdf3f6800be3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-31 21:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-30 3:38 [PATCH net v2] net: don't touch dev->stats in BPF redirect paths Jakub Kicinski
2026-01-30 18:54 ` Eric Dumazet
2026-01-31 21:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox