]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
dcb: Add -s to enable statistics
authorPetr Machata <me@pmachata.org>
Thu, 10 Dec 2020 23:02:20 +0000 (00:02 +0100)
committerDavid Ahern <dsahern@gmail.com>
Mon, 14 Dec 2020 16:41:50 +0000 (16:41 +0000)
Allow selective display of statistical counters by passing -s.

Signed-off-by: Petr Machata <me@pmachata.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
dcb/dcb.c
dcb/dcb.h
man/man8/dcb.8

index 7c0beee4368682da414c99d880178b0fe7970145..9332a8b2e3d41843d0ef4ff37e03662a42c50eca 100644 (file)
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -310,7 +310,8 @@ static void dcb_help(void)
                "Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n"
                "       dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n"
                "where  OBJECT := ets\n"
-               "       OPTIONS := [ -V | --Version | -j | --json | -p | --pretty | -v | --verbose ]\n");
+               "       OPTIONS := [ -V | --Version | -j | --json | -p | --pretty\n"
+               "                  | -s | --statistics | -v | --verbose ]\n");
 }
 
 static int dcb_cmd(struct dcb *dcb, int argc, char **argv)
@@ -346,6 +347,7 @@ int main(int argc, char **argv)
                { "batch",              required_argument,      NULL, 'b' },
                { "json",               no_argument,            NULL, 'j' },
                { "pretty",             no_argument,            NULL, 'p' },
+               { "statistics",         no_argument,            NULL, 's' },
                { "Netns",              required_argument,      NULL, 'N' },
                { "help",               no_argument,            NULL, 'h' },
                { NULL, 0, NULL, 0 }
@@ -363,7 +365,7 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       while ((opt = getopt_long(argc, argv, "b:fhjpvN:V",
+       while ((opt = getopt_long(argc, argv, "b:fhjpsvN:V",
                                  long_options, NULL)) >= 0) {
 
                switch (opt) {
@@ -383,6 +385,9 @@ int main(int argc, char **argv)
                case 'p':
                        pretty = true;
                        break;
+               case 's':
+                       dcb->stats = true;
+                       break;
                case 'N':
                        if (netns_switch(optarg)) {
                                ret = EXIT_FAILURE;
index d22176888811c53c3fbae1eba910a489c88ac200..b2a13b3065f2c5abb909d0d401c1aa82c4fb788e 100644 (file)
--- a/dcb/dcb.h
+++ b/dcb/dcb.h
@@ -11,6 +11,7 @@ struct dcb {
        char *buf;
        struct mnl_socket *nl;
        bool json_output;
+       bool stats;
 };
 
 int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
index f318435caa985f43c14509d434d8211e340f6be2..f853b7baaf336a3d512ab1ca7470bfc0b5f31f6c 100644 (file)
@@ -51,6 +51,11 @@ Generate JSON output.
 .BR "\-p" , " --pretty"
 When combined with -j generate a pretty JSON output.
 
+.TP
+.BR "\-s" , " --statistics"
+If the object in question contains any statistical counters, shown them as
+part of the "show" output.
+
 .SH OBJECTS
 
 .TP