The default policy for Ip6Config is Ip6ConfigPolicyAutomatic, 
which results in all NIC ports starting SARR process when it 
receives RA message with M flag from IPv6 router. So, this 
patch is used to changes the the default IPv6 config policy to 
Ip6ConfigPolicyManualand also defer the SetData operation after 
Ip6ConfigProtocol installed. This update let the other platform 
drivers have chance to change the default config data by consume 
Ip6ConfigProtocol.

Cc: Subramanian Sriram <srira...@hpe.com>
Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahm...@hpe.com>
Cc: Ye Ting <ting...@intel.com>
Cc: Fu Siyuan <siyuan...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c |  4 +-
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h | 22 ++++++++++-
 NetworkPkg/Ip6Dxe/Ip6Driver.c     | 81 ++++++++++++++++++++++++++-------------
 NetworkPkg/Ip6Dxe/Ip6Dxe.inf      |  2 +-
 4 files changed, 78 insertions(+), 31 deletions(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 75d4f23..62a8ae2 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -1,9 +1,9 @@
 /** @file
   The implementation of EFI IPv6 Configuration Protocol.
 
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
 
   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.
@@ -2207,11 +2207,11 @@ Ip6ConfigInitInstance (
 
   DataItem           = &Instance->DataItem[Ip6ConfigDataTypePolicy];
   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];
   DataItem->SetData  = Ip6ConfigSetDadXmits;
   DataItem->Data.Ptr = &Instance->DadXmits;
diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
index 581978b..2f0e446 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
@@ -1,9 +1,9 @@
 /** @file
   Definitions for EFI IPv6 Configuartion Protocol implementation.
 
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
 
   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.
@@ -214,10 +214,30 @@ struct _IP6_CONFIG_INSTANCE {
   IP6_FORM_CALLBACK_INFO                    CallbackInfo;
   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.
   
   @param[in]     This          Points to the EFI_DHCP6_PROTOCOL.
   @param[in]     Context       The pointer to the IP6 configuration instance 
data.
diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c
index 076dc60..ba70290 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Driver.c
+++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c
@@ -1,9 +1,9 @@
 /** @file
   The driver binding and service binding protocol for IP6 driver.
 
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
 
   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
@@ -260,11 +260,10 @@ Ip6CreateService (
 {
   IP6_SERVICE                           *IpSb;
   EFI_STATUS                            Status;
   EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *MnpToken;
   EFI_MANAGED_NETWORK_CONFIG_DATA       *Config;
-  IP6_CONFIG_DATA_ITEM                  *DataItem;
 
   ASSERT (Service != NULL);
 
   *Service = NULL;
 
@@ -474,34 +473,10 @@ Ip6CreateService (
                   );
   if (EFI_ERROR (Status)) {
     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;
   return EFI_SUCCESS;
 
@@ -533,10 +508,16 @@ Ip6DriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   )
 {
   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
   //
   Status = gBS->OpenProtocol (
@@ -558,21 +539,67 @@ Ip6DriverBindingStart (
     return Status;
   }
 
   ASSERT (IpSb != NULL);
 
+  Ip6Cfg  = &IpSb->Ip6ConfigInstance.Ip6Config;
+
   //
   // Install the Ip6ServiceBinding Protocol onto ControlerHandle
   //
   Status = gBS->InstallMultipleProtocolInterfaces (
                   &ControllerHandle,
                   &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)) {
     //
     // ready to go: start the receiving and timer
     //
diff --git a/NetworkPkg/Ip6Dxe/Ip6Dxe.inf b/NetworkPkg/Ip6Dxe/Ip6Dxe.inf
index 76e068d..2d0fecc 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Dxe.inf
+++ b/NetworkPkg/Ip6Dxe/Ip6Dxe.inf
@@ -5,11 +5,11 @@
 #  Neighbor Discovery Protocol (ND), Multicast Listener Discovery Protocol 
(MLD), 
 #  and a subset of the Internet Control Message Protocol (ICMPv6). This driver 
 #  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.<BR>
+#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
 #
 #  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.
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to