[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180710210558.20278-22-stephen@networkplumber.org>
Date: Tue, 10 Jul 2018 14:05:48 -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 21/31] tc/hhf: implement JSON output
From: Stephen Hemminger <sthemmin@...rosoft.com>
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
tc/q_hhf.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tc/q_hhf.c b/tc/q_hhf.c
index 21186a92c017..daea6bbcdd65 100644
--- a/tc/q_hhf.c
+++ b/tc/q_hhf.c
@@ -127,8 +127,6 @@ static int hhf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
unsigned int evict_timeout;
unsigned int non_hh_weight;
- SPRINT_BUF(b1);
-
if (opt == NULL)
return 0;
@@ -137,37 +135,38 @@ static int hhf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (tb[TCA_HHF_BACKLOG_LIMIT] &&
RTA_PAYLOAD(tb[TCA_HHF_BACKLOG_LIMIT]) >= sizeof(__u32)) {
limit = rta_getattr_u32(tb[TCA_HHF_BACKLOG_LIMIT]);
- fprintf(f, "limit %up ", limit);
+ print_uint(PRINT_ANY, "limit", "limit %up ", limit);
}
if (tb[TCA_HHF_QUANTUM] &&
RTA_PAYLOAD(tb[TCA_HHF_QUANTUM]) >= sizeof(__u32)) {
quantum = rta_getattr_u32(tb[TCA_HHF_QUANTUM]);
- fprintf(f, "quantum %u ", quantum);
+ print_uint(PRINT_ANY, "quantum", "quantum %u ", quantum);
}
if (tb[TCA_HHF_HH_FLOWS_LIMIT] &&
RTA_PAYLOAD(tb[TCA_HHF_HH_FLOWS_LIMIT]) >= sizeof(__u32)) {
hh_limit = rta_getattr_u32(tb[TCA_HHF_HH_FLOWS_LIMIT]);
- fprintf(f, "hh_limit %u ", hh_limit);
+ print_uint(PRINT_ANY, "hh_limit", "hh_limit %u ", hh_limit);
}
if (tb[TCA_HHF_RESET_TIMEOUT] &&
RTA_PAYLOAD(tb[TCA_HHF_RESET_TIMEOUT]) >= sizeof(__u32)) {
reset_timeout = rta_getattr_u32(tb[TCA_HHF_RESET_TIMEOUT]);
- fprintf(f, "reset_timeout %s ", sprint_time(reset_timeout, b1));
+ print_time("reset_timeout", "reset_timeout %s ", reset_timeout);
}
if (tb[TCA_HHF_ADMIT_BYTES] &&
RTA_PAYLOAD(tb[TCA_HHF_ADMIT_BYTES]) >= sizeof(__u32)) {
admit_bytes = rta_getattr_u32(tb[TCA_HHF_ADMIT_BYTES]);
- fprintf(f, "admit_bytes %u ", admit_bytes);
+ print_uint(PRINT_ANY, "admit_bytes", "admit_bytes %u ", admit_bytes);
}
if (tb[TCA_HHF_EVICT_TIMEOUT] &&
RTA_PAYLOAD(tb[TCA_HHF_EVICT_TIMEOUT]) >= sizeof(__u32)) {
evict_timeout = rta_getattr_u32(tb[TCA_HHF_EVICT_TIMEOUT]);
- fprintf(f, "evict_timeout %s ", sprint_time(evict_timeout, b1));
+ print_time("evict_timeout", "evict_timeout %s ", evict_timeout);
}
if (tb[TCA_HHF_NON_HH_WEIGHT] &&
RTA_PAYLOAD(tb[TCA_HHF_NON_HH_WEIGHT]) >= sizeof(__u32)) {
non_hh_weight = rta_getattr_u32(tb[TCA_HHF_NON_HH_WEIGHT]);
- fprintf(f, "non_hh_weight %u ", non_hh_weight);
+ print_uint(PRINT_ANY, "non_hh_weight",
+ "non_hh_weight %u ", non_hh_weight);
}
return 0;
}
@@ -185,9 +184,10 @@ static int hhf_print_xstats(struct qdisc_util *qu, FILE *f,
st = RTA_DATA(xstats);
- fprintf(f, " drop_overlimit %u hh_overlimit %u tot_hh %u cur_hh %u",
- st->drop_overlimit, st->hh_overlimit,
- st->hh_tot_count, st->hh_cur_count);
+ print_uint(PRINT_ANY, "drop_overlimit", "drop_overlimit %u", st->drop_overlimit);
+ print_uint(PRINT_ANY, "hh_overlimit", "hh_overlimit %u", st->hh_overlimit);
+ print_uint(PRINT_ANY, "tot_count", "tot_hh %u", st->hh_tot_count);
+ print_uint(PRINT_ANY, "cur_count", "cur_hh %u", st->hh_cur_count);
return 0;
}
--
2.18.0
Powered by blists - more mailing lists