From: Chris Horn Date: Tue, 15 Apr 2025 21:06:08 +0000 (-0600) Subject: LU-18928 lnet: Fix lnetctl peer/net set help option X-Git-Tag: 2.16.55~58 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=353bf1d2c55fff8eea6ceca1ba11c64fc093a6c6;p=fs%2Flustre-release.git LU-18928 lnet: Fix lnetctl peer/net set help option 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 Change-Id: I7f55208b530a62e0c8bd14f1e50a36dba555f1a6 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58808 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lnet/utils/lnetctl.c b/lnet/utils/lnetctl.c index 343f269..2700b7e4 100644 --- a/lnet/utils/lnetctl.c +++ b/lnet/utils/lnetctl.c @@ -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);