Whamcloud - gitweb
LU-18928 lnet: Fix lnetctl peer/net set help option 08/58808/4
authorChris Horn <chris.horn@hpe.com>
Tue, 15 Apr 2025 21:06:08 +0000 (15:06 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 2 May 2025 02:21:15 +0000 (02:21 +0000)
jt_set_peer/ni_value do not correctly check return value of
check_cmd() function. As a result they report an error when user
specified '-h' option.

Test-Parameters: trivial testlist=sanity-lnet
Fixes: 9b05e87248 ("LU-10391 lnet: support updating LNet local NI settings")
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: I7f55208b530a62e0c8bd14f1e50a36dba555f1a6
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58808
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetctl.c

index 343f269..2700b7e 100644 (file)
@@ -392,6 +392,14 @@ static inline void print_help(const command_t cmds[], const char *cmd_type,
        }
 }
 
+/*
+ * Perform some basic input validation.
+ * Returns:
+ *     LUSTRE_CFG_RC_BAD_PARAM: when minimum number of arguments has not been
+ *                              supplied
+ *     > 0: when '-h' or '--help' has been supplied
+ *     0: when the "check" passes and command can continue execution
+ */
 static int check_cmd(const command_t *cmd_list, const char *cmd,
                     const char *sub_cmd, const int min_args,
                     int argc, char **argv)
@@ -3533,7 +3541,7 @@ static int jt_set_ni_value(int argc, char **argv)
 {
        int rc = check_cmd(net_cmds, "net", "set", 0, argc, argv);
 
-       if (rc < 0)
+       if (rc)
                return rc;
 
        return set_value_helper(argc, argv, LNET_CMD_NETS);
@@ -3543,7 +3551,7 @@ static int jt_set_peer_ni_value(int argc, char **argv)
 {
        int rc = check_cmd(peer_cmds, "peer", "set", 0, argc, argv);
 
-       if (rc < 0)
+       if (rc)
                return rc;
 
        return set_value_helper(argc, argv, LNET_CMD_PEERS);