MdeModulePkg: Clean the previous address since the policy changed

The previous DNS server data will be retained after the policy
changes from Dhcp to Static. 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:12:21 +08:00
parent 065ae7d717
commit 24b41b75f8
1 changed files with 31 additions and 31 deletions

View File

@ -1146,39 +1146,39 @@ Ip4Config2SetPolicy (
return EFI_ABORTED;
}
} else {
//
// The policy is changed. Clean the ManualAddress, Gateway and DnsServers,
// shrink the variable data size, and fire up all the related events.
//
DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
DataItem = &Instance->DataItem[Ip4Config2DataTypeGateway];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
DataItem = &Instance->DataItem[Ip4Config2DataTypeDnsServer];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
if (NewPolicy == Ip4Config2PolicyDhcp) {
//
// The policy is changed from static to dhcp:
// Clean the ManualAddress, Gateway and DnsServers, shrink the variable
// data size, and fire up all the related events.
//
DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
DataItem = &Instance->DataItem[Ip4Config2DataTypeGateway];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
DataItem = &Instance->DataItem[Ip4Config2DataTypeDnsServer];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_VOLATILE);
NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
} else {
//
// The policy is changed from dhcp to static. Stop the DHCPv4 process