NetworkPkg: Change the default IPv6 config policy

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>
This commit is contained in:
Jiaxin Wu 2016-02-25 10:52:13 +08:00
parent 7648748e99
commit 4720106b99
4 changed files with 78 additions and 31 deletions

View File

@ -1,7 +1,7 @@
/** @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
@ -2209,7 +2209,7 @@ Ip6ConfigInitInstance (
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];

View File

@ -1,7 +1,7 @@
/** @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
@ -215,6 +215,26 @@ struct _IP6_CONFIG_INSTANCE {
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.

View File

@ -1,7 +1,7 @@
/** @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
@ -262,7 +262,6 @@ Ip6CreateService (
EFI_STATUS Status;
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
EFI_MANAGED_NETWORK_CONFIG_DATA *Config;
IP6_CONFIG_DATA_ITEM *DataItem;
ASSERT (Service != NULL);
@ -476,30 +475,6 @@ Ip6CreateService (
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;
@ -535,6 +510,12 @@ Ip6DriverBindingStart (
{
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
@ -560,6 +541,8 @@ Ip6DriverBindingStart (
ASSERT (IpSb != NULL);
Ip6Cfg = &IpSb->Ip6ConfigInstance.Ip6Config;
//
// Install the Ip6ServiceBinding Protocol onto ControlerHandle
//
@ -568,9 +551,53 @@ Ip6DriverBindingStart (
&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)) {
//

View File

@ -7,7 +7,7 @@
# 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