* [PATCH net-next-2.6] typhoon: fix a race in typhoon_do_get_stats
@ 2010-08-24 14:18 Eric Dumazet
2010-08-24 14:52 ` David Dillow
2010-08-25 23:37 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2010-08-24 14:18 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Its important to store 'final' values in counters,
not using them as temporary variables,
or this might break some SNMP applications.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
drivers/net/typhoon.c | 46 +++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 2e50077..3f4681f 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -962,36 +962,34 @@ typhoon_do_get_stats(struct typhoon *tp)
* The extra status reported would be a good candidate for
* ethtool_ops->get_{strings,stats}()
*/
- stats->tx_packets = le32_to_cpu(s->txPackets);
- stats->tx_bytes = le64_to_cpu(s->txBytes);
- stats->tx_errors = le32_to_cpu(s->txCarrierLost);
- stats->tx_carrier_errors = le32_to_cpu(s->txCarrierLost);
- stats->collisions = le32_to_cpu(s->txMultipleCollisions);
- stats->rx_packets = le32_to_cpu(s->rxPacketsGood);
- stats->rx_bytes = le64_to_cpu(s->rxBytesGood);
- stats->rx_fifo_errors = le32_to_cpu(s->rxFifoOverruns);
+ stats->tx_packets = le32_to_cpu(s->txPackets) +
+ saved->tx_packets;
+ stats->tx_bytes = le64_to_cpu(s->txBytes) +
+ saved->tx_bytes;
+ stats->tx_errors = le32_to_cpu(s->txCarrierLost) +
+ saved->tx_errors;
+ stats->tx_carrier_errors = le32_to_cpu(s->txCarrierLost) +
+ saved->tx_carrier_errors;
+ stats->collisions = le32_to_cpu(s->txMultipleCollisions) +
+ saved->collisions;
+ stats->rx_packets = le32_to_cpu(s->rxPacketsGood) +
+ saved->rx_packets;
+ stats->rx_bytes = le64_to_cpu(s->rxBytesGood) +
+ saved->rx_bytes;
+ stats->rx_fifo_errors = le32_to_cpu(s->rxFifoOverruns) +
+ saved->rx_fifo_errors;
stats->rx_errors = le32_to_cpu(s->rxFifoOverruns) +
- le32_to_cpu(s->BadSSD) + le32_to_cpu(s->rxCrcErrors);
- stats->rx_crc_errors = le32_to_cpu(s->rxCrcErrors);
- stats->rx_length_errors = le32_to_cpu(s->rxOversized);
+ le32_to_cpu(s->BadSSD) + le32_to_cpu(s->rxCrcErrors) +
+ saved->rx_errors;
+ stats->rx_crc_errors = le32_to_cpu(s->rxCrcErrors) +
+ saved->rx_crc_errors;
+ stats->rx_length_errors = le32_to_cpu(s->rxOversized) +
+ saved->rx_length_errors;
tp->speed = (s->linkStatus & TYPHOON_LINK_100MBPS) ?
SPEED_100 : SPEED_10;
tp->duplex = (s->linkStatus & TYPHOON_LINK_FULL_DUPLEX) ?
DUPLEX_FULL : DUPLEX_HALF;
- /* add in the saved statistics
- */
- stats->tx_packets += saved->tx_packets;
- stats->tx_bytes += saved->tx_bytes;
- stats->tx_errors += saved->tx_errors;
- stats->collisions += saved->collisions;
- stats->rx_packets += saved->rx_packets;
- stats->rx_bytes += saved->rx_bytes;
- stats->rx_fifo_errors += saved->rx_fifo_errors;
- stats->rx_errors += saved->rx_errors;
- stats->rx_crc_errors += saved->rx_crc_errors;
- stats->rx_length_errors += saved->rx_length_errors;
-
return 0;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next-2.6] typhoon: fix a race in typhoon_do_get_stats
2010-08-24 14:18 [PATCH net-next-2.6] typhoon: fix a race in typhoon_do_get_stats Eric Dumazet
@ 2010-08-24 14:52 ` David Dillow
2010-08-25 23:37 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Dillow @ 2010-08-24 14:52 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
On Tue, 2010-08-24 at 16:18 +0200, Eric Dumazet wrote:
> Its important to store 'final' values in counters,
> not using them as temporary variables,
> or this might break some SNMP applications.
Acked-by: David Dillow <dave@thedillows.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next-2.6] typhoon: fix a race in typhoon_do_get_stats
2010-08-24 14:18 [PATCH net-next-2.6] typhoon: fix a race in typhoon_do_get_stats Eric Dumazet
2010-08-24 14:52 ` David Dillow
@ 2010-08-25 23:37 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2010-08-25 23:37 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 24 Aug 2010 16:18:13 +0200
> Its important to store 'final' values in counters,
> not using them as temporary variables,
> or this might break some SNMP applications.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-25 23:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-24 14:18 [PATCH net-next-2.6] typhoon: fix a race in typhoon_do_get_stats Eric Dumazet
2010-08-24 14:52 ` David Dillow
2010-08-25 23:37 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).