[ofw] [patch][IPoIB_NDIS6_CM] DHCP fix- Linux interop
Alex Naslednikov
xalex at mellanox.co.il
Thu Aug 26 06:52:38 PDT 2010
The format of Client Identifier Field (CID) was changed.
/* The CID will contain of:
CID[0] = DHCP_OPT_CLIENT_ID == 61
CID[1] = coIPoIB_CID_Len == 22
CID[2:13] = coIBDefaultDHCPPrefix; (Here CID[2] always == coIPoIB_HwTypeIB == 0xFF)
CID[14:21] = GUID;
*/
Signed-off by: Alexander Naslednikov (xalex at mellanox.co.il)
Index: B:/users/xalex/MLNX_WinOF-2_1_2/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp
===================================================================
--- B:/users/xalex/MLNX_WinOF-2_1_2/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp (revision 6117)
+++ B:/users/xalex/MLNX_WinOF-2_1_2/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp (revision 6118)
@@ -2727,16 +2727,22 @@
if( p_cid ) /* from client */
{
/* Validate that the length and type of the option is as required. */
- if( p_cid[1] != 21 )
+ IPOIB_PRINT(TRACE_LEVEL_VERBOSE, IPOIB_DBG_RECV,
+ ("DHCP CID received is:"));
+ for (int i=0; i < coIPoIB_CID_TotalLen; ++i) {
+ IPOIB_PRINT(TRACE_LEVEL_VERBOSE, IPOIB_DBG_RECV,
+ ("[%d] 0x%x: \n",i, p_cid[i]));
+ }
+ if( p_cid[1] != coIPoIB_CID_Len )
{
IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
- ("Client-identifier length not 21 as required.\n") );
+ ("Client-identifier length is not equal to %d as required.\n",coIPoIB_CID_Len) );
return IB_INVALID_SETTING;
}
- if( p_cid[2] != DHCP_HW_TYPE_IB )
+ if( p_cid[2] != coIPoIB_HwTypeIB)
{
IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
- ("Client-identifier type is wrong.\n") );
+ ("Client-identifier type is %d <> %d and wrong \n", p_cid[2], coIPoIB_HwTypeIB) );
return IB_INVALID_SETTING;
}
/*
@@ -2746,8 +2752,10 @@
*/
p_cid[1] = sizeof (ib_net64_t) + 1;// CID length
p_cid[2] = DHCP_HW_TYPE_ETH;// CID type
- RtlMoveMemory( &p_cid[3], &p_cid[15], sizeof (ib_net64_t) );
- RtlFillMemory(&p_cid[11], 12, 0);
+ //Copy the GUID to the 3-d byte of CID
+ RtlMoveMemory( &p_cid[3], &p_cid[coIPoIB_CID_TotalLen - sizeof (ib_net64_t)], sizeof (ib_net64_t) );
+ // Clear the rest
+ RtlFillMemory(&p_cid[3+sizeof (ib_net64_t)],coIPoIB_CID_TotalLen - 3 -sizeof (ib_net64_t), 0);
RtlCopyMemory( p_dhcp->chaddr, &p_src->mac, sizeof(p_src->mac) );
RtlFillMemory( &p_dhcp->chaddr[sizeof(p_src->mac)],
@@ -4512,7 +4520,6 @@
uint8_t *p_option, *p_cid = NULL;
uint8_t msg = 0;
size_t len;
- ib_gid_t gid;
IPOIB_ENTER( IPOIB_DBG_SEND );
@@ -4624,10 +4631,11 @@
if( p_cid[1] == HW_ADDR_LEN+1 && !cl_memcmp( &p_cid[3],
&s_buf->p_port->p_adapter->params.conf_mac.addr, HW_ADDR_LEN ) )
{
- /* Make sure there's room to extend it. 23 is the size of
- * the CID option for IPoIB.
+ ASSERT( FALSE );
+ /* Make sure there's room to extend it. 22 is the size of
+ * the CID option for IPoIB. (20 is the length, one byte for type and the second for lenght field)
*/
- if( buf_len + 23 - p_cid[1] > sizeof(dhcp_pkt_t) )
+ if( buf_len + coIPoIB_CID_TotalLen - p_cid[1] > sizeof(dhcp_pkt_t) )
{
IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
("Can't convert CID to IPoIB format.\n") );
@@ -4640,13 +4648,8 @@
p_cid += len;
p_cid[0] = DHCP_OPT_CLIENT_ID;
- p_cid[1] = 21;
- p_cid[2] = DHCP_HW_TYPE_IB;
+ p_cid[1] = coIPoIB_CID_Len;
}
- else
- {
- p_cid[2] = DHCP_HW_TYPE_IB;
- }
}
else
{
@@ -4654,7 +4657,7 @@
* Make sure there's room to extend it. 23 is the size of
* the CID option for IPoIB.
*/
- if( buf_len + 23 > sizeof(dhcp_pkt_t) )
+ if( buf_len + coIPoIB_CID_TotalLen > sizeof(dhcp_pkt_t) )
{
IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
("Can't convert CID to IPoIB format.\n") );
@@ -4662,18 +4665,19 @@
}
p_cid = p_option;
- p_option = p_cid + 23;
- p_option[0] = DHCP_OPT_END;
p_cid[0] = DHCP_OPT_CLIENT_ID;
- p_cid[1] = 21;
- p_cid[2] = DHCP_HW_TYPE_IB;
+ p_cid[1] = coIPoIB_CID_Len;
}
- CL_ASSERT( p_cid[1] == 21 );
- p_cid[23]= DHCP_OPT_END;
- ib_gid_set_default( &gid, s_buf->p_port->p_adapter->guids.port_guid.guid );
- cl_memcpy( &p_cid[7], &gid, sizeof(ib_gid_t) );
- cl_memcpy( &p_cid[3], &s_buf->p_port->ib_mgr.qpn, sizeof(s_buf->p_port->ib_mgr.qpn) );
+ CL_ASSERT( p_cid[1] == coIPoIB_CID_Len);
+ p_cid[coIPoIB_CID_TotalLen]= DHCP_OPT_END;
+
+ // Copy the default prefix for ALL DHCP messages
+ cl_memcpy( &p_cid[2], &coIBDefaultDHCPPrefix[0], sizeof coIBDefaultDHCPPrefix);
+ // Copy the GUID into the last 8 bytes of the CID field
+ cl_memcpy( &p_cid[2+ sizeof(coIBDefaultDHCPPrefix)],&s_buf->p_port->p_adapter->guids.port_guid.guid ,
+ sizeof(s_buf->p_port->p_adapter->guids.port_guid.guid) );
+
p_ib_dhcp->htype = DHCP_HW_TYPE_IB;
/* update lengths to include any change we made */
@@ -4690,6 +4694,8 @@
/* Server messages. */
case DHCPOFFER:
+ p_ib_dhcp->htype = 0x20;
+ p_ib_dhcp->hlen = 0x8;
case DHCPACK:
case DHCPNAK:
/* don't touch server messages */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100826/2a166016/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipoib_DHCP_fix_linux_interop.patch
Type: application/octet-stream
Size: 5119 bytes
Desc: ipoib_DHCP_fix_linux_interop.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100826/2a166016/attachment.obj>
More information about the ofw
mailing list