From patchwork Sat Nov 25 14:48:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 841249 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="IuW+yGjg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ykbXz3C2Cz9s9Y for ; Sun, 26 Nov 2017 01:48:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751859AbdKYOsp (ORCPT ); Sat, 25 Nov 2017 09:48:45 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:45697 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbdKYOsm (ORCPT ); Sat, 25 Nov 2017 09:48:42 -0500 Received: by mail-wm0-f66.google.com with SMTP id 9so26748049wme.4 for ; Sat, 25 Nov 2017 06:48:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rvq0Ge6PVBMi3Tqbuxpb4uBROzWEQGt5PGtchpC9djM=; b=IuW+yGjgwpMYnqRpwmWxLMGpS1/u+laRutjjw4BoJ4Nv38dX9xSKesl3GPsgVDd9ku JaUonqXQVhmOcjWFd8snz+PD8h0nrQdeAIKi0vG5l3oIoFbaIBgJIOYSusHHyPXCpb2a ucvZUf7BzCI+0fOb+FHMyeAstA1sCkjkvlt+YUdm3nB1AZ6/yUIq2sdI8f8JOiG9KOnM zdsnUpBd+Izu28EDCrKdztPHeUzyEH8DiXyhh/T7jkTYbSCQpOqICFPsPtEvFolW8zcU hvFwUNYOVh2xOadqv+0BDuhzolPs8f3nUxcDTFElMClXZ7dA0hE0Yl93DksJehKvivCj 6iDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rvq0Ge6PVBMi3Tqbuxpb4uBROzWEQGt5PGtchpC9djM=; b=NhZNZScuGZY+xf0l+eco2X+rF27kFRQtGTSm1TAWB1am76NI159q73vyqDK4v53PlR bt7DpFiGniYLoA8XFIKMmTwwyVqmMLL3X7NIkYhy5nYE70Fq+w/57ekjjBKsNlPIRmvk WUedNdt5uWK3rPVHr4MAN0Mzq5xoVJhM8g3zhFxtxvXN0wD44o5nohZOr/ikXYQ/czjK hSCTlDIBbKJk3sHm9sjDbiJeXcJ7zbPpx3Y7tBTSaxaqQO19oU4XqE+QuWpjlGFah7eU cgRSL6Z28PP5muiKo7fJwTAfb5Fv/AgsB/98Fv4HyhJEs3MOw852icO4ClJgnOhj3I+7 QIxA== X-Gm-Message-State: AJaThX4ns1sAFh3pImswZHaC3+Po2AE8thzvij1tZkZovilDMGA6DEU1 q6eiItUAAUtTIPl2NKWL7q6ALG1Z X-Google-Smtp-Source: AGs4zMboIKR5Mnr91mExKH2nj17EtCFSKNI5TOSrFsYgeKh+5u8iNQ6GjvGOakqfl3LYjuPUyFDO4w== X-Received: by 10.28.174.140 with SMTP id x134mr4036991wme.103.1511621321057; Sat, 25 Nov 2017 06:48:41 -0800 (PST) Received: from localhost (ip-89-103-66-66.net.upcbroadband.cz. [89.103.66.66]) by smtp.gmail.com with ESMTPSA id n143sm25295291wmd.31.2017.11.25.06.48.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Nov 2017 06:48:40 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, jhs@mojatatu.com, mlxsw@mellanox.com Subject: [patch iproute2 04/11] tc: jsonify htb qdisc Date: Sat, 25 Nov 2017 15:48:28 +0100 Message-Id: <20171125144835.5045-5-jiri@resnulli.us> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171125144835.5045-1-jiri@resnulli.us> References: <20171125144835.5045-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Add json output to htb qdisc. Signed-off-by: Jiri Pirko --- tc/q_htb.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tc/q_htb.c b/tc/q_htb.c index ffb43aa..3fc2acb 100644 --- a/tc/q_htb.c +++ b/tc/q_htb.c @@ -293,9 +293,10 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (RTA_PAYLOAD(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) return -1; if (!hopt->level) { - fprintf(f, "prio %d ", (int)hopt->prio); + print_int(PRINT_ANY, "prio", "prio ", (int)hopt->prio); if (show_details) - fprintf(f, "quantum %d ", (int)hopt->quantum); + print_int(PRINT_ANY, "quantum", "quantum ", + (int)hopt->quantum); } rate64 = hopt->rate.rate; @@ -341,16 +342,21 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) gopt = RTA_DATA(tb[TCA_HTB_INIT]); if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1; - fprintf(f, "r2q %d default %x direct_packets_stat %u", - gopt->rate2quantum, gopt->defcls, gopt->direct_pkts); - if (show_details) - fprintf(f, " ver %d.%d", gopt->version >> 16, gopt->version & 0xffff); + print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum); + print_uint(PRINT_ANY, "default", " default %u", gopt->defcls); + print_uint(PRINT_ANY, "direct_packets_stat", + " direct_packets_stat %u", gopt->direct_pkts); + if (show_details) { + sprintf(b1, "%d.%d", gopt->version >> 16, gopt->version & 0xffff); + print_string(PRINT_ANY, "ver", " ver %s", b1); + } } if (tb[TCA_HTB_DIRECT_QLEN] && RTA_PAYLOAD(tb[TCA_HTB_DIRECT_QLEN]) >= sizeof(__u32)) { __u32 direct_qlen = rta_getattr_u32(tb[TCA_HTB_DIRECT_QLEN]); - fprintf(f, " direct_qlen %u", direct_qlen); + print_uint(PRINT_ANY, "direct_qlen", " direct_qlen %u", + direct_qlen); } return 0; }