Skip to content

Commit

Permalink
net: net: add a core netdev->tx_dropped counter
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Mar 28, 2014
1 parent 4327950 commit 015f068
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1311,9 +1311,10 @@ struct net_device {
int iflink;

struct net_device_stats stats;
atomic_long_t rx_dropped; /* dropped packets by core network
* Do not use this in drivers.
*/

/* dropped packets by core network, Do not use this in drivers */
atomic_long_t rx_dropped;
atomic_long_t tx_dropped;

#ifdef CONFIG_WIRELESS_EXT
/* List of functions to handle Wireless Extensions (instead of ioctl).
Expand Down
2 changes: 2 additions & 0 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
rc = -ENETDOWN;
rcu_read_unlock_bh();

atomic_long_inc(&dev->tx_dropped);
kfree_skb(skb);
return rc;
out:
Expand Down Expand Up @@ -6238,6 +6239,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
netdev_stats_to_stats64(storage, &dev->stats);
}
storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
return storage;
}
EXPORT_SYMBOL(dev_get_stats);
Expand Down

0 comments on commit 015f068

Please sign in to comment.