From: Stephen Hemminger Subject: [PATCH v2 iproute2-next 20/31] tc/choke: implement JSON output Date: Tue, 10 Jul 2018 14:05:47 -0700 Message-ID: <20180710210558.20278-21-stephen@networkplumber.org> References: <20180710210558.20278-1-stephen@networkplumber.org> Cc: Stephen Hemminger , Stephen Hemminger To: netdev@vger.kernel.org Return-path: Received: from mail-pf0-f193.google.com ([209.85.192.193]:34711 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732333AbeGJVMi (ORCPT ); Tue, 10 Jul 2018 17:12:38 -0400 Received: by mail-pf0-f193.google.com with SMTP id e10-v6so16922514pfn.1 for ; Tue, 10 Jul 2018 14:11:45 -0700 (PDT) In-Reply-To: <20180710210558.20278-1-stephen@networkplumber.org> Sender: netdev-owner@vger.kernel.org List-ID: From: Stephen Hemminger Signed-off-by: Stephen Hemminger --- tc/q_choke.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tc/q_choke.c b/tc/q_choke.c index b269b1338b6d..718743f4a998 100644 --- a/tc/q_choke.c +++ b/tc/q_choke.c @@ -185,19 +185,23 @@ static int choke_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) RTA_PAYLOAD(tb[TCA_CHOKE_MAX_P]) >= sizeof(__u32)) max_P = rta_getattr_u32(tb[TCA_CHOKE_MAX_P]); - fprintf(f, "limit %up min %up max %up ", - qopt->limit, qopt->qth_min, qopt->qth_max); + print_uint(PRINT_ANY, "limit", "limit %up", qopt->limit); + print_uint(PRINT_ANY, "min", " min %up", qopt->qth_min); + print_uint(PRINT_ANY, "max", " max %up ", qopt->qth_max); if (qopt->flags & TC_RED_ECN) - fprintf(f, "ecn "); + print_null(PRINT_ANY, "ecn", "ecn ", NULL); if (show_details) { - fprintf(f, "ewma %u ", qopt->Wlog); + print_uint(PRINT_ANY, "ewma", "ewma %u ", qopt->Wlog); if (max_P) - fprintf(f, "probability %g ", max_P / pow(2, 32)); + print_float(PRINT_ANY, "probability", + "probability %g ", max_P / pow(2, 32)); else - fprintf(f, "Plog %u ", qopt->Plog); - fprintf(f, "Scell_log %u", qopt->Scell_log); + print_uint(PRINT_ANY, "plog", + "Plog %u ", qopt->Plog); + print_uint(PRINT_ANY, "scell_log", + "Scell_log %u", qopt->Scell_log); } return 0; } @@ -214,8 +218,11 @@ static int choke_print_xstats(struct qdisc_util *qu, FILE *f, return -1; st = RTA_DATA(xstats); - fprintf(f, " marked %u early %u pdrop %u other %u matched %u", - st->marked, st->early, st->pdrop, st->other, st->matched); + print_uint(PRINT_ANY, "marked", " marked %u", st->marked); + print_uint(PRINT_ANY, "early", " early %u", st->early); + print_uint(PRINT_ANY, "pdrop", " pdrop %u", st->pdrop); + print_uint(PRINT_ANY, "other", " other %u", st->other); + print_uint(PRINT_ANY, "matched", " matched %u", st->matched); return 0; } -- 2.18.0