From: Petr Machata Date: Mon, 9 May 2022 13:59:58 +0000 (+0200) Subject: ipstats: Add a third level of stats hierarchy, a "suite" X-Git-Tag: v5.19.0~24^2~1^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6900b79b13d7bc329955b4f9e8c7470d42ae2fa;p=thirdparty%2Fiproute2.git ipstats: Add a third level of stats hierarchy, a "suite" 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 Reviewed-by: Ido Schimmel Signed-off-by: David Ahern --- diff --git a/ip/ipstats.c b/ip/ipstats.c index 5b9333e3e..0e7f2b3c9 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 7eaaf122b..a82fe9f75 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"