]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: fix segfault on health command
authorAndrea Claudi <aclaudi@redhat.com>
Wed, 4 Sep 2019 17:26:14 +0000 (19:26 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 4 Sep 2019 19:01:19 +0000 (12:01 -0700)
devlink segfaults when using grace_period without reporter

$ devlink health set pci/0000:00:09.0 grace_period 3500
Segmentation fault

devlink is instead supposed to gracefully fail printing a warning
message

$ devlink health set pci/0000:00:09.0 grace_period 3500
Reporter's name is expected.

This happens because DL_OPT_HEALTH_REPORTER_NAME and
DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD are both defined as BIT(27).
When dl_opts_put() parse options and grace_period is set, it erroneously
tries to set reporter name to null.

This is fixed simply shifting by 1 bit enumeration starting with
DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD.

Fixes: b18d89195b16 ("devlink: Add devlink health set command")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
devlink/devlink.c

index 91c85dc1de7309eca66267700ed0371c8f90d391..0293373928f50c9328e1e376122361e1ec444a67 100644 (file)
@@ -231,8 +231,8 @@ static void ifname_map_free(struct ifname_map *ifname_map)
 #define DL_OPT_FLASH_FILE_NAME BIT(25)
 #define DL_OPT_FLASH_COMPONENT BIT(26)
 #define DL_OPT_HEALTH_REPORTER_NAME    BIT(27)
-#define DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD BIT(27)
-#define DL_OPT_HEALTH_REPORTER_AUTO_RECOVER    BIT(28)
+#define DL_OPT_HEALTH_REPORTER_GRACEFUL_PERIOD BIT(28)
+#define DL_OPT_HEALTH_REPORTER_AUTO_RECOVER    BIT(29)
 
 struct dl_opts {
        uint32_t present; /* flags of present items */