Whamcloud - gitweb
LU-10391 lnet: Fix lnetctl peer set --all 91/53791/5
authorChris Horn <chris.horn@hpe.com>
Tue, 23 Jan 2024 21:54:05 +0000 (14:54 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 15 Feb 2024 06:59:15 +0000 (06:59 +0000)
When the --all flag is specified as part of the lnetctl peer set
command,  a primary NID argument is not sent to the peer doit command.
The "peer set" case uses NLM_F_REPLACE flag, so in this case the
primary NID argument is optional.

Added test cases to validate behavior of the lnetctl peer set
command.

Test-Parameters: trivial
Fixes: 8a0fdfa0b2 ("LU-10391 lnet: migrate peer NI control to Netlink")
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: I58de030b061280e837de27611bc701a3affab0f3
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53791
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c
lustre/tests/sanity-lnet.sh

index 1efd0fb..2b64450 100644 (file)
@@ -6434,7 +6434,8 @@ static int lnet_peer_ni_cmd(struct sk_buff *skb, struct genl_info *info)
                                struct nlattr *rlist;
                                int rem3;
 
-                               if (LNET_NID_IS_ANY(&pnid)) {
+                               if (!(info->nlhdr->nlmsg_flags & NLM_F_REPLACE) &&
+                                   LNET_NID_IS_ANY(&pnid)) {
                                        GENL_SET_ERR_MSG(info,
                                                         "missing required primary NID");
                                        GOTO(report_err, rc);
index 1849d27..76de6fb 100755 (executable)
@@ -3816,6 +3816,95 @@ test_500() {
 }
 run_test 500 "Check deadlock on ping target update"
 
+do_peer_set_health_test() {
+       local test_val="$1"
+       shift
+       local nid_arg="$@"
+
+       local max_hval
+
+       if [[ ${nid_arg} == --all ]]; then
+               max_hval=$($LNETCTL peer show -v 2 2>/dev/null |
+                          awk '/health value/{print $NF}' | xargs echo |
+                          sed 's/ /+/g' | bc -l)
+       else
+               max_hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
+                          awk '/health value/{print $NF}' | xargs echo |
+                          sed 's/ /+/g' | bc -l)
+       fi
+
+       (( max_hval >= 1000 )) && (( max_hval % 1000 == 0)) ||
+               error "Unexpected max health value $max_hval"
+
+       lnet_health_pre || return $?
+
+       do_lnetctl peer set --health $test_val ${nid_arg} ||
+               error "failed to set health value"
+
+       lnet_health_post || return $?
+
+       local hval
+
+       if [[ ${nid_arg} == --all ]]; then
+               hval=$($LNETCTL peer show -v 2 2>/dev/null |
+                      awk '/health value/{print $NF}' | xargs echo |
+                      sed 's/ /+/g' | bc -l)
+       else
+               hval=$($LNETCTL peer show ${nid_arg} -v 2 2>/dev/null |
+                      awk '/health value/{print $NF}' | xargs echo |
+                      sed 's/ /+/g' | bc -l)
+       fi
+
+       check_remote_health || return $?
+
+       echo "hval: $hval max_hval: $max_hval"
+       (( hval == max_hval )) || error "Failed to reset health to max"
+
+       return 0
+}
+
+test_501() {
+       reinit_dlc || return $?
+
+       setup_health_test false || return $?
+
+       $LCTL set_param debug=-1
+
+       $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
+               error "Failed to add drop rule"
+
+       local test_val
+
+       for test_val in 0 500; do
+               do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
+               do_peer_set_health_test $test_val --all || return $?
+       done
+
+       cleanup_health_test
+}
+run_test 501 "Verify lnetctl peer set --health (SR)"
+
+test_502() {
+       reinit_dlc || return $?
+
+       setup_health_test true || return $?
+
+       $LCTL set_param debug=-1
+
+       $LCTL net_drop_add -s *@tcp -d *@tcp -r 1 ||
+               error "Failed to add drop rule"
+
+       local test_val
+
+       for test_val in 0 500; do
+               do_peer_set_health_test $test_val --nid ${RNIDS[0]} || return $?
+               do_peer_set_health_test $test_val --all || return $?
+       done
+
+       cleanup_health_test
+}
+run_test 502 "Verify lnetctl peer set --health (MR)"
+
 complete_test $SECONDS
 cleanup_testsuite
 exit_status