Subject: Re: [PATCH net] net: don't touch dev->stats in BPF redirect paths

From: Jakub Kicinski <[email-masked]>
Date: Thu, 29 Jan 2026 15:54:46 -0800

On Thu, 29 Jan 2026 09:45:10 +0200 Gal Pressman wrote:
> On 28/01/2026 18:10, Jakub Kicinski 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().
> > 
> > Reported-by: Gal Pressman <[email-masked]>
> > Link: https://lore.kernel.org/[email-masked]
> > Fixes: b4ab31414970 ("bpf: Add redirect_neigh helper as redirect drop-in")
> > Signed-off-by: Jakub Kicinski <[email-masked]>  
> 
> Aha, this kinda makes my mlx5 fix redundant.
> I'm debating whether I should send a revert?

Up to you, it doesn't hurt.
I guess the main reason to revert would be to catch similar bugs 
in the future, given the popularity of mlx5, but up to you if
you want to be exposed to such bugs :)

> > 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);  
> 
> The commit message didn't mention anything about changing tx_errors to
> tx_dropped.

Fair, let me respin with a note.