[openib-general] [PATCH] osm: reviewing osmtest - osmtest.c

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Wed Oct 11 01:08:28 PDT 2006


Hi Hal

This patch fixes a bunch of ignored errors in osmtest.c
(plus some cosmetics).
In particular, for some reason osmtest.c doesn't treat
IB_INVALID_PARAMETER as an error.
I couldn't find any reasonable explanation to it.
Perhaps it was usefull while writing osmtest?

Yevgeny

Signed-off-by:  Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>

Index: osmtest.c
===================================================================
--- osmtest.c	(revision 9776)
+++ osmtest.c	(working copy)
@@ -582,12 +582,9 @@ osmtest_query_res_cb( IN osmv_query_res_
 
   if( p_rec->status != IB_SUCCESS )
   {
-    if ( p_rec->status != IB_INVALID_PARAMETER )
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_query_res_cb: ERR 0003: "
-               "Error on query (%s)\n", ib_get_err_str( p_rec->status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_query_res_cb: ERR 0003: "
+             "Error on query (%s)\n", ib_get_err_str( p_rec->status ) );
   }
 
   OSM_LOG_EXIT( &p_osmt->log );
@@ -723,12 +720,9 @@ osmtest_validate_sa_class_port_info( IN 
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_validate_sa_class_port_info: ERR 0070: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_validate_sa_class_port_info: ERR 0070: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
@@ -826,12 +820,9 @@ osmtest_get_node_rec( IN osmtest_t * con
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_node_rec: ERR 0072: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_node_rec: ERR 0072: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
@@ -913,12 +904,9 @@ osmtest_get_node_rec_by_lid( IN osmtest_
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_node_rec_by_lid: ERR 0074: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_node_rec_by_lid: ERR 0074: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
@@ -1232,6 +1220,8 @@ osmtest_get_port_rec( IN osmtest_t * con
   return ( status );
 }
 
+/**********************************************************************
+ **********************************************************************/
 ib_api_status_t
 osmtest_get_port_rec_by_num( IN osmtest_t * const p_osmt,
                              IN ib_net16_t const lid,
@@ -1294,12 +1284,9 @@ osmtest_get_port_rec_by_num( IN osmtest_
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_port_rec_by_num: ERR 0078: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_port_rec_by_num: ERR 0078: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
 
     if( status == IB_REMOTE_ERROR )
     {
@@ -1611,7 +1598,6 @@ osmtest_stress_path_recs_by_guid ( IN os
       /* next one please */
       p_dst_node = ( node_t * ) cl_qmap_next( &p_dst_node->map_item );
     }
-/* } */
 
     p_src_node = ( node_t * ) cl_qmap_next( &p_src_node->map_item );
   }
@@ -1810,7 +1796,11 @@ osmtest_wrong_sm_key_ignored( IN osmtest
   req.sm_key = 9999;
   context.result.p_result_madw = NULL;
 
+  osm_log( &p_osmt->log, OSM_LOG_ERROR,
+           "osmtest_wrong_sm_key_ignored: " EXPECTING_ERRORS_START "\n" );
   status = osmv_query_sa( p_osmt->h_bind, &req );
+  osm_log( &p_osmt->log, OSM_LOG_ERROR,
+           "osmtest_wrong_sm_key_ignored: " EXPECTING_ERRORS_END "\n" );
 
   /* since we use a wrong sm_key we should get a timeout */
   if( status != IB_TIMEOUT )
@@ -2494,7 +2484,7 @@ osmtest_write_all_node_recs(
     status = osmtest_get_node_rec_by_lid( p_osmt, cl_ntoh16( lid ), &context );
     if( status != IB_SUCCESS )
     {
-      if ( (status != IB_INVALID_PARAMETER) && (status != IB_SA_MAD_STATUS_NO_RECORDS))
+      if ( status != IB_SA_MAD_STATUS_NO_RECORDS )
       {
         osm_log( &p_osmt->log, OSM_LOG_DEBUG,
                  "osmtest_write_all_node_recs: ERR 0028: "
@@ -2615,7 +2605,7 @@ osmtest_write_all_port_recs( IN osmtest_
                                             &context );
       if( status != IB_SUCCESS )
       {
-        if( (status != IB_INVALID_PARAMETER) && (status != IB_SA_MAD_STATUS_NO_RECORDS))
+        if( status != IB_SA_MAD_STATUS_NO_RECORDS )
         {
           osm_log( &p_osmt->log, OSM_LOG_ERROR,
                    "osmtest_write_all_port_recs: WRN 0122: "
@@ -2690,6 +2680,7 @@ osmtest_write_all_path_recs( IN osmtest_
   int num_recs, i;
   cl_qmap_t *p_tbl;
   node_t *p_src_node, *p_dst_node;
+  ib_api_status_t got_status = IB_SUCCESS;
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_write_all_path_recs );
 
@@ -2725,11 +2716,13 @@ osmtest_write_all_path_recs( IN osmtest_
 
       if( status != IB_SUCCESS )
       {
-        osm_log( &p_osmt->log, OSM_LOG_DEBUG,
-                 "osmtest_write_all_path_recs: WRN 0124: "
+        osm_log( &p_osmt->log, OSM_LOG_ERROR,
+                 "osmtest_write_all_path_recs: ERR 0124: "
                  "failed to get path info from LID:0x%X To LID:0x%X (%s)\n",
                  p_src_node->rec.lid, p_dst_node->rec.lid,
                  ib_get_err_str( status ) );
+        /* remember the first error status */
+        got_status = ( got_status == IB_SUCCESS ) ? status : got_status;
       }
       else
       {
@@ -2757,6 +2750,9 @@ osmtest_write_all_path_recs( IN osmtest_
     p_src_node = ( node_t * ) cl_qmap_next( &p_src_node->map_item );
   }
 
+  if ( got_status != IB_SUCCESS )
+     status = got_status;
+
   /*
    * Return the IB query MAD to the pool as necessary.
    */
@@ -4252,6 +4248,8 @@ osmtest_validate_all_node_recs( IN osmte
   return ( status );
 }
 
+/**********************************************************************
+ **********************************************************************/
 static ib_api_status_t
 osmtest_validate_all_guidinfo_recs( IN osmtest_t * const p_osmt )
 {   
@@ -4457,12 +4455,9 @@ osmtest_get_link_rec_by_lid( IN osmtest_
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_link_rec_by_lid: ERR 007B: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_link_rec_by_lid: ERR 007B: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
@@ -4546,12 +4541,9 @@ osmtest_get_guidinfo_rec_by_lid( IN osmt
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_guidinfo_rec_by_lid: ERR 007D: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_guidinfo_rec_by_lid: ERR 007D: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
@@ -4636,12 +4628,9 @@ osmtest_get_pkeytbl_rec_by_lid( IN osmte
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_pkeytbl_rec_by_lid: ERR 007F: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_pkeytbl_rec_by_lid: ERR 007F: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
@@ -4725,12 +4714,9 @@ osmtest_get_lft_rec_by_lid( IN osmtest_t
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_get_lft_rec_by_lid: ERR 008B: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_lft_rec_by_lid: ERR 008B: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
@@ -4803,12 +4789,9 @@ osmtest_sminfo_record_request(
 
   if( status != IB_SUCCESS )
   {
-    if (status != IB_INVALID_PARAMETER)
-    {
-      osm_log( &p_osmt->log, OSM_LOG_ERROR,
-               "osmtest_sminfo_record_request: ERR 008D: "
-               "ib_query failed (%s)\n", ib_get_err_str( status ) );
-    }
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_sminfo_record_request: ERR 008D: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
     if( status == IB_REMOTE_ERROR )
     {
       p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
@@ -4985,6 +4968,7 @@ osmtest_validate_single_node_rec_lid( IN
                "osmtest_validate_single_node_rec_lid: ERR 0107: " 
                "osmtest_validate_node_data failed (%s)\n",
                ib_get_err_str( status ) );
+      goto Exit;
     }
   }
 
@@ -5069,6 +5053,7 @@ osmtest_validate_single_path_rec_guid_pa
   size_t num_recs;
   osmv_query_req_t req;
   uint32_t i;
+  boolean_t got_error = FALSE;
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_validate_single_path_rec_guid_pair );
 
@@ -5146,6 +5131,7 @@ osmtest_validate_single_path_rec_guid_pa
                ", received 0x%016" PRIx64 "\n",
                cl_ntoh64( p_pair->dest_guid ),
                cl_ntoh64( p_rec->dgid.unicast.interface_id ) );
+      got_error = TRUE;
     }
 
     if( p_rec->sgid.unicast.interface_id != p_pair->src_guid )
@@ -5157,6 +5143,7 @@ osmtest_validate_single_path_rec_guid_pa
                ", received 0x%016" PRIx64 ".\n",
                cl_ntoh64( p_pair->src_guid ),
                cl_ntoh64( p_rec->sgid.unicast.interface_id ) );
+      got_error = TRUE;
     }
 
     status = osmtest_validate_path_rec( p_osmt, p_rec );
@@ -5166,10 +5153,14 @@ osmtest_validate_single_path_rec_guid_pa
                "osmtest_validate_single_path_rec_guid_pair: ERR 0114: " 
                "osmtest_validate_path_rec failed (%s)\n",
                ib_get_err_str( status ) );
+      got_error = TRUE;
     }
-    if (status != IB_SUCCESS )
+    if ( got_error || (status != IB_SUCCESS) )
     {
       osm_dump_path_record( &p_osmt->log, p_rec, OSM_LOG_VERBOSE );
+      if ( status == IB_SUCCESS )
+         status = IB_ERROR;
+      goto Exit;
     }
   }
 
@@ -5319,6 +5310,14 @@ osmtest_validate_single_node_recs( IN os
     status = osmtest_validate_single_node_rec_lid( p_osmt,
                                                    (ib_net16_t) cl_qmap_key ((cl_map_item_t*)p_node),
                                                    p_node );
+    if( status != IB_SUCCESS )
+    {
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmtest_validate_single_node_recs: ERR 011A: " 
+               "osmtest_validate_single_node_rec_lid (%s)\n",
+               ib_get_err_str( status ) );
+      goto Exit;
+    }
     cnt++;
     p_node = ( node_t * ) cl_qmap_next( &p_node->map_item );
   }
@@ -5376,6 +5375,14 @@ osmtest_validate_single_port_recs( IN os
   while( p_port != ( port_t * ) cl_qmap_end( p_port_key_tbl ) )
   {
     status = osmtest_validate_single_port_rec_lid( p_osmt, p_port );
+    if( status != IB_SUCCESS )
+    {
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmtest_validate_single_port_recs: ERR 011B: "
+               "osmtest_validate_single_port_rec_lid (%s)\n",
+               ib_get_err_str( status ) );
+      goto Exit;
+    }
     cnt++;
     p_port = ( port_t * ) cl_qmap_next( &p_port->map_item );
   }
@@ -6664,6 +6671,7 @@ osmtest_parse_port( IN osmtest_t * const
              "osmtest_parse_port: ERR 0126: " 
              "LID must be specified for defined ports\n" );
     port_delete( p_port );
+    status = IB_ERROR;
     goto Exit;
   }
 
@@ -6689,6 +6697,7 @@ osmtest_parse_path( IN osmtest_t * const
   boolean_t done = FALSE;
   path_t *p_path;
   const osmtest_token_t *p_tok;
+  boolean_t got_error = FALSE;
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_parse_path );
 
@@ -6728,6 +6737,7 @@ osmtest_parse_path( IN osmtest_t * const
                "osmtest_parse_path: ERR 0128: " 
                "Ignoring line %u with unknown token: %s\n",
                *p_line_num, &line[offset] );
+      got_error = TRUE;
       continue;
     }
 
@@ -6833,10 +6843,16 @@ osmtest_parse_path( IN osmtest_t * const
                  "Ignoring line %u with unknown token: %s\n",
                  *p_line_num, &line[offset] );
 
+        got_error = TRUE;
         break;
     }
   }
 
+  if ( got_error ) 
+  {
+     status = IB_ERROR;
+     goto Exit;
+  }
   /*
    * Make sure the user specified enough information, then
    * add this object to the database.
@@ -6844,6 +6860,7 @@ osmtest_parse_path( IN osmtest_t * const
   if( osmtest_path_rec_kay_is_valid( p_osmt, p_path ) == FALSE )
   {
     path_delete( p_path );
+    status = IB_ERROR;
     goto Exit;
   }
 
@@ -6868,6 +6885,7 @@ osmtest_parse_link( IN osmtest_t * const
   char line[OSMTEST_MAX_LINE_LEN];
   boolean_t done = FALSE;
   const osmtest_token_t *p_tok;
+  boolean_t got_error = FALSE;
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_parse_link);
 
@@ -6904,6 +6922,7 @@ osmtest_parse_link( IN osmtest_t * const
                "osmtest_parse_link: ERR 012B: "
                "Ignoring line %u with unknown token: %s\n",
                *p_line_num, &line[offset] );
+      got_error = TRUE;
       continue;
     }
 
@@ -6934,11 +6953,14 @@ osmtest_parse_link( IN osmtest_t * const
                  "osmtest_parse_link: ERR 012C: "
                  "Ignoring line %u with unknown token: %s\n",
                  *p_line_num, &line[offset] );
-
+        got_error = TRUE;
         break;
     }
   }
 
+  if ( got_error )
+     status = IB_ERROR;
+
  Exit:
   OSM_LOG_EXIT( &p_osmt->log );
   return ( status );
@@ -6955,6 +6977,7 @@ osmtest_create_db( IN osmtest_t * const 
   char line[OSMTEST_MAX_LINE_LEN];
   uint32_t line_num = 0;
   const osmtest_token_t *p_tok;
+  boolean_t got_error = FALSE;
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_create_db );
 
@@ -6988,6 +7011,7 @@ osmtest_create_db( IN osmtest_t * const 
       osm_log( &p_osmt->log, OSM_LOG_ERROR,
                "osmtest_create_db: ERR 0131: " 
                "Ignoring line %u: %s\n", line_num, &line[offset] );
+      got_error = TRUE;
       continue;
     }
 
@@ -7023,9 +7047,13 @@ osmtest_create_db( IN osmtest_t * const 
         osm_log( &p_osmt->log, OSM_LOG_ERROR,
                  "osmtest_create_db: ERR 0132: " 
                  "Ignoring line %u: %s\n", line_num, &line[offset] );
+        got_error = TRUE;
         break;
     }
 
+    if ( got_error )
+       status = IB_ERROR;
+
     if( status != IB_SUCCESS )
     {
       osm_log( &p_osmt->log, OSM_LOG_ERROR,





More information about the general mailing list