NetworkPkg: Clean the previous address since the policy changed

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.hegde@hpe.com>
Cc: Subramanian Sriram <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Tested-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
This commit is contained in:
Jiaxin Wu 2016-09-21 15:13:37 +08:00
parent 24b41b75f8
commit 00df35fe41
1 changed files with 27 additions and 28 deletions

View File

@ -665,36 +665,35 @@ Ip6ConfigSetPolicy (
return EFI_ABORTED;
} 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);
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[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 {
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.