diff mbox series

[31/40] lnet: remove crash with UDSP

Message ID 1681042400-15491-32-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: backport OpenSFS changes from March XX, 2023 | expand

Commit Message

James Simmons April 9, 2023, 12:13 p.m. UTC
From: Cyril Bordage <cbordage@whamcloud.com>

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15944
Lustre-commit: c56b9455f05f760ae ("LU-15944 lnet: remove crash with UDSP")
Signed-off-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48801
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>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/lnet/udsp.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/lnet/udsp.c b/net/lnet/lnet/udsp.c
index deaca51..eb9a614 100644
--- a/net/lnet/lnet/udsp.c
+++ b/net/lnet/lnet/udsp.c
@@ -74,13 +74,17 @@ 
  *     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
  */
@@ -536,7 +540,8 @@  enum udsp_apply {
 
 	/* 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))) {