diff mbox

[opensm] osm_state_mgr.c: Improve error flow with wrong LIDs

Message ID 53AC0862.604@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock June 26, 2014, 11:47 a.m. UTC
From: Vladimir Koushnir <vladimirk@mellanox.com>

In case of errors, setting NULL in the entry of port_lid_tbl
should be done only for LIDs assigned by lid manager in
order to avoid unnecessary expansion of port_lid_tbl and
further incorrect max_lid calculation that is based
on port_lid_tbl vector size.

Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_state_mgr.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_state_mgr.c b/opensm/osm_state_mgr.c
index 11e8353..3c76f62 100644
--- a/opensm/osm_state_mgr.c
+++ b/opensm/osm_state_mgr.c
@@ -1438,7 +1438,7 @@  static void state_mgr_check_tbl_consistency(IN osm_sm_t * sm)
 			 * same for this lid. Nothing to do. */
 			continue;
 
-		if (p_port_ref == NULL)
+		if (p_port_ref == NULL) {
 			/* There is an object in the subnet database for this
 			 * lid, but no such object exists in the reference
 			 * port_list_tbl. This can occur if we wanted to assign
@@ -1455,7 +1455,8 @@  static void state_mgr_check_tbl_consistency(IN osm_sm_t * sm)
 				cl_ntoh64(osm_port_get_guid(p_port_stored)),
 				p_port_stored->p_node->print_desc,
 				p_port_stored->p_physp->port_num);
-		else if (p_port_stored == NULL)
+			cl_ptr_vector_set(p_port_lid_tbl, lid, NULL);
+		} else if (p_port_stored == NULL)
 			/* There is an object in the new database, but no
 			 * object in our subnet database. This is the matching
 			 * case of the prior check - the port still has its
@@ -1467,7 +1468,7 @@  static void state_mgr_check_tbl_consistency(IN osm_sm_t * sm)
 				cl_ntoh64(osm_port_get_guid(p_port_ref)),
 				p_port_ref->p_node->print_desc,
 				p_port_ref->p_physp->port_num, lid);
-		else
+		else {
 			/* if we reached here then p_port_stored != p_port_ref.
 			 * We were trying to set a lid to p_port_stored, but
 			 * it didn't reach it, and p_port_ref also didn't get
@@ -1483,11 +1484,9 @@  static void state_mgr_check_tbl_consistency(IN osm_sm_t * sm)
 				cl_ntoh64(osm_port_get_guid(p_port_stored)),
 				p_port_stored->p_node->print_desc,
 				p_port_stored->p_physp->port_num);
-
-		/* In any of these cases we want to set NULL in the
-		 * port_lid_tbl, since this entry is invalid. Also, make sure
-		 * we'll do another heavy sweep. */
-		cl_ptr_vector_set(p_port_lid_tbl, lid, NULL);
+			cl_ptr_vector_set(p_port_lid_tbl, lid, NULL);
+		}
+		/* Make sure we'll do another heavy sweep. */
 		sm->p_subn->subnet_initialization_error = TRUE;
 	}