diff mbox series

[iproute2-next,05/10] ipstats: Add a third level of stats hierarchy, a "suite"

Message ID 11d977863011c6bb3d764ce59d9f5863f4f042f9.1652104101.git.petrm@nvidia.com (mailing list archive)
State Accepted
Commit c6900b79b13d7bc329955b4f9e8c7470d42ae2fa
Delegated to: David Ahern
Headers show
Series ip stats: Support for xstats and afstats | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Petr Machata May 9, 2022, 1:59 p.m. UTC
To show statistics nested under IFLA_STATS_LINK_XSTATS_SLAVE or
IFLA_STATS_LINK_XSTATS, one would use "group" to select the top-level
attribute, then "subgroup" to select the link type, which is itself a nest,
and then would lack a way to denote which attribute to select out of the
link-type nest.

To that end, add the selector level "suite", which is filtered in the
userspace.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
 ip/ipstats.c        | 9 ++++++++-
 man/man8/ip-stats.8 | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/ip/ipstats.c b/ip/ipstats.c
index 5b9333e3..0e7f2b3c 100644
--- a/ip/ipstats.c
+++ b/ip/ipstats.c
@@ -34,6 +34,7 @@  struct ipstats_stat_show_attrs {
 static const char *const ipstats_levels[] = {
 	"group",
 	"subgroup",
+	"suite",
 };
 
 enum {
@@ -1024,7 +1025,7 @@  static int do_help(void)
 
 	fprintf(stderr,
 		"Usage: ip stats help\n"
-		"       ip stats show [ dev DEV ] [ group GROUP [ subgroup SUBGROUP ] ... ] ...\n"
+		"       ip stats show [ dev DEV ] [ group GROUP [ subgroup SUBGROUP [ suite SUITE ] ... ] ... ] ...\n"
 		"       ip stats set dev DEV l3_stats { on | off }\n"
 		);
 
@@ -1048,6 +1049,8 @@  static int do_help(void)
 			continue;
 
 		for (j = 0; j < desc->nsubs; j++) {
+			size_t k;
+
 			if (j == 0)
 				fprintf(stderr, "%s SUBGROUP := {", desc->name);
 			else
@@ -1057,6 +1060,10 @@  static int do_help(void)
 
 			if (desc->subs[j]->kind != IPSTATS_STAT_DESC_KIND_GROUP)
 				continue;
+
+			for (k = 0; k < desc->subs[j]->nsubs; k++)
+				fprintf(stderr, " [ suite %s ]",
+					desc->subs[j]->subs[k]->name);
 		}
 		if (opened)
 			fprintf(stderr, " }\n");
diff --git a/man/man8/ip-stats.8 b/man/man8/ip-stats.8
index 7eaaf122..a82fe9f7 100644
--- a/man/man8/ip-stats.8
+++ b/man/man8/ip-stats.8
@@ -19,7 +19,8 @@  ip-stats \- manage and show interface statistics
 .RB "[ " group
 .IR GROUP " [ "
 .BI subgroup " SUBGROUP"
-.R " ] ... ] ..."
+.RB " [ " suite
+.IR " SUITE" " ] ... ] ... ] ..."
 
 .ti -8
 .BR "ip stats set"