[PATCH iproute2-next] ip-address: Fix negative prints of large TX rate limits

Subsystems: the rest

STALE3144d

3 messages, 2 authors, 2018-03-08 · open the first message on its own page

[PATCH iproute2-next] ip-address: Fix negative prints of large TX rate limits

From: Tariq Toukan <hidden>
Date: 2018-03-08 13:48:58

TX rate limit fields are unsigned (__u32).
Print them using %u.

Tested:
$ ip link set ens1 vf 1 rate 2294967296
$ ip link show |grep -iE "vf 1" | grep rate

before:
vf 1 MAC 00:00:00:00:00:00, tx rate -2000000000 (Mbps), max_tx_rate -2000000000Mbps, ...

after:
vf 1 MAC 00:00:00:00:00:00, tx rate 2294967296 (Mbps), max_tx_rate 2294967296Mbps, ...

Fixes: 3fd86630876a ("iproute2: rework SR-IOV VF support")
Fixes: 8c29ae7cc249 ("ip link: Fix crash on older kernels when show VF dev")
Fixes: f89a2a05ffa9 ("Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool")
Fixes: ae7229d5f99e ("ip: Add support for setting and showing SR-IOV virtual funtion link params")
Fixes: d0e720111aad ("ip: ipaddress.c: add support for json output")
Signed-off-by: Tariq Toukan <redacted>
---
 ip/ipaddress.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index d01d7030b442..a4e410597461 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -418,7 +418,7 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 	if (vf_tx_rate->rate)
 		print_int(PRINT_ANY,
 			  "tx_rate",
-			  ", tx rate %d (Mbps)",
+			  ", tx rate %u (Mbps)",
 			  vf_tx_rate->rate);
 
 	if (vf[IFLA_VF_RATE]) {
@@ -433,9 +433,9 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 			close_json_object();
 		} else {
 			if (max_tx)
-				fprintf(fp, ", max_tx_rate %dMbps", max_tx);
+				fprintf(fp, ", max_tx_rate %uMbps", max_tx);
 			if (min_tx)
-				fprintf(fp, ", min_tx_rate %dMbps", min_tx);
+				fprintf(fp, ", min_tx_rate %uMbps", min_tx);
 		}
 	}
 
-- 
1.8.3.1

Re: [PATCH iproute2-next] ip-address: Fix negative prints of large TX rate limits

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-03-08 15:38:40

On Thu,  8 Mar 2018 15:48:27 +0200
Tariq Toukan [off-list ref] wrote:
quoted hunk
 	if (vf_tx_rate->rate)
 		print_int(PRINT_ANY,
 			  "tx_rate",
-			  ", tx rate %d (Mbps)",
+			  ", tx rate %u (Mbps)",
 			  vf_tx_rate->rate)
JSON output has same sign bug. You need to use print_uint here.

Re: [PATCH iproute2-next] ip-address: Fix negative prints of large TX rate limits

From: Tariq Toukan <hidden>
Date: 2018-03-08 15:56:59


On 08/03/2018 5:38 PM, Stephen Hemminger wrote:
On Thu,  8 Mar 2018 15:48:27 +0200
Tariq Toukan [off-list ref] wrote:
quoted
  	if (vf_tx_rate->rate)
  		print_int(PRINT_ANY,
  			  "tx_rate",
-			  ", tx rate %d (Mbps)",
+			  ", tx rate %u (Mbps)",
  			  vf_tx_rate->rate)
JSON output has same sign bug. You need to use print_uint here.
Thanks Stephen, I'm fixing it...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help