[ofa-general] [PATCH] opensm/osm_sa_link_record: prevent potential endless recursion

Sasha Khapyorsky sashak at voltaire.com
Sat Nov 22 03:51:33 PST 2008


This patch eliminates osm_node_get_any_physp_ptr() use which can return
invalid port in case of "port moving". In this case SA LinkRecord query
issued without source and destination LIDs will cause to endless
recursion and OpenSM crash.

The problem is easily reproducible for example when two ports HCA
originally connected by one port to a fabric will be reconnected quickly
(in less than OpenSM discovery cycle time) by another port and then
(after OpenSM sweep is finished) we will run 'saquery LinkRecord'.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/opensm/osm_sa_link_record.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/opensm/opensm/osm_sa_link_record.c b/opensm/opensm/osm_sa_link_record.c
index c48df14..b92845e 100644
--- a/opensm/opensm/osm_sa_link_record.c
+++ b/opensm/opensm/osm_sa_link_record.c
@@ -342,18 +342,18 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 			p_node = (osm_node_t *)cl_qmap_head(p_node_tbl);
 
 			while (p_node != (osm_node_t *)cl_qmap_end(p_node_tbl)) {
-				/*
-				   Get only one port for each node.
-				   After the recursive call, this function will
-				   scan all the ports of this node anyway.
-				 */
-				p_src_physp = osm_node_get_any_physp_ptr(p_node);
-				p_src_port = osm_get_port_by_guid(sa->p_subn,
-				        osm_physp_get_port_guid(p_src_physp));
-				__osm_lr_rcv_get_port_links(sa, p_lr,
-							    p_src_port, NULL,
-							    comp_mask, p_list,
-							    p_req_physp);
+				num_ports = osm_node_get_num_physp(p_node);
+				for (port_num = 1; port_num < num_ports;
+				     port_num++) {
+					p_src_physp =
+					    osm_node_get_physp_ptr(p_node,
+								   port_num);
+					if (p_src_physp)
+						__osm_lr_rcv_get_physp_link
+						    (sa, p_lr, p_src_physp,
+						     NULL, comp_mask, p_list,
+						     p_req_physp);
+				}
 				p_node = (osm_node_t *) cl_qmap_next(&p_node->
 								     map_item);
 			}
-- 
1.6.0.3.517.g759a




More information about the general mailing list