]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: fix "devlink health dump" command without arg
authorJiri Pirko <jiri@nvidia.com>
Tue, 19 Apr 2022 17:15:11 +0000 (19:15 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 25 Apr 2022 20:32:47 +0000 (13:32 -0700)
Fix bug when user calls "devlink health dump" without "show" or "clear":
$ devlink health dump
Command "(null)" not found

Put the dump command into a separate helper as it is usual in the rest
of the code. Also, treat no cmd as "show", as it is common for other
devlink objects.

Fixes: 041e6e651a8e ("devlink: Add devlink health dump show command")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
devlink/devlink.c

index da9f97788bcf33e7d316d76997f0e6176254d310..aab739f7f4372b57c7003b627587656c0bb1b9e8 100644 (file)
@@ -8526,6 +8526,23 @@ static void cmd_health_help(void)
        pr_err("                          [ auto_dump    { true | false } ]\n");
 }
 
+static int cmd_health_dump(struct dl *dl)
+{
+       if (dl_argv_match(dl, "help")) {
+               cmd_health_help();
+               return 0;
+       } else if (dl_argv_match(dl, "show") ||
+                  dl_argv_match(dl, "list") || dl_no_arg(dl)) {
+               dl_arg_inc(dl);
+               return cmd_health_dump_show(dl);
+       } else if (dl_argv_match(dl, "clear")) {
+               dl_arg_inc(dl);
+               return cmd_health_dump_clear(dl);
+       }
+       pr_err("Command \"%s\" not found\n", dl_argv(dl));
+       return -ENOENT;
+}
+
 static int cmd_health(struct dl *dl)
 {
        if (dl_argv_match(dl, "help")) {
@@ -8546,13 +8563,7 @@ static int cmd_health(struct dl *dl)
                return cmd_health_test(dl);
        } else if (dl_argv_match(dl, "dump")) {
                dl_arg_inc(dl);
-               if (dl_argv_match(dl, "show")) {
-                       dl_arg_inc(dl);
-                       return cmd_health_dump_show(dl);
-               } else if (dl_argv_match(dl, "clear")) {
-                       dl_arg_inc(dl);
-                       return cmd_health_dump_clear(dl);
-               }
+               return cmd_health_dump(dl);
        } else if (dl_argv_match(dl, "set")) {
                dl_arg_inc(dl);
                return cmd_health_set_params(dl);