[ipoib] fix DHCP client id insertion.
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 10 Jul 2008 07:51:20 +0000 (07:51 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 10 Jul 2008 07:51:20 +0000 (07:51 +0000)
singed by: anatolyg@voltaire.com

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

ulp/ipoib/kernel/ipoib_port.c

index 4c2091b..bff78c3 100644 (file)
@@ -3217,6 +3217,19 @@ __send_mgr_filter_udp(
 }\r
 \r
 \r
+unsigned short ipchksum(unsigned short *ip, int len)\r
+{\r
+    unsigned long sum = 0;\r
+\r
+    len >>= 1;\r
+    while (len--) {\r
+        sum += *(ip++);\r
+        if (sum > 0xFFFF)\r
+            sum -= 0xFFFF;\r
+    }\r
+    return (unsigned short)((~sum) & 0x0000FFFF);\r
+}\r
+\r
 static NDIS_STATUS\r
 __send_mgr_filter_dhcp(\r
        IN                              ipoib_port_t* const                     p_port,\r
@@ -3318,7 +3331,7 @@ __send_mgr_filter_dhcp(
                                {\r
                                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                                                ("Can't convert CID to IPoIB format.\n") );\r
-                                       return IB_INSUFFICIENT_MEMORY;\r
+                                       return NDIS_STATUS_RESOURCES;\r
                                }\r
                                /* Move the existing options down, and add a new CID option */\r
                                len = p_option - ( p_cid + p_cid[1] + 2 );\r
@@ -3362,6 +3375,17 @@ __send_mgr_filter_dhcp(
                cl_memcpy( &p_cid[7], &gid, sizeof(ib_gid_t) );\r
                cl_memcpy( &p_cid[3], &p_port->ib_mgr.qpn, sizeof(p_port->ib_mgr.qpn) );                \r
                p_ib_dhcp->htype = DHCP_HW_TYPE_IB;\r
+\r
+               /* update lengths to include any change we made */\r
+               p_desc->p_buf->ip.hdr.length = cl_ntoh16( sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );\r
+               p_desc->p_buf->ip.prot.udp.hdr.length = cl_ntoh16( sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t) );\r
+\r
+               /* update crc in ip header */\r
+               if( !p_port->p_adapter->params.send_chksum_offload )\r
+               {\r
+                       p_desc->p_buf->ip.hdr.chksum = 0;\r
+                       p_desc->p_buf->ip.hdr.chksum = ipchksum((unsigned short*) &p_desc->p_buf->ip.hdr, sizeof(ip_hdr_t));\r
+               }\r
                break;\r
 \r
        /* Server messages. */\r