[openib-general] [PATCH] OpenSM/SA: Properly handle non base LID requests to some SA records

Hal Rosenstock halr at voltaire.com
Tue Jun 13 09:42:19 PDT 2006


OpenSM/SA: Properly handle non base LID requests to some SA records

In osm_sa_node_record.c and osm_sa_portinfo_record.c, properly handle
non base LID requests per C15-0.1.11: Query responses shall contain a
port's base LID in  any LID component of a RID. So when LMC is non 0,
the only records that appear are those with the base LID and not with
any masked LIDs. Furthermore, if a query comes in on a non base LID, the
LID in the RID returned is only with the base LID.

Also, fixed some endian issues in osm_log messages.

Note: Similar patch for other affected SA records will follow.

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: opensm/osm_sa_node_record.c
===================================================================
--- opensm/osm_sa_node_record.c	(revision 7961)
+++ opensm/osm_sa_node_record.c	(working copy)
@@ -200,12 +200,11 @@ __osm_nr_rcv_create_nr(
   uint8_t                  port_num;
   uint8_t                  num_ports;
   uint16_t                 match_lid_ho;
-  uint16_t                 lid_ho;
+  ib_net16_t               base_lid;
   ib_net16_t               base_lid_ho;
   ib_net16_t               max_lid_ho;
   uint8_t                  lmc;
   ib_net64_t               port_guid;
-  ib_api_status_t          status;
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_nr_rcv_create_nr );
 
@@ -245,7 +244,8 @@ __osm_nr_rcv_create_nr(
     if( match_port_guid && ( port_guid != match_port_guid ) )
       continue;
 
-    base_lid_ho = cl_ntoh16( osm_physp_get_base_lid( p_physp ) );
+    base_lid = osm_physp_get_base_lid( p_physp );
+    base_lid_ho = cl_ntoh16( base_lid );
     lmc = osm_physp_get_lmc( p_physp );
     max_lid_ho = (uint16_t)( base_lid_ho + (1 << lmc) - 1 );
     match_lid_ho = cl_ntoh16( match_lid );
@@ -260,29 +260,18 @@ __osm_nr_rcv_create_nr(
         osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
                  "__osm_nr_rcv_create_nr: "
                  "Comparing LID: 0x%X <= 0x%X <= 0x%X\n",
-                 cl_ntoh16( base_lid_ho ),
-                 cl_ntoh16( match_lid_ho ),
-                 cl_ntoh16( max_lid_ho )
+                 base_lid_ho, match_lid_ho, max_lid_ho
                  );
       }
 
       if( (match_lid_ho <= max_lid_ho) && (match_lid_ho >= base_lid_ho) )
       {
-        __osm_nr_rcv_new_nr( p_rcv, p_node, p_list, port_guid, match_lid );
+        __osm_nr_rcv_new_nr( p_rcv, p_node, p_list, port_guid, base_lid );
       }
     }
     else
     {
-      /*
-        For every lid value create a Node Record.
-      */
-      for( lid_ho = base_lid_ho; lid_ho <= max_lid_ho; lid_ho++ )
-      {
-        status = __osm_nr_rcv_new_nr( p_rcv, p_node, p_list,
-                                      port_guid, cl_hton16( lid_ho ) );
-        if( status != IB_SUCCESS )
-          break;
-      }
+      __osm_nr_rcv_new_nr( p_rcv, p_node, p_list, port_guid, base_lid );
     }
   }
 
Index: opensm/osm_sa_portinfo_record.c
===================================================================
--- opensm/osm_sa_portinfo_record.c	(revision 7961)
+++ opensm/osm_sa_portinfo_record.c	(working copy)
@@ -194,9 +194,9 @@ __osm_sa_pir_create(
   IN osm_pir_search_ctxt_t*   const p_ctxt )
 {
   uint8_t               lmc;
-  uint16_t              lid_ho;
   uint16_t              max_lid_ho;
   uint16_t              base_lid_ho;
+  uint16_t              match_lid_ho;
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_sa_pir_create );
 
@@ -218,17 +218,28 @@ __osm_sa_pir_create(
 
   if( p_ctxt->comp_mask & IB_PIR_COMPMASK_LID )
   {
-    __osm_pir_rcv_new_pir( p_rcv, p_physp, p_ctxt->p_list,
-                           p_ctxt->p_rcvd_rec->lid );
-  }
-  else
-  {
-    for( lid_ho = base_lid_ho; lid_ho <= max_lid_ho; lid_ho++ )
+    match_lid_ho = cl_ntoh16( p_ctxt->p_rcvd_rec->lid );
+
+    /*
+      We validate that the lid belongs to this node.
+    */
+    if( osm_log_is_active( p_rcv->p_log, OSM_LOG_DEBUG ) )
     {
-      __osm_pir_rcv_new_pir( p_rcv, p_physp, p_ctxt->p_list,
-                             cl_hton16( lid_ho ) );
+      osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
+               "__osm_sa_pir_create: "
+               "Comparing LID: 0x%X <= 0x%X <= 0x%X\n",
+               base_lid_ho, match_lid_ho, max_lid_ho
+               );
     }
+
+    if ( match_lid_ho < base_lid_ho || match_lid_ho > max_lid_ho )
+      goto Exit;
   }
+
+  __osm_pir_rcv_new_pir( p_rcv, p_physp, p_ctxt->p_list,
+                         cl_hton16( base_lid_ho ) );
+
+ Exit:
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 







More information about the general mailing list