<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876"></HEAD>
<BODY>
<DIV><SPAN class=480040111-15092010><FONT color=#0000ff size=2
face=Arial>Applied at 2927</FONT></SPAN></DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> Alex Naslednikov <BR><B>Sent:</B>
Wednesday, September 01, 2010 3:56 PM<BR><B>To:</B>
ofw@lists.openfabrics.org<BR><B>Subject:</B> [ofw][Patch][ipoib] DHCP fix for
ipoib (NDIS5)<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT size=2 face=Arial>This is the extension of the same patch for
IPoIB_NDIS6_CM<BR>It assumes that IPoIB_NDIS6_CM DHCP patch was previously
applied,<BR>because it assumes that changes at ip_packet.h are already
done<BR>The format of Client Identifier Field (CID) was changed.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>/* The CID will contain of: <BR> CID[0] =
DHCP_OPT_CLIENT_ID == 61<BR> CID[1] = coIPoIB_CID_Len ==
22<BR> CID[2:13] = coIBDefaultDHCPPrefix; (Here CID[2] always ==
coIPoIB_HwTypeIB == 0xFF)<BR> CID[14:21] = GUID;<BR>*/<BR>Signed-off by:
Alexander Naslednikov (xalex at mellanox.co.il)<BR>Index:
B:/users/xalex/MLNX_WinOF-2_1_2/ulp/ipoib/kernel/ipoib_port.c<BR>===================================================================<BR>---
B:/users/xalex/MLNX_WinOF-2_1_2/ulp/ipoib/kernel/ipoib_port.c (revision
6408)<BR>+++
B:/users/xalex/MLNX_WinOF-2_1_2/ulp/ipoib/kernel/ipoib_port.c (revision
6409)<BR>@@ -2370,17 +2370,24 @@<BR> <BR> if( p_cid ) /* from
client */<BR> {<BR>+ int i;<BR> /*
Validate that the length and type of the option is as required.
*/<BR>- if( p_cid[1] != 21
)<BR>+ IPOIB_PRINT(TRACE_LEVEL_VERBOSE,
IPOIB_DBG_RECV,<BR>+ ("DHCP CID received
is:"));<BR>+ for ( i=0; i < coIPoIB_CID_TotalLen; ++i)
{<BR>+ IPOIB_PRINT(TRACE_LEVEL_VERBOSE,
IPOIB_DBG_RECV,<BR>+ ("[%d] 0x%x: \n",i,
p_cid[i]));<BR>+ }<BR>+ if( p_cid[1] != coIPoIB_CID_Len
)<BR> {<BR> IPOIB_PRINT_EXIT(
TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,<BR>- ("Client-identifier length not 21
as required.\n") );<BR>+ ("Client-identifier length is
not equal to %d as required.\n",coIPoIB_CID_Len)
);<BR> return
IB_INVALID_SETTING;<BR> }<BR>- if( p_cid[2] !=
DHCP_HW_TYPE_IB )<BR>+ if( p_cid[2] !=
coIPoIB_HwTypeIB)<BR> {<BR> IPOIB_PRINT_EXIT(
TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,<BR>- ("Client-identifier type is
wrong.\n") );<BR>+ ("Client-identifier type is %d
<> %d and wrong \n", p_cid[2], coIPoIB_HwTypeIB)
);<BR> return
IB_INVALID_SETTING;<BR> }<BR> /*<BR>@@ -2390,8
+2397,10 @@<BR> */<BR> p_cid[1] =
sizeof (ib_net64_t) + 1;// CID length <BR> p_cid[2] =
DHCP_HW_TYPE_ETH;// CID type<BR>- RtlMoveMemory( &p_cid[3],
&p_cid[15], sizeof (ib_net64_t)
);<BR>- RtlFillMemory(&p_cid[11], 12, 0);<BR>+ //Copy
the GUID to the 3-d byte of CID<BR>+ RtlMoveMemory( &p_cid[3],
&p_cid[coIPoIB_CID_TotalLen - sizeof (ib_net64_t)], sizeof (ib_net64_t)
);<BR>+ // Clear the
rest<BR>+ RtlFillMemory(&p_cid[3+sizeof
(ib_net64_t)],coIPoIB_CID_TotalLen - 3 -sizeof (ib_net64_t),
0);<BR> <BR> RtlCopyMemory( p_dhcp->chaddr,
&p_src->mac, sizeof(p_src->mac) );<BR> RtlFillMemory(
&p_dhcp->chaddr[sizeof(p_src->mac)],<BR>@@ -3555,7 +3564,6
@@<BR> uint8_t *p_option, *p_cid =
NULL;<BR> uint8_t msg =
0;<BR> size_t len;<BR>- ib_gid_t gid;<BR> <BR> IPOIB_ENTER(
IPOIB_DBG_SEND );<BR> <BR>@@ -3632,14 +3640,29 @@<BR> /*
Fix up the client identifier option */<BR> if( p_cid
)<BR> {<BR>- /* do we need to replace it
? len eq ETH MAC sz 'and' MAC is mine */<BR>- if(
p_cid[1] == HW_ADDR_LEN+1 && !cl_memcmp(
&p_cid[3],<BR>- &p_port->p_adapter->params.conf_mac.addr,
HW_ADDR_LEN ) )<BR>- {<BR>- /* Make sure
there's room to extend it. 23 is the size of<BR>-
* the CID option for IPoIB.<BR>+ /* The length of client
identifier should be equal to ETH MAC size */<BR>+ if(
p_cid[1] == HW_ADDR_LEN+1 ) {<BR>+<BR>+ /* MAC should be
mine except the case below */<BR>+ if ( cl_memcmp(
&p_cid[3],
<BR>+ &p_port->p_adapter->params.conf_mac.addr,
HW_ADDR_LEN )
)<BR>+ <BR>+ {<BR>+ /*
According to <A
href="http://support.microsoft.com/kb/945948">http://support.microsoft.com/kb/945948</A><BR>+
* This behavior occurs because the server sends a Dynamic Host Configuration
Protocol (DHCP) <BR>+ * INFORM message to the
network. This DHCP INFORM message contains a MAC address that is
<BR>+ * unrelated to the addresses to which
the physical network adapters are assigned. <BR>+
* The packets are expected. Therefore, the packets are not seen as
malicious.<BR>+ * IPoIB will replace this
demo MAC address by its GUID as for regular DHCP_INFORM
packet<BR>+ */<BR>+
IPOIB_PRINT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,<BR>+ ("NDIS sends
client message with other than mine MAC ADDRESS to search other DHCP servers\n")
);<BR>+ }<BR>+ <BR>+ /*
Make sure there's room to extend it. 22 is the size
of<BR>+ * the CID option for IPoIB. (20 is the length,
one byte for type and the second for lenght
field)<BR> */<BR>- if(
buf_len + 23 - p_cid[1] > sizeof(dhcp_pkt_t)
)<BR>+ if( buf_len + coIPoIB_CID_TotalLen - p_cid[1] >
sizeof(dhcp_pkt_t)
)<BR> {<BR> IPOIB_PRINT_EXIT(
TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,<BR> ("Can't convert
CID to IPoIB format.\n") );<BR>@@ -3652,16 +3675,17
@@<BR> <BR> p_cid +=
len;<BR> p_cid[0] =
DHCP_OPT_CLIENT_ID;<BR>- p_cid[1] =
21;<BR>- p_cid[2] =
DHCP_HW_TYPE_IB;<BR>- }<BR>+ p_cid[1] =
coIPoIB_CID_Len;<BR>+ }
<BR> else<BR> {<BR>- //<BR>- //
BUGBUG:: We reach this code, need to handle it
correctly<BR>- // <BR>- p_cid[2]
= DHCP_HW_TYPE_IB;<BR>+ ASSERT( FALSE
);<BR>+ IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,<BR>+ (" Invalid Client Identifier
Format\n") );<BR>+ return
NDIS_STATUS_INVALID_DATA;<BR> }<BR>+ <BR>+ <BR> }<BR> else<BR> {<BR>@@
-3669,7 +3693,7 @@<BR> * Make sure there's room to
extend it. 23 is the size of<BR> * the CID option
for IPoIB.<BR> */<BR>- if( buf_len + 23
> sizeof(dhcp_pkt_t) )<BR>+ if( buf_len +
coIPoIB_CID_TotalLen > sizeof(dhcp_pkt_t)
)<BR> {<BR> IPOIB_PRINT_EXIT(
TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,<BR> ("Can't convert CID to
IPoIB format.\n") );<BR>@@ -3677,27 +3701,21
@@<BR> }<BR> <BR> p_cid =
p_option;<BR>- p_option = p_cid +
23;<BR>- p_option[0] =
DHCP_OPT_END;<BR> p_cid[0] =
DHCP_OPT_CLIENT_ID;<BR>- p_cid[1] =
21;<BR>- p_cid[2] =
DHCP_HW_TYPE_IB;<BR>+ p_cid[1] =
coIPoIB_CID_Len;<BR> }<BR> <BR>- CL_ASSERT(
p_cid[1] == 21 );<BR>- p_cid[23]=
DHCP_OPT_END;<BR>- ib_gid_set_default( &gid,
p_port->p_adapter->guids.port_guid.guid );<BR>- cl_memcpy(
&p_cid[7], &gid, sizeof(ib_gid_t) );<BR>- cl_memcpy(
&p_cid[3], &p_port->ib_mgr.qpn, sizeof(p_port->ib_mgr.qpn)
); <BR>+ CL_ASSERT( p_cid[1] ==
coIPoIB_CID_Len);<BR>+ p_cid[coIPoIB_CID_TotalLen]=
DHCP_OPT_END;<BR>+ <BR>+ // Copy the default prefix for
ALL DHCP messages<BR>+ cl_memcpy( &p_cid[2],
&coIBDefaultDHCPPrefix[0], sizeof coIBDefaultDHCPPrefix);<BR>+ //
Copy the GUID into the last 8 bytes of the CID field<BR>+ cl_memcpy(
&p_cid[2+
sizeof(coIBDefaultDHCPPrefix)],&p_port->p_adapter->guids.port_guid.guid
, <BR>+ sizeof(p_port->p_adapter->guids.port_guid.guid)
);<BR>+ <BR> p_ib_dhcp->htype =
DHCP_HW_TYPE_IB;<BR> <BR>- /* update lengths to include any
change we made */<BR>- p_desc->p_buf->ip.hdr.length =
cl_ntoh16( sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t)
);<BR>- p_desc->p_buf->ip.prot.udp.hdr.length = cl_ntoh16(
sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );<BR>-<BR>- /* update crc in
ip header */<BR>- p_desc->p_buf->ip.hdr.chksum =
0;<BR>- p_desc->p_buf->ip.hdr.chksum = ipchksum((unsigned
short*) &p_desc->p_buf->ip.hdr,
sizeof(ip_hdr_t));<BR> break;<BR> <BR> /*
Server messages. */<BR>@@ -3712,10 +3730,21
@@<BR> ("Invalide message type.\n")
);<BR> return
NDIS_STATUS_INVALID_DATA;<BR> }<BR>+<BR>+ /* update lengths to
include any change we made */<BR>+ p_desc->p_buf->ip.hdr.length =
cl_ntoh16( sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t)
);<BR>+ p_desc->p_buf->ip.prot.udp.hdr.length = cl_ntoh16(
sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );<BR>+<BR>+ /* update crc in ip
header */<BR>+ p_desc->p_buf->ip.hdr.chksum =
0;<BR>+ p_desc->p_buf->ip.hdr.chksum = ipchksum((unsigned short*)
&p_desc->p_buf->ip.hdr, sizeof(ip_hdr_t));<BR>+<BR> /* no
chksum for udp */<BR> p_desc->p_buf->ip.prot.udp.hdr.chksum =
0;<BR> p_desc->local_ds[1].vaddr = cl_get_physaddr(
p_desc->p_buf );<BR>- p_desc->local_ds[1].length = sizeof(ip_hdr_t)
+ sizeof(udp_hdr_t) +
sizeof(dhcp_pkt_t);<BR>+ p_desc->local_ds[1].length = sizeof(ip_hdr_t)
<BR>+ + sizeof(udp_hdr_t)
<BR>+ +
sizeof(dhcp_pkt_t);<BR> p_desc->local_ds[1].lkey =
p_port->ib_mgr.lkey;<BR> p_desc->wr.num_ds =
2;<BR> IPOIB_EXIT( IPOIB_DBG_SEND );<BR></FONT></DIV></BODY></HTML>