netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Henriksson <andreas@fatal.se>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, cfriesen@nortel.com,
	shemminger@linux-foundation.org
Subject: Re: iproute2 showing wrong number of bytes on 64bit architectures.
Date: Wed, 11 Jul 2007 13:50:07 +0200	[thread overview]
Message-ID: <20070711115007.GA27431@scream.fatal.se> (raw)

(Sorry for breaking the thread, please CC me on future replies...)

If I understand the discussion correctly, the problem in itself isn't greater
then that different methods of gathering the statistics have different
rollovers and thus confuse people who aren't aware of which method each tool
uses. The the main issue with fixing this is that it needs to be handled
gently to not break the userspace API/ABI.

I see three different paths...

a) just ignore the issue and let everybody who run into this stay confused
and cry about linux being crap unless they dig deeper and gets informed of
the different interfaces and their rollovers.

b) be lazy and fix only the confusion by making sure that the statistics in
/proc/net/dev also rolls over at 32bits so that all exported statistics show
the same number (while ignoring possible problems with 32bit rollovers, like
fast networks might roll over too quickly and make the stats useless).

c) take the more painful route of switching over to 64bit statistics in
netlink. Add 64bit interface, port userspace tools, deprecate the old 32bit
interface. (I guess exporting as u64 even on 32bit architectures wouldn't
hurt them, even if they still will rollover at (unsigned long) 32 bits.)


I'd prefer not to do (a). Would (b) be acceptable? If not, could someone who
is more familiar with how to do netlink please help me out with a patch for
adding the required kernel part of (c)?
(I'm going away for 2 weeks on friday, so I'll pick up whatever needs doing
when I'm back...)


Here's a completely untested patch for (b):


--- linux-2.6.22/net/core/dev.c	2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22/net/core/dev.c.new	2007-07-11 13:56:21.000000000 +0200
@@ -2184,23 +2184,24 @@
 {
 	struct net_device_stats *stats = dev->get_stats(dev);
 
-	seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
-		   "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
-		   dev->name, stats->rx_bytes, stats->rx_packets,
-		   stats->rx_errors,
-		   stats->rx_dropped + stats->rx_missed_errors,
-		   stats->rx_fifo_errors,
-		   stats->rx_length_errors + stats->rx_over_errors +
-		    stats->rx_crc_errors + stats->rx_frame_errors,
-		   stats->rx_compressed, stats->multicast,
-		   stats->tx_bytes, stats->tx_packets,
-		   stats->tx_errors, stats->tx_dropped,
-		   stats->tx_fifo_errors, stats->collisions,
-		   stats->tx_carrier_errors +
-		    stats->tx_aborted_errors +
+	/* Always rollover stats at 32bits to match netlink interface */
+	seq_printf(seq, "%6s:%8u %7u %4u %4u %4u %5u %10u %9u "
+		   "%8u %7u %4u %4u %4u %5u %7u %10u\n",
+		   dev->name, (u32)stats->rx_bytes, (u32)stats->rx_packets,
+		   (u32)stats->rx_errors,
+		   (u32)(stats->rx_dropped + stats->rx_missed_errors),
+		   (u32)stats->rx_fifo_errors,
+		   (u32)(stats->rx_length_errors + stats->rx_over_errors +
+		    stats->rx_crc_errors + stats->rx_frame_errors),
+		   (u32)stats->rx_compressed, (u32)stats->multicast,
+		   (u32)stats->tx_bytes, (u32)stats->tx_packets,
+		   (u32)stats->tx_errors, (u32)stats->tx_dropped,
+		   (u32)stats->tx_fifo_errors, (u32)stats->collisions,
+		   (u32)(stats->tx_carrier_errors +
+		    ustats->tx_aborted_errors +
 		    stats->tx_window_errors +
-		    stats->tx_heartbeat_errors,
-		   stats->tx_compressed);
+		    stats->tx_heartbeat_errors),
+		   (u32)stats->tx_compressed);
 }
 
 /*


-- 
Regards,
Andreas Henriksson

             reply	other threads:[~2007-07-11 12:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-11 11:50 Andreas Henriksson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-01-13 14:14 iproute2 showing wrong number of bytes on 64bit architectures Norman Rasmussen
2007-07-10 15:56 Fw: " Stephen Hemminger
2007-07-10 18:05 ` David Miller
2007-07-10 18:17   ` Chris Friesen
2007-07-10 18:36     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070711115007.GA27431@scream.fatal.se \
    --to=andreas@fatal.se \
    --cc=cfriesen@nortel.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).