[ofa-general] [PATCH] opensm: remove osm_node_get_any_physp_ptr() function
Sasha Khapyorsky
sashak at voltaire.com
Sun Nov 23 01:32:08 PST 2008
The function osm_node_get_any_physp_ptr() is dangerous because it uses
potentially outdated local port number from NodeInfo. The port moving
and/or PortInfo Get failures may cause that pointer to a wrong
(unintialized) port will be returned. This patch removes this funtion
completely.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
opensm/include/opensm/osm_node.h | 36 ------------------------------------
opensm/opensm/osm_state_mgr.c | 13 +++++++++----
2 files changed, 9 insertions(+), 40 deletions(-)
diff --git a/opensm/include/opensm/osm_node.h b/opensm/include/opensm/osm_node.h
index 8d90f88..50b3598 100644
--- a/opensm/include/opensm/osm_node.h
+++ b/opensm/include/opensm/osm_node.h
@@ -236,42 +236,6 @@ static inline osm_physp_t *osm_node_get_physp_ptr(IN osm_node_t * const p_node,
* Node object
*********/
-/****f* OpenSM: Node/osm_node_get_any_physp_ptr
-* NAME
-* osm_node_get_any_physp_ptr
-*
-* DESCRIPTION
-* Returns a pointer to any valid physical port object associated
-* with this node. This operation is mostly meaningful for switches,
-* in which case all the Physical Ports share the same GUID.
-*
-* SYNOPSIS
-*/
-static inline osm_physp_t *osm_node_get_any_physp_ptr(IN const osm_node_t *
- const p_node)
-{
- CL_ASSERT(p_node);
- return ((osm_physp_t *) & p_node->
- physp_table[ib_node_info_get_local_port_num
- (&p_node->node_info)]);
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* RETURN VALUES
-* Returns a pointer to any valid physical port object associated
-* with this node. This operation is mostly meaningful for switches,
-* in which case all the Physical Ports share the same GUID.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
/****f* OpenSM: Node/osm_node_get_type
* NAME
* osm_node_get_type
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 599af0a..56212fe 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -524,7 +524,8 @@ static void __osm_state_mgr_get_node_desc(IN cl_map_item_t * const p_object,
osm_madw_context_t mad_context;
osm_node_t *const p_node = (osm_node_t *) p_object;
osm_sm_t *sm = context;
- osm_physp_t *p_physp;
+ osm_physp_t *p_physp = NULL;
+ unsigned i, num_ports;
ib_api_status_t status;
OSM_LOG_ENTER(sm->p_log);
@@ -541,10 +542,14 @@ static void __osm_state_mgr_get_node_desc(IN cl_map_item_t * const p_object,
cl_ntoh64(osm_node_get_node_guid (p_node)));
/* get a physp to request from. */
- p_physp = osm_node_get_any_physp_ptr(p_node);
- if (!osm_physp_is_valid(p_physp)) {
+ num_ports = osm_node_get_num_physp(p_node);
+ for (i = 0; i < num_ports; i++)
+ if ((p_physp = osm_node_get_physp_ptr(p_node, i)))
+ break;
+
+ if (!p_physp) {
OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 331C: "
- "Failed to get valid physical port object\n");
+ "Failed to find any valid physical port object.\n");
goto exit;
}
--
1.6.0.4.766.g6fc4a
More information about the general
mailing list