lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180710210558.20278-32-stephen@networkplumber.org>
Date:   Tue, 10 Jul 2018 14:05:58 -0700
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     netdev@...r.kernel.org
Cc:     Stephen Hemminger <sthemmin@...rosoft.com>,
        Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH v2 iproute2-next 31/31] tc/fq_codel: use JSON helpers

From: Stephen Hemminger <sthemmin@...rosoft.com>

New routines make doing JSON output of time and size
easier and consistent.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 tc/q_fq_codel.c | 38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/tc/q_fq_codel.c b/tc/q_fq_codel.c
index 02ad2214110b..4cdaec58bf0a 100644
--- a/tc/q_fq_codel.c
+++ b/tc/q_fq_codel.c
@@ -163,8 +163,6 @@ static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt
 	unsigned int ce_threshold;
 	unsigned int memory_limit;
 
-	SPRINT_BUF(b1);
-
 	if (opt == NULL)
 		return 0;
 
@@ -188,30 +186,22 @@ static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt
 	if (tb[TCA_FQ_CODEL_TARGET] &&
 	    RTA_PAYLOAD(tb[TCA_FQ_CODEL_TARGET]) >= sizeof(__u32)) {
 		target = rta_getattr_u32(tb[TCA_FQ_CODEL_TARGET]);
-		print_uint(PRINT_JSON, "target", NULL, target);
-		print_string(PRINT_FP, NULL, "target %s ",
-			     sprint_time(target, b1));
+		print_time("target", "target %s ", target);
 	}
 	if (tb[TCA_FQ_CODEL_CE_THRESHOLD] &&
 	    RTA_PAYLOAD(tb[TCA_FQ_CODEL_CE_THRESHOLD]) >= sizeof(__u32)) {
 		ce_threshold = rta_getattr_u32(tb[TCA_FQ_CODEL_CE_THRESHOLD]);
-		print_uint(PRINT_JSON, "ce_threshold", NULL, ce_threshold);
-		print_string(PRINT_FP, NULL, "ce_threshold %s ",
-			     sprint_time(ce_threshold, b1));
+		print_time("ce_threshold", "ce_threshold %s ", ce_threshold);
 	}
 	if (tb[TCA_FQ_CODEL_INTERVAL] &&
 	    RTA_PAYLOAD(tb[TCA_FQ_CODEL_INTERVAL]) >= sizeof(__u32)) {
 		interval = rta_getattr_u32(tb[TCA_FQ_CODEL_INTERVAL]);
-		print_uint(PRINT_JSON, "interval", NULL, interval);
-		print_string(PRINT_FP, NULL, "interval %s ",
-			     sprint_time(interval, b1));
+		print_time("interval", "interval %s ", interval);
 	}
 	if (tb[TCA_FQ_CODEL_MEMORY_LIMIT] &&
 	    RTA_PAYLOAD(tb[TCA_FQ_CODEL_MEMORY_LIMIT]) >= sizeof(__u32)) {
 		memory_limit = rta_getattr_u32(tb[TCA_FQ_CODEL_MEMORY_LIMIT]);
-		print_uint(PRINT_JSON, "memory_limit", NULL, memory_limit);
-		print_string(PRINT_FP, NULL, "memory_limit %s ",
-			     sprint_size(memory_limit, b1));
+		print_size("memory_limit", "memory_limit %s ", memory_limit);
 	}
 	if (tb[TCA_FQ_CODEL_ECN] &&
 	    RTA_PAYLOAD(tb[TCA_FQ_CODEL_ECN]) >= sizeof(__u32)) {
@@ -228,8 +218,6 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
 {
 	struct tc_fq_codel_xstats _st = {}, *st;
 
-	SPRINT_BUF(b1);
-
 	if (xstats == NULL)
 		return 0;
 
@@ -268,21 +256,13 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
 			st->class_stats.count);
 		print_uint(PRINT_ANY, "lastcount", " lastcount %u",
 			st->class_stats.lastcount);
-		print_uint(PRINT_JSON, "ldelay", NULL,
-			st->class_stats.ldelay);
-		print_string(PRINT_FP, NULL, " ldelay %s",
-			sprint_time(st->class_stats.ldelay, b1));
+		print_time("ldelay", " ldelay %s",
+			   st->class_stats.ldelay);
+
 		if (st->class_stats.dropping) {
 			print_bool(PRINT_ANY, "dropping", " dropping", true);
-			if (st->class_stats.drop_next < 0)
-				print_string(PRINT_FP, NULL, " drop_next -%s",
-					sprint_time(-st->class_stats.drop_next, b1));
-			else {
-				print_uint(PRINT_JSON, "drop_next", NULL,
-					st->class_stats.drop_next);
-				print_string(PRINT_FP, NULL, " drop_next %s",
-					sprint_time(st->class_stats.drop_next, b1));
-			}
+			print_time("drop_next", " drop_next %s",
+				   st->class_stats.drop_next);
 		}
 	}
 	return 0;
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ