In osm_ucast_mgr, where osm_req_set is called for SwitchInfo,
authoreitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 7 Nov 2005 13:52:13 +0000 (13:52 +0000)
committereitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 7 Nov 2005 13:52:13 +0000 (13:52 +0000)
fix bug where it copies more memory than it should into the SMP.

While running opensm with valgrind, it was found out that there is a
problemĀ  with osm_req_set function. It clears the madw.data by size of
IB_SMP_DATA_SIZE, but the function doesn't require a payload of this
size. In osm_ucast_mgr there was a call to the function with a payload
of smaller size (for SwitchInfo).

To fix it, payload_size to the osm_req_set was added.

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@144 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/opensm/user/include/opensm/osm_req.h
ulp/opensm/user/opensm/osm_lid_mgr.c
ulp/opensm/user/opensm/osm_link_mgr.c
ulp/opensm/user/opensm/osm_mcast_mgr.c
ulp/opensm/user/opensm/osm_req.c
ulp/opensm/user/opensm/osm_state_mgr.c
ulp/opensm/user/opensm/osm_sw_info_rcv.c
ulp/opensm/user/opensm/osm_ucast_mgr.c

index 72e4ff0..43c3aa4 100644 (file)
@@ -305,6 +305,7 @@ osm_req_set(
        IN const osm_req_t* const p_req,
        IN const osm_dr_path_t* const p_path,
        IN const uint8_t* const p_payload,
+   IN const size_t payload_size,
        IN const uint16_t attr_id,
        IN const uint32_t attr_mod,
        IN const cl_disp_msgid_t err_msg,
@@ -320,6 +321,9 @@ osm_req_set(
 *      p_payload
 *              [in] Pointer to the SMP payload to send.
 *
+*  payload_size
+*              [in] The size of the payload to be copied to the SMP data field.
+*
 *      attr_id
 *              [in] Attribute ID to request.
 *
index c1042af..f06fae3 100644 (file)
@@ -1151,6 +1151,7 @@ __osm_lid_mgr_set_physp_pi(
     status = osm_req_set( p_mgr->p_req,
                           osm_physp_get_dr_path_ptr( p_physp ),
                           payload,
+                          sizeof(payload),
                           IB_MAD_ATTR_PORT_INFO,
                           cl_hton32(osm_physp_get_port_num( p_physp )),
                           CL_DISP_MSGID_NONE,
index 469c591..cf99298 100644 (file)
@@ -352,6 +352,7 @@ osm_link_mgr_set_physp_pi(
     status = osm_req_set( p_mgr->p_req,
                           osm_physp_get_dr_path_ptr( p_physp ),
                           payload,
+                          sizeof(payload),
                           IB_MAD_ATTR_PORT_INFO,
                           cl_hton32(port_num),
                           CL_DISP_MSGID_NONE,
index b152fc3..4401c96 100644 (file)
@@ -485,6 +485,7 @@ __osm_mcast_mgr_set_tbl(
     status = osm_req_set( p_mgr->p_req,
                           p_path,
                           (void*)block,
+                          sizeof(block),
                           IB_MAD_ATTR_MCAST_FWD_TBL,
                           cl_hton32( block_id_ho ),
                           CL_DISP_MSGID_NONE,
index 908bb9f..7306a9d 100644 (file)
@@ -207,6 +207,7 @@ osm_req_set(
   IN const osm_req_t* const p_req,
   IN const osm_dr_path_t* const p_path,
   IN const uint8_t* const p_payload,
+  IN const size_t payload_size,
   IN const uint16_t attr_id,
   IN const uint32_t attr_mod,
   IN const cl_disp_msgid_t err_msg,
@@ -283,7 +284,7 @@ osm_req_set(
     p_madw->context = *p_context;
 
   cl_memcpy( osm_madw_get_smp_ptr( p_madw )->data,
-             p_payload, IB_SMP_DATA_SIZE );
+             p_payload, payload_size );
 
   osm_vl15_post( p_req->p_vl15, p_madw );
 
index df29764..3d94c45 100644 (file)
@@ -1665,6 +1665,7 @@ __osm_state_mgr_send_handover(
    status = osm_req_set( p_mgr->p_req,
                          osm_physp_get_dr_path_ptr
                          ( osm_port_get_default_phys_ptr( p_port ) ), payload,
+                         sizeof(payload),
                          IB_MAD_ATTR_SM_INFO, IB_SMINFO_ATTR_MOD_HANDOVER,
                          CL_DISP_MSGID_NONE, &context );
 
index 5ac945d..51762ae 100644 (file)
@@ -81,6 +81,7 @@ __osm_si_rcv_clear_sc_bit(
   status = osm_req_set( p_rcv->p_req,
                         osm_node_get_any_dr_path_ptr( p_node ),
                         payload,
+                        sizeof(payload),
                         IB_MAD_ATTR_SWITCH_INFO,
                         0,
                         CL_DISP_MSGID_NONE,
index 796eb94..2a93e9c 100644 (file)
@@ -847,6 +847,7 @@ __osm_ucast_mgr_set_table(
   status = osm_req_set( p_mgr->p_req,
                         p_path,
                         (uint8_t*)&si,
+                        sizeof(si),
                         IB_MAD_ATTR_SWITCH_INFO,
                         0,
                         CL_DISP_MSGID_NONE,
@@ -881,6 +882,7 @@ __osm_ucast_mgr_set_table(
     status = osm_req_set( p_mgr->p_req,
                           p_path,
                           block,
+                          sizeof(block),
                           IB_MAD_ATTR_LIN_FWD_TBL,
                           cl_hton32( block_id_ho ),
                           CL_DISP_MSGID_NONE,