From patchwork Wed Dec 25 19:04:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215383 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n3bfr5U1"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFS0jnVz9sPn for ; Thu, 26 Dec 2019 06:04:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbfLYTE2 (ORCPT ); Wed, 25 Dec 2019 14:04:28 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32783 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTE2 (ORCPT ); Wed, 25 Dec 2019 14:04:28 -0500 Received: by mail-pg1-f195.google.com with SMTP id 6so11906560pgk.0 for ; Wed, 25 Dec 2019 11:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kb5qCsjYafCum84Oq6JPO5h0JkqJVlXcvm2isWnTNkE=; b=n3bfr5U1BSG2YmPUqTNw1fgmW+oYAJ54YPd0ee+moc6tCM0zreVw1XcgsCJ7g71iJ4 MNBLqZK5CvJk/S2Onaty17wjMkrt7XsHmrLdqNK/v0WRSPejiqhJOQ1l+XmjGTx1hVyZ OCMJN6NDfeEX6H2CKx6lhjpjP9urdBDHB7XlWjCtploOcrGs++9weptf8UfR58ziTVTF B6/ynCtSi7yIc5Ruc4YPz1Hr8bfITaOEQvzHSy+pVDvJr8ZJ62yFz+INRxGdyqCyXgXJ xSmPZS8P/7K2fqJ1WiRrZCFIuw6NFBKjCIvTJN1f2wZjC0bGmPIiu1Ow4+UGueUgEhOS yeMQ== 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=kb5qCsjYafCum84Oq6JPO5h0JkqJVlXcvm2isWnTNkE=; b=jZrZE7HIrGK+Eyq59r6D5O+HGDgO4SGBhql45FAXr5kI25L9ws4/pYjG0ifHhcPSDJ XLE215fZmBiScxOeQzBGfjUTXOkZwvRl799KFO+IBPWoLyk++jO5zXPA6rTIqvFKzbn+ 7gcYQ8t0ZHQ6TsYUc7PkLwusVgCKA8Y2TKb48zuWBy7GMZ2xSMvfjJeD6v2ewAxsKPNb F29tvIEHRT/sP9jHhC0/YGDpXYXboBQ8ZB/lxYD8cEUQ7kKgLZakHnJQ0CXSlyUvF+y7 pmv1mokDAm36XXQGpkCrDAPm3Hl65NNJv/U6+I7vNKB6CaSzSbqyyKNxDKrQ6nStEP4X kSCg== X-Gm-Message-State: APjAAAXMLzERnrP5o+LUU73wJc+ofL3fKLZ3Sxt9mcJTAo1Oag0ECM8C hTc7mr767gjPO7WNgksDrxumCI6da8U= X-Google-Smtp-Source: APXvYqzXc4PlLeislTfriZl0ebKSJaiCg0SNY02rSLR1WlAz+p1amvxWfEoelQ3jk2UlzieXdA9bZA== X-Received: by 2002:a62:8202:: with SMTP id w2mr45824040pfd.100.1577300667465; Wed, 25 Dec 2019 11:04:27 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:26 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 01/10] tc: cbs: add support for JSON output Date: Thu, 26 Dec 2019 00:34:09 +0530 Message-Id: <20191225190418.8806-2-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the CBS Qdisc. Signed-off-by: Leslie Monis --- tc/q_cbs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tc/q_cbs.c b/tc/q_cbs.c index 9515a1f7..13bb08e9 100644 --- a/tc/q_cbs.c +++ b/tc/q_cbs.c @@ -125,11 +125,11 @@ static int cbs_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (RTA_PAYLOAD(tb[TCA_CBS_PARMS]) < sizeof(*qopt)) return -1; - fprintf(f, "hicredit %d ", qopt->hicredit); - fprintf(f, "locredit %d ", qopt->locredit); - fprintf(f, "sendslope %d ", qopt->sendslope); - fprintf(f, "idleslope %d ", qopt->idleslope); - fprintf(f, "offload %d ", qopt->offload); + print_int(PRINT_ANY, "hicredit", "hicredit %d ", qopt->hicredit); + print_int(PRINT_ANY, "locredit", "locredit %d ", qopt->locredit); + print_int(PRINT_ANY, "sendslope", "sendslope %d ", qopt->sendslope); + print_int(PRINT_ANY, "idleslope", "idleslope %d ", qopt->idleslope); + print_int(PRINT_ANY, "offload", "offload %d ", qopt->offload); return 0; } From patchwork Wed Dec 25 19:04:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215384 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IGN8wnzz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFS4m7Fz9sR0 for ; Thu, 26 Dec 2019 06:04:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbfLYTEb (ORCPT ); Wed, 25 Dec 2019 14:04:31 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39127 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEb (ORCPT ); Wed, 25 Dec 2019 14:04:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id g6so6720495plp.6 for ; Wed, 25 Dec 2019 11:04:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T3xmfSy4nQpr7oRVpOuoPJKT1UHKpcMPxvddXK0xNo4=; b=IGN8wnzzpmYfFZqQvrdNBYN15BHqMgmPUuTilJShzXeiijD/hVsaO3pgcqEt4F7Fph PZTw4IoY/mfvyIYyEX4Y3gk6nZ5r/LV9f4DgT3BOxUDpv+HAhYV1tBA99839vZTOIR+c L8vAqH0pI6Ef8Td0Fyqr/KxTYjSC7rHQmGcR03bbGuqR4cG1swXpxH8RMW/VDqDtC5pc W2F9erOiSTvGjWGTomSiOhdHUnEcKxkGGyL/B01P+3l4MVTTqhE3ksAiOU3mrIKryBRR MtYPkHJZPME8FbHaCzHwY4/HNY61myymGN+7fT69BGiKxAAbtL/WsvV7YpjGtVEnk2kq biYQ== 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=T3xmfSy4nQpr7oRVpOuoPJKT1UHKpcMPxvddXK0xNo4=; b=b+hhD5r/HcMRaTDZvWPRzkE5Ui2PPyyiHNXHCW2Ti8GRtm3CsP9nBcNsaqny9WYsTY Uow8mh/Py7jiwXnQ+U1QMZ+/uaF+25AmZWVSC/O79/tdyFmSNVjboTxZot3IVyzRHoL4 OJFbeCwD2NYKJhyj64VLBDC/IFS5T+l1z5GfPWcjZRpRkRGIgc5FzDhWIW+Jysi6kGrk RAMmL+Ewfe/WHDwQegoLK4xIopR+n482cYrJMZjklIpTKjuBeVmI9oYZUtzhchzjDLmE P1l9W6fQUeX32CQ2dup+EqJ2zTrS/bgrYmjehKKZGSemWNGF1SJafaAShm/ZS0eqBBSg pMEQ== X-Gm-Message-State: APjAAAWMQ162ZDSp2CgvhiCBOwFK7NIZv7BfcMlVRFd8W24MTLpA/3lN NorufoF/cLp/vRkjlAX6BhG+OHkzSNc= X-Google-Smtp-Source: APXvYqxZKG5DHeWP/oC19TlyY8K13iXOqh4fzc1bwiWNuLrARlkjR3dJSvMJD2sPdvsgtoeyDDDqHA== X-Received: by 2002:a17:902:d204:: with SMTP id t4mr43234831ply.167.1577300670214; Wed, 25 Dec 2019 11:04:30 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:29 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 02/10] tc: choke: add support for JSON output Date: Thu, 26 Dec 2019 00:34:10 +0530 Message-Id: <20191225190418.8806-3-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the choke Qdisc. Also, use the long double format specifier to print the value of "probability". Signed-off-by: Leslie Monis --- tc/q_choke.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tc/q_choke.c b/tc/q_choke.c index 648d9ad7..570c3599 100644 --- a/tc/q_choke.c +++ b/tc/q_choke.c @@ -186,18 +186,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); tc_red_print_flags(qopt->flags); 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 %lg ", 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 +219,13 @@ 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; } From patchwork Wed Dec 25 19:04:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215385 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="H9r8Uom+"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFT1NQ8z9sPJ for ; Thu, 26 Dec 2019 06:04:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726899AbfLYTEf (ORCPT ); Wed, 25 Dec 2019 14:04:35 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:50663 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEe (ORCPT ); Wed, 25 Dec 2019 14:04:34 -0500 Received: by mail-pj1-f66.google.com with SMTP id r67so2498405pjb.0 for ; Wed, 25 Dec 2019 11:04:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mvo41UBGA7AjiMNPhpLLI3n0hzH/aO2pyn+RBJk+AjQ=; b=H9r8Uom+AmQanBrAW5cUNZOqdSRmu9sWXEcOSYBg/Pla1gByWYTRa2lp+FdyyehAvw CftdHSJcUMVn2pb9oSdO2AoMzG4SRiSxXYbE3v9ShW5g9LtWibUzwSkrwgtQqYSJuCx1 lj/w5hIeg3XR0RdRt15qhqMItD8Nu5tYLp+yl4j7Qfi5xU6AsiU01nlu7EU7WzhYdH3n jSBaeVMv7qbLy7peRrep04WWJj6f834IGIRL63Nv0n2Q+qDAw+6XJIL6Mpo63TfEUQe9 9mMDIfwMg26vWVoVULKZs0kRnAouXbKx3bMfcS/0iuZHOoFGarcUltIOWuwRDeC1H9Jk FPwg== 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=Mvo41UBGA7AjiMNPhpLLI3n0hzH/aO2pyn+RBJk+AjQ=; b=H6gu6NL/n+8QbOftLGxHg84BOxO753H8kdFP9NZfClnzkHTCeH3BD57InrosTUaUbv 8EJjr1lTvQUXvxcFAyJFRRHecUMisyPo0CHY4jTuwfx807JDLM3yja8qSyU7TaiXH/W1 Z3lKZMpeDue7Xpx2AqcuFmfeAgemnjmz6bnLR1D1wtTLCg5AOGZZBhK1IqrSnrNpFKJW s2pFpFlAvR2xr2vvn4Q0mdaQJnIGdwl2QSfWmEeku9RXfScG5ODcPYYrycv+SYrilz5R lVDrPYOCjsxsV+v7IpyhHzH1G1zSOydBGA7uxL58KoAN2NR+/SZi/zmdsIgT88ObEC0X +XHQ== X-Gm-Message-State: APjAAAVy1nDCg8ZJthrtprshWBMD6Sb7egh2QQIXUHlBUxB3PVlLTGRG GMvwZcNgn+gQHKML3ItQZE0NbhwTjBA= X-Google-Smtp-Source: APXvYqw+4qC/y408/du2UalhoUX0g2ib1gYiQSNLBPEcBnrhtCOWSsUPUy1t2kBLHMmaafKUHQ8Ezw== X-Received: by 2002:a17:90a:c385:: with SMTP id h5mr14379718pjt.122.1577300673298; Wed, 25 Dec 2019 11:04:33 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:32 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 03/10] tc: codel: add support for JSON output Date: Thu, 26 Dec 2019 00:34:11 +0530 Message-Id: <20191225190418.8806-4-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the CoDel Qdisc. Signed-off-by: Leslie Monis --- tc/q_codel.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/tc/q_codel.c b/tc/q_codel.c index 849cc040..c72a5779 100644 --- a/tc/q_codel.c +++ b/tc/q_codel.c @@ -144,28 +144,34 @@ static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (tb[TCA_CODEL_LIMIT] && RTA_PAYLOAD(tb[TCA_CODEL_LIMIT]) >= sizeof(__u32)) { limit = rta_getattr_u32(tb[TCA_CODEL_LIMIT]); - fprintf(f, "limit %up ", limit); + print_uint(PRINT_ANY, "limit", "limit %up ", limit); } if (tb[TCA_CODEL_TARGET] && RTA_PAYLOAD(tb[TCA_CODEL_TARGET]) >= sizeof(__u32)) { target = rta_getattr_u32(tb[TCA_CODEL_TARGET]); - fprintf(f, "target %s ", sprint_time(target, b1)); + print_uint(PRINT_JSON, "target", NULL, target); + print_string(PRINT_FP, NULL, "target %s ", + sprint_time(target, b1)); } if (tb[TCA_CODEL_CE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_CODEL_CE_THRESHOLD]) >= sizeof(__u32)) { ce_threshold = rta_getattr_u32(tb[TCA_CODEL_CE_THRESHOLD]); - fprintf(f, "ce_threshold %s ", sprint_time(ce_threshold, b1)); + print_uint(PRINT_JSON, "ce_threshold", NULL, ce_threshold); + print_string(PRINT_FP, NULL, "ce_threshold %s ", + sprint_time(ce_threshold, b1)); } if (tb[TCA_CODEL_INTERVAL] && RTA_PAYLOAD(tb[TCA_CODEL_INTERVAL]) >= sizeof(__u32)) { interval = rta_getattr_u32(tb[TCA_CODEL_INTERVAL]); - fprintf(f, "interval %s ", sprint_time(interval, b1)); + print_uint(PRINT_JSON, "interval", NULL, interval); + print_string(PRINT_FP, NULL, "interval %s ", + sprint_time(interval, b1)); } if (tb[TCA_CODEL_ECN] && RTA_PAYLOAD(tb[TCA_CODEL_ECN]) >= sizeof(__u32)) { ecn = rta_getattr_u32(tb[TCA_CODEL_ECN]); if (ecn) - fprintf(f, "ecn "); + print_bool(PRINT_ANY, "ecn", "ecn ", true); } return 0; @@ -187,18 +193,31 @@ static int codel_print_xstats(struct qdisc_util *qu, FILE *f, st = &_st; } - fprintf(f, " count %u lastcount %u ldelay %s", - st->count, st->lastcount, sprint_time(st->ldelay, b1)); + print_uint(PRINT_ANY, "count", " count %u", st->count); + print_uint(PRINT_ANY, "lastcount", " lastcount %u", st->lastcount); + print_uint(PRINT_JSON, "ldelay", NULL, st->ldelay); + print_string(PRINT_FP, NULL, " ldelay %s", sprint_time(st->ldelay, b1)); + if (st->dropping) - fprintf(f, " dropping"); + print_bool(PRINT_ANY, "dropping", " dropping", true); + + print_int(PRINT_JSON, "drop_next", NULL, st->drop_next); if (st->drop_next < 0) - fprintf(f, " drop_next -%s", sprint_time(-st->drop_next, b1)); + print_string(PRINT_FP, NULL, " drop_next -%s", + sprint_time(-st->drop_next, b1)); else - fprintf(f, " drop_next %s", sprint_time(st->drop_next, b1)); - fprintf(f, "\n maxpacket %u ecn_mark %u drop_overlimit %u", - st->maxpacket, st->ecn_mark, st->drop_overlimit); + print_string(PRINT_FP, NULL, " drop_next %s", + sprint_time(st->drop_next, b1)); + + print_nl(); + print_uint(PRINT_ANY, "maxpacket", " maxpacket %u", st->maxpacket); + print_uint(PRINT_ANY, "ecn_mark", " ecn_mark %u", st->ecn_mark); + print_uint(PRINT_ANY, "drop_overlimit", " drop_overlimit %u", + st->drop_overlimit); + if (st->ce_mark) - fprintf(f, " ce_mark %u", st->ce_mark); + print_uint(PRINT_ANY, "ce_mark", " ce_mark %u", st->ce_mark); + return 0; } From patchwork Wed Dec 25 19:04:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215386 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hOnSdPGh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFT4tQ0z9sPn for ; Thu, 26 Dec 2019 06:04:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbfLYTEi (ORCPT ); Wed, 25 Dec 2019 14:04:38 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37007 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEi (ORCPT ); Wed, 25 Dec 2019 14:04:38 -0500 Received: by mail-pg1-f193.google.com with SMTP id q127so11905508pga.4 for ; Wed, 25 Dec 2019 11:04:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J7CQlcXpOUjeb/5cC8Zez9CmZ6l4f1wFJfw0kZ5ngE4=; b=hOnSdPGhahgH0Bm8SJeM3zJJqK6X4rHMH7Q2CRT8d6Nf0+f72zjqm2HMFRG39gzlo4 DmEU6B2O8F0WT3feQj3MZRNdmTjBuu0zGUtew1TvfBk9+BEnSrPWk//IHUmY2lUcsOMa vXrX5JY1GEbksgIypaOqgI2HbN96PucSju7ajgBiYFANX8BeOAISPfkoY6ze5jcqVzfQ 8tQpeWq0AvqtvgkEXuhSUYKIFH+72+f4jsRf8DXlUm3m05yP9a087vLZwMyQFvu5bBPM S9B2D4M7SPIU5AzCBhgEW5TnZcktuQJUnoHQWFDArekWmlxqgHcPPMx+JVF+bvyusAz8 0L1A== 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=J7CQlcXpOUjeb/5cC8Zez9CmZ6l4f1wFJfw0kZ5ngE4=; b=TKJDtqj7jUG8bp9yQd9E25v0z++YHKMsDXwkQXOvSmbJY1+ydPaLs2e5+s5l2IHi4e rFTgxz/zE5zxfg0fuwhKMGFGzizIh7u2eghdPd+3tCBd5vF5gIT5tu0qQ4NRD2d5Lp6E CT1IW1iC30nwIq8NJwU8y4TbsFajsevnAIjLZKY/xyyp28xXIuZLJ+76aQ0WBBAeepg4 0KTQ3kYAXf7OamrgsEKFchITJ2C1WUoUKDu+ZZBM8U0o8G+2D7T6L+H6akEZurCMORzA gIEAMCgb6eI7aCOhrjzezCFczHrIQXDnQ6ouC+82EaGGx9Dwulnl+dea7g7ib8TZ2UKJ agyQ== X-Gm-Message-State: APjAAAV4FH9pwY7TL2T064li/J1L86W8IMl/IXZkOYTJDdeZu83YxgdK TtKvvdemog+hcr/0Pc/69n6a7jZQ+KE= X-Google-Smtp-Source: APXvYqwFu3B4T7d0/Ij+yjmzL6DG63srm1G0wHDfOhbABqpprA75Q2M534VeVm+eKHoiUhrqgUJXjA== X-Received: by 2002:a63:7d8:: with SMTP id 207mr44700372pgh.154.1577300676426; Wed, 25 Dec 2019 11:04:36 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:35 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger , Eric Dumazet Subject: [PATCH iproute2-next 04/10] tc: fq: add support for JSON output Date: Thu, 26 Dec 2019 00:34:12 +0530 Message-Id: <20191225190418.8806-5-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the FQ Qdisc. Use the "KEY VALUE" format for oneline output of statistics instead of "VALUE KEY", and remove unnecessary commas from the output. Use sprint_size() to print size values in fq_print_opt(). Use sprint_time64() to print time values in fq_print_xstats(). Also, update the man page to reflect the changes in the output format. Cc: Eric Dumazet Signed-off-by: Leslie Monis --- man/man8/tc-fq.8 | 14 +++--- tc/q_fq.c | 108 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 83 insertions(+), 39 deletions(-) diff --git a/man/man8/tc-fq.8 b/man/man8/tc-fq.8 index 1febe62b..27385aae 100644 --- a/man/man8/tc-fq.8 +++ b/man/man8/tc-fq.8 @@ -90,15 +90,15 @@ Experienced. This is useful for DCTCP-style congestion control algorithms that require marking at very shallow queueing thresholds. .SH EXAMPLES -#tc qdisc add dev eth0 root est 1sec 4sec fq ce_threshold 4ms +#tc qdisc add dev eth0 root fq ce_threshold 4ms .br -#tc -s -d qdisc sh dev eth0 +#tc -s -d qdisc show dev eth0 .br -qdisc fq 800e: root refcnt 9 limit 10000p flow_limit 1000p buckets 1024 orphan_mask 1023 quantum 3028 initial_quantum 15140 low_rate_threshold 550Kbit refill_delay 40.0ms ce_threshold 4.0ms - Sent 533368436185 bytes 352296695 pkt (dropped 0, overlimits 0 requeues 1339864) - rate 39220Mbit 3238202pps backlog 12417828b 358p requeues 1339864 - 1052 flows (852 inactive, 0 throttled) - 112 gc, 0 highprio, 212 throttled, 21501 ns latency, 470241 ce_mark +qdisc fq 8001: dev eth0 root refcnt 2 limit 10000p flow_limit 100p buckets 1024 orphan_mask 1023 quantum 3028b initial_quantum 15140b low_rate_threshold 550Kbit refill_delay 40.0ms ce_threshold 4.0ms + Sent 72149092 bytes 48062 pkt (dropped 2176, overlimits 0 requeues 0) + backlog 1937920b 1280p requeues 0 + flows 34 (inactive 17 throttled 0) + gc 0 highprio 0 throttled 0 ce_mark 47622 flows_plimit 2176 .br .SH SEE ALSO .BR tc (8), diff --git a/tc/q_fq.c b/tc/q_fq.c index caf232ec..44d8a7e0 100644 --- a/tc/q_fq.c +++ b/tc/q_fq.c @@ -265,71 +265,94 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (tb[TCA_FQ_PLIMIT] && RTA_PAYLOAD(tb[TCA_FQ_PLIMIT]) >= sizeof(__u32)) { plimit = rta_getattr_u32(tb[TCA_FQ_PLIMIT]); - fprintf(f, "limit %up ", plimit); + print_uint(PRINT_ANY, "limit", "limit %up ", plimit); } if (tb[TCA_FQ_FLOW_PLIMIT] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_PLIMIT]) >= sizeof(__u32)) { flow_plimit = rta_getattr_u32(tb[TCA_FQ_FLOW_PLIMIT]); - fprintf(f, "flow_limit %up ", flow_plimit); + print_uint(PRINT_ANY, "flow_limit", "flow_limit %up ", + flow_plimit); } if (tb[TCA_FQ_BUCKETS_LOG] && RTA_PAYLOAD(tb[TCA_FQ_BUCKETS_LOG]) >= sizeof(__u32)) { buckets_log = rta_getattr_u32(tb[TCA_FQ_BUCKETS_LOG]); - fprintf(f, "buckets %u ", 1U << buckets_log); + print_uint(PRINT_ANY, "buckets", "buckets %u ", + 1U << buckets_log); } if (tb[TCA_FQ_ORPHAN_MASK] && RTA_PAYLOAD(tb[TCA_FQ_ORPHAN_MASK]) >= sizeof(__u32)) { orphan_mask = rta_getattr_u32(tb[TCA_FQ_ORPHAN_MASK]); - fprintf(f, "orphan_mask %u ", orphan_mask); + print_uint(PRINT_ANY, "orphan_mask", "orphan_mask %u ", + orphan_mask); } if (tb[TCA_FQ_RATE_ENABLE] && RTA_PAYLOAD(tb[TCA_FQ_RATE_ENABLE]) >= sizeof(int)) { pacing = rta_getattr_u32(tb[TCA_FQ_RATE_ENABLE]); if (pacing == 0) - fprintf(f, "nopacing "); + print_bool(PRINT_ANY, "pacing", "nopacing ", false); } if (tb[TCA_FQ_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_QUANTUM]); - fprintf(f, "quantum %u ", quantum); + print_uint(PRINT_JSON, "quantum", NULL, quantum); + print_string(PRINT_FP, NULL, "quantum %s ", + sprint_size(quantum, b1)); } if (tb[TCA_FQ_INITIAL_QUANTUM] && RTA_PAYLOAD(tb[TCA_FQ_INITIAL_QUANTUM]) >= sizeof(__u32)) { quantum = rta_getattr_u32(tb[TCA_FQ_INITIAL_QUANTUM]); - fprintf(f, "initial_quantum %u ", quantum); + print_uint(PRINT_JSON, "initial_quantum", NULL, quantum); + print_string(PRINT_FP, NULL, "initial_quantum %s ", + sprint_size(quantum, b1)); } if (tb[TCA_FQ_FLOW_MAX_RATE] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_MAX_RATE]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_FLOW_MAX_RATE]); - if (rate != ~0U) - fprintf(f, "maxrate %s ", sprint_rate(rate, b1)); + if (rate != ~0U) { + print_uint(PRINT_JSON, "maxrate", NULL, rate); + print_string(PRINT_FP, NULL, "maxrate %s ", + sprint_rate(rate, b1)); + } } if (tb[TCA_FQ_FLOW_DEFAULT_RATE] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_DEFAULT_RATE]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_FLOW_DEFAULT_RATE]); - if (rate != 0) - fprintf(f, "defrate %s ", sprint_rate(rate, b1)); + if (rate != 0) { + print_uint(PRINT_JSON, "defrate", NULL, rate); + print_string(PRINT_FP, NULL, "defrate %s ", + sprint_rate(rate, b1)); + } } if (tb[TCA_FQ_LOW_RATE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_FQ_LOW_RATE_THRESHOLD]) >= sizeof(__u32)) { rate = rta_getattr_u32(tb[TCA_FQ_LOW_RATE_THRESHOLD]); - if (rate != 0) - fprintf(f, "low_rate_threshold %s ", sprint_rate(rate, b1)); + if (rate != 0) { + print_uint(PRINT_JSON, "low_rate_threshold", NULL, + rate); + print_string(PRINT_FP, NULL, "low_rate_threshold %s ", + sprint_rate(rate, b1)); + } } if (tb[TCA_FQ_FLOW_REFILL_DELAY] && RTA_PAYLOAD(tb[TCA_FQ_FLOW_REFILL_DELAY]) >= sizeof(__u32)) { refill_delay = rta_getattr_u32(tb[TCA_FQ_FLOW_REFILL_DELAY]); - fprintf(f, "refill_delay %s ", sprint_time(refill_delay, b1)); + print_uint(PRINT_JSON, "refill_delay", NULL, refill_delay); + print_string(PRINT_FP, NULL, "refill_delay %s ", + sprint_time(refill_delay, b1)); } if (tb[TCA_FQ_CE_THRESHOLD] && RTA_PAYLOAD(tb[TCA_FQ_CE_THRESHOLD]) >= sizeof(__u32)) { ce_threshold = rta_getattr_u32(tb[TCA_FQ_CE_THRESHOLD]); - if (ce_threshold != ~0U) - fprintf(f, "ce_threshold %s ", sprint_time(ce_threshold, b1)); + if (ce_threshold != ~0U) { + print_uint(PRINT_JSON, "ce_threshold", NULL, + ce_threshold); + print_string(PRINT_FP, NULL, "ce_threshold %s ", + sprint_time(ce_threshold, b1)); + } } return 0; @@ -340,6 +363,8 @@ static int fq_print_xstats(struct qdisc_util *qu, FILE *f, { struct tc_fq_qd_stats *st, _st; + SPRINT_BUF(b1); + if (xstats == NULL) return 0; @@ -348,32 +373,51 @@ static int fq_print_xstats(struct qdisc_util *qu, FILE *f, st = &_st; - fprintf(f, " %u flows (%u inactive, %u throttled)", - st->flows, st->inactive_flows, st->throttled_flows); + print_uint(PRINT_ANY, "flows", " flows %u", st->flows); + print_uint(PRINT_ANY, "inactive", " (inactive %u", st->inactive_flows); + print_uint(PRINT_ANY, "throttled", " throttled %u)", + st->throttled_flows); - if (st->time_next_delayed_flow > 0) - fprintf(f, ", next packet delay %llu ns", st->time_next_delayed_flow); + if (st->time_next_delayed_flow > 0) { + print_lluint(PRINT_JSON, "next_packet_delay", NULL, + st->time_next_delayed_flow); + print_string(PRINT_FP, NULL, " next_packet_delay %s", + sprint_time64(st->time_next_delayed_flow, b1)); + } - fprintf(f, "\n %llu gc, %llu highprio", - st->gc_flows, st->highprio_packets); + print_nl(); + print_lluint(PRINT_ANY, "gc", " gc %llu", st->gc_flows); + print_lluint(PRINT_ANY, "highprio", " highprio %llu", + st->highprio_packets); if (st->tcp_retrans) - fprintf(f, ", %llu retrans", st->tcp_retrans); + print_lluint(PRINT_ANY, "retrans", " retrans %llu", + st->tcp_retrans); - fprintf(f, ", %llu throttled", st->throttled); + print_lluint(PRINT_ANY, "throttled", " throttled %llu", st->throttled); - if (st->unthrottle_latency_ns) - fprintf(f, ", %u ns latency", st->unthrottle_latency_ns); + if (st->unthrottle_latency_ns) { + print_uint(PRINT_JSON, "latency", NULL, + st->unthrottle_latency_ns); + print_string(PRINT_FP, NULL, " latency %s", + sprint_time64(st->unthrottle_latency_ns, b1)); + } if (st->ce_mark) - fprintf(f, ", %llu ce_mark", st->ce_mark); + print_lluint(PRINT_ANY, "ce_mark", " ce_mark %llu", + st->ce_mark); if (st->flows_plimit) - fprintf(f, ", %llu flows_plimit", st->flows_plimit); - - if (st->pkts_too_long || st->allocation_errors) - fprintf(f, "\n %llu too long pkts, %llu alloc errors\n", - st->pkts_too_long, st->allocation_errors); + print_lluint(PRINT_ANY, "flows_plimit", " flows_plimit %llu", + st->flows_plimit); + + if (st->pkts_too_long || st->allocation_errors) { + print_nl(); + print_lluint(PRINT_ANY, "pkts_too_long", + " pkts_too_long %llu", st->pkts_too_long); + print_lluint(PRINT_ANY, "alloc_errors", " alloc_erros %llu", + st->allocation_errors); + } return 0; } From patchwork Wed Dec 25 19:04:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215387 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="szGST0eA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFV1hc9z9sR0 for ; Thu, 26 Dec 2019 06:04:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbfLYTEl (ORCPT ); Wed, 25 Dec 2019 14:04:41 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36440 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEk (ORCPT ); Wed, 25 Dec 2019 14:04:40 -0500 Received: by mail-pl1-f194.google.com with SMTP id a6so8937657plm.3 for ; Wed, 25 Dec 2019 11:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aTQv0dZQzf9wyCSPINQULSMpdY5/6Oq+U/PQTbi9hZE=; b=szGST0eA9jGzEKxF3hM8aBzIng3jwwgnfPwBOf3PUeC5mR+xj0g0ixMWIukrrlpfO1 V/2sOr9mHX0l/kIavqNoGNXWXIqpYKNc+t+qA09Filp81dpKf3bBy1AgUFYkTut8KvT8 fPKtHJ0JbIrJSGuAjmgR3Mr/zjPRY1LNfjI/ui6Z7gA4SLESHYjwVCXw1bcwE6KqrD51 bPzHR+yAsJwlA4IPvHl+4g4J7+QAqIS5+m7RzUQBM8ZkCtB35CcegYFhow56j4kPNcwn D7kYCe649ziNzp12y68fdvwOFfbHqYKwo8xQX+m+Q2W8nl0vLStW6t6pakBe1tQF7JL6 oq2A== 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=aTQv0dZQzf9wyCSPINQULSMpdY5/6Oq+U/PQTbi9hZE=; b=RqWL3syYEjPig0DxcI38Ihy9sN/pgSHMKyTKsuX2m2oelPesyvtUT2gHOhUYxtMz4u 7fb0+s4XJj2+dxe2CBro7fi/3ErUbf+gEJlxOYMuEGTXWMX1nBJ3dJ+IWlj4j/zOR5Qs q6gbeKOa2A9kKisdXtDUsCFlUwYLjCzisIWgPyOtnBxTVvi7Ki3W8gEPbqjwMvwHZu9q GHSEnzarJ3SrkdY6kYrmjmWIxtXrmdAzGKecELvW/aa6ZgMAeyvHqamqoxKg7mOR/sfv iRSnuobn6jvbG90CcFtsB2PjVcTe5A7ESL0z/OSR0nAXHeafSrou0IvwIK2vYhehtqYH OcKg== X-Gm-Message-State: APjAAAVT/TC8eXfTmeLHY9aoV9/VB11tlDtGM53L5StmV3gLLmYbcsCn K9SJ99vUY0i/W1vH9g86huiOLBGh9KQ= X-Google-Smtp-Source: APXvYqyPNjdZd9Gq3CyA4sSNuIVVnhzaocd90Dx7RGqS38CT91AqQXpOrQLi+FBu2vrWO5kV+dM2GA== X-Received: by 2002:a17:902:9b84:: with SMTP id y4mr40907707plp.13.1577300679461; Wed, 25 Dec 2019 11:04:39 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:38 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 05/10] tc: hhf: add support for JSON output Date: Thu, 26 Dec 2019 00:34:13 +0530 Message-Id: <20191225190418.8806-6-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the HHF Qdisc. Also, use sprint_size() to print size values. Signed-off-by: Leslie Monis --- tc/q_hhf.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/tc/q_hhf.c b/tc/q_hhf.c index 5ee6642f..f8888011 100644 --- a/tc/q_hhf.c +++ b/tc/q_hhf.c @@ -138,37 +138,46 @@ 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_JSON, "quantum", NULL, quantum); + print_string(PRINT_FP, NULL, "quantum %s ", + sprint_size(quantum, b1)); } 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_uint(PRINT_JSON, "reset_timeout", NULL, reset_timeout); + print_string(PRINT_FP, NULL, "reset_timeout %s ", + sprint_time(reset_timeout, b1)); } 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_JSON, "admit_bytes", NULL, admit_bytes); + print_string(PRINT_FP, NULL, "admit_bytes %s ", + sprint_size(admit_bytes, b1)); } 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_uint(PRINT_JSON, "evict_timeout", NULL, evict_timeout); + print_string(PRINT_FP, NULL, "evict_timeout %s ", + sprint_time(evict_timeout, b1)); } 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; } @@ -186,9 +195,13 @@ 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_hh", " tot_hh %u", st->hh_tot_count); + print_uint(PRINT_ANY, "cur_hh", " cur_hh %u", st->hh_cur_count); + return 0; } From patchwork Wed Dec 25 19:04:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215388 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gHCkwimq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFV4ZrXz9sPJ for ; Thu, 26 Dec 2019 06:04:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbfLYTEo (ORCPT ); Wed, 25 Dec 2019 14:04:44 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37761 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEn (ORCPT ); Wed, 25 Dec 2019 14:04:43 -0500 Received: by mail-pl1-f193.google.com with SMTP id c23so9671105plz.4 for ; Wed, 25 Dec 2019 11:04:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CPrWCJ0Wg1MOU5b+rweHaFZhX0i6NpV2QOswsjpE9I0=; b=gHCkwimqAabukCpNyJGtrtCoRTc3moyGvuWlaffTINCIxv74NXDa3B8sp0+4Xox9x+ bYr234ET3gelE5kcWQHBmbvpYvcLdpjMnYfO0QSXZ/qTq3CwVelLay1LirnW5jvef2dQ Fq+mWsx7FdBEIDHbo/PhUj2iOqUR4pgVxQkcoHmhu9JXzN2NZPE8RVCZJH8r7qFnKmJB o1So+j87FOrxAqNuvg0mLmeSc/LR1c7zfdHvecz+cQ7D5xCJL+dt9LYO4qrWm1fBeaG8 3hXC4gfS96vWLDvTFc6YW6tvLsBL5DI8Hgl5eqPY6pRGOLo6Mzwy83p+srsQkrGRpi+D bAnQ== 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=CPrWCJ0Wg1MOU5b+rweHaFZhX0i6NpV2QOswsjpE9I0=; b=Ye/LyS+hgZkNsTMtTHsz7DWa3Uy9Xn6/ht7n9lsdyKGB45zwLx9kHzth6CH8aVGq2u bTPF8uYBd5HPUObzp0Da5Wm2NfUnxyte0Bugx+EGXY8BUiFYOTTGN5NxZjEFvf6SG2/8 cNiZpw1csFAARz5qZU+/iNXmfXTaXpKQSYJ6HXu+M+fxnVIARpHxfQYu+px6ZAr3u4Qm Uxz1d/moU+4HIb4uCRaMdw2gXGeORei9z9RQFQ0YLoUpUW+03Gzm8oMqSJSWoX/2QUnl UiUvEnA1RV7TagJDOgUGP0qClq3d62nX5vLn9YmBS5h1kWovmWap2s7ePVh3NgxrjU87 eZTQ== X-Gm-Message-State: APjAAAXEq39sZq8MYf1I/Q7jlLfFVcaYn7dCsT+wH7WSRVxbLfVHU07D Q7Mab1E2j4QR4KBeVIVNcXoUCxV65DU= X-Google-Smtp-Source: APXvYqwrz448MkQhv3bPiUwsNrH+kWXZcenwkxFDDb3NdfNg8LVWCMbb62Zx/H1afuF+SAUbFpe9DQ== X-Received: by 2002:a17:902:d915:: with SMTP id c21mr42561362plz.295.1577300682499; Wed, 25 Dec 2019 11:04:42 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:41 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 06/10] tc: pie: add support for JSON output Date: Thu, 26 Dec 2019 00:34:14 +0530 Message-Id: <20191225190418.8806-7-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the PIE Qdisc. Use sprint_time() to print the value of tc_pie_xstats->delay. Use the long double format specifier to print tc_pie_xstats->prob. Also, fix the indentation in the oneline output of statistics and update the man page to reflect this change. Signed-off-by: Leslie Monis --- man/man8/tc-pie.8 | 16 ++++++++-------- tc/q_pie.c | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/man/man8/tc-pie.8 b/man/man8/tc-pie.8 index bdcfba51..0db97d13 100644 --- a/man/man8/tc-pie.8 +++ b/man/man8/tc-pie.8 @@ -107,32 +107,32 @@ is turned off. qdisc pie 8036: dev eth0 root refcnt 2 limit 1000p target 15.0ms tupdate 16.0ms alpha 2 beta 20 Sent 31216108 bytes 20800 pkt (dropped 80, overlimits 0 requeues 0) backlog 16654b 11p requeues 0 - prob 0.006161 delay 15666us - pkts_in 20811 overlimit 0 dropped 80 maxq 50 ecn_mark 0 + prob 0.006161 delay 15666us + pkts_in 20811 overlimit 0 dropped 80 maxq 50 ecn_mark 0 # tc qdisc add dev eth0 root pie dq_rate_estimator # tc -s qdisc show qdisc pie 8036: dev eth0 root refcnt 2 limit 1000p target 15.0ms tupdate 16.0ms alpha 2 beta 20 Sent 63947420 bytes 42414 pkt (dropped 41, overlimits 0 requeues 0) backlog 271006b 179p requeues 0 - prob 0.000092 delay 22200us avg_dq_rate 12145996 - pkts_in 41 overlimit 343 dropped 0 maxq 50 ecn_mark 0 + prob 0.000092 delay 22200us avg_dq_rate 12145996 + pkts_in 41 overlimit 343 dropped 0 maxq 50 ecn_mark 0 # tc qdisc add dev eth0 root pie limit 100 target 20ms tupdate 30ms ecn # tc -s qdisc show qdisc pie 8036: dev eth0 root refcnt 2 limit 100p target 20.0ms tupdate 32.0ms alpha 2 beta 20 ecn Sent 6591724 bytes 4442 pkt (dropped 27, overlimits 0 requeues 0) backlog 18168b 12p requeues 0 - prob 0.008845 delay 11348us - pkts_in 4454 overlimit 0 dropped 27 maxq 65 ecn_mark 0 + prob 0.008845 delay 11348us + pkts_in 4454 overlimit 0 dropped 27 maxq 65 ecn_mark 0 # tc qdisc add dev eth0 root pie limit 100 target 50ms tupdate 30ms bytemode # tc -s qdisc show qdisc pie 8036: dev eth0 root refcnt 2 limit 100p target 50.0ms tupdate 32.0ms alpha 2 beta 20 bytemode Sent 1616274 bytes 1137 pkt (dropped 0, overlimits 0 requeues 0) backlog 13626b 9p requeues 0 - prob 0.000000 delay 0us - pkts_in 1146 overlimit 0 dropped 0 maxq 23 ecn_mark 0 + prob 0.000000 delay 0us + pkts_in 1146 overlimit 0 dropped 0 maxq 23 ecn_mark 0 .SH SEE ALSO .BR tc (8), diff --git a/tc/q_pie.c b/tc/q_pie.c index fda98a71..709a78b4 100644 --- a/tc/q_pie.c +++ b/tc/q_pie.c @@ -156,40 +156,44 @@ static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (tb[TCA_PIE_LIMIT] && RTA_PAYLOAD(tb[TCA_PIE_LIMIT]) >= sizeof(__u32)) { limit = rta_getattr_u32(tb[TCA_PIE_LIMIT]); - fprintf(f, "limit %up ", limit); + print_uint(PRINT_ANY, "limit", "limit %up ", limit); } if (tb[TCA_PIE_TARGET] && RTA_PAYLOAD(tb[TCA_PIE_TARGET]) >= sizeof(__u32)) { target = rta_getattr_u32(tb[TCA_PIE_TARGET]); - fprintf(f, "target %s ", sprint_time(target, b1)); + print_uint(PRINT_JSON, "target", NULL, target); + print_string(PRINT_FP, NULL, "target %s ", + sprint_time(target, b1)); } if (tb[TCA_PIE_TUPDATE] && RTA_PAYLOAD(tb[TCA_PIE_TUPDATE]) >= sizeof(__u32)) { tupdate = rta_getattr_u32(tb[TCA_PIE_TUPDATE]); - fprintf(f, "tupdate %s ", sprint_time(tupdate, b1)); + print_uint(PRINT_JSON, "tupdate", NULL, tupdate); + print_string(PRINT_FP, NULL, "tupdate %s ", + sprint_time(tupdate, b1)); } if (tb[TCA_PIE_ALPHA] && RTA_PAYLOAD(tb[TCA_PIE_ALPHA]) >= sizeof(__u32)) { alpha = rta_getattr_u32(tb[TCA_PIE_ALPHA]); - fprintf(f, "alpha %u ", alpha); + print_uint(PRINT_ANY, "alpha", "alpha %u ", alpha); } if (tb[TCA_PIE_BETA] && RTA_PAYLOAD(tb[TCA_PIE_BETA]) >= sizeof(__u32)) { beta = rta_getattr_u32(tb[TCA_PIE_BETA]); - fprintf(f, "beta %u ", beta); + print_uint(PRINT_ANY, "beta", "beta %u ", beta); } if (tb[TCA_PIE_ECN] && RTA_PAYLOAD(tb[TCA_PIE_ECN]) >= sizeof(__u32)) { ecn = rta_getattr_u32(tb[TCA_PIE_ECN]); if (ecn) - fprintf(f, "ecn "); + print_bool(PRINT_ANY, "ecn", "ecn ", true); } if (tb[TCA_PIE_BYTEMODE] && RTA_PAYLOAD(tb[TCA_PIE_BYTEMODE]) >= sizeof(__u32)) { bytemode = rta_getattr_u32(tb[TCA_PIE_BYTEMODE]); if (bytemode) - fprintf(f, "bytemode "); + print_bool(PRINT_ANY, "bytemode", "bytemode ", true); } if (tb[TCA_PIE_DQ_RATE_ESTIMATOR] && @@ -197,7 +201,8 @@ static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) dq_rate_estimator = rta_getattr_u32(tb[TCA_PIE_DQ_RATE_ESTIMATOR]); if (dq_rate_estimator) - fprintf(f, "dq_rate_estimator "); + print_bool(PRINT_ANY, "dq_rate_estimator", + "dq_rate_estimator ", true); } return 0; @@ -208,6 +213,8 @@ static int pie_print_xstats(struct qdisc_util *qu, FILE *f, { struct tc_pie_xstats *st; + SPRINT_BUF(b1); + if (xstats == NULL) return 0; @@ -215,18 +222,24 @@ static int pie_print_xstats(struct qdisc_util *qu, FILE *f, return -1; st = RTA_DATA(xstats); - /*prob is returned as a fracion of maximum integer value */ - fprintf(f, "prob %f delay %uus", - (double)st->prob / (double)UINT64_MAX, st->delay); + + /* prob is returned as a fracion of maximum integer value */ + print_float(PRINT_ANY, "prob", " prob %lg", + (double)st->prob / (double)UINT64_MAX); + print_uint(PRINT_JSON, "delay", NULL, st->delay); + print_string(PRINT_FP, NULL, " delay %s", sprint_time(st->delay, b1)); if (st->dq_rate_estimating) - fprintf(f, " avg_dq_rate %u\n", st->avg_dq_rate); - else - fprintf(f, "\n"); + print_uint(PRINT_ANY, "avg_dq_rate", " avg_dq_rate %u", + st->avg_dq_rate); + + print_nl(); + print_uint(PRINT_ANY, "pkts_in", " pkts_in %u", st->packets_in); + print_uint(PRINT_ANY, "overlimit", " overlimit %u", st->overlimit); + print_uint(PRINT_ANY, "dropped", " dropped %u", st->dropped); + print_uint(PRINT_ANY, "maxq", " maxq %u", st->maxq); + print_uint(PRINT_ANY, "ecn_mark", " ecn_mark %u", st->ecn_mark); - fprintf(f, "pkts_in %u overlimit %u dropped %u maxq %u ecn_mark %u\n", - st->packets_in, st->overlimit, st->dropped, st->maxq, - st->ecn_mark); return 0; } From patchwork Wed Dec 25 19:04:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215389 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l+0u5tYQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFY0gWtz9sPJ for ; Thu, 26 Dec 2019 06:04:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbfLYTEr (ORCPT ); Wed, 25 Dec 2019 14:04:47 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33304 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEq (ORCPT ); Wed, 25 Dec 2019 14:04:46 -0500 Received: by mail-pl1-f193.google.com with SMTP id c13so9679426pls.0 for ; Wed, 25 Dec 2019 11:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8RN6kuhyriHZK/j1hHtEORpizIMkmj/7AdrHVuede8s=; b=l+0u5tYQ3NvaFn7G6mi39+gbFcRrG2PbCFfFN/52rzTgdqk330atHjrGxLlJJBrkzt 7pVfhIs+JZ6tSZpAiAnSlt9XVgb3dHnQEH+gomt+3U9giawKtnft9gEew9o+H8fkCLuD 3Tqtph5BJt606LZIJbjehRPRuXu/WR+PyEeSKGBSv+VPy7yHB4V7iYOu1v4/3exqQBxZ L/gK3MaDcM2qg2+38J51JVcgDEN7imByhJnRXPmKVaJJ9B1hrt1g3SpMFa2s2Kh8gogo 9bWVRTRuvy592OQU4hrOJvOYFNRwx0GHyvtDWVpcCx+S3cjqeajs9JbrWmW3E48ddZdw 9cxQ== 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=8RN6kuhyriHZK/j1hHtEORpizIMkmj/7AdrHVuede8s=; b=nTDiA50jN2EfNbW2sOR74UDsbEt7Yxc3ngCbj3/vii25Zfr6c5MPvUZihEoNgf9oIC eccVch6maylP8i10HyDL9+lrGGrRkUSdNyp/jMjFI5wstAkMEWjBwQsB+kOwQDwfPITO qelH5sBCS3Lhp+ON0jXwE3CaOHVXGPd0PklpEv9Y+6P/Zv1j9Y5ByFBdk5Ohr00gHyiR bIMIxOOsgp7z65wi9lC8ap9Zb4v9gSW+qJAPQHItWOZL6mQARpJtr6AAm8aXTTz1Y+sM Q2iqoKuavImIxhYwe87PGLVda/ebeIXnakPBw3xefpmIh9+XTKwwOqawey4Hb5FygLjb VH0g== X-Gm-Message-State: APjAAAVwAYMyygVTcM5bEkCxvqhrH7J1mrCesmQ2fvaObwP9VLXbE7kt GonzgcV+mtgrSy22nfRn/90TLysHorg= X-Google-Smtp-Source: APXvYqy8sge1W4VvDIb5BBOK8MNXdcy4mq73GrFBMy+8+MZAeEpFTj1hezEPNrrHNhEYqeS2lVobdw== X-Received: by 2002:a17:902:ba94:: with SMTP id k20mr4823440pls.60.1577300685567; Wed, 25 Dec 2019 11:04:45 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:45 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 07/10] tc: sfb: add support for JSON output Date: Thu, 26 Dec 2019 00:34:15 +0530 Message-Id: <20191225190418.8806-8-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the SFB Qdisc. Make the output for options "rehash" and "db" explicit. Use the long double format specifier to print probability values. Use sprint_time() to print time values. Also, fix the indentation in sfb_print_opt(). Signed-off-by: Leslie Monis --- tc/q_sfb.c | 67 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/tc/q_sfb.c b/tc/q_sfb.c index 7f48c6e0..8af55d98 100644 --- a/tc/q_sfb.c +++ b/tc/q_sfb.c @@ -143,6 +143,8 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) struct rtattr *tb[__TCA_SFB_MAX]; struct tc_sfb_qopt *qopt; + SPRINT_BUF(b1); + if (opt == NULL) return 0; @@ -153,14 +155,27 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (RTA_PAYLOAD(tb[TCA_SFB_PARMS]) < sizeof(*qopt)) return -1; - fprintf(f, - "limit %d max %d target %d\n" - " increment %.5f decrement %.5f penalty rate %d burst %d (%ums %ums)", - qopt->limit, qopt->max, qopt->bin_size, - (double)qopt->increment / SFB_MAX_PROB, - (double)qopt->decrement / SFB_MAX_PROB, - qopt->penalty_rate, qopt->penalty_burst, - qopt->rehash_interval, qopt->warmup_time); + print_uint(PRINT_JSON, "rehash", NULL, qopt->rehash_interval * 1000); + print_string(PRINT_FP, NULL, "rehash %s ", + sprint_time(qopt->rehash_interval * 1000, b1)); + + print_uint(PRINT_JSON, "db", NULL, qopt->warmup_time * 1000); + print_string(PRINT_FP, NULL, "db %s ", + sprint_time(qopt->warmup_time * 1000, b1)); + + print_uint(PRINT_ANY, "limit", "limit %up ", qopt->limit); + print_uint(PRINT_ANY, "max", "max %up ", qopt->max); + print_uint(PRINT_ANY, "target", "target %up ", qopt->bin_size); + + print_float(PRINT_ANY, "increment", "increment %lg ", + (double)qopt->increment / SFB_MAX_PROB); + print_float(PRINT_ANY, "decrement", "decrement %lg ", + (double)qopt->decrement / SFB_MAX_PROB); + + print_uint(PRINT_ANY, "penalty_rate", "penalty_rate %upps ", + qopt->penalty_rate); + print_uint(PRINT_ANY, "penalty_burst", "penalty_burst %up ", + qopt->penalty_burst); return 0; } @@ -168,24 +183,32 @@ static int sfb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) static int sfb_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats) { - struct tc_sfb_xstats *st; + struct tc_sfb_xstats *st; - if (xstats == NULL) - return 0; + if (xstats == NULL) + return 0; + + if (RTA_PAYLOAD(xstats) < sizeof(*st)) + return -1; - if (RTA_PAYLOAD(xstats) < sizeof(*st)) - return -1; + st = RTA_DATA(xstats); - st = RTA_DATA(xstats); - fprintf(f, - " earlydrop %u penaltydrop %u bucketdrop %u queuedrop %u childdrop %u marked %u\n" - " maxqlen %u maxprob %.5f avgprob %.5f ", - st->earlydrop, st->penaltydrop, st->bucketdrop, st->queuedrop, st->childdrop, - st->marked, - st->maxqlen, (double)st->maxprob / SFB_MAX_PROB, - (double)st->avgprob / SFB_MAX_PROB); + print_uint(PRINT_ANY, "earlydrop", " earlydrop %u", st->earlydrop); + print_uint(PRINT_ANY, "penaltydrop", " penaltydrop %u", + st->penaltydrop); + print_uint(PRINT_ANY, "bucketdrop", " bucketdrop %u", st->bucketdrop); + print_uint(PRINT_ANY, "queuedrop", " queuedrop %u", st->queuedrop); + print_uint(PRINT_ANY, "childdrop", " childdrop %u", st->childdrop); + print_uint(PRINT_ANY, "marked", " marked %u", st->marked); + print_nl(); + print_uint(PRINT_ANY, "maxqlen", " maxqlen %u", st->maxqlen); - return 0; + print_float(PRINT_ANY, "maxprob", " maxprob %lg", + (double)st->maxprob / SFB_MAX_PROB); + print_float(PRINT_ANY, "avgprob", " avgprob %lg", + (double)st->avgprob / SFB_MAX_PROB); + + return 0; } struct qdisc_util sfb_qdisc_util = { From patchwork Wed Dec 25 19:04:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215390 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bo78ttC9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFb5thjz9sPJ for ; Thu, 26 Dec 2019 06:04:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbfLYTEu (ORCPT ); Wed, 25 Dec 2019 14:04:50 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:37473 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEt (ORCPT ); Wed, 25 Dec 2019 14:04:49 -0500 Received: by mail-pj1-f65.google.com with SMTP id m13so2582952pjb.2 for ; Wed, 25 Dec 2019 11:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8BM4lmgMz7f1OUZm6GWOmaJ8rrEuG2SU2JKwCv1rhQ8=; b=Bo78ttC9HMGVG7YmNlT/WMpbxXtEtg4VAQ9IUBgBOKfDTQZ932lOkPzK8WO+nTGtX2 uhGVxa0E+BOkI20AGRYJNgl8r5gkXEsCdikk0YjcgmAVYoSazJQcKcLW3MHfs0Y1t2V2 2brDIOUXlhzrv9wWymoYMVGVDPPDkxWyCDQn1iRGnZIAvKVWrOFsKQiMJW0ODhX5CTSS d5M6XkYmghgakRmfTwNiImZe0m+ksay5bgfvLcsqhhvEhgw5PaAY5WYQUBDuSazntCtW U9Rkcr/Oxgsq/tCTWtp7wKkDOH4K2B06GyuUd72h2nZITnp1H7bjdVIjyvFWGs7aJ628 +Crw== 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=8BM4lmgMz7f1OUZm6GWOmaJ8rrEuG2SU2JKwCv1rhQ8=; b=Z9JHMQw+SFeN1+LuPH77u71x+DHOo4RA33FvETCaivggmNTuOAqz3Bicpznnw/JsaY GV/dE74LI26Bl9tyi2qNWbzKyFD7nnSD59fmzmdGPrPNokVnjIgVPjj4JmFejRTd+7r+ VcDXovA8cBGjt2uRHMy0a0Qh6uQTOuauzQk5ANPQOWyPLC7PJPU4qVDIhTcOm6PvG2Y9 ihCoOkHuATS4CK/QkU3BQadeBFEGOutfo9pzN50cnFFwuK6+CYjsJ39s93sZIYnabRtj Q5+oe3oMSJtjYJHy1QoamhntLmFSbfpJLmJz+K+M5vhCEbfj5r5o4BLXb9GIsFhrTEW0 N6Kw== X-Gm-Message-State: APjAAAXK3Esgn+btDEpjk5Suy89ldiWgFkbKMjzwZvsUZ8zAad6KTYq6 hisjyqWDza9wNYT1myIK/vVK2xFeYgI= X-Google-Smtp-Source: APXvYqwCVZsgZE+DJbiSA49LWcJuR8C/Tuv2QzQkWk1KDMI3qE91j4OpOdfbfAAkJH+yThFwA9Fg+Q== X-Received: by 2002:a17:902:788e:: with SMTP id q14mr42467093pll.305.1577300688754; Wed, 25 Dec 2019 11:04:48 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:48 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 08/10] tc: sfq: add support for JSON output Date: Thu, 26 Dec 2019 00:34:16 +0530 Message-Id: <20191225190418.8806-9-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the SFQ Qdisc. Use the long double format specifier to print the value of "probability". Also, fix the indentation in the online output of the contents in the tc_sfqred_stats structure. Signed-off-by: Leslie Monis --- tc/q_sfq.c | 66 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/tc/q_sfq.c b/tc/q_sfq.c index 4998921d..2b9bbcd2 100644 --- a/tc/q_sfq.c +++ b/tc/q_sfq.c @@ -217,35 +217,53 @@ static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (RTA_PAYLOAD(opt) >= sizeof(*qopt_ext)) qopt_ext = RTA_DATA(opt); qopt = RTA_DATA(opt); - fprintf(f, "limit %up ", qopt->limit); - fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1)); + + print_uint(PRINT_ANY, "limit", "limit %up ", qopt->limit); + print_uint(PRINT_JSON, "quantum", NULL, qopt->quantum); + print_string(PRINT_FP, NULL, "quantum %s ", + sprint_size(qopt->quantum, b1)); + if (qopt_ext && qopt_ext->depth) - fprintf(f, "depth %u ", qopt_ext->depth); + print_uint(PRINT_ANY, "depth", "depth %u ", qopt_ext->depth); if (qopt_ext && qopt_ext->headdrop) - fprintf(f, "headdrop "); + print_bool(PRINT_ANY, "headdrop", "headdrop ", true); + if (show_details) + print_uint(PRINT_ANY, "flows", "flows %u ", qopt->flows); + + print_uint(PRINT_ANY, "divisor", "divisor %u ", qopt->divisor); - if (show_details) { - fprintf(f, "flows %u/%u ", qopt->flows, qopt->divisor); - } - fprintf(f, "divisor %u ", qopt->divisor); if (qopt->perturb_period) - fprintf(f, "perturb %dsec ", qopt->perturb_period); + print_int(PRINT_ANY, "perturb", "perturb %dsec ", + qopt->perturb_period); if (qopt_ext && qopt_ext->qth_min) { - fprintf(f, "\n ewma %u ", qopt_ext->Wlog); - fprintf(f, "min %s max %s probability %g ", - sprint_size(qopt_ext->qth_min, b2), - sprint_size(qopt_ext->qth_max, b3), - qopt_ext->max_P / pow(2, 32)); + print_uint(PRINT_ANY, "ewma", "ewma %u ", qopt_ext->Wlog); + print_uint(PRINT_JSON, "min", NULL, qopt_ext->qth_min); + print_string(PRINT_FP, NULL, "min %s ", + sprint_size(qopt_ext->qth_min, b2)); + print_uint(PRINT_JSON, "max", NULL, qopt_ext->qth_max); + print_string(PRINT_FP, NULL, "max %s ", + sprint_size(qopt_ext->qth_max, b3)); + print_float(PRINT_ANY, "probability", "probability %lg ", + qopt_ext->max_P / pow(2, 32)); tc_red_print_flags(qopt_ext->flags); if (show_stats) { - fprintf(f, "\n prob_mark %u prob_mark_head %u prob_drop %u", - qopt_ext->stats.prob_mark, - qopt_ext->stats.prob_mark_head, - qopt_ext->stats.prob_drop); - fprintf(f, "\n forced_mark %u forced_mark_head %u forced_drop %u", - qopt_ext->stats.forced_mark, - qopt_ext->stats.forced_mark_head, - qopt_ext->stats.forced_drop); + print_nl(); + print_uint(PRINT_ANY, "prob_mark", " prob_mark %u", + qopt_ext->stats.prob_mark); + print_uint(PRINT_ANY, "prob_mark_head", + " prob_mark_head %u", + qopt_ext->stats.prob_mark_head); + print_uint(PRINT_ANY, "prob_drop", " prob_drop %u", + qopt_ext->stats.prob_drop); + print_nl(); + print_uint(PRINT_ANY, "forced_mark", + " forced_mark %u", + qopt_ext->stats.forced_mark); + print_uint(PRINT_ANY, "forced_mark_head", + " forced_mark_head %u", + qopt_ext->stats.forced_mark_head); + print_uint(PRINT_ANY, "forced_drop", " forced_drop %u", + qopt_ext->stats.forced_drop); } } return 0; @@ -262,8 +280,8 @@ static int sfq_print_xstats(struct qdisc_util *qu, FILE *f, return -1; st = RTA_DATA(xstats); - fprintf(f, " allot %d ", st->allot); - fprintf(f, "\n"); + print_int(PRINT_ANY, "allot", " allot %d", st->allot); + return 0; } From patchwork Wed Dec 25 19:04:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215391 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MZxAKKE5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFf2ZFzz9sPJ for ; Thu, 26 Dec 2019 06:04:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727002AbfLYTEx (ORCPT ); Wed, 25 Dec 2019 14:04:53 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43474 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTEx (ORCPT ); Wed, 25 Dec 2019 14:04:53 -0500 Received: by mail-pg1-f194.google.com with SMTP id k197so11890324pga.10 for ; Wed, 25 Dec 2019 11:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HCvDnd7fT6xG8rVYm75P2CW0sx9MupXZHTgbQNylMfo=; b=MZxAKKE5QeQJPV4v+EBP+m3JnoCQL4C6jgU8XBJ1SnroVaRUSkS6H0YHPtAs/p4ZQx X0ZY9X65It3WtdMBlyCWHCgJB/QUdH5xRUcdiLRPWg5JT3vVoTcI76yBuZ40gw7lrcAV 0xpgoknTKswPSZDadrj5QL7yRIMfzNf05bilzMEq56hHyt811SoN5meCzgQyg/OwHyBl sF8ih56/u/BKUUwWTLklT2Xj7uaU1nLywdh0mdayV6ZRnt/7lqA0VfBktIfp4ngv1BvU ecKz5tDQIbOu8jJYJ0e/Jl2wIMbTLzhtd6xnSwnub5K/qp0Ubo0tMO/m/b+2tW1IOAmh St6w== 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=HCvDnd7fT6xG8rVYm75P2CW0sx9MupXZHTgbQNylMfo=; b=TjwdZQoxro5hpNJsOy1Fxjm0QqR7uBjUR14r29CTocPrcCUcYWjfZp8MvziVk7EQZG s1zLHSSlMySufxwwG3nCQ5dYs53igw1CgFMzLZRnr4HqTNS4dEbjUsFlqXQXTFsUMTYl 7f0QnlCu6l1Bab2cfwIVdYo93/4i5iHeYakit5EE+iOOf37/tKrpvvzV4tzJf95VPj1Q synGKKp2h5T0PR1Qixh1o6ZgeDeik5U3FzDfh3cTWBgkvXlgXvhBVfEyGLzk3F/mfGBn K2+kFVr6DbAQ6XXzoTfzD093QKgi12n3bq7BNqHbV9Hrc0wpOe5jVTZeVldQtLyYybCi 2yKA== X-Gm-Message-State: APjAAAVzFygwj6w9jdQGnkOMLru8h3s3AvpNg6ImuNlP5CCk7FZojTOo FRKxAVevNsx2DeupPY5oW8V85YtL6gg= X-Google-Smtp-Source: APXvYqzzt3y0i+OlA5dIq2OuxF/Wuz9sAnGVQlrDOkffuC5qjE03ViVz02E++wYVee1C2mOziJUClQ== X-Received: by 2002:aa7:820d:: with SMTP id k13mr46288438pfi.10.1577300692028; Wed, 25 Dec 2019 11:04:52 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:51 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger Subject: [PATCH iproute2-next 09/10] tc: tbf: add support for JSON output Date: Thu, 26 Dec 2019 00:34:17 +0530 Message-Id: <20191225190418.8806-10-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Enable proper JSON output for the TBF Qdisc. Also, fix the style of the statement that's calculating "latency" in tbf_print_opt(). Signed-off-by: Leslie Monis --- tc/q_tbf.c | 68 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/tc/q_tbf.c b/tc/q_tbf.c index 57a9736c..5135b1d6 100644 --- a/tc/q_tbf.c +++ b/tc/q_tbf.c @@ -264,7 +264,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) struct tc_tbf_qopt *qopt; unsigned int linklayer; double buffer, mtu; - double latency; + double latency, lat2; __u64 rate64 = 0, prate64 = 0; SPRINT_BUF(b1); @@ -286,53 +286,79 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (tb[TCA_TBF_RATE64] && RTA_PAYLOAD(tb[TCA_TBF_RATE64]) >= sizeof(rate64)) rate64 = rta_getattr_u64(tb[TCA_TBF_RATE64]); - fprintf(f, "rate %s ", sprint_rate(rate64, b1)); + print_u64(PRINT_JSON, "rate", NULL, rate64); + print_string(PRINT_FP, NULL, "rate %s ", sprint_rate(rate64, b1)); buffer = tc_calc_xmitsize(rate64, qopt->buffer); if (show_details) { - fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1), - 1<rate.cell_log, sprint_size(qopt->rate.mpu, b2)); + sprintf(b1, "%s/%u", sprint_size(buffer, b2), + 1 << qopt->rate.cell_log); + print_string(PRINT_ANY, "burst", "burst %s ", b1); + print_uint(PRINT_JSON, "mpu", NULL, qopt->rate.mpu); + print_string(PRINT_FP, NULL, "mpu %s ", + sprint_size(qopt->rate.mpu, b1)); } else { - fprintf(f, "burst %s ", sprint_size(buffer, b1)); + print_u64(PRINT_JSON, "burst", NULL, buffer); + print_string(PRINT_FP, NULL, "burst %s ", + sprint_size(buffer, b1)); } if (show_raw) - fprintf(f, "[%08x] ", qopt->buffer); + print_hex(PRINT_ANY, "burst_raw", "[%08x] ", qopt->buffer); prate64 = qopt->peakrate.rate; if (tb[TCA_TBF_PRATE64] && RTA_PAYLOAD(tb[TCA_TBF_PRATE64]) >= sizeof(prate64)) prate64 = rta_getattr_u64(tb[TCA_TBF_PRATE64]); if (prate64) { - fprintf(f, "peakrate %s ", sprint_rate(prate64, b1)); + print_u64(PRINT_JSON, "peakrate", NULL, prate64); + print_string(PRINT_FP, NULL, "peakrate %s ", + sprint_rate(prate64, b1)); if (qopt->mtu || qopt->peakrate.mpu) { mtu = tc_calc_xmitsize(prate64, qopt->mtu); if (show_details) { - fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1), - 1<peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2)); + sprintf(b1, "%s/%u", sprint_size(mtu, b2), + 1 << qopt->peakrate.cell_log); + print_string(PRINT_ANY, "mtu", "mtu %s ", b1); + print_uint(PRINT_JSON, "mpu", NULL, + qopt->peakrate.mpu); + print_string(PRINT_FP, NULL, "mpu %s ", + sprint_size(qopt->peakrate.mpu, + b1)); } else { - fprintf(f, "minburst %s ", sprint_size(mtu, b1)); + print_u64(PRINT_JSON, "minburst", NULL, mtu); + print_string(PRINT_FP, NULL, "minburst %s ", + sprint_size(mtu, b1)); } if (show_raw) - fprintf(f, "[%08x] ", qopt->mtu); + print_hex(PRINT_ANY, "mtu_raw", "[%08x] ", + qopt->mtu); } } - latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)rate64) - tc_core_tick2time(qopt->buffer); + latency = TIME_UNITS_PER_SEC * (qopt->limit / (double)rate64) - + tc_core_tick2time(qopt->buffer); if (prate64) { - double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)prate64) - tc_core_tick2time(qopt->mtu); + lat2 = TIME_UNITS_PER_SEC * (qopt->limit / (double)prate64) - + tc_core_tick2time(qopt->mtu); if (lat2 > latency) latency = lat2; } - if (latency >= 0.0) - fprintf(f, "lat %s ", sprint_time(latency, b1)); - if (show_raw || latency < 0.0) - fprintf(f, "limit %s ", sprint_size(qopt->limit, b1)); - - if (qopt->rate.overhead) { - fprintf(f, "overhead %d", qopt->rate.overhead); + if (latency >= 0.0) { + print_u64(PRINT_JSON, "lat", NULL, latency); + print_string(PRINT_FP, NULL, "lat %s ", + sprint_time(latency, b1)); + } + if (show_raw || latency < 0.0) { + print_uint(PRINT_JSON, "limit", NULL, qopt->limit); + print_string(PRINT_FP, NULL, "limit %s ", + sprint_size(qopt->limit, b1)); } + if (qopt->rate.overhead) + print_int(PRINT_ANY, "overhead", "overhead %d ", + qopt->rate.overhead); linklayer = (qopt->rate.linklayer & TC_LINKLAYER_MASK); if (linklayer > TC_LINKLAYER_ETHERNET || show_details) - fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, b3)); + print_string(PRINT_ANY, "linklayer", "linklayer %s ", + sprint_linklayer(linklayer, b3)); return 0; } From patchwork Wed Dec 25 19:04:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leslie Monis X-Patchwork-Id: 1215392 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GKU9FWVy"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47jjFj4mWhz9sPn for ; Thu, 26 Dec 2019 06:04:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727011AbfLYTE4 (ORCPT ); Wed, 25 Dec 2019 14:04:56 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35030 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfLYTE4 (ORCPT ); Wed, 25 Dec 2019 14:04:56 -0500 Received: by mail-pl1-f194.google.com with SMTP id g6so9676022plt.2 for ; Wed, 25 Dec 2019 11:04:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zFwjOzvEwYsCMqPxR9qSVrNAmD1MKfKMdVbc5ZQpsKU=; b=GKU9FWVyJlq2ngYV5Dy9jxjkQ/3Ks3wgrHjpnpD7pz1Jm3oOTRPazHiru+cvB5aafB uqyEXVYAG7IRgli5lQz/KBD+qYQzLxAxLS0oziQPLAGfGJa3ZONK4ppbr1p5qbwzpuJ/ 2Wiy+jMq5qR8rnbUuu5yBz+TrFItnTMYSpdMLkud8Q8wf2rqsaODrK/TrHRq8UUzlMNQ G9K/QunPY0xjqYO7fNKkMZ9sqSqZqvyCk7bmLCKt7aGG7fGyVcZM+zLEQaVzaSkgKbTQ si3nuA3aGcjCG4eUwTbyV2APHO0VvL42n5YKeNybIcOSKLm0vjpSNJCP2XQ1KFk7q7jR E/AA== 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:mime-version:content-transfer-encoding; bh=zFwjOzvEwYsCMqPxR9qSVrNAmD1MKfKMdVbc5ZQpsKU=; b=MYz7zv5yBB705nt6dA8JY7mjTSz9H9xS1LISUBwJr4/VB1ym0Bs0OFCLgQ6WX0x9I1 xB8MgZp1QXAWsi7IX6u3g5ToBdLak1LLod2g+3KiRyBLxuHWr1PfRqJW9mAjfgGr0em9 kiZncg2jE5w/MMEN4rLbXiHiAnMFuybe7PMKTQfJSqUg9Ld3ebyNrLXxx+tRj/dp9qqe 6g9iQVLt3ynPTKVTbKOp/qMIVDdufMNOn0txy7BRntjjjI5pGH/EeQaQtCJy8Klw18wD Xk6f5V0Kx5PLAqwMrocOUlZwrewfvb7rvCCeJM1DyO7UzR/hfU1/r8hA3hESM8gcmoXZ gI9g== X-Gm-Message-State: APjAAAXFtJ/ra0GTAQL4qvz9Z/XaXA+d7vZn//rQgcNDK2wEMDAn0e2I zytDrJMoOS2a15L9+qr3B9SFaySNC4o= X-Google-Smtp-Source: APXvYqxfvzbNA/iw4mi8bKgjcNnG97KEwX4l8OF9m7P1bEj/vs6FUu/YB7eJr85rp6ghsOtmRsgGwQ== X-Received: by 2002:a17:902:b611:: with SMTP id b17mr43008580pls.210.1577300695173; Wed, 25 Dec 2019 11:04:55 -0800 (PST) Received: from localhost.localdomain ([103.89.235.106]) by smtp.gmail.com with ESMTPSA id j28sm30019719pgb.36.2019.12.25.11.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2019 11:04:54 -0800 (PST) From: Leslie Monis To: Linux NetDev Cc: David Ahern , Stephen Hemminger , =?utf-8?b?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vu?= =?utf-8?q?sen?= Subject: [PATCH iproute2-next 10/10] tc: fq_codel: fix missing statistic in JSON output Date: Thu, 26 Dec 2019 00:34:18 +0530 Message-Id: <20191225190418.8806-11-lesliemonis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191225190418.8806-1-lesliemonis@gmail.com> References: <20191225190418.8806-1-lesliemonis@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Print JSON object even if tc_fq_codel_xstats->class_stats.drop_next is negative. Cc: Toke Høiland-Jørgensen Fixes: 997f2dc19378 ("tc: Add JSON output of fq_codel stats") Signed-off-by: Leslie Monis --- tc/q_fq_codel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tc/q_fq_codel.c b/tc/q_fq_codel.c index 12ce3fbf..efed4d28 100644 --- a/tc/q_fq_codel.c +++ b/tc/q_fq_codel.c @@ -276,12 +276,12 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f, sprint_time(st->class_stats.ldelay, b1)); if (st->class_stats.dropping) { print_bool(PRINT_ANY, "dropping", " dropping", true); + print_int(PRINT_JSON, "drop_next", NULL, + st->class_stats.drop_next); if (st->class_stats.drop_next < 0) print_string(PRINT_FP, NULL, " drop_next -%s", sprint_time(-st->class_stats.drop_next, b1)); else { - print_uint(PRINT_JSON, "drop_next", NULL, - st->class_stats.drop_next); print_string(PRINT_FP, NULL, " drop_next %s", sprint_time(st->class_stats.drop_next, b1)); }