From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7FF2221CB87BF for ; Mon, 1 Jan 2018 22:19:43 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2018 22:24:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,495,1508828400"; d="scan'208";a="16821364" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 01 Jan 2018 22:24:44 -0800 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 1 Jan 2018 22:24:44 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 1 Jan 2018 22:24:43 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Tue, 2 Jan 2018 14:24:42 +0800 From: "Wu, Jiaxin" To: "Wang, Fan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" Thread-Topic: [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E Thread-Index: AQHTg3OtlazYhbqTA0av5kk3I11U3KNgHZwA Date: Tue, 2 Jan 2018 06:24:42 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274163586FF@SHSMSX103.ccr.corp.intel.com> References: <1514861087-5868-1-git-send-email-fan.wang@intel.com> In-Reply-To: <1514861087-5868-1-git-send-email-fan.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmU2YjhlN2YtMmY3My00NDc3LWIwNTMtOTE0ODI1ODMxOTcxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkMyOEpUclFBRGlId252SVBsWW9wdVFCQTh0amZyQU1JVGJIaXd5TlhRcVk9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] [Patch] MdeModulePkg: Add error handling when IP address is Class E X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 06:19:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiaxin Wu Please update the copyright before commit the patch. Thanks, Jiaxin > -----Original Message----- > From: Wang, Fan > Sent: Tuesday, January 2, 2018 10:45 AM > To: edk2-devel@lists.01.org > Cc: Wang, Fan ; Wu, Jiaxin ; Ye, > Ting ; Fu, Siyuan > Subject: [Patch] [Patch] MdeModulePkg: Add error handling when IP > address is Class E >=20 > From: Wang Fan >=20 > The Dhcp4.TransmitReceive() API should be able to use at any time accordi= ng > to UEFI spec. While in classless addressing network, the netmask must be > explicitly provided together with the station address. > But if the DHCP instance haven't be configured with a valid netmask, we > need > compute it according to the classful addressing rule. In such case, if th= e > user configures with class E IP address, ASSERT will happen, we need to > handle > this case and return error status code. >=20 > Cc: Jiaxin Wu > Cc: Ye Ting > Cc: Fu Siyuan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan > --- > MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 13 > +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > index aad6674..b95aede 100644 > --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c > @@ -1184,12 +1184,14 @@ EfiDhcp4Build ( > Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 insta= nce. >=20 > @param[in] UdpIo The UdpIo being created. > @param[in] Context Dhcp4 instance. >=20 > - @retval EFI_SUCCESS UdpIo is configured successfully. > - @retval other Other error occurs. > + @retval EFI_SUCCESS UdpIo is configured successfully. > + @retval EFI_INVALID_PARAMETER Class E IP address is not supported o= r > other parameters > + are not valid. > + @retval other Other error occurs. > **/ > EFI_STATUS > EFIAPI > Dhcp4InstanceConfigUdpIo ( > IN UDP_IO *UdpIo, > @@ -1227,11 +1229,18 @@ Dhcp4InstanceConfigUdpIo ( > // provided together with the station address. > // If the DHCP instance haven't be configured with a valid netmask, = we > could only > // compute it according to the classful addressing rule. > // > Class =3D NetGetIpClass (ClientAddr); > + // > + // Class E IP address is not supported here! > + // > ASSERT (Class < IP4_ADDR_CLASSE); > + if (Class >=3D IP4_ADDR_CLASSE) { > + return EFI_INVALID_PARAMETER; > + } > + > SubnetMask =3D gIp4AllMasks[Class << 3]; > } else { > SubnetMask =3D DhcpSb->Netmask; > } >=20 > -- > 1.9.5.msysgit.1