Thread (9 messages) 9 messages, 3 authors, 2010-08-28

Re: [PATCH v2] slip: Use net_device_stats from struct net_device

From: Tobias Klauser <tklauser@distanz.ch>
Date: 2010-08-26 09:18:03

On 2010-08-26 at 10:39:32 +0200, Eric Dumazet [off-list ref] wrote:
Le jeudi 26 août 2010 à 10:28 +0200, Tobias Klauser a écrit :
quoted
@@ -562,12 +563,12 @@ static struct net_device_stats *
 sl_get_stats(struct net_device *dev)
 {
 	struct net_device_stats *stats = &dev->stats;
-	struct slip *sl = netdev_priv(dev);
-	unsigned long c_rx_dropped = 0;
 #ifdef SL_INCLUDE_CSLIP
+	unsigned long c_rx_dropped = 0;
 	unsigned long c_rx_fifo_errors = 0;
 	unsigned long c_tx_fifo_errors = 0;
 	unsigned long c_collisions = 0;
+	struct slip *sl = netdev_priv(dev);
 	struct slcompress *comp = sl->slcomp;
 
 	if (comp) {
@@ -579,17 +580,9 @@ sl_get_stats(struct net_device *dev)
 	stats->rx_fifo_errors = sl->rx_compressed + c_rx_fifo_errors;
 	stats->tx_fifo_errors = sl->tx_compressed + c_tx_fifo_errors;
 	stats->collisions     = sl->tx_misses + c_collisions;
+	stats->rx_dropped    += c_rx_dropped;
Sorry this bit is wrong.

You cannot do "stats->somefield += somevalue", since its cumulative for
each call to "cat /proc/net/dev"
Sorry for getting it wrong the second time and wasting your time. I
didn't read your answer to the first patch careful enough (I should have
used ndo_get_stats64 as you clearly stated). Hopefully I get it right in
v3 :-)

Sorry again and thanks a lot
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help