Skip to contentSkip to conversation

iproute: fix tc -iec display of Mibit rates

PATCH Applied Andreas Henriksson 2 participants 2 messages Mar 9, 2012 – Mar 10, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iproute: fix tc -iec display of Mibit rates

As reported by Thomas Mühlgrabner <[email protected]> in http://bugs.debian.org/662979 :

When showing htb class configuration with "tc -iec class show", the output for Mibit is actually the value for bit.
Example: configure a class with a ceil of 1000Mibit. Output states 1048576000 Mibit.

The cause is missing parenteses in the display code of tc....

(Please also note that a lower value of 100Mibit will be displayed as 102400 Kibit, which I think is kind of ugly.)

tc/tc_util.c +1 -1
index 5829d61..36e3c7d 100644
@@ -203,7 +203,7 @@ void print_rate(char *buf, int len, __u32 rate)
 
 	if (use_iec) {
 		if (tmp >= 1000.0*1024.0*1024.0)
-			snprintf(buf, len, "%.0fMibit", tmp/1024.0*1024.0);
+			snprintf(buf, len, "%.0fMibit", tmp/(1024.0*1024.0));
 		else if (tmp >= 1000.0*1024)
 			snprintf(buf, len, "%.0fKibit", tmp/1024);
 		else
#1 lore raw
Quoted 21 lines · On Fri, 9 Mar 2012 17:09:19 +0100 Andreas Henriksson <[email protected]> wrote:

As reported by Thomas Mühlgrabner <[email protected]> in http://bugs.debian.org/662979 :

When showing htb class configuration with "tc -iec class show", the output for Mibit is actually the value for bit.
Example: configure a class with a ceil of 1000Mibit. Output states 1048576000 Mibit.

The cause is missing parenteses in the display code of tc....

(Please also note that a lower value of 100Mibit will be displayed as 102400 Kibit, which I think is kind of ugly.)

tc/tc_util.c +0 -0
index 5829d61..36e3c7d 100644

tc/tc_util.c void print_rate(char *buf, int len, __u32 rate) · line 209

Quoted 8 lines
tc/tc_util.c +1 -1
@@ -203,7 +203,7 @@ void print_rate(char *buf, int len, __u32 rate)
 
 	if (use_iec) {
 		if (tmp >= 1000.0*1024.0*1024.0)
-			snprintf(buf, len, "%.0fMibit", tmp/1024.0*1024.0);
+			snprintf(buf, len, "%.0fMibit", tmp/(1024.0*1024.0));
 		else if (tmp >= 1000.0*1024)
 			snprintf(buf, len, "%.0fKibit", tmp/1024);
 		else

Applied