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: <20180709194856.18922-10-stephen@networkplumber.org>
Date:   Mon,  9 Jul 2018 12:48:56 -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 iproute2-next 9/9] tc/sfq: add json support

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

Convert to use JSON

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 tc/q_sfq.c | 65 ++++++++++++++++++++++++++++++++----------------------
 1 file changed, 39 insertions(+), 26 deletions(-)

diff --git a/tc/q_sfq.c b/tc/q_sfq.c
index 6a1d853b7c93..cc8ce0dddf7e 100644
--- a/tc/q_sfq.c
+++ b/tc/q_sfq.c
@@ -205,9 +205,6 @@ static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	struct tc_sfq_qopt *qopt;
 	struct tc_sfq_qopt_v1 *qopt_ext = NULL;
 
-	SPRINT_BUF(b1);
-	SPRINT_BUF(b2);
-	SPRINT_BUF(b3);
 	if (opt == NULL)
 		return 0;
 
@@ -216,36 +213,53 @@ static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	if (RTA_PAYLOAD(opt) >= sizeof(*qopt_ext))
 		qopt_ext = RTA_DATA(opt);
 	qopt = RTA_DATA(opt);
-	fprintf(f, "limit %up ", qopt->limit);
-	fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
+
+	print_uint(PRINT_ANY, "limit", "limit %up ", qopt->limit);
+	print_size("quantum", "quantum %s ", qopt->quantum);
+	
 	if (qopt_ext && qopt_ext->depth)
-		fprintf(f, "depth %u ", qopt_ext->depth);
+		print_uint(PRINT_ANY, "depth",
+			   "depth %u ", qopt_ext->depth);
 	if (qopt_ext && qopt_ext->headdrop)
-		fprintf(f, "headdrop ");
+		print_null(PRINT_ANY, "headdrop", "headdrop ", NULL);
 
 	if (show_details) {
-		fprintf(f, "flows %u/%u ", qopt->flows, qopt->divisor);
+		print_uint(PRINT_ANY, "flows", "flows %u", qopt->flows);
+		print_uint(PRINT_ANY, "divisor", "/%u ", qopt->divisor);
+	} else {
+		print_uint(PRINT_ANY, "divisor", "divisor %u ", qopt->divisor);
 	}
-	fprintf(f, "divisor %u ", qopt->divisor);
+
 	if (qopt->perturb_period)
-		fprintf(f, "perturb %dsec ", qopt->perturb_period);
+		print_int(PRINT_ANY, "perturb",
+			  "perturb %dsec ", qopt->perturb_period);
+
 	if (qopt_ext && qopt_ext->qth_min) {
-		fprintf(f, "\n ewma %u ", qopt_ext->Wlog);
-		fprintf(f, "min %s max %s probability %g ",
-			sprint_size(qopt_ext->qth_min, b2),
-			sprint_size(qopt_ext->qth_max, b3),
-			qopt_ext->max_P / pow(2, 32));
+		print_string(PRINT_FP, NULL, "%s", _SL_);
+		print_uint(PRINT_ANY, "ewma", " ewma %u ", qopt_ext->Wlog);
+		print_size("qth_min", "min %s" , qopt_ext->qth_min);
+		print_size("qth_max", "max %s ", qopt_ext->qth_max);
+		print_float(PRINT_ANY, "probability", "probability %g ",
+			    qopt_ext->max_P / pow(2, 32));
+
 		if (qopt_ext->flags & TC_RED_ECN)
-			fprintf(f, "ecn ");
+			print_null(PRINT_ANY, "ecn", "ecn ", NULL);
+
 		if (show_stats) {
-			fprintf(f, "\n prob_mark %u prob_mark_head %u prob_drop %u",
-				qopt_ext->stats.prob_mark,
-				qopt_ext->stats.prob_mark_head,
-				qopt_ext->stats.prob_drop);
-			fprintf(f, "\n forced_mark %u forced_mark_head %u forced_drop %u",
-				qopt_ext->stats.forced_mark,
-				qopt_ext->stats.forced_mark_head,
-				qopt_ext->stats.forced_drop);
+			print_string(PRINT_FP, NULL, "%s", _SL_);
+			print_uint(PRINT_ANY, "prob_mark", " prob_mark %u",
+				   qopt_ext->stats.prob_mark);
+			print_uint(PRINT_ANY, "prob_mark_head", " prob_mark_head %u",
+				   qopt_ext->stats.prob_mark_head);
+			print_uint(PRINT_ANY, "prob_drop"," prob_drop %u",
+				   qopt_ext->stats.prob_drop);
+			print_string(PRINT_FP, NULL, "%s", _SL_);
+			print_uint(PRINT_ANY, "forced_mark", " forced_mark %u",
+				   qopt_ext->stats.forced_mark);
+			print_uint(PRINT_ANY, "forced_mark_head", " forced_mark_head %u",
+				   qopt_ext->stats.forced_mark_head);
+			print_uint(PRINT_ANY, "forced_drop"," forced_drop %u",
+				   qopt_ext->stats.forced_drop);
 		}
 	}
 	return 0;
@@ -262,8 +276,7 @@ static int sfq_print_xstats(struct qdisc_util *qu, FILE *f,
 		return -1;
 	st = RTA_DATA(xstats);
 
-	fprintf(f, " allot %d ", st->allot);
-	fprintf(f, "\n");
+	print_int(PRINT_ANY, "allot", "allot %d\n", st->allot);
 	return 0;
 }
 
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ