Skip to content

Commit 015f068

Browse files
edumazetdavem330
authored andcommitted
net: net: add a core netdev->tx_dropped counter
Dropping packets in __dev_queue_xmit() when transmit queue is stopped (NIC TX ring buffer full or BQL limit reached) currently outputs a syslog message. It would be better to get a precise count of such events available in netdevice stats so that monitoring tools can have a clue. This extends the work done in caf586e ("net: add a core netdev->rx_dropped counter") Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4327950 commit 015f068

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/linux/netdevice.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,9 +1311,10 @@ struct net_device {
13111311
int iflink;
13121312

13131313
struct net_device_stats stats;
1314-
atomic_long_t rx_dropped; /* dropped packets by core network
1315-
* Do not use this in drivers.
1316-
*/
1314+
1315+
/* dropped packets by core network, Do not use this in drivers */
1316+
atomic_long_t rx_dropped;
1317+
atomic_long_t tx_dropped;
13171318

13181319
#ifdef CONFIG_WIRELESS_EXT
13191320
/* List of functions to handle Wireless Extensions (instead of ioctl).

net/core/dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
28802880
rc = -ENETDOWN;
28812881
rcu_read_unlock_bh();
28822882

2883+
atomic_long_inc(&dev->tx_dropped);
28832884
kfree_skb(skb);
28842885
return rc;
28852886
out:
@@ -6238,6 +6239,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
62386239
netdev_stats_to_stats64(storage, &dev->stats);
62396240
}
62406241
storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
6242+
storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
62416243
return storage;
62426244
}
62436245
EXPORT_SYMBOL(dev_get_stats);

0 commit comments

Comments
 (0)