]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[IPOIB] incorporate trunk commit svn.2927
authorStan Smith <stan.smith@intel.com>
Wed, 15 Sep 2010 16:52:15 +0000 (16:52 +0000)
committerStan Smith <stan.smith@intel.com>
Wed, 15 Sep 2010 16:52:15 +0000 (16:52 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@2929 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

branches/WOF2-3/ulp/ipoib/kernel/ipoib_port.c

index 4a8290bfbbdb08bea3f9cb491ee2a89ef7f82c3b..462a9c476cc0c72b1bae76e15e1d0349f4f0d0a8 100644 (file)
@@ -2365,17 +2365,24 @@ __recv_dhcp(
 \r
        if( p_cid ) /* from client */\r
        {\r
+               int i;\r
                /* Validate that the length and type of the option is as required. */\r
-               if( p_cid[1] != 21 )\r
+               IPOIB_PRINT(TRACE_LEVEL_VERBOSE, IPOIB_DBG_RECV,\r
+                                       ("DHCP CID received is:"));\r
+               for ( i=0; i < coIPoIB_CID_TotalLen; ++i) {\r
+                       IPOIB_PRINT(TRACE_LEVEL_VERBOSE, IPOIB_DBG_RECV,\r
+                               ("[%d] 0x%x: \n",i, p_cid[i]));\r
+               }\r
+               if( p_cid[1] != coIPoIB_CID_Len )\r
                {\r
                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                               ("Client-identifier length not 21 as required.\n") );\r
+                               ("Client-identifier length is not equal to %d as required.\n",coIPoIB_CID_Len) );\r
                        return IB_INVALID_SETTING;\r
                }\r
-               if( p_cid[2] != DHCP_HW_TYPE_IB )\r
+               if( p_cid[2] != coIPoIB_HwTypeIB)\r
                {\r
                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                               ("Client-identifier type is wrong.\n") );\r
+                               ("Client-identifier type is %d <> %d and wrong \n", p_cid[2], coIPoIB_HwTypeIB) );\r
                        return IB_INVALID_SETTING;\r
                }\r
                /*\r
@@ -2385,8 +2392,10 @@ __recv_dhcp(
                 */\r
                p_cid[1] =  sizeof (ib_net64_t) + 1;// CID length \r
                p_cid[2] =  DHCP_HW_TYPE_ETH;// CID type\r
-               RtlMoveMemory( &p_cid[3], &p_cid[15], sizeof (ib_net64_t) );\r
-               RtlFillMemory(&p_cid[11], 12, 0);\r
+               //Copy the GUID to the 3-d byte of CID\r
+               RtlMoveMemory( &p_cid[3], &p_cid[coIPoIB_CID_TotalLen - sizeof (ib_net64_t)], sizeof (ib_net64_t) );\r
+               // Clear the rest\r
+               RtlFillMemory(&p_cid[3+sizeof (ib_net64_t)],coIPoIB_CID_TotalLen - 3 -sizeof (ib_net64_t), 0);\r
 \r
                RtlCopyMemory( p_dhcp->chaddr, &p_src->mac, sizeof(p_src->mac) );\r
                RtlFillMemory( &p_dhcp->chaddr[sizeof(p_src->mac)],\r
@@ -3550,7 +3559,6 @@ __send_mgr_filter_dhcp(
        uint8_t                         *p_option, *p_cid = NULL;\r
        uint8_t                         msg = 0;\r
        size_t                          len;\r
-       ib_gid_t                        gid;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
@@ -3627,14 +3635,29 @@ __send_mgr_filter_dhcp(
                /* Fix up the client identifier option */\r
                if( p_cid )\r
                {\r
-                       /* do we need to replace it ?  len eq ETH MAC sz 'and' MAC is mine */\r
-                       if( p_cid[1] == HW_ADDR_LEN+1 && !cl_memcmp( &p_cid[3],\r
-                               &p_port->p_adapter->params.conf_mac.addr, HW_ADDR_LEN ) )\r
-                       {\r
-                               /* Make sure there's room to extend it.  23 is the size of\r
-                                * the CID option for IPoIB.\r
+                       /* The length of client identifier should be equal to  ETH MAC size */\r
+                       if( p_cid[1] == HW_ADDR_LEN+1 ) {\r
+\r
+                               /* MAC should be mine except the case below */\r
+                               if ( cl_memcmp( &p_cid[3], \r
+                                       &p_port->p_adapter->params.conf_mac.addr, HW_ADDR_LEN ) )\r
+                               \r
+                               {\r
+                                       /* According to http://support.microsoft.com/kb/945948\r
+                                        * This behavior occurs because the server sends a Dynamic Host Configuration Protocol (DHCP) \r
+                                        * INFORM message to the network. This DHCP INFORM message contains a MAC address that is \r
+                                        *  unrelated to the addresses to which the physical network adapters are assigned. \r
+                                        * The packets are expected. Therefore, the packets are not seen as malicious.\r
+                                        *  IPoIB will replace this demo MAC address by its GUID as for regular DHCP_INFORM packet\r
+                                        */\r
+                                        IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                                                       ("NDIS sends client message with other than mine MAC ADDRESS to search other DHCP servers\n") );\r
+                               }\r
+                       \r
+                               /* Make sure there's room to extend it.  22 is the size of\r
+                                * the CID option for IPoIB. (20 is the length, one byte for type and the second for lenght field)\r
                                 */\r
-                               if( buf_len + 23 - p_cid[1] > sizeof(dhcp_pkt_t) )\r
+                               if( buf_len + coIPoIB_CID_TotalLen - p_cid[1] > sizeof(dhcp_pkt_t) )\r
                                {\r
                                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                                                ("Can't convert CID to IPoIB format.\n") );\r
@@ -3647,14 +3670,17 @@ __send_mgr_filter_dhcp(
                                \r
                                p_cid += len;\r
                                p_cid[0] = DHCP_OPT_CLIENT_ID;\r
-                               p_cid[1] = 21;\r
-                               p_cid[2] = DHCP_HW_TYPE_IB;\r
-                       }\r
+                               p_cid[1] = coIPoIB_CID_Len;\r
+                       } \r
                        else\r
                        {\r
-                               ASSERT(FALSE); // Do we ever reach here? does it work correct?\r
-                               p_cid[2] = DHCP_HW_TYPE_IB;\r
+                               ASSERT( FALSE );\r
+                               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                                       (" Invalid Client Identifier Format\n") );\r
+                               return NDIS_STATUS_INVALID_DATA;\r
                        }\r
+                               \r
+                               \r
                }\r
                else\r
                {\r
@@ -3662,7 +3688,7 @@ __send_mgr_filter_dhcp(
                         * Make sure there's room to extend it.  23 is the size of\r
                         * the CID option for IPoIB.\r
                         */\r
-                       if( buf_len + 23 > sizeof(dhcp_pkt_t) )\r
+                       if( buf_len + coIPoIB_CID_TotalLen > sizeof(dhcp_pkt_t) )\r
                        {\r
                                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                                        ("Can't convert CID to IPoIB format.\n") );\r
@@ -3670,27 +3696,21 @@ __send_mgr_filter_dhcp(
                        }\r
 \r
                        p_cid = p_option;\r
-                       p_option = p_cid + 23;\r
-                       p_option[0] = DHCP_OPT_END;\r
                        p_cid[0] = DHCP_OPT_CLIENT_ID;\r
-                       p_cid[1] = 21;\r
-                       p_cid[2] = DHCP_HW_TYPE_IB;\r
+                       p_cid[1] = coIPoIB_CID_Len;\r
                }\r
 \r
-               CL_ASSERT( p_cid[1] == 21 );\r
-               p_cid[23]= DHCP_OPT_END;\r
-               ib_gid_set_default( &gid, p_port->p_adapter->guids.port_guid.guid );\r
-               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
+               CL_ASSERT( p_cid[1] == coIPoIB_CID_Len);\r
+               p_cid[coIPoIB_CID_TotalLen]= DHCP_OPT_END;\r
+               \r
+               // Copy the default prefix for ALL DHCP messages\r
+               cl_memcpy( &p_cid[2], &coIBDefaultDHCPPrefix[0], sizeof coIBDefaultDHCPPrefix);\r
+               // Copy the GUID into the last 8 bytes of the CID field\r
+               cl_memcpy( &p_cid[2+ sizeof(coIBDefaultDHCPPrefix)],&p_port->p_adapter->guids.port_guid.guid , \r
+                       sizeof(p_port->p_adapter->guids.port_guid.guid) );\r
+               \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
-               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
                break;\r
 \r
        /* Server messages. */\r
@@ -3705,10 +3725,21 @@ __send_mgr_filter_dhcp(
                        ("Invalide message type.\n") );\r
                return NDIS_STATUS_INVALID_DATA;\r
        }\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
+       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
        /* no chksum for udp */\r
        p_desc->p_buf->ip.prot.udp.hdr.chksum = 0;\r
        p_desc->local_ds[1].vaddr = cl_get_physaddr( p_desc->p_buf );\r
-       p_desc->local_ds[1].length = sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t);\r
+       p_desc->local_ds[1].length = sizeof(ip_hdr_t) \r
+                                                               + sizeof(udp_hdr_t) \r
+                                                               + sizeof(dhcp_pkt_t);\r
        p_desc->local_ds[1].lkey = p_port->ib_mgr.lkey;\r
        p_desc->wr.num_ds = 2;\r
        IPOIB_EXIT( IPOIB_DBG_SEND );\r