From nobody Fri Dec 27 01:57:27 2024 Delivered-To: importer@patchew.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; 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 1501050522981538.7864791391103; Tue, 25 Jul 2017 23:28:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 72E5821C9127A; Tue, 25 Jul 2017 23:26:37 -0700 (PDT) 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 548CC21AEB0C0 for ; Tue, 25 Jul 2017 23:26:35 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 25 Jul 2017 23:28:37 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.131]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2017 23:28:36 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,413,1496127600"; d="scan'208";a="997280361" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Wed, 26 Jul 2017 14:28:29 +0800 Message-Id: <1501050511-16884-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1501050511-16884-1-git-send-email-jiaxin.wu@intel.com> References: <1501050511-16884-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 1/3] MdePkg: Update the comments of Ip4Config2/Ip6Config Protocol 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 , Fu Siyuan , Wu Jiaxin 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" Update the comments of Ip4Config2/Ip6Config Protocol to consistent with UEFI Spec 2.7, which provides the capability to clear specific individual data types. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdePkg/Include/Protocol/Ip4Config2.h | 17 +++++++++++------ MdePkg/Include/Protocol/Ip6Config.h | 15 ++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/MdePkg/Include/Protocol/Ip4Config2.h b/MdePkg/Include/Protocol= /Ip4Config2.h index fca2bb5..ced63cb 100644 --- a/MdePkg/Include/Protocol/Ip4Config2.h +++ b/MdePkg/Include/Protocol/Ip4Config2.h @@ -1,10 +1,10 @@ /** @file This file provides a definition of the EFI IPv4 Configuration II Protocol. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at
http://opensource.org/licenses/bsd-license.php =20 @@ -49,29 +49,35 @@ typedef enum { Ip4Config2DataTypePolicy, /// /// The station addresses set manually for the EFI IPv4 network=20 /// stack. It is only configurable when the policy is=20 /// Ip4Config2PolicyStatic. The corresponding Data is of=20 - /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. + /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. When DataSize=20 + /// is 0 and Data is NULL, the existing configuration is cleared=20 + /// from the EFI IPv4 Configuration II Protocol instance. /// Ip4Config2DataTypeManualAddress, /// /// The gateway addresses set manually for the EFI IPv4 network=20 /// stack running on the communication device this EFI IPv4=20 /// Configuration II Protocol manages. It is not configurable when=20 /// the policy is Ip4Config2PolicyDhcp. The gateway=20 /// addresses must be unicast IPv4 addresses. The corresponding=20 /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances. + /// When DataSize is 0 and Data is NULL, the existing configuration=20 + /// is cleared from the EFI IPv4 Configuration II Protocol instance. /// Ip4Config2DataTypeGateway, /// /// The DNS server list for the EFI IPv4 network stack running on=20 /// the communication device this EFI IPv4 Configuration II=20 /// Protocol manages. It is not configurable when the policy is=20 /// Ip4Config2PolicyDhcp. The DNS server addresses must be=20 /// unicast IPv4 addresses. The corresponding Data is a pointer to=20 - /// an array of EFI_IPv4_ADDRESS instances. + /// an array of EFI_IPv4_ADDRESS instances. When DataSize=20 + /// is 0 and Data is NULL, the existing configuration is cleared=20 + /// from the EFI IPv4 Configuration II Protocol instance. /// Ip4Config2DataTypeDnsServer, Ip4Config2DataTypeMaximum } EFI_IP4_CONFIG2_DATA_TYPE; =20 @@ -184,13 +190,12 @@ typedef struct { =20 @retval EFI_SUCCESS The specified configuration data for the= EFI IPv4 network stack is set=20 successfully. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is NULL. - Data is NULL. - One or more fields in Data do not match = the requirement of the data type=20 - indicated by DataType. + One or more fields in Data and DataSize = do not match the=20 + requirement of the data type indicated b= y DataType. @retval EFI_WRITE_PROTECTED The specified configuration data is read= -only or the specified configuration=20 data can not be set under the current po= licy. @retval EFI_ACCESS_DENIED Another set operation on the specified c= onfiguration data is already in process. @retval EFI_NOT_READY An asynchronous process is invoked to se= t the specified configuration data and=20 the process is not finished yet. diff --git a/MdePkg/Include/Protocol/Ip6Config.h b/MdePkg/Include/Protocol/= Ip6Config.h index b2c3be9..bcb8ba2 100644 --- a/MdePkg/Include/Protocol/Ip6Config.h +++ b/MdePkg/Include/Protocol/Ip6Config.h @@ -1,10 +1,10 @@ /** @file This file provides a definition of the EFI IPv6 Configuration Protocol. =20 -Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at
http://opensource.org/licenses/bsd-license.php =20 @@ -64,29 +64,35 @@ typedef enum { Ip6ConfigDataTypeDupAddrDetectTransmits, ///=20 /// The station addresses set manually for the EFI=20 /// IPv6 network stack. It is only configurable when the policy is=20 /// Ip6ConfigPolicyManual. The corresponding Data is a=20 - /// pointer to an array of EFI_IPv6_ADDRESS instances. + /// pointer to an array of EFI_IPv6_ADDRESS instances. When=20 + /// DataSize is 0 and Data is NULL, the existing configuration=20 + /// is cleared from the EFI IPv6 Configuration Protocol instance. ///=20 Ip6ConfigDataTypeManualAddress, ///=20 /// The gateway addresses set manually for the EFI IPv6=20 /// network stack running on the communication device this EFI=20 /// IPv6 Configuration Protocol manages. It is not configurable when=20 /// the policy is Ip6ConfigPolicyAutomatic. The gateway=20 /// addresses must be unicast IPv6 addresses. The corresponding=20 /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. + /// When DataSize is 0 and Data is NULL, the existing configuration=20 + /// is cleared from the EFI IPv6 Configuration Protocol instance. ///=20 Ip6ConfigDataTypeGateway, ///=20 /// The DNS server list for the EFI IPv6 network stack=20 /// running on the communication device this EFI IPv6=20 /// Configuration Protocol manages. It is not configurable when the=20 /// policy is Ip6ConfigPolicyAutomatic.The DNS server=20 /// addresses must be unicast IPv6 addresses. The corresponding=20 /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. + /// When DataSize is 0 and Data is NULL, the existing configuration=20 + /// is cleared from the EFI IPv6 Configuration Protocol instance. ///=20 Ip6ConfigDataTypeDnsServer, /// /// The number of this enumeration memebers. /// @@ -226,13 +232,12 @@ typedef struct { =20 @retval EFI_SUCCESS The specified configuration data for the E= FI IPv6=20 network stack is set successfully. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: - This is NULL. - - Data is NULL. - - One or more fields in Data do not match = the requirement of the=20 - data type indicated by DataType.=20 + - One or more fields in Data and DataSize = do not match the=20 + requirement of the data type indicated b= y DataType.=20 @retval EFI_WRITE_PROTECTED The specified configuration data is read-o= nly or the specified=20 configuration data can not be set under th= e current policy @retval EFI_ACCESS_DENIED Another set operation on the specified con= figuration=20 data is already in process. @retval EFI_NOT_READY An asynchronous process is invoked to set = the specified --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:57:27 2024 Delivered-To: importer@patchew.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; 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 1501050525514429.8461198719625; Tue, 25 Jul 2017 23:28:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AECA821D0B65B; Tue, 25 Jul 2017 23:26:38 -0700 (PDT) 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 116A621AEB0D9 for ; Tue, 25 Jul 2017 23:26:37 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 25 Jul 2017 23:28:39 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.131]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2017 23:28:37 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,413,1496127600"; d="scan'208";a="997280367" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Wed, 26 Jul 2017 14:28:30 +0800 Message-Id: <1501050511-16884-3-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1501050511-16884-1-git-send-email-jiaxin.wu@intel.com> References: <1501050511-16884-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 2/3] MdeModulePkg/Ip4Dxe: Support SetData interface to clear specific configuration 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 , Fu Siyuan , Wu Jiaxin 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" UEFI Spec 2.7 adds the clarification on SetData interface usage to clear sp= ecific individual data types. This patch is to support this feature. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 285 ++++++++++++++---= ---- 1 file changed, 190 insertions(+), 95 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeMo= dulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c index 3e38085..26530e3 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c @@ -1239,63 +1239,127 @@ Ip4Config2SetManualAddress ( EFI_STATUS Status; IP4_ADDR StationAddress; IP4_ADDR SubnetMask; VOID *Ptr; IP4_SERVICE *IpSb; + IP4_INTERFACE *IpIf; + IP4_ROUTE_TABLE *RouteTable; + + DataItem =3D NULL; + Status =3D EFI_SUCCESS; + Ptr =3D NULL; + IpIf =3D NULL; + RouteTable =3D NULL; =20 IpSb =3D IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); =20 ASSERT (Instance->DataItem[Ip4Config2DataTypeManualAddress].Status !=3D = EFI_NOT_READY); =20 - if (((DataSize % sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS)) !=3D 0) || (Da= taSize =3D=3D 0)) { + if ((DataSize !=3D 0) && ((DataSize % sizeof (EFI_IP4_CONFIG2_MANUAL_ADD= RESS)) !=3D 0)) { return EFI_BAD_BUFFER_SIZE; } =20 if (Instance->Policy !=3D Ip4Config2PolicyStatic) { return EFI_WRITE_PROTECTED; } =20 - NewAddress =3D *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data); + DataItem =3D &Instance->DataItem[Ip4Config2DataTypeManualAddress]; =20 - StationAddress =3D EFI_NTOHL (NewAddress.Address); - SubnetMask =3D EFI_NTOHL (NewAddress.SubnetMask); + if (Data !=3D NULL && DataSize !=3D 0) { + NewAddress =3D *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data); =20 - // - // Check whether the StationAddress/SubnetMask pair is valid. - // - if (!Ip4StationAddressValid (StationAddress, SubnetMask)) { - return EFI_INVALID_PARAMETER; - } + StationAddress =3D EFI_NTOHL (NewAddress.Address); + SubnetMask =3D EFI_NTOHL (NewAddress.SubnetMask); =20 - // - // Store the new data, and init the DataItem status to EFI_NOT_READY bec= ause - // we may have an asynchronous configuration process. - // - Ptr =3D AllocateCopyPool (DataSize, Data); - if (Ptr =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } + // + // Check whether the StationAddress/SubnetMask pair is valid. + // + if (!Ip4StationAddressValid (StationAddress, SubnetMask)) { + return EFI_INVALID_PARAMETER; + } =20 - DataItem =3D &Instance->DataItem[Ip4Config2DataTypeManualAddress]; - if (DataItem->Data.Ptr !=3D NULL) { - FreePool (DataItem->Data.Ptr); - } - =20 - DataItem->Data.Ptr =3D Ptr; - DataItem->DataSize =3D DataSize; - DataItem->Status =3D EFI_NOT_READY; + // + // Store the new data, and init the DataItem status to EFI_NOT_READY b= ecause + // we may have an asynchronous configuration process. + // + Ptr =3D AllocateCopyPool (DataSize, Data); + if (Ptr =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } =20 - IpSb->Reconfig =3D TRUE; - Status =3D Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask); + if (DataItem->Data.Ptr !=3D NULL) { + FreePool (DataItem->Data.Ptr); + } + =20 + DataItem->Data.Ptr =3D Ptr; + DataItem->DataSize =3D DataSize; + DataItem->Status =3D EFI_NOT_READY; + + IpSb->Reconfig =3D TRUE; + Status =3D Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask); =20 - DataItem->Status =3D Status;=20 + DataItem->Status =3D Status; =20 - if (EFI_ERROR (DataItem->Status) && DataItem->Status !=3D EFI_NOT_READY)= { - if (Ptr !=3D NULL) { - FreePool (Ptr); + if (EFI_ERROR (DataItem->Status) && DataItem->Status !=3D EFI_NOT_READ= Y) { + if (Ptr !=3D NULL) { + FreePool (Ptr); + } + DataItem->Data.Ptr =3D NULL;=20 + } + } else { + // + // DataSize is 0 and Data is NULL, clean up the manual address. + // + if (DataItem->Data.Ptr !=3D NULL) { + FreePool (DataItem->Data.Ptr); + } + DataItem->Data.Ptr =3D NULL; + DataItem->DataSize =3D 0; + DataItem->Status =3D EFI_NOT_FOUND; + + // + // Free the default router table and Interface, clean up the assemble = table. + // + if (IpSb->DefaultInterface !=3D NULL) { + if (IpSb->DefaultRouteTable !=3D NULL) { + Ip4FreeRouteTable (IpSb->DefaultRouteTable); + IpSb->DefaultRouteTable =3D NULL; =20 + } + + Ip4CancelReceive (IpSb->DefaultInterface); + + Ip4FreeInterface (IpSb->DefaultInterface, NULL); + IpSb->DefaultInterface =3D NULL; + } + + Ip4CleanAssembleTable (&IpSb->Assemble); + + // + // Create new default interface and route table. + // =20 + IpIf =3D Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image); + if (IpIf =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + RouteTable =3D Ip4CreateRouteTable (); + if (RouteTable =3D=3D NULL) { + Ip4FreeInterface (IpIf, NULL); + return EFI_OUT_OF_RESOURCES; + } + =20 + IpSb->DefaultInterface =3D IpIf; + InsertHeadList (&IpSb->Interfaces, &IpIf->Link); + IpSb->DefaultRouteTable =3D RouteTable; + Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb); + + // + // Reset the State to unstarted.=20 + // + if (IpSb->State =3D=3D IP4_SERVICE_CONFIGED || IpSb->State =3D=3D IP4_= SERVICE_STARTED) { + IpSb->State =3D IP4_SERVICE_UNSTARTED; } - DataItem->Data.Ptr =3D NULL;=20 } =20 return Status; } =20 @@ -1340,98 +1404,114 @@ Ip4Config2SetGateway ( UINTN NewGatewayCount; BOOLEAN OneRemoved; BOOLEAN OneAdded; VOID *Tmp; =20 - if ((DataSize % sizeof (EFI_IPv4_ADDRESS) !=3D 0) || (DataSize =3D=3D 0)= ) { + OldGateway =3D NULL; + NewGateway =3D NULL; + OneRemoved =3D FALSE; + OneAdded =3D FALSE; + Tmp =3D NULL; + + if ((DataSize !=3D 0) && (DataSize % sizeof (EFI_IPv4_ADDRESS) !=3D 0)) { return EFI_BAD_BUFFER_SIZE; } =20 if (Instance->Policy !=3D Ip4Config2PolicyStatic) { return EFI_WRITE_PROTECTED; } =20 IpSb =3D IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); =20 - NewGateway =3D (EFI_IPv4_ADDRESS *) Data; - NewGatewayCount =3D DataSize / sizeof (EFI_IPv4_ADDRESS); - for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { - CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR)); - - if ((IpSb->DefaultInterface->SubnetMask !=3D 0) &&=20 - !NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetM= ask)) { - return EFI_INVALID_PARAMETER; - } - - for (Index2 =3D Index1 + 1; Index2 < NewGatewayCount; Index2++) { - if (EFI_IP4_EQUAL (NewGateway + Index1, NewGateway + Index2)) { - return EFI_INVALID_PARAMETER; - } - } - } -=20 - DataItem =3D &Instance->DataItem[Ip4Config2DataTypeGateway]; + DataItem =3D &Instance->DataItem[Ip4Config2DataTypeGateway]; OldGateway =3D DataItem->Data.Gateway; OldGatewayCount =3D DataItem->DataSize / sizeof (EFI_IPv4_ADDRESS); - OneRemoved =3D FALSE; - OneAdded =3D FALSE; - - if (NewGatewayCount !=3D OldGatewayCount) { - Tmp =3D AllocatePool (DataSize); - if (Tmp =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - } else { - Tmp =3D NULL; - } =20 for (Index1 =3D 0; Index1 < OldGatewayCount; Index1++) { // - // Remove this route entry. + // Remove the old route entry. // CopyMem (&Gateway, OldGateway + Index1, sizeof (IP4_ADDR)); Ip4DelRoute ( IpSb->DefaultRouteTable, IP4_ALLZERO_ADDRESS, IP4_ALLZERO_ADDRESS, NTOHL (Gateway) ); OneRemoved =3D TRUE; - } =20 - for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { - CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR)); - Ip4AddRoute ( - IpSb->DefaultRouteTable, - IP4_ALLZERO_ADDRESS, - IP4_ALLZERO_ADDRESS, - NTOHL (Gateway) - ); =20 - - OneAdded =3D TRUE; - } + if (Data !=3D NULL && DataSize !=3D 0) { + NewGateway =3D (EFI_IPv4_ADDRESS *) Data; + NewGatewayCount =3D DataSize / sizeof (EFI_IPv4_ADDRESS); + for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { + CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR)); =20 + if ((IpSb->DefaultInterface->SubnetMask !=3D 0) &&=20 + !NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->Subne= tMask)) { + return EFI_INVALID_PARAMETER; + } =20 - if (!OneRemoved && !OneAdded) { - DataItem->Status =3D EFI_SUCCESS; - return EFI_ABORTED; - } else { + for (Index2 =3D Index1 + 1; Index2 < NewGatewayCount; Index2++) { + if (EFI_IP4_EQUAL (NewGateway + Index1, NewGateway + Index2)) { + return EFI_INVALID_PARAMETER; + } + } + } =20 - if (Tmp !=3D NULL) { - if (DataItem->Data.Ptr !=3D NULL) { - FreePool (DataItem->Data.Ptr); + if (NewGatewayCount !=3D OldGatewayCount) { + Tmp =3D AllocatePool (DataSize); + if (Tmp =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; } - DataItem->Data.Ptr =3D Tmp; + } else { + Tmp =3D NULL; } =20 - CopyMem (DataItem->Data.Ptr, Data, DataSize); - DataItem->DataSize =3D DataSize; - DataItem->Status =3D EFI_SUCCESS; - return EFI_SUCCESS; + for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { + // + // Add the new route entry. + // + CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR)); + Ip4AddRoute ( + IpSb->DefaultRouteTable, + IP4_ALLZERO_ADDRESS, + IP4_ALLZERO_ADDRESS, + NTOHL (Gateway) + ); =20 + + OneAdded =3D TRUE; + } + + if (!OneRemoved && !OneAdded) { + DataItem->Status =3D EFI_SUCCESS; + return EFI_ABORTED; + } else { + if (Tmp !=3D NULL) { + if (DataItem->Data.Ptr !=3D NULL) { + FreePool (DataItem->Data.Ptr); + } + DataItem->Data.Ptr =3D Tmp; + } + + CopyMem (DataItem->Data.Ptr, Data, DataSize); + DataItem->DataSize =3D DataSize; + DataItem->Status =3D EFI_SUCCESS; + } + } else { + // + // DataSize is 0 and Data is NULL, clean up the Gateway address. + // + if (DataItem->Data.Ptr !=3D NULL) { + FreePool (DataItem->Data.Ptr); + } + DataItem->Data.Ptr =3D NULL; + DataItem->DataSize =3D 0; + DataItem->Status =3D EFI_NOT_FOUND; } =20 + return EFI_SUCCESS; } =20 /** The work function is to set the DNS server list for the EFI IPv4 network=20 stack running on the communication device that this EFI_IP4_CONFIG2_PROT= OCOL=20 @@ -1459,13 +1539,15 @@ Ip4Config2SetDnsServer ( IN IP4_CONFIG2_INSTANCE *Instance, IN UINTN DataSize, IN VOID *Data ) { - IP4_CONFIG2_DATA_ITEM *Item; + EFI_STATUS Status; + IP4_CONFIG2_DATA_ITEM *Item; =20 - Item =3D NULL; + Status =3D EFI_SUCCESS; + Item =3D NULL; =20 if (Instance->Policy !=3D Ip4Config2PolicyStatic) { return EFI_WRITE_PROTECTED; } =20 @@ -1473,11 +1555,25 @@ Ip4Config2SetDnsServer ( =20 if (DATA_ATTRIB_SET (Item->Attribute, DATA_ATTRIB_VOLATILE)) { REMOVE_DATA_ATTRIB (Item->Attribute, DATA_ATTRIB_VOLATILE); } =20 - return Ip4Config2SetDnsServerWorker (Instance, DataSize, Data); + if (Data !=3D NULL && DataSize !=3D 0) { + Status =3D Ip4Config2SetDnsServerWorker (Instance, DataSize, Data); + } else { + // + // DataSize is 0 and Data is NULL, clean up the DnsServer address.=20 + // + if (Item->Data.Ptr !=3D NULL) { + FreePool (Item->Data.Ptr); + } + Item->Data.Ptr =3D NULL; + Item->DataSize =3D 0; + Item->Status =3D EFI_NOT_FOUND; + } + =20 + return Status; } =20 /** Generate the operational state of the interface this IP4 config2 instanc= e manages and output in EFI_IP4_CONFIG2_INTERFACE_INFO. @@ -1552,13 +1648,12 @@ Ip4Config2OnDhcp4Event ( =20 @retval EFI_SUCCESS The specified configuration data for the E= FI IPv6 network stack was set successfully. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: - This is NULL. - - Data is NULL. - - One or more fields in Data do not match = the requirement of the - data type indicated by DataType. + - One or more fields in Data and DataSize = do not match the=20 + requirement of the data type indicated b= y DataType. @retval EFI_WRITE_PROTECTED The specified configuration data is read-o= nly or the specified configuration data cannot be set under the= current policy. @retval EFI_ACCESS_DENIED Another set operation on the specified con= figuration data is already in process. @retval EFI_NOT_READY An asynchronous process was invoked to set= the specified @@ -1582,11 +1677,11 @@ EfiIp4Config2SetData ( EFI_TPL OldTpl; EFI_STATUS Status; IP4_CONFIG2_INSTANCE *Instance; IP4_SERVICE *IpSb; =20 - if ((This =3D=3D NULL) || (Data =3D=3D NULL)) { + if ((This =3D=3D NULL) || (Data =3D=3D NULL && DataSize !=3D 0) || (Data= !=3D NULL && DataSize =3D=3D 0)) { return EFI_INVALID_PARAMETER; } =20 if (DataType >=3D Ip4Config2DataTypeMaximum) { return EFI_UNSUPPORTED; --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:57:27 2024 Delivered-To: importer@patchew.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; 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 1501050528194564.3108409424441; Tue, 25 Jul 2017 23:28:48 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0DBF321D0DE74; Tue, 25 Jul 2017 23:26:41 -0700 (PDT) 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 0013221C91278 for ; Tue, 25 Jul 2017 23:26:38 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 25 Jul 2017 23:28:41 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.131]) by orsmga003.jf.intel.com with ESMTP; 25 Jul 2017 23:28:39 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,413,1496127600"; d="scan'208";a="997280375" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Wed, 26 Jul 2017 14:28:31 +0800 Message-Id: <1501050511-16884-4-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1501050511-16884-1-git-send-email-jiaxin.wu@intel.com> References: <1501050511-16884-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 3/3] NetworkPkg/Ip6Dxe: Support SetData interface to clear specific configuration 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 , Fu Siyuan , Wu Jiaxin 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" UEFI Spec 2.7 adds the clarification on SetData interface usage to clear sp= ecific individual data types. This patch is to support this feature. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 692 ++++++++++++++++++++++------------= ---- 1 file changed, 399 insertions(+), 293 deletions(-) diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c b/NetworkPkg/Ip6Dxe/Ip6Confi= gImpl.c index 7c7acc7..9e9dc89 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c @@ -917,254 +917,333 @@ Ip6ConfigSetManualAddress ( LIST_ENTRY *Entry2; IP6_INTERFACE *IpIf; IP6_PREFIX_LIST_ENTRY *PrefixEntry; EFI_STATUS Status; BOOLEAN IsUpdated; + LIST_ENTRY *Next; + IP6_DAD_ENTRY *DadEntry; + IP6_DELAY_JOIN_LIST *DelayNode; + + NewAddress =3D NULL; + TmpAddress =3D NULL; + CurrentAddrInfo =3D NULL; + Copy =3D NULL; + Entry =3D NULL; + Entry2 =3D NULL; + IpIf =3D NULL; + PrefixEntry =3D NULL; + Next =3D NULL; + DadEntry =3D NULL; + DelayNode =3D NULL; + Status =3D EFI_SUCCESS; =20 ASSERT (Instance->DataItem[Ip6ConfigDataTypeManualAddress].Status !=3D E= FI_NOT_READY); =20 - if (((DataSize % sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)) !=3D 0) || (Dat= aSize =3D=3D 0)) { + if ((DataSize !=3D 0) && ((DataSize % sizeof (EFI_IP6_CONFIG_MANUAL_ADDR= ESS)) !=3D 0)) { return EFI_BAD_BUFFER_SIZE; } =20 if (Instance->Policy !=3D Ip6ConfigPolicyManual) { return EFI_WRITE_PROTECTED; } =20 - NewAddressCount =3D DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); - NewAddress =3D (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data; + IpSb =3D IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance); =20 - for (Index1 =3D 0; Index1 < NewAddressCount; Index1++, NewAddress++) { + DataItem =3D &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; =20 - if (NetIp6IsLinkLocalAddr (&NewAddress->Address) || - !NetIp6IsValidUnicast (&NewAddress->Address) || - (NewAddress->PrefixLength > 128) - ) { - // - // make sure the IPv6 address is unicast and not link-local address = && - // the prefix length is valid. - // - return EFI_INVALID_PARAMETER; - } + if (Data !=3D NULL && DataSize !=3D 0) { + NewAddressCount =3D DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); + NewAddress =3D (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data; =20 - TmpAddress =3D NewAddress + 1; - for (Index2 =3D Index1 + 1; Index2 < NewAddressCount; Index2++, TmpAdd= ress++) { - // - // Any two addresses in the array can't be equal. - // - if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) { + for (Index1 =3D 0; Index1 < NewAddressCount; Index1++, NewAddress++) { =20 + if (NetIp6IsLinkLocalAddr (&NewAddress->Address) || + !NetIp6IsValidUnicast (&NewAddress->Address) || + (NewAddress->PrefixLength > 128) + ) { + // + // make sure the IPv6 address is unicast and not link-local addres= s && + // the prefix length is valid. + // return EFI_INVALID_PARAMETER; } + + TmpAddress =3D NewAddress + 1; + for (Index2 =3D Index1 + 1; Index2 < NewAddressCount; Index2++, TmpA= ddress++) { + // + // Any two addresses in the array can't be equal. + // + if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) { + + return EFI_INVALID_PARAMETER; + } + } } - } =20 - IpSb =3D IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance); + // + // Build the current source address list. + // + InitializeListHead (&CurrentSourceList); + CurrentSourceCount =3D 0; =20 - // - // Build the current source address list. - // - InitializeListHead (&CurrentSourceList); - CurrentSourceCount =3D 0; + NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { + IpIf =3D NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INT= ERFACE_SIGNATURE); =20 - NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { - IpIf =3D NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INTER= FACE_SIGNATURE); + NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) { + CurrentAddrInfo =3D NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_IN= FO, Link, IP6_ADDR_INFO_SIGNATURE); =20 - NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) { - CurrentAddrInfo =3D NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_INFO= , Link, IP6_ADDR_INFO_SIGNATURE); + Copy =3D AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), C= urrentAddrInfo); + if (Copy =3D=3D NULL) { + break; + } =20 - Copy =3D AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), Cur= rentAddrInfo); - if (Copy =3D=3D NULL) { - break; + InsertTailList (&CurrentSourceList, &Copy->Link); + CurrentSourceCount++; } + } + + // + // Update the value... a long journey starts + // + NewAddress =3D AllocateCopyPool (DataSize, Data); + if (NewAddress =3D=3D NULL) { + Ip6RemoveAddr (NULL, &CurrentSourceList, &CurrentSourceCount, NULL, = 0); =20 - InsertTailList (&CurrentSourceList, &Copy->Link); - CurrentSourceCount++; + return EFI_OUT_OF_RESOURCES; } - } =20 - // - // Update the value... a long journey starts - // - NewAddress =3D AllocateCopyPool (DataSize, Data); - if (NewAddress =3D=3D NULL) { - Ip6RemoveAddr (NULL, &CurrentSourceList, &CurrentSourceCount, NULL, 0); + // + // Store the new data, and init the DataItem status to EFI_NOT_READY b= ecause + // we may have an asynchronous configuration process. + // + if (DataItem->Data.Ptr !=3D NULL) { + FreePool (DataItem->Data.Ptr); + } + DataItem->Data.Ptr =3D NewAddress; + DataItem->DataSize =3D DataSize; + DataItem->Status =3D EFI_NOT_READY; =20 - return EFI_OUT_OF_RESOURCES; - } + // + // Trigger DAD, it's an asynchronous process. + // + IsUpdated =3D FALSE; =20 - // - // Store the new data, and init the DataItem status to EFI_NOT_READY bec= ause - // we may have an asynchronous configuration process. - // - DataItem =3D &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; - if (DataItem->Data.Ptr !=3D NULL) { - FreePool (DataItem->Data.Ptr); - } - DataItem->Data.Ptr =3D NewAddress; - DataItem->DataSize =3D DataSize; - DataItem->Status =3D EFI_NOT_READY; + for (Index1 =3D 0; Index1 < NewAddressCount; Index1++, NewAddress++) { + if (Ip6IsOneOfSetAddress (IpSb, &NewAddress->Address, NULL, &Current= AddrInfo)) { + ASSERT (CurrentAddrInfo !=3D NULL); + // + // Remove this already existing source address from the CurrentSou= rceList + // built before. + // + Ip6RemoveAddr ( + NULL, + &CurrentSourceList, + &CurrentSourceCount, + &CurrentAddrInfo->Address, + 128 + ); =20 - // - // Trigger DAD, it's an asynchronous process. - // - IsUpdated =3D FALSE; + // + // If the new address's prefix length is not specified, just use t= he previous configured + // prefix length for this address. + // + if (NewAddress->PrefixLength =3D=3D 0) { + NewAddress->PrefixLength =3D CurrentAddrInfo->PrefixLength; + } =20 - for (Index1 =3D 0; Index1 < NewAddressCount; Index1++, NewAddress++) { - if (Ip6IsOneOfSetAddress (IpSb, &NewAddress->Address, NULL, &CurrentAd= drInfo)) { - ASSERT (CurrentAddrInfo !=3D NULL); - // - // Remove this already existing source address from the CurrentSourc= eList - // built before. - // - Ip6RemoveAddr ( - NULL, - &CurrentSourceList, - &CurrentSourceCount, - &CurrentAddrInfo->Address, - 128 - ); + // + // This manual address is already in use, see whether prefix lengt= h is changed. + // + if (NewAddress->PrefixLength !=3D CurrentAddrInfo->PrefixLength) { + // + // Remove the on-link prefix table, the route entry will be remo= ved + // implicitly. + // + PrefixEntry =3D Ip6FindPrefixListEntry ( + IpSb, + TRUE, + CurrentAddrInfo->PrefixLength, + &CurrentAddrInfo->Address + ); + if (PrefixEntry !=3D NULL) { + Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); + } =20 - // - // If the new address's prefix length is not specified, just use the= previous configured - // prefix length for this address. - // - if (NewAddress->PrefixLength =3D=3D 0) { - NewAddress->PrefixLength =3D CurrentAddrInfo->PrefixLength; - } + // + // Save the prefix length. + // + CurrentAddrInfo->PrefixLength =3D NewAddress->PrefixLength; + IsUpdated =3D TRUE; + } =20 - // - // This manual address is already in use, see whether prefix length = is changed. - // - if (NewAddress->PrefixLength !=3D CurrentAddrInfo->PrefixLength) { // - // Remove the on-link prefix table, the route entry will be removed - // implicitly. + // create a new on-link prefix entry. // PrefixEntry =3D Ip6FindPrefixListEntry ( IpSb, TRUE, - CurrentAddrInfo->PrefixLength, - &CurrentAddrInfo->Address + NewAddress->PrefixLength, + &NewAddress->Address ); - if (PrefixEntry !=3D NULL) { - Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); + if (PrefixEntry =3D=3D NULL) { + Ip6CreatePrefixListEntry ( + IpSb, + TRUE, + (UINT32) IP6_INFINIT_LIFETIME, + (UINT32) IP6_INFINIT_LIFETIME, + NewAddress->PrefixLength, + &NewAddress->Address + ); } =20 + CurrentAddrInfo->IsAnycast =3D NewAddress->IsAnycast; // - // Save the prefix length. + // Artificially mark this address passed DAD be'coz it is already = in use. + // + Ip6ManualAddrDadCallback (TRUE, &NewAddress->Address, Instance); + } else { + // + // A new address. // - CurrentAddrInfo->PrefixLength =3D NewAddress->PrefixLength; IsUpdated =3D TRUE; + + // + // Set the new address, this will trigger DAD and activate the add= ress if + // DAD succeeds. + // + Ip6SetAddress ( + IpSb->DefaultInterface, + &NewAddress->Address, + NewAddress->IsAnycast, + NewAddress->PrefixLength, + (UINT32) IP6_INFINIT_LIFETIME, + (UINT32) IP6_INFINIT_LIFETIME, + Ip6ManualAddrDadCallback, + Instance + ); } + } + + // + // Check the CurrentSourceList, it now contains those addresses curren= tly in + // use and will be removed. + // + IpIf =3D IpSb->DefaultInterface; + + while (!IsListEmpty (&CurrentSourceList)) { + IsUpdated =3D TRUE; + + CurrentAddrInfo =3D NET_LIST_HEAD (&CurrentSourceList, IP6_ADDRESS_I= NFO, Link); =20 // - // create a new on-link prefix entry. + // This local address is going to be removed, the IP instances that = are + // currently using it will be destroyed. + // + Ip6RemoveAddr ( + IpSb, + &IpIf->AddressList, + &IpIf->AddressCount, + &CurrentAddrInfo->Address, + 128 + ); + + // + // Remove the on-link prefix table, the route entry will be removed + // implicitly. // PrefixEntry =3D Ip6FindPrefixListEntry ( IpSb, TRUE, - NewAddress->PrefixLength, - &NewAddress->Address + CurrentAddrInfo->PrefixLength, + &CurrentAddrInfo->Address ); - if (PrefixEntry =3D=3D NULL) { - Ip6CreatePrefixListEntry ( - IpSb, - TRUE, - (UINT32) IP6_INFINIT_LIFETIME, - (UINT32) IP6_INFINIT_LIFETIME, - NewAddress->PrefixLength, - &NewAddress->Address - ); + if (PrefixEntry !=3D NULL) { + Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); } =20 - CurrentAddrInfo->IsAnycast =3D NewAddress->IsAnycast; - // - // Artificially mark this address passed DAD be'coz it is already in= use. - // - Ip6ManualAddrDadCallback (TRUE, &NewAddress->Address, Instance); + RemoveEntryList (&CurrentAddrInfo->Link); + FreePool (CurrentAddrInfo); + } + + if (IsUpdated) { + if (DataItem->Status =3D=3D EFI_NOT_READY) { + // + // If DAD is disabled on this interface, the configuration process= is + // actually synchronous, and the data item's status will be change= d to + // the final status before we reach here, just check it. + // + Status =3D EFI_NOT_READY; + } else { + Status =3D EFI_SUCCESS; + } } else { // - // A new address. + // No update is taken, reset the status to success and return EFI_AB= ORTED. // - IsUpdated =3D TRUE; + DataItem->Status =3D EFI_SUCCESS; + Status =3D EFI_ABORTED; + } + } else { + // + // DataSize is 0 and Data is NULL, clean up the manual address. + // + if (DataItem->Data.Ptr !=3D NULL) { + FreePool (DataItem->Data.Ptr); + } + DataItem->Data.Ptr =3D NULL; + DataItem->DataSize =3D 0; + DataItem->Status =3D EFI_NOT_FOUND; =20 - // - // Set the new address, this will trigger DAD and activate the addre= ss if - // DAD succeeds. - // - Ip6SetAddress ( - IpSb->DefaultInterface, - &NewAddress->Address, - NewAddress->IsAnycast, - NewAddress->PrefixLength, + Ip6CleanDefaultRouterList (IpSb); + Ip6CleanPrefixListTable (IpSb, &IpSb->OnlinkPrefix); + Ip6CleanPrefixListTable (IpSb, &IpSb->AutonomousPrefix); + Ip6CleanAssembleTable (&IpSb->Assemble); + + if (IpSb->LinkLocalOk) { + Ip6CreatePrefixListEntry ( + IpSb, + TRUE, (UINT32) IP6_INFINIT_LIFETIME, (UINT32) IP6_INFINIT_LIFETIME, - Ip6ManualAddrDadCallback, - Instance + IP6_LINK_LOCAL_PREFIX_LENGTH, + &IpSb->LinkLocalAddr ); } - } =20 - // - // Check the CurrentSourceList, it now contains those addresses currentl= y in - // use and will be removed. - // - IpIf =3D IpSb->DefaultInterface; - - while (!IsListEmpty (&CurrentSourceList)) { - IsUpdated =3D TRUE; - - CurrentAddrInfo =3D NET_LIST_HEAD (&CurrentSourceList, IP6_ADDRESS_INF= O, Link); - - // - // This local address is going to be removed, the IP instances that are - // currently using it will be destroyed. - // Ip6RemoveAddr ( IpSb, - &IpIf->AddressList, - &IpIf->AddressCount, - &CurrentAddrInfo->Address, - 128 + &IpSb->DefaultInterface->AddressList, + &IpSb->DefaultInterface->AddressCount, + NULL, + 0 ); =20 - // - // Remove the on-link prefix table, the route entry will be removed - // implicitly. - // - PrefixEntry =3D Ip6FindPrefixListEntry ( - IpSb, - TRUE, - CurrentAddrInfo->PrefixLength, - &CurrentAddrInfo->Address - ); - if (PrefixEntry !=3D NULL) { - Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); - } - - RemoveEntryList (&CurrentAddrInfo->Link); - FreePool (CurrentAddrInfo); - } - - if (IsUpdated) { - if (DataItem->Status =3D=3D EFI_NOT_READY) { + NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { // - // If DAD is disabled on this interface, the configuration process is - // actually synchronous, and the data item's status will be changed = to - // the final status before we reach here, just check it. + // Remove all pending delay node and DAD entries for the global addr= esses. // - Status =3D EFI_NOT_READY; - } else { - Status =3D EFI_SUCCESS; + IpIf =3D NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INT= ERFACE_SIGNATURE); + + NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DelayJoinList) { + DelayNode =3D NET_LIST_USER_STRUCT (Entry2, IP6_DELAY_JOIN_LIST, L= ink); + if (!NetIp6IsLinkLocalAddr (&DelayNode->AddressInfo->Address)) { + RemoveEntryList (&DelayNode->Link); + FreePool (DelayNode); + } + } + + NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DupAddrDetectList) { + DadEntry =3D NET_LIST_USER_STRUCT_S (Entry2, IP6_DAD_ENTRY, Link, = IP6_DAD_ENTRY_SIGNATURE); + + if (!NetIp6IsLinkLocalAddr (&DadEntry->AddressInfo->Address)) { + // + // Fail this DAD entry if the address is not link-local. + // + Ip6OnDADFinished (FALSE, IpIf, DadEntry); + } + } } - } else { - // - // No update is taken, reset the status to success and return EFI_ABOR= TED. - // - DataItem->Status =3D EFI_SUCCESS; - Status =3D EFI_ABORTED; } =20 return Status; } =20 @@ -1208,98 +1287,107 @@ Ip6ConfigSetGateway ( BOOLEAN OneAdded; IP6_SERVICE *IpSb; IP6_DEFAULT_ROUTER *DefaultRouter; VOID *Tmp; =20 - if ((DataSize % sizeof (EFI_IPv6_ADDRESS) !=3D 0) || (DataSize =3D=3D 0)= ) { + OldGateway =3D NULL; + NewGateway =3D NULL; + Item =3D NULL; + DefaultRouter =3D NULL; + Tmp =3D NULL; + OneRemoved =3D FALSE; + OneAdded =3D FALSE; + + if ((DataSize !=3D 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) !=3D 0)) { return EFI_BAD_BUFFER_SIZE; } =20 if (Instance->Policy !=3D Ip6ConfigPolicyManual) { return EFI_WRITE_PROTECTED; } =20 - NewGateway =3D (EFI_IPv6_ADDRESS *) Data; - NewGatewayCount =3D DataSize / sizeof (EFI_IPv6_ADDRESS); - for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { - - if (!NetIp6IsValidUnicast (NewGateway + Index1)) { - - return EFI_INVALID_PARAMETER; - } - - for (Index2 =3D Index1 + 1; Index2 < NewGatewayCount; Index2++) { - if (EFI_IP6_EQUAL (NewGateway + Index1, NewGateway + Index2)) { - return EFI_INVALID_PARAMETER; - } - } - } - IpSb =3D IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance); Item =3D &Instance->DataItem[Ip6ConfigDataTypeGateway]; OldGateway =3D Item->Data.Gateway; OldGatewayCount =3D Item->DataSize / sizeof (EFI_IPv6_ADDRESS); - OneRemoved =3D FALSE; - OneAdded =3D FALSE; - - if (NewGatewayCount !=3D OldGatewayCount) { - Tmp =3D AllocatePool (DataSize); - if (Tmp =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - } else { - Tmp =3D NULL; - } =20 for (Index1 =3D 0; Index1 < OldGatewayCount; Index1++) { // - // Find the gateways that are no long in the new setting and remove th= em. + // Remove this default router. // - for (Index2 =3D 0; Index2 < NewGatewayCount; Index2++) { - if (EFI_IP6_EQUAL (OldGateway + Index1, NewGateway + Index2)) { - OneRemoved =3D TRUE; - break; + DefaultRouter =3D Ip6FindDefaultRouter (IpSb, OldGateway + Index1); + if (DefaultRouter !=3D NULL) { + Ip6DestroyDefaultRouter (IpSb, DefaultRouter); + OneRemoved =3D TRUE; + } + } + + if (Data !=3D NULL && DataSize !=3D 0) { + NewGateway =3D (EFI_IPv6_ADDRESS *) Data; + NewGatewayCount =3D DataSize / sizeof (EFI_IPv6_ADDRESS); + for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { + + if (!NetIp6IsValidUnicast (NewGateway + Index1)) { + + return EFI_INVALID_PARAMETER; + } + + for (Index2 =3D Index1 + 1; Index2 < NewGatewayCount; Index2++) { + if (EFI_IP6_EQUAL (NewGateway + Index1, NewGateway + Index2)) { + return EFI_INVALID_PARAMETER; + } } } =20 - if (Index2 =3D=3D NewGatewayCount) { - // - // Remove this default router. - // - DefaultRouter =3D Ip6FindDefaultRouter (IpSb, OldGateway + Index1); - if (DefaultRouter !=3D NULL) { - Ip6DestroyDefaultRouter (IpSb, DefaultRouter); + if (NewGatewayCount !=3D OldGatewayCount) { + Tmp =3D AllocatePool (DataSize); + if (Tmp =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; } + } else { + Tmp =3D NULL; } - } =20 - for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { + for (Index1 =3D 0; Index1 < NewGatewayCount; Index1++) { =20 - DefaultRouter =3D Ip6FindDefaultRouter (IpSb, NewGateway + Index1); - if (DefaultRouter =3D=3D NULL) { - Ip6CreateDefaultRouter (IpSb, NewGateway + Index1, IP6_INF_ROUTER_LI= FETIME); - OneAdded =3D TRUE; + DefaultRouter =3D Ip6FindDefaultRouter (IpSb, NewGateway + Index1); + if (DefaultRouter =3D=3D NULL) { + Ip6CreateDefaultRouter (IpSb, NewGateway + Index1, IP6_INF_ROUTER_= LIFETIME); + OneAdded =3D TRUE; + } } - } =20 - if (!OneRemoved && !OneAdded) { - Item->Status =3D EFI_SUCCESS; - return EFI_ABORTED; - } else { + if (!OneRemoved && !OneAdded) { + Item->Status =3D EFI_SUCCESS; + return EFI_ABORTED; + } else { =20 - if (Tmp !=3D NULL) { - if (Item->Data.Ptr !=3D NULL) { - FreePool (Item->Data.Ptr); + if (Tmp !=3D NULL) { + if (Item->Data.Ptr !=3D NULL) { + FreePool (Item->Data.Ptr); + } + Item->Data.Ptr =3D Tmp; } - Item->Data.Ptr =3D Tmp; - } =20 - CopyMem (Item->Data.Ptr, Data, DataSize); - Item->DataSize =3D DataSize; - Item->Status =3D EFI_SUCCESS; - return EFI_SUCCESS; + CopyMem (Item->Data.Ptr, Data, DataSize); + Item->DataSize =3D DataSize; + Item->Status =3D EFI_SUCCESS; + return EFI_SUCCESS; + } + } else { + // + // DataSize is 0 and Data is NULL, clean up the Gateway address. + // + if (Item->Data.Ptr !=3D NULL) { + FreePool (Item->Data.Ptr); + } + Item->Data.Ptr =3D NULL; + Item->DataSize =3D 0; + Item->Status =3D EFI_NOT_FOUND; } + + return EFI_SUCCESS; } =20 /** The work function for EfiIp6ConfigSetData() to set the DNS server list f= or the EFI IPv6 network stack running on the communication device that this EFI= IPv6 @@ -1337,87 +1425,106 @@ Ip6ConfigSetDnsServer ( UINTN NewDnsCount; IP6_CONFIG_DATA_ITEM *Item; BOOLEAN OneAdded; VOID *Tmp; =20 - if ((DataSize % sizeof (EFI_IPv6_ADDRESS) !=3D 0) || (DataSize =3D=3D 0)= ) { + OldDns =3D NULL; + NewDns =3D NULL; + Item =3D NULL; + Tmp =3D NULL; + + if ((DataSize =3D=3D 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) !=3D 0)= ) { return EFI_BAD_BUFFER_SIZE; } =20 if (Instance->Policy !=3D Ip6ConfigPolicyManual) { return EFI_WRITE_PROTECTED; } =20 - Item =3D &Instance->DataItem[Ip6ConfigDataTypeDnsServer]; - NewDns =3D (EFI_IPv6_ADDRESS *) Data; - OldDns =3D Item->Data.DnsServers; - NewDnsCount =3D DataSize / sizeof (EFI_IPv6_ADDRESS); - OldDnsCount =3D Item->DataSize / sizeof (EFI_IPv6_ADDRESS); - OneAdded =3D FALSE; + Item =3D &Instance->DataItem[Ip6ConfigDataTypeDnsServer]; =20 - if (NewDnsCount !=3D OldDnsCount) { - Tmp =3D AllocatePool (DataSize); - if (Tmp =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - } else { - Tmp =3D NULL; - } + if (Data !=3D NULL && DataSize !=3D 0) { + NewDns =3D (EFI_IPv6_ADDRESS *) Data; + OldDns =3D Item->Data.DnsServers; + NewDnsCount =3D DataSize / sizeof (EFI_IPv6_ADDRESS); + OldDnsCount =3D Item->DataSize / sizeof (EFI_IPv6_ADDRESS); + OneAdded =3D FALSE; =20 - for (NewIndex =3D 0; NewIndex < NewDnsCount; NewIndex++) { - - if (!NetIp6IsValidUnicast (NewDns + NewIndex)) { - // - // The dns server address must be unicast. - // - if (Tmp !=3D NULL) { - FreePool (Tmp); + if (NewDnsCount !=3D OldDnsCount) { + Tmp =3D AllocatePool (DataSize); + if (Tmp =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; } - return EFI_INVALID_PARAMETER; + } else { + Tmp =3D NULL; } =20 - if (OneAdded) { - // - // If any address in the new setting is not in the old settings, ski= p the - // comparision below. - // - continue; - } + for (NewIndex =3D 0; NewIndex < NewDnsCount; NewIndex++) { =20 - for (OldIndex =3D 0; OldIndex < OldDnsCount; OldIndex++) { - if (EFI_IP6_EQUAL (NewDns + NewIndex, OldDns + OldIndex)) { + if (!NetIp6IsValidUnicast (NewDns + NewIndex)) { // - // If found break out. + // The dns server address must be unicast. // - break; + if (Tmp !=3D NULL) { + FreePool (Tmp); + } + return EFI_INVALID_PARAMETER; } - } =20 - if (OldIndex =3D=3D OldDnsCount) { - OneAdded =3D TRUE; + if (OneAdded) { + // + // If any address in the new setting is not in the old settings, s= kip the + // comparision below. + // + continue; + } + + for (OldIndex =3D 0; OldIndex < OldDnsCount; OldIndex++) { + if (EFI_IP6_EQUAL (NewDns + NewIndex, OldDns + OldIndex)) { + // + // If found break out. + // + break; + } + } + + if (OldIndex =3D=3D OldDnsCount) { + OneAdded =3D TRUE; + } } - } =20 - if (!OneAdded && (DataSize =3D=3D Item->DataSize)) { + if (!OneAdded && (DataSize =3D=3D Item->DataSize)) { + // + // No new item is added and the size is the same. + // + Item->Status =3D EFI_SUCCESS; + return EFI_ABORTED; + } else { + if (Tmp !=3D NULL) { + if (Item->Data.Ptr !=3D NULL) { + FreePool (Item->Data.Ptr); + } + Item->Data.Ptr =3D Tmp; + } + + CopyMem (Item->Data.Ptr, Data, DataSize); + Item->DataSize =3D DataSize; + Item->Status =3D EFI_SUCCESS; + } + } else { // - // No new item is added and the size is the same. + // DataSize is 0 and Data is NULL, clean up the DnsServer address.=20 // - Item->Status =3D EFI_SUCCESS; - return EFI_ABORTED; - } else { - if (Tmp !=3D NULL) { - if (Item->Data.Ptr !=3D NULL) { - FreePool (Item->Data.Ptr); - } - Item->Data.Ptr =3D Tmp; + if (Item->Data.Ptr !=3D NULL) { + FreePool (Item->Data.Ptr); } - - CopyMem (Item->Data.Ptr, Data, DataSize); - Item->DataSize =3D DataSize; - Item->Status =3D EFI_SUCCESS; - return EFI_SUCCESS; + Item->Data.Ptr =3D NULL; + Item->DataSize =3D 0; + Item->Status =3D EFI_NOT_FOUND; } + + return EFI_SUCCESS; } =20 /** Generate the operational state of the interface this IP6 config instance= manages and output in EFI_IP6_CONFIG_INTERFACE_INFO. @@ -1822,13 +1929,12 @@ Ip6ConfigOnDhcp6SbInstalled ( =20 @retval EFI_SUCCESS The specified configuration data for the E= FI IPv6 network stack was set successfully. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: - This is NULL. - - Data is NULL. - - One or more fields in Data do not match = the requirement of the - data type indicated by DataType. + - One or more fields in Data and DataSized= o not match the=20 + requirement of the data type indicated b= y DataType. @retval EFI_WRITE_PROTECTED The specified configuration data is read-o= nly or the specified configuration data cannot be set under the= current policy. @retval EFI_ACCESS_DENIED Another set operation on the specified con= figuration data is already in process. @retval EFI_NOT_READY An asynchronous process was invoked to set= the specified @@ -1852,11 +1958,11 @@ EfiIp6ConfigSetData ( EFI_TPL OldTpl; EFI_STATUS Status; IP6_CONFIG_INSTANCE *Instance; IP6_SERVICE *IpSb; =20 - if ((This =3D=3D NULL) || (Data =3D=3D NULL)) { + if ((This =3D=3D NULL) || (Data =3D=3D NULL && DataSize !=3D 0) || (Data= !=3D NULL && DataSize =3D=3D 0)) { return EFI_INVALID_PARAMETER; } =20 if (DataType >=3D Ip6ConfigDataTypeMaximum) { return EFI_UNSUPPORTED; --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel