diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c index 75d4f23fb0..62a8ae298c 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c @@ -1,7 +1,7 @@ /** @file The implementation of EFI IPv6 Configuration Protocol. - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, 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 @@ -2209,7 +2209,7 @@ Ip6ConfigInitInstance ( DataItem->SetData = Ip6ConfigSetPolicy; DataItem->Data.Ptr = &Instance->Policy; DataItem->DataSize = sizeof (Instance->Policy); - Instance->Policy = Ip6ConfigPolicyAutomatic; + Instance->Policy = Ip6ConfigPolicyManual; SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED); DataItem = &Instance->DataItem[Ip6ConfigDataTypeDupAddrDetectTransmits]; diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h index 581978bd5e..2f0e4467d1 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h @@ -1,7 +1,7 @@ /** @file Definitions for EFI IPv6 Configuartion Protocol implementation. - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, 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 @@ -215,6 +215,26 @@ struct _IP6_CONFIG_INSTANCE { IP6_CONFIG_NVDATA Ip6NvData; }; +/** + Read the configuration data from variable storage according to the VarName and + gEfiIp6ConfigProtocolGuid. It checks the integrity of variable data. If the + data is corrupted, it clears the variable data to ZERO. Othewise, it outputs the + configuration data to IP6_CONFIG_INSTANCE. + + @param[in] VarName The pointer to the variable name + @param[in, out] Instance The pointer to the IP6 config instance data. + + @retval EFI_NOT_FOUND The variable can not be found or already corrupted. + @retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete the operation. + @retval EFI_SUCCESS The configuration data was retrieved successfully. + +**/ +EFI_STATUS +Ip6ConfigReadConfigData ( + IN CHAR16 *VarName, + IN OUT IP6_CONFIG_INSTANCE *Instance + ); + /** The event process routine when the DHCPv6 server is answered with a reply packet for an information request. diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c index 076dc605e6..ba702904b5 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Driver.c +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c @@ -1,7 +1,7 @@ /** @file The driver binding and service binding protocol for IP6 driver. - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
This program and the accompanying materials @@ -262,7 +262,6 @@ Ip6CreateService ( EFI_STATUS Status; EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken; EFI_MANAGED_NETWORK_CONFIG_DATA *Config; - IP6_CONFIG_DATA_ITEM *DataItem; ASSERT (Service != NULL); @@ -476,30 +475,6 @@ Ip6CreateService ( goto ON_ERROR; } - // - // If there is any manual address, set it. - // - DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeManualAddress]; - if (DataItem->Data.Ptr != NULL) { - DataItem->SetData ( - &IpSb->Ip6ConfigInstance, - DataItem->DataSize, - DataItem->Data.Ptr - ); - } - - // - // If there is any gateway address, set it. - // - DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway]; - if (DataItem->Data.Ptr != NULL) { - DataItem->SetData ( - &IpSb->Ip6ConfigInstance, - DataItem->DataSize, - DataItem->Data.Ptr - ); - } - InsertHeadList (&IpSb->Interfaces, &IpSb->DefaultInterface->Link); *Service = IpSb; @@ -535,6 +510,12 @@ Ip6DriverBindingStart ( { IP6_SERVICE *IpSb; EFI_STATUS Status; + EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; + IP6_CONFIG_DATA_ITEM *DataItem; + + IpSb = NULL; + Ip6Cfg = NULL; + DataItem = NULL; // // Test for the Ip6 service binding protocol @@ -560,6 +541,8 @@ Ip6DriverBindingStart ( ASSERT (IpSb != NULL); + Ip6Cfg = &IpSb->Ip6ConfigInstance.Ip6Config; + // // Install the Ip6ServiceBinding Protocol onto ControlerHandle // @@ -568,9 +551,53 @@ Ip6DriverBindingStart ( &gEfiIp6ServiceBindingProtocolGuid, &IpSb->ServiceBinding, &gEfiIp6ConfigProtocolGuid, - &IpSb->Ip6ConfigInstance.Ip6Config, + Ip6Cfg, NULL ); + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } + + // + // Read the config data from NV variable again. + // The default data can be changed by other drivers. + // + Status = Ip6ConfigReadConfigData (IpSb->MacString, &IpSb->Ip6ConfigInstance); + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } + + // + // If there is any default manual address, set it. + // + DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeManualAddress]; + if (DataItem->Data.Ptr != NULL) { + Status = Ip6Cfg->SetData ( + Ip6Cfg, + Ip6ConfigDataTypeManualAddress, + DataItem->DataSize, + DataItem->Data.Ptr + ); + if (EFI_ERROR(Status)) { + goto ON_ERROR; + } + } + + // + // If there is any default gateway address, set it. + // + DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway]; + if (DataItem->Data.Ptr != NULL) { + Status = Ip6Cfg->SetData ( + Ip6Cfg, + Ip6ConfigDataTypeGateway, + DataItem->DataSize, + DataItem->Data.Ptr + ); + if (EFI_ERROR(Status)) { + goto ON_ERROR; + } + } if (!EFI_ERROR (Status)) { // diff --git a/NetworkPkg/Ip6Dxe/Ip6Dxe.inf b/NetworkPkg/Ip6Dxe/Ip6Dxe.inf index 76e068daba..2d0fecc77e 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Dxe.inf +++ b/NetworkPkg/Ip6Dxe/Ip6Dxe.inf @@ -7,7 +7,7 @@ # also provides the mechanism to set and get various types of configurations for # the EFI IPv6 network stack. # -# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2016, 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