From f4e23a6549ce7fd18b8f278808bfc4ab9085b8d8 Mon Sep 17 00:00:00 2001 From: Chris Horn Date: Tue, 23 Jan 2024 14:54:05 -0700 Subject: [PATCH] LU-10391 lnet: Fix lnetctl peer set --all 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 Change-Id: I58de030b061280e837de27611bc701a3affab0f3 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53791 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Frank Sehr Reviewed-by: Cyril Bordage Reviewed-by: Oleg Drokin --- lnet/lnet/api-ni.c | 3 +- lustre/tests/sanity-lnet.sh | 89 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 1efd0fb..2b64450 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -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); diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index 1849d27..76de6fb 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -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 -- 1.8.3.1