From: Stephen Hemminger Subject: [PATCH v2 iproute2-next 12/31] tc/rr: implement JSON output Date: Tue, 10 Jul 2018 14:05:39 -0700 Message-ID: <20180710210558.20278-13-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-pg1-f193.google.com ([209.85.215.193]:43481 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732265AbeGJVOM (ORCPT ); Tue, 10 Jul 2018 17:14:12 -0400 Received: by mail-pg1-f193.google.com with SMTP id v13-v6so2318213pgr.10 for ; Tue, 10 Jul 2018 14:13:18 -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_rr.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tc/q_rr.c b/tc/q_rr.c index 843a4faeef41..dcc58ac98ba2 100644 --- a/tc/q_rr.c +++ b/tc/q_rr.c @@ -101,13 +101,19 @@ static int rr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) sizeof(*qopt))) return -1; - fprintf(f, "bands %u priomap ", qopt->bands); + print_uint(PRINT_ANY, "bands", "bands %u priomap ", qopt->bands); + open_json_array(PRINT_JSON, "priomap"); for (i = 0; i <= TC_PRIO_MAX; i++) - fprintf(f, " %d", qopt->priomap[i]); + print_uint(PRINT_ANY, NULL, " %u", qopt->priomap[i]); + close_json_array(PRINT_JSON, NULL); - if (tb[TCA_PRIO_MQ]) - fprintf(f, " multiqueue: %s ", - rta_getattr_u8(tb[TCA_PRIO_MQ]) ? "on" : "off"); + if (tb[TCA_PRIO_MQ]) { + bool mq = rta_getattr_u8(tb[TCA_PRIO_MQ]); + + print_string(PRINT_FP, NULL, " multiqueue: %s ", + mq ? "on" : "off"); + print_bool(PRINT_JSON, "multiqueue", NULL, mq); + } return 0; } -- 2.18.0