[ofw] [patch][IPoIB_NDIS6_CM] DHCP fix- Linux interop
Alex Naslednikov
xalex at mellanox.co.il
Mon Aug 30 05:32:10 PDT 2010
The DHCP interop patch again
Index: inc/kernel/ip_packet.h
===================================================================
--- inc/kernel/ip_packet.h (revision 6071)
+++ inc/kernel/ip_packet.h (working copy)
@@ -461,6 +461,30 @@
/* Minimum DHCP size is without options (but with 4-byte magic cookie). */
#define DHCP_MIN_SIZE (sizeof(dhcp_pkt_t) + DHCP_COOKIE_SIZE - DHCP_OPTIONS_SIZE )
+// The length of IPoIB data inside CID field of DHCP packets
+static const uint8_t coIPoIB_CID_Len = 20;
+static const uint8_t coIPoIB_CID_TotalLen = 22;
+
+
+//static const uint8_t coIPoIB_HwTypeIB = 0xFF; - This definition will not work for C-code (C- C2099)
+#define coIPoIB_HwTypeIB 0xFF
+
+// The default prefix of IPoIB CID field within CID.
+static const uint8_t coIBDefaultDHCPPrefix[] = {
+ coIPoIB_HwTypeIB, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x2, 0x0,
+ 0x0, 0x2, 0xc, 0x0
+};
+
+/* The CID will contain of:
+ CID[0] = DHCP_OPT_CLIENT_ID;
+ CID[1] = coIPoIB_CID_Len;
+ CID[2:13] = coIBDefaultDHCPPrefix; (Here CID[2] always == coIPoIB_HwTypeIB)
+ CID[14:21] = GUID;
+*/
+
+
+
#include <complib/cl_packon.h>
/****s* IB Network Drivers/dhcp_pkt_t
* NAME
Index: ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp
===================================================================
--- ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp (revision 6071)
+++ ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp (working copy)
@@ -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,34 +4665,27 @@
}
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 */
- s_buf->p_send_buf->ip.hdr.length = cl_ntoh16( sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );
- s_buf->p_send_buf->ip.prot.udp.hdr.length = cl_ntoh16( sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );
-
- /* update crc in ip header */
- //if( !p_port->p_adapter->params.send_chksum_offload )
- //{ //TODO ?
- s_buf->p_send_buf->ip.hdr.chksum = 0;
- s_buf->p_send_buf->ip.hdr.chksum = ipchksum((unsigned short*) &s_buf->p_send_buf->ip.hdr, sizeof(ip_hdr_t));
- //} TODO ??
break;
/* Server messages. */
case DHCPOFFER:
+ p_ib_dhcp->htype = 0x20;
+ p_ib_dhcp->hlen = 0x8;
case DHCPACK:
case DHCPNAK:
/* don't touch server messages */
@@ -4700,7 +4696,14 @@
("Invalide message type.\n") );
return NDIS_STATUS_INVALID_DATA;
}
- /* no chksum for udp */
+
+ s_buf->p_send_buf->ip.hdr.length = cl_ntoh16( sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );
+ s_buf->p_send_buf->ip.prot.udp.hdr.length = cl_ntoh16( sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );
+ s_buf->p_send_buf->ip.hdr.chksum = 0;
+ s_buf->p_send_buf->ip.hdr.chksum = ipchksum((unsigned short*) &s_buf->p_send_buf->ip.hdr, sizeof(ip_hdr_t));
+
+
+ /* no chksum for udp, in a case when HW does not support checksum offload */
s_buf->p_send_buf->ip.prot.udp.hdr.chksum = 0;
p_desc->send_wr[0].local_ds[1].vaddr = cl_get_physaddr( s_buf->p_send_buf );
p_desc->send_wr[0].local_ds[1].length = sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t);
________________________________
From: Alex Naslednikov
Sent: Sunday, August 29, 2010 8:38 AM
To: 'Smith, Stan'; Tzachi Dar; Uri Habusha
Cc: ofw at lists.openfabrics.org
Subject: RE: [ofw][patch][IPoIB_NDIS6_CM] DHCP fix- Linux interop
I was surprised to find that this patch was never applied.
It was another functionality patch, but it is not related to this one.
I will resend the patch attached below
XaleX
________________________________
From: Smith, Stan [mailto:stan.smith at intel.com]
Sent: Friday, August 27, 2010 8:01 PM
To: Alex Naslednikov; Tzachi Dar; Uri Habusha
Cc: ofw at lists.openfabrics.org
Subject: RE: [ofw][patch][IPoIB_NDIS6_CM] DHCP fix- Linux interop
Gentlemen,
The DHCP patch for Linux interop was never applied to OpenIB SVN tree?
The patch you supplied did not apply cleanly, nor was it complete; did not compile.
Missing definitions for
coIPoIB_CID_TotalLen
coIPoIB_CID_Len
coIPoIB_HwTypeIB
coIBDefaultDHCPPrefix
Please advise.
Given the major mismatches experiences I've had of late between OpenIB SVN tree (ipoib_ndis6_cm) and your internal tree, would you please send me your ipoib_NDIS6_CM\ipoib_port.cpp file so I can verify the hand patching I've done (Uri's & your patches) plus attempt to update the SVN copy to closer match what you have (at times the patch fuzz is over 200 lines).
thanks,
stan.
________________________________
From: Alex Naslednikov [mailto:xalex at mellanox.co.il]
Sent: Thursday, August 26, 2010 6:53 AM
To: ofw at lists.openfabrics.org; Smith, Stan
Subject: [ofw][patch][IPoIB_NDIS6_CM] DHCP fix- Linux interop
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/20100830/5fcf6193/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DHCP_interop_patch.patch
Type: application/octet-stream
Size: 7152 bytes
Desc: DHCP_interop_patch.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100830/5fcf6193/attachment.obj>
More information about the ofw
mailing list