aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/loopback.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-09-30 17:06:55 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-05 17:47:55 -0400
commitcaf586e5f23cebb2a68cbaf288d59dbbf2d74052 (patch)
tree5c0dfcf5a14c55501f9225835c83abddb8d1876e /drivers/net/loopback.c
parenta00eac0c459abecb539fb2a2abd3122dd7ca5d4a (diff)
net: add a core netdev->rx_dropped counter
In various situations, a device provides a packet to our stack and we drop it before it enters protocol stack : - softnet backlog full (accounted in /proc/net/softnet_stat) - bad vlan tag (not accounted) - unknown/unregistered protocol (not accounted) We can handle a per-device counter of such dropped frames at core level, and automatically adds it to the device provided stats (rx_dropped), so that standard tools can be used (ifconfig, ip link, cat /proc/net/dev) This is a generalization of commit 8990f468a (net: rx_dropped accounting), thus reverting it. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/loopback.c')
-rw-r--r--drivers/net/loopback.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 4b0e30b564e5..2d9663a1c54d 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -64,7 +64,6 @@ struct pcpu_lstats {
64 u64 packets; 64 u64 packets;
65 u64 bytes; 65 u64 bytes;
66 struct u64_stats_sync syncp; 66 struct u64_stats_sync syncp;
67 unsigned long drops;
68}; 67};
69 68
70/* 69/*
@@ -90,8 +89,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
90 lb_stats->bytes += len; 89 lb_stats->bytes += len;
91 lb_stats->packets++; 90 lb_stats->packets++;
92 u64_stats_update_end(&lb_stats->syncp); 91 u64_stats_update_end(&lb_stats->syncp);
93 } else 92 }
94 lb_stats->drops++;
95 93
96 return NETDEV_TX_OK; 94 return NETDEV_TX_OK;
97} 95}
@@ -101,7 +99,6 @@ static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev,
101{ 99{
102 u64 bytes = 0; 100 u64 bytes = 0;
103 u64 packets = 0; 101 u64 packets = 0;
104 u64 drops = 0;
105 int i; 102 int i;
106 103
107 for_each_possible_cpu(i) { 104 for_each_possible_cpu(i) {
@@ -115,14 +112,11 @@ static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev,
115 tbytes = lb_stats->bytes; 112 tbytes = lb_stats->bytes;
116 tpackets = lb_stats->packets; 113 tpackets = lb_stats->packets;
117 } while (u64_stats_fetch_retry(&lb_stats->syncp, start)); 114 } while (u64_stats_fetch_retry(&lb_stats->syncp, start));
118 drops += lb_stats->drops;
119 bytes += tbytes; 115 bytes += tbytes;
120 packets += tpackets; 116 packets += tpackets;
121 } 117 }
122 stats->rx_packets = packets; 118 stats->rx_packets = packets;
123 stats->tx_packets = packets; 119 stats->tx_packets = packets;
124 stats->rx_dropped = drops;
125 stats->rx_errors = drops;
126 stats->rx_bytes = bytes; 120 stats->rx_bytes = bytes;
127 stats->tx_bytes = bytes; 121 stats->tx_bytes = bytes;
128 return stats; 122 return stats;