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]
Date: Tue, 12 Mar 2024 15:53:28 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2 1/5] tc: support JSON for legacy stats

The extended stats already supported JSON output, add to the
legacy stats as well.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 tc/tc_util.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index aa7cf60faa6d..615e3e9cc377 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -804,28 +804,30 @@ void print_tcstats_attr(FILE *fp, struct rtattr *tb[], const char *prefix,
 		memcpy(&st, RTA_DATA(tb[TCA_STATS]),
 		       MIN(RTA_PAYLOAD(tb[TCA_STATS]), sizeof(st)));
 
-		fprintf(fp,
-			"%sSent %llu bytes %u pkts (dropped %u, overlimits %u) ",
-			prefix, (unsigned long long)st.bytes,
-			st.packets, st.drops, st.overlimits);
+		print_string(PRINT_FP, NULL, "%s", prefix);
+		print_lluint(PRINT_ANY, "bytes", "Sent %llu bytes",
+			     (unsigned long long)st.bytes);
+		print_uint(PRINT_ANY, "packets", " %u pkts", st.packets);
+		print_uint(PRINT_ANY, "dropped", " (dropped %u,", st.drops);
+		print_uint(PRINT_ANY, "overlimits", " overlimits %u) ", st.overlimits);
 
 		if (st.bps || st.pps || st.qlen || st.backlog) {
-			fprintf(fp, "\n%s", prefix);
+			print_nl();
+			print_string(PRINT_FP, NULL, "%s", prefix);
+
 			if (st.bps || st.pps) {
-				fprintf(fp, "rate ");
+				print_string(PRINT_FP, NULL, "rate ", NULL);
 				if (st.bps)
-					tc_print_rate(PRINT_FP, NULL, "%s ",
-						      st.bps);
+					tc_print_rate(PRINT_ANY, "rate", "%s ", st.bps);
 				if (st.pps)
-					fprintf(fp, "%upps ", st.pps);
+					print_uint(PRINT_ANY, "pps", "%upps ", st.pps);
 			}
 			if (st.qlen || st.backlog) {
-				fprintf(fp, "backlog ");
+				print_string(PRINT_FP, NULL, "backlog ", NULL);
 				if (st.backlog)
-					print_size(PRINT_FP, NULL, "%s ",
-						   st.backlog);
+					print_size(PRINT_ANY, "backlog", "%s ", st.backlog);
 				if (st.qlen)
-					fprintf(fp, "%up ", st.qlen);
+					print_uint(PRINT_ANY, "qlen", "%up ", st.qlen);
 			}
 		}
 	}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ