lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181119230335.11771-6-jakub.kicinski@netronome.com>
Date:   Mon, 19 Nov 2018 15:03:32 -0800
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     dsahern@...il.com, stephen@...workplumber.org
Cc:     oss-drivers@...ronome.com, netdev@...r.kernel.org,
        Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [PATCH iproute2-next 5/8] tc: gred: separate out stats printing

Printing GRED statistics is long and deserves a function on its own.

Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@...ronome.com>
---
 tc/q_gred.c | 67 +++++++++++++++++++++++++++--------------------------
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/tc/q_gred.c b/tc/q_gred.c
index 768b77ba3b0d..501437bc5abe 100644
--- a/tc/q_gred.c
+++ b/tc/q_gred.c
@@ -265,6 +265,38 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n
 	return 0;
 }
 
+static void gred_print_stats(struct tc_gred_qopt *qopt)
+{
+	SPRINT_BUF(b1);
+
+	if (!is_json_context())
+		printf("\n  Queue size: ");
+
+	print_uint(PRINT_JSON, "qave", NULL, qopt->qave);
+	print_string(PRINT_FP, NULL, "average %s ",
+		     sprint_size(qopt->qave, b1));
+
+	print_uint(PRINT_JSON, "backlog", NULL, qopt->backlog);
+	print_string(PRINT_FP, NULL, "current %s ",
+		     sprint_size(qopt->backlog, b1));
+
+	if (!is_json_context())
+		printf("\n  Dropped packets: ");
+
+	print_uint(PRINT_ANY, "forced_drop", "forced %u ", qopt->forced);
+	print_uint(PRINT_ANY, "prob_drop", "early %u ", qopt->early);
+	print_uint(PRINT_ANY, "pdrop", "pdrop %u ", qopt->pdrop);
+	print_uint(PRINT_ANY, "other", "other %u ", qopt->other);
+
+	if (!is_json_context())
+		printf("\n  Total packets: ");
+
+	print_uint(PRINT_ANY, "packets", "%u ", qopt->packets);
+
+	print_uint(PRINT_JSON, "bytes", NULL, qopt->bytesin);
+	print_string(PRINT_FP, NULL, "(%s) ", sprint_size(qopt->bytesin, b1));
+}
+
 static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 {
 	struct rtattr *tb[TCA_GRED_MAX + 1];
@@ -348,39 +380,8 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 			print_uint(PRINT_ANY, "Scell_log", "Scell_log %u ",
 				   qopt->Scell_log);
 		}
-		if (show_stats) {
-			if (!is_json_context())
-				printf("\n  Queue size: ");
-
-			print_uint(PRINT_JSON, "qave", NULL, qopt->qave);
-			print_string(PRINT_FP, NULL, "average %s ",
-				     sprint_size(qopt->qave, b1));
-
-			print_uint(PRINT_JSON, "backlog", NULL, qopt->backlog);
-			print_string(PRINT_FP, NULL, "current %s ",
-				     sprint_size(qopt->backlog, b1));
-
-			if (!is_json_context())
-				printf("\n  Dropped packets: ");
-
-			print_uint(PRINT_ANY, "forced_drop", "forced %u ",
-				   qopt->forced);
-			print_uint(PRINT_ANY, "prob_drop", "early %u ",
-				   qopt->early);
-			print_uint(PRINT_ANY, "pdrop", "pdrop %u ",
-				   qopt->pdrop);
-			print_uint(PRINT_ANY, "other", "other %u ",
-				   qopt->other);
-
-			if (!is_json_context())
-				printf("\n  Total packets: ");
-
-			print_uint(PRINT_ANY, "packets", "%u ", qopt->packets);
-
-			print_uint(PRINT_JSON, "bytes", NULL, qopt->bytesin);
-			print_string(PRINT_FP, NULL, "(%s) ",
-				     sprint_size(qopt->bytesin, b1));
-		}
+		if (show_stats)
+			gred_print_stats(qopt);
 		close_json_object();
 	}
 	close_json_array(PRINT_JSON, "vqs");
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ