OpenSM/osm_lid_mgr.c: Fix base LID if needed to eliminate potential
infinite loop

If SMA responds with base LID of 0xffff in PortInfo, the for loops
following the call to osm_port_get_lid_range_ho would cause an infinite
loop.

Signed-off-by: Hal Rosenstock <[EMAIL PROTECTED]>

Index: opensm/osm_lid_mgr.c
===================================================================
--- opensm/osm_lid_mgr.c        (revision 9907)
+++ opensm/osm_lid_mgr.c        (working copy)
@@ -326,6 +326,16 @@ Exit:
   return( status );
 }
 
+static uint16_t
+__osm_trim_lid(
+  IN uint16_t lid )
+{
+  if ((lid > IB_LID_UCAST_END_HO) ||
+      (lid < IB_LID_UCAST_START_HO))
+    return 0;
+  return lid;
+}
+
 /**********************************************************************
  initialize the manager for a new sweep:
  scans the known persistent assignment and port_lid_tbl
@@ -427,6 +437,8 @@ __osm_lid_mgr_init_sweep(
        p_port = (osm_port_t*)cl_qmap_next( &p_port->map_item ) )
   {
     osm_port_get_lid_range_ho(p_port, &disc_min_lid, &disc_max_lid);
+    disc_min_lid = __osm_trim_lid(disc_min_lid);
+    disc_max_lid = __osm_trim_lid(disc_max_lid);
     for (lid = disc_min_lid; lid <= disc_max_lid; lid++)
       cl_ptr_vector_set(p_discovered_vec, lid, p_port );
     /* make sure the guid2lid entry is valid. If not, clean it. */
@@ -795,6 +807,8 @@ __osm_lid_mgr_cleanup_discovered_port_li
   uint16_t         max_tbl_lid = (uint16_t)(cl_ptr_vector_get_size( 
p_discovered_vec ));
 
   osm_port_get_lid_range_ho(p_port, &min_lid, &max_lid);
+  min_lid = __osm_trim_lid(min_lid);
+  max_lid = __osm_trim_lid(max_lid);
   for (lid = min_lid; lid <= max_lid; lid++)
   {
     if ((lid < max_tbl_lid ) &&




_______________________________________________
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to