Skip to content

Commit 8f3c4d0

Browse files
Cruzer-Sgregkh
authored andcommitted
net: natsemi: fix rx_dropped double accounting on netif_rx() failure
[ Upstream commit 93ab488 ] `netif_rx()` already increments `rx_dropped` core stat when it fails. The driver was also updating `ndev->stats.rx_dropped` in the same path. Since both are reported together via `ip -s -s` command, this resulted in drops being counted twice in user-visible stats. Keep the driver update on `if (unlikely(!skb))`, but skip it after `netif_rx()` errors. Fixes: caf586e ("net: add a core netdev->rx_dropped counter") Signed-off-by: Yeounsu Moon <yyyynoom@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250913060135.35282-3-yyyynoom@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f87aa70 commit 8f3c4d0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/net/ethernet/natsemi/ns83820.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static void rx_irq(struct net_device *ndev)
820820
struct ns83820 *dev = PRIV(ndev);
821821
struct rx_info *info = &dev->rx_info;
822822
unsigned next_rx;
823-
int rx_rc, len;
823+
int len;
824824
u32 cmdsts;
825825
__le32 *desc;
826826
unsigned long flags;
@@ -881,8 +881,10 @@ static void rx_irq(struct net_device *ndev)
881881
if (likely(CMDSTS_OK & cmdsts)) {
882882
#endif
883883
skb_put(skb, len);
884-
if (unlikely(!skb))
884+
if (unlikely(!skb)) {
885+
ndev->stats.rx_dropped++;
885886
goto netdev_mangle_me_harder_failed;
887+
}
886888
if (cmdsts & CMDSTS_DEST_MULTI)
887889
ndev->stats.multicast++;
888890
ndev->stats.rx_packets++;
@@ -901,15 +903,12 @@ static void rx_irq(struct net_device *ndev)
901903
__vlan_hwaccel_put_tag(skb, htons(ETH_P_IPV6), tag);
902904
}
903905
#endif
904-
rx_rc = netif_rx(skb);
905-
if (NET_RX_DROP == rx_rc) {
906-
netdev_mangle_me_harder_failed:
907-
ndev->stats.rx_dropped++;
908-
}
906+
netif_rx(skb);
909907
} else {
910908
dev_kfree_skb_irq(skb);
911909
}
912910

911+
netdev_mangle_me_harder_failed:
913912
nr++;
914913
next_rx = info->next_rx;
915914
desc = info->descs + (DESC_SIZE * next_rx);

0 commit comments

Comments
 (0)