[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180710210558.20278-30-stephen@networkplumber.org>
Date: Tue, 10 Jul 2018 14:05: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 v2 iproute2-next 29/31] tc/hfsc: convert to JSON output
From: Stephen Hemminger <sthemmin@...rosoft.com>
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
tc/q_hfsc.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index f34b1b2fe2a9..e2f366b8a189 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -113,7 +113,8 @@ hfsc_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
qopt = RTA_DATA(opt);
if (qopt->defcls != 0)
- fprintf(f, "default %x ", qopt->defcls);
+ print_0xhex(PRINT_ANY, "default",
+ "default %x ", qopt->defcls);
return 0;
}
@@ -129,13 +130,12 @@ hfsc_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
return -1;
st = RTA_DATA(xstats);
- fprintf(f, " period %u ", st->period);
+ print_uint(PRINT_ANY, "period", " period %u ", st->period);
if (st->work != 0)
- fprintf(f, "work %llu bytes ", (unsigned long long) st->work);
+ print_u64(PRINT_ANY, "work", "work %llu bytes ", st->work);
if (st->rtwork != 0)
- fprintf(f, "rtwork %llu bytes ", (unsigned long long) st->rtwork);
- fprintf(f, "level %u ", st->level);
- fprintf(f, "\n");
+ print_u64(PRINT_ANY, "rtwork", "rtwork %llu bytes ", st->rtwork);
+ print_uint(PRINT_ANY, "level", "level %u ", st->level);
return 0;
}
@@ -214,14 +214,14 @@ hfsc_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
}
static void
-hfsc_print_sc(FILE *f, char *name, struct tc_service_curve *sc)
+hfsc_print_sc(FILE *f, const char *name, const struct tc_service_curve *sc)
{
- SPRINT_BUF(b1);
-
- fprintf(f, "%s ", name);
- fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1));
- fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
- fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1));
+ print_string(PRINT_FP, NULL, "%s ", name);
+ open_json_object(name);
+ print_rate("m1", "m1 %s ", sc->m1);
+ print_time("d", "d %s ", tc_core_ktime2time(sc->d));
+ print_rate("m2", "m2 %s ", sc->m2);
+ close_json_object();
}
static int
--
2.18.0
Powered by blists - more mailing lists