]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Change the default IPv6 config policy
authorJiaxin Wu <jiaxin.wu@intel.com>
Thu, 25 Feb 2016 02:52:13 +0000 (10:52 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Wed, 2 Mar 2016 07:43:52 +0000 (15:43 +0800)
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 <sriram-s@hpe.com>
Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Subramanian Sriram <sriram-s@hpe.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
NetworkPkg/Ip6Dxe/Ip6Driver.c
NetworkPkg/Ip6Dxe/Ip6Dxe.inf

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