iproute/backport-devlink-fix-devlink-health-dump-command-without-arg.patch
jiangheng 0dae3f3f5e backport some patches from community
(cherry picked from commit 0dbe7b66f5c5e6d62893f05700882fc2e417d182)
2022-10-10 22:11:18 +08:00

67 lines
2.2 KiB
Diff

From e81fd551a1a0ffa7983d25f5e756a5c5b6cb4a9a Mon Sep 17 00:00:00 2001
From: Jiri Pirko <jiri@nvidia.com>
Date: Tue, 19 Apr 2022 19:15:11 +0200
Subject: [PATCH] devlink: fix "devlink health dump" command without arg
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>
Conflict: NA
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=e81fd551a1
---
devlink/devlink.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 3abbff6..db74539 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6862,6 +6862,23 @@ static void cmd_health_help(void)
pr_err(" devlink health set DEV reporter REPORTER_NAME { grace_period | auto_recover } { msec | boolean }\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")) {
@@ -6879,13 +6896,7 @@ static int cmd_health(struct dl *dl)
return cmd_health_diagnose(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);
--
2.23.0