diff mbox

[net-next] net: Make it easier to parse /proc/net/dev contents.

Message ID 20100105155052.13309.1197.stgit@firesoul.comx.local
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Jesper Dangaard Brouer Jan. 5, 2010, 3:50 p.m. UTC
The contents of /proc/net/dev is annoying to parse, because
it changes whether there is a space after the "ethX:" or not.
It depends upon the size of the "Receive bytes" counter,
if the number is below 7 digits, then there is whitespaces
else if the number is 8 digits or above there is no space
between the ":" and the number.

This patch changes the output to assure there is always a space
between the ":" and the number.  Given that all existing userspace
application already need to handle the whitespaces, I see
no breakage of existing tools.

Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
---

 net/core/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Dumazet Jan. 6, 2010, 5:57 a.m. UTC | #1
Le 05/01/2010 16:50, Jesper Dangaard Brouer a écrit :
> The contents of /proc/net/dev is annoying to parse, because
> it changes whether there is a space after the "ethX:" or not.
> It depends upon the size of the "Receive bytes" counter,
> if the number is below 7 digits, then there is whitespaces
> else if the number is 8 digits or above there is no space
> between the ":" and the number.
> 
> This patch changes the output to assure there is always a space
> between the ":" and the number.  Given that all existing userspace
> application already need to handle the whitespaces, I see
> no breakage of existing tools.
> 
> Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 7, 2010, 8:59 a.m. UTC | #2
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 06 Jan 2010 06:57:17 +0100

> Le 05/01/2010 16:50, Jesper Dangaard Brouer a écrit :
>> The contents of /proc/net/dev is annoying to parse, because
>> it changes whether there is a space after the "ethX:" or not.
>> It depends upon the size of the "Receive bytes" counter,
>> if the number is below 7 digits, then there is whitespaces
>> else if the number is 8 digits or above there is no space
>> between the ":" and the number.
>> 
>> This patch changes the output to assure there is always a space
>> between the ":" and the number.  Given that all existing userspace
>> application already need to handle the whitespaces, I see
>> no breakage of existing tools.
>> 
>> Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
> 
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index f9aa699..3a86252 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3207,7 +3207,7 @@  static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
 {
 	const struct net_device_stats *stats = dev_get_stats(dev);
 
-	seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
+	seq_printf(seq, "%6s: %7lu %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,