From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ABC411A1E25 for ; Mon, 5 Sep 2016 18:02:31 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 05 Sep 2016 18:02:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,289,1470726000"; d="scan'208";a="164770602" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 05 Sep 2016 18:02:31 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 5 Sep 2016 18:02:30 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.109]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.250]) with mapi id 14.03.0248.002; Tue, 6 Sep 2016 09:02:28 +0800 From: "Fu, Siyuan" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: Santhapur Naveen , "Ye, Ting" Thread-Topic: [Patch] MdeModulePkg: Support classless IP for DHCPv4 TransmitReceive() Thread-Index: AQHR+RLT3Fv/BYJynky9aadDlSvFfKBrwnpQ Date: Tue, 6 Sep 2016 01:02:28 +0000 Message-ID: References: <1471498722-36656-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1471498722-36656-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmFmZDY4YjEtZjEyNC00MmYzLTg1Y2EtOTJkNDJlZmMxYzM0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InVcLzZ4NmViN2crWVNMRGdPaFVoTDBDak9HaHlWQ25jMlpMZEQwQlRRcU9FPSJ9 x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg: Support classless IP for DHCPv4 TransmitReceive() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Sep 2016 01:02:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan > -----Original Message----- > From: Wu, Jiaxin > Sent: Thursday, August 18, 2016 1:39 PM > To: edk2-devel@lists.01.org > Cc: Santhapur Naveen ; Ye, Ting > ; Fu, Siyuan > Subject: [Patch] MdeModulePkg: Support classless IP for DHCPv4 > TransmitReceive() >=20 > The IP address should not be treated as classful one if DHCP options > contain a classless IP with its true subnet mask. Otherwise, DHCPv4 > TransmitReceive() will failed. This real subnet mask will be parsed > and recorded in DhcpSb->Netmask. So, we need check it before get the > IP's corresponding subnet mask. >=20 > Cc: Santhapur Naveen > Cc: Ye Ting > Cc: Fu Siyuan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiaxin Wu > --- > .../Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 28 +++++++++++++++-= - > ----- > 1 file changed, 20 insertions(+), 8 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > index 4f491b4..79f7cde 100644 > --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > @@ -1,9 +1,9 @@ > /** @file > This file implement the EFI_DHCP4_PROTOCOL interface. >=20 > -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -1186,18 +1186,20 @@ Dhcp4InstanceConfigUdpIo ( > IN UDP_IO *UdpIo, > IN VOID *Context > ) > { > DHCP_PROTOCOL *Instance; > + DHCP_SERVICE *DhcpSb; > EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token; > EFI_UDP4_CONFIG_DATA UdpConfigData; > IP4_ADDR ClientAddr; > IP4_ADDR Ip; > INTN Class; > IP4_ADDR SubnetMask; >=20 > Instance =3D (DHCP_PROTOCOL *) Context; > + DhcpSb =3D Instance->Service; > Token =3D Instance->Token; >=20 > ZeroMem (&UdpConfigData, sizeof (EFI_UDP4_CONFIG_DATA)); >=20 > UdpConfigData.AcceptBroadcast =3D TRUE; > @@ -1206,14 +1208,19 @@ Dhcp4InstanceConfigUdpIo ( > UdpConfigData.DoNotFragment =3D TRUE; >=20 > ClientAddr =3D EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr); > Ip =3D HTONL (ClientAddr); > CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS)= ); > - > - Class =3D NetGetIpClass (ClientAddr); > - ASSERT (Class < IP4_ADDR_CLASSE); > - SubnetMask =3D gIp4AllMasks[Class << 3]; > + > + if (DhcpSb->Netmask =3D=3D 0) { > + Class =3D NetGetIpClass (ClientAddr); > + ASSERT (Class < IP4_ADDR_CLASSE); > + SubnetMask =3D gIp4AllMasks[Class << 3]; > + } else { > + SubnetMask =3D DhcpSb->Netmask; > + } > + > Ip =3D HTONL (SubnetMask); > CopyMem (&UdpConfigData.SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS)); >=20 > if ((Token->ListenPointCount =3D=3D 0) || (Token- > >ListenPoints[0].ListenPort =3D=3D 0)) { > UdpConfigData.StationPort =3D DHCP_CLIENT_PORT; > @@ -1574,16 +1581,21 @@ EfiDhcp4TransmitReceive ( > EndPoint.RemotePort =3D DHCP_SERVER_PORT; > } else { > EndPoint.RemotePort =3D Token->RemotePort; > } >=20 > + if (DhcpSb->Netmask =3D=3D 0) { > + Class =3D NetGetIpClass (ClientAddr); > + ASSERT (Class < IP4_ADDR_CLASSE); > + SubnetMask =3D gIp4AllMasks[Class << 3]; > + } else { > + SubnetMask =3D DhcpSb->Netmask; > + } > + > // > // Get the gateway. > // > - Class =3D NetGetIpClass (ClientAddr); > - ASSERT (Class < IP4_ADDR_CLASSE); > - SubnetMask =3D gIp4AllMasks[Class << 3]; > ZeroMem (&Gateway, sizeof (Gateway)); > if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], > SubnetMask)) { > CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof > (EFI_IPv4_ADDRESS)); > Gateway.Addr[0] =3D NTOHL (Gateway.Addr[0]); > } > -- > 1.9.5.msysgit.1