Whamcloud - gitweb
LU-15944 lnet: remove crash with UDSP 01/48801/7
authorCyril Bordage <cbordage@whamcloud.com>
Thu, 29 Sep 2022 15:19:19 +0000 (17:19 +0200)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Mar 2023 03:28:04 +0000 (03:28 +0000)
The following sequence of commands caused a crash:
  # lnetctl udsp add --dst tcp --prio 1
  # lnetctl discover 192.168.122.60@tcp
Pointer to lnet_peer_net in udsp_info is checked before used.

Comments about syntax of "lnetctl udsp" command were updated.

Test-Parameters: trivial testlist=lnet-selftest,sanity-lnet
Signed-off-by: Cyril Bordage <cbordage@whamcloud.com>
Change-Id: Ie3ae40b184e22627655e7f3813c5d16d38a6cfb8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48801
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/udsp.c
lnet/utils/lnetctl.c
lustre/tests/sanity-lnet.sh

index bd8efda..e073d12 100644 (file)
  *     from the policy list.
  *
  *   Generally, the syntax is as follows
- *     lnetctl policy <add | del | show>
- *      --src:      ip2nets syntax specifying the local NID to match
- *      --dst:      ip2nets syntax specifying the remote NID to match
- *      --rte:      ip2nets syntax specifying the router NID to match
- *      --priority: Priority to apply to rule matches
- *      --idx:      Index of where to insert or delete the rule
- *                  By default add appends to the end of the rule list
+ *     lnetctl udsp add: add a udsp
+ *      --src: ip2nets syntax specifying the local NID to match
+ *      --dst: ip2nets syntax specifying the remote NID to match
+ *      --rte: ip2nets syntax specifying the router NID to match
+ *      --priority: priority value (0 - highest priority)
+ *      --idx: index of where to insert the rule.
+ *             By default, appends to the end of the rule list.
+ *     lnetctl udsp del: delete a udsp
+ *      --idx: index of the Policy.
+ *     lnetctl udsp show: show udsps
+ *       --idx: index of the policy to show.
  *
  * Author: Amir Shehata
  */
@@ -538,7 +542,8 @@ lnet_udsp_apply_rule_on_lpni(struct udsp_info *udi)
 
        /* check if looking for a net match */
        if (!rc &&
-           (lnet_get_list_len(&lp_match->ud_addr_range) ||
+           (!udi->udi_lpn ||
+            lnet_get_list_len(&lp_match->ud_addr_range) ||
             !cfs_match_net(udi->udi_lpn->lpn_net_id,
                           lp_match->ud_net_id.udn_net_type,
                           &lp_match->ud_net_id.udn_net_num_range))) {
index d33e386..f908cd8 100644 (file)
@@ -3171,7 +3171,7 @@ static int jt_del_udsp(int argc, char **argv)
                                idx = 0;
                        break;
                case '?':
-                       print_help(udsp_cmds, "udsp", "add");
+                       print_help(udsp_cmds, "udsp", "del");
                default:
                        return 0;
                }
index 976e3e1..ca65bba 100755 (executable)
@@ -3353,6 +3353,62 @@ test_302() {
 }
 run_test 302 "Check that peer debug info can be dumped"
 
+check_udsp_prio() {
+       local target_net="${1}"
+       local target_nid="${2}"
+       local expect_net="${3}"
+       local expect_nid="${4}"
+       local type="${5}"
+
+       declare -a nids
+       declare -a net_prios
+       declare -a nid_prios
+
+       nids=( $($LNETCTL ${type} show -v 5 | awk '/- nid:/{print $NF}' |
+                xargs echo) )
+
+       net_prios=( $($LNETCTL ${type} show -v 5 |
+                     awk '/net priority:/{print $NF}' | xargs echo) )
+
+       nid_prios=( $($LNETCTL ${type} show -v 5 |
+                     awk '/nid priority:/{print $NF}' | xargs echo) )
+
+       (( ${#nids[@]} != ${#net_prios[@]} )) &&
+               error "Wrong # net prios ${#nids[@]} != ${#net_prios[@]}"
+
+       (( ${#nids[@]} != ${#nid_prios[@]} )) &&
+               error "Wrong # nid prios ${#nids[@]} != ${#nid_prios[@]}"
+
+       local i
+
+       for ((i = 0; i < ${#nids[@]}; i++)); do
+               [[ -n ${target_net} ]] &&
+                       [[ ${nids[i]##*@} != "${target_net}" ]] &&
+                       continue
+               [[ -n ${target_nid} ]] &&
+                       [[ ${nids[i]} != "${target_nid}" ]] &&
+                       continue
+
+               echo "${nids[i]}: net_prio ${net_prios[i]} expect ${expect_net}"
+               (( net_prios[i] != expect_net )) &&
+                       error "Wrong net priority \"${net_prios[i]}\" expect ${expect_net}"
+
+               echo "${nids[i]}: nid_prio ${nid_prios[i]} expect ${expect_nid}"
+               (( nid_prios[i] != expect_nid )) &&
+                       error "Wrong nid priority \"${nid_prios[i]}\" expect ${expect_nid}"
+       done
+
+       return 0
+}
+
+check_peer_udsp_prio() {
+       check_udsp_prio "${1}" "${2}" "${3}" "${4}" "peer"
+}
+
+check_net_udsp_prio() {
+       check_udsp_prio "${1}" "${2}" "${3}" "${4}" "net"
+}
+
 test_400() {
        reinit_dlc || return $?
 
@@ -3364,6 +3420,24 @@ test_400() {
 }
 run_test 400 "Check for udsp add/delete net rule without net num"
 
+test_401() {
+       reinit_dlc || return $?
+
+       do_lnetctl net add --net ${NETTYPE} --if ${INTERFACES[0]} ||
+               error "Failed to add net"
+
+       do_lnetctl udsp add --dst ${NETTYPE} --prio 1 ||
+               error "Failed to add peer net priority rule"
+
+       do_lnetctl discover $($LCTL list_nids | head -n 1) ||
+               error "Failed to discover peer"
+
+       check_peer_udsp_prio "${NETTYPE}" "" "1" "-1"
+
+       return 0
+}
+run_test 401 "Discover peer after adding peer net UDSP rule"
+
 complete $SECONDS
 
 cleanup_testsuite