]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
dcb: Add -i to enable IEC mode
authorPetr Machata <me@pmachata.org>
Thu, 10 Dec 2020 23:02:21 +0000 (00:02 +0100)
committerDavid Ahern <dsahern@gmail.com>
Mon, 14 Dec 2020 16:41:54 +0000 (16:41 +0000)
Allow switching "dcb" into the ISO/IEC mode of units by passing -i.

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 9332a8b2e3d41843d0ef4ff37e03662a42c50eca..4b4a5b9354c64c6a5841e57ce39be9a58d4ecc3e 100644 (file)
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -310,8 +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\n"
-               "                  | -s | --statistics | -v | --verbose ]\n");
+               "       OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n"
+               "                  | -p | --pretty | -s | --statistics | -v | --verbose]\n");
 }
 
 static int dcb_cmd(struct dcb *dcb, int argc, char **argv)
@@ -345,6 +345,7 @@ int main(int argc, char **argv)
                { "Version",            no_argument,            NULL, 'V' },
                { "force",              no_argument,            NULL, 'f' },
                { "batch",              required_argument,      NULL, 'b' },
+               { "iec",                no_argument,            NULL, 'i' },
                { "json",               no_argument,            NULL, 'j' },
                { "pretty",             no_argument,            NULL, 'p' },
                { "statistics",         no_argument,            NULL, 's' },
@@ -365,7 +366,7 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       while ((opt = getopt_long(argc, argv, "b:fhjpsvN:V",
+       while ((opt = getopt_long(argc, argv, "b:fhijpsvN:V",
                                  long_options, NULL)) >= 0) {
 
                switch (opt) {
@@ -394,6 +395,9 @@ int main(int argc, char **argv)
                                goto dcb_free;
                        }
                        break;
+               case 'i':
+                       dcb->use_iec = true;
+                       break;
                case 'h':
                        dcb_help();
                        return 0;
index b2a13b3065f2c5abb909d0d401c1aa82c4fb788e..8637efc159b952faa006750608d267d61d9a3116 100644 (file)
--- a/dcb/dcb.h
+++ b/dcb/dcb.h
@@ -12,6 +12,7 @@ struct dcb {
        struct mnl_socket *nl;
        bool json_output;
        bool stats;
+       bool use_iec;
 };
 
 int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
index f853b7baaf336a3d512ab1ca7470bfc0b5f31f6c..15b43942585adf448696eacaf57c14d8f366e2f4 100644 (file)
@@ -43,6 +43,11 @@ failure will cause termination of dcb.
 Don't terminate dcb on errors in batch mode. If there were any errors during
 execution of the commands, the application return code will be non zero.
 
+.TP
+.BR "\-i" , " --iec"
+When showing rates, use ISO/IEC 1024-based prefixes (Ki, Mi, Bi) instead of
+the 1000-based ones (K, M, B).
+
 .TP
 .BR "\-j" , " --json"
 Generate JSON output.