The previous DNS server data will be retained after the policy
changes from Auto to Manual. This patch is used to clean the
previous dhcp configuration data.

Cc: Hegde Nagaraj P <nagaraj-p.he...@hpe.com>
Cc: Subramanian Sriram <srira...@hpe.com>
Cc: Ye Ting <ting...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 59 +++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 54522f9..75ecec1 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -663,40 +663,39 @@ Ip6ConfigSetPolicy (
 
   if (NewPolicy == Instance->Policy) {
 
     return EFI_ABORTED;
   } else {
-
-    if (NewPolicy == Ip6ConfigPolicyAutomatic) {
-      //
-      // Clean the ManualAddress, Gateway and DnsServers, shrink the variable
-      // data size, and fire up all the related events.
-      //
-      DataItem           = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
-      if (DataItem->Data.Ptr != NULL) {
-        FreePool (DataItem->Data.Ptr);
-      }
-      DataItem->Data.Ptr = NULL;
-      DataItem->DataSize = 0;
-      DataItem->Status   = EFI_NOT_FOUND;
-      NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
-
-      DataItem           = &Instance->DataItem[Ip6ConfigDataTypeGateway];
-      if (DataItem->Data.Ptr != NULL) {
-        FreePool (DataItem->Data.Ptr);
-      }
-      DataItem->Data.Ptr = NULL;
-      DataItem->DataSize = 0;
-      DataItem->Status   = EFI_NOT_FOUND;
-      NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
-
-      DataItem           = &Instance->DataItem[Ip6ConfigDataTypeDnsServer];
-      DataItem->Data.Ptr = NULL;
-      DataItem->DataSize = 0;
-      DataItem->Status   = EFI_NOT_FOUND;
-      NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
-    } else {
+    //
+    // Clean the ManualAddress, Gateway and DnsServers, shrink the variable
+    // data size, and fire up all the related events.
+    //
+    DataItem           = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
+    if (DataItem->Data.Ptr != NULL) {
+      FreePool (DataItem->Data.Ptr);
+    }
+    DataItem->Data.Ptr = NULL;
+    DataItem->DataSize = 0;
+    DataItem->Status   = EFI_NOT_FOUND;
+    NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
+
+    DataItem           = &Instance->DataItem[Ip6ConfigDataTypeGateway];
+    if (DataItem->Data.Ptr != NULL) {
+      FreePool (DataItem->Data.Ptr);
+    }
+    DataItem->Data.Ptr = NULL;
+    DataItem->DataSize = 0;
+    DataItem->Status   = EFI_NOT_FOUND;
+    NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
+
+    DataItem           = &Instance->DataItem[Ip6ConfigDataTypeDnsServer];
+    DataItem->Data.Ptr = NULL;
+    DataItem->DataSize = 0;
+    DataItem->Status   = EFI_NOT_FOUND;
+    NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
+    
+    if (NewPolicy == Ip6ConfigPolicyManual) {
       //
       // The policy is changed from automatic to manual. Stop the DHCPv6 
process
       // and destroy the DHCPv6 child.
       //
       if (Instance->Dhcp6Handle != NULL) {
-- 
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