From nobody Mon May 6 00:59:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1511159514610261.54461092877375; Sun, 19 Nov 2017 22:31:54 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5D0972034710B; Sun, 19 Nov 2017 22:27:38 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 8A8A020347105 for ; Sun, 19 Nov 2017 22:27:36 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2017 22:31:50 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.117]) by FMSMGA003.fm.intel.com with ESMTP; 19 Nov 2017 22:31:48 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,425,1505804400"; d="scan'208";a="3780607" From: fanwang2 To: edk2-devel@lists.01.org Date: Mon, 20 Nov 2017 14:31:13 +0800 Message-Id: <1511159473-7968-1-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [Patch] MdeModulePkg: Add error handling when IP address is Class E X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The Dhcp4.TransmitReceive() API should be able to use at any time according 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 the user configures with class E IP address, ASSERT will happen, we need to handle this case and return error status code. 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 | 20 +++++++++++++++++= +-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModul= ePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c index 1db4c66..65ea64e 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c @@ -1173,12 +1173,14 @@ EfiDhcp4Build ( Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instanc= e. =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 or ot= her parameters + are not valid. + @retval other Other error occurs. **/ EFI_STATUS EFIAPI Dhcp4InstanceConfigUdpIo ( IN UDP_IO *UdpIo, @@ -1216,11 +1218,25 @@ 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); + + // + // IP4_ADDR_CLASSA 1 // Deprecated + // IP4_ADDR_CLASSB 2 // Deprecated + // IP4_ADDR_CLASSC 3 // Deprecated + // IP4_ADDR_CLASSD 4 + // IP4_ADDR_CLASSE 5 + // + // Class E IP address is not supported here! + // ASSERT (Class < IP4_ADDR_CLASSE); + if (Class =3D=3D IP4_ADDR_CLASSE) { + return EFI_INVALID_PARAMETER; + } + SubnetMask =3D gIp4AllMasks[Class << 3]; } else { SubnetMask =3D DhcpSb->Netmask; } =20 --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel