summaryrefslogtreecommitdiff
path: root/Core
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2017-05-10 23:30:57 +0800
committerGuo Mang <mang.guo@intel.com>2017-07-12 11:24:40 +0800
commit6fcd5adbd70612570ecf6c36f88eafe79595dd7f (patch)
treedea56e9186cf6fbbd7baa6880536e4d7367d49b2 /Core
parent2c24df5e59172408b71bf390b75aadc753a54093 (diff)
downloadedk2-platforms-6fcd5adbd70612570ecf6c36f88eafe79595dd7f.tar.xz
NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP
DHCP4 service allows only one of its children to be configured in the active state. If the DHCP4 D.O.R.A started by IP4 auto configuration and has not been completed, the Dhcp4 state machine will not be in the right state for the iSCSI to start a new round D.O.R.A. So, we need to switch it's policy to static. Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> (cherry picked from commit ef810bc807188224a752ffbcf5e7f4b651291cee)
Diffstat (limited to 'Core')
-rw-r--r--Core/NetworkPkg/IScsiDxe/IScsiDhcp.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/Core/NetworkPkg/IScsiDxe/IScsiDhcp.c b/Core/NetworkPkg/IScsiDxe/IScsiDhcp.c
index 43ae50bbff..6587a05993 100644
--- a/Core/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/Core/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -371,6 +371,50 @@ IScsiParseDhcpAck (
return Status;
}
+/**
+ This function will switch the IP4 configuration policy to Static.
+
+ @param[in] Ip4Config2 Pointer to the IP4 configuration protocol.
+
+ @retval EFI_SUCCESS The policy is already configured to static.
+ @retval Others Other error as indicated.
+
+**/
+EFI_STATUS
+IScsiSetIp4Policy (
+ IN EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2
+ )
+{
+ EFI_IP4_CONFIG2_POLICY Policy;
+ EFI_STATUS Status;
+ UINTN DataSize;
+
+ DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
+ Status = Ip4Config2->GetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ &DataSize,
+ &Policy
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Policy != Ip4Config2PolicyStatic) {
+ Policy = Ip4Config2PolicyStatic;
+ Status= Ip4Config2->SetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ sizeof (EFI_IP4_CONFIG2_POLICY),
+ &Policy
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
/**
Parse the DHCP ACK to get the address configuration and DNS information.
@@ -393,6 +437,7 @@ IScsiDoDhcp (
)
{
EFI_HANDLE Dhcp4Handle;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
EFI_DHCP4_PROTOCOL *Dhcp4;
EFI_STATUS Status;
EFI_DHCP4_PACKET_OPTION *ParaList;
@@ -401,6 +446,7 @@ IScsiDoDhcp (
BOOLEAN MediaPresent;
Dhcp4Handle = NULL;
+ Ip4Config2 = NULL;
Dhcp4 = NULL;
ParaList = NULL;
@@ -414,6 +460,21 @@ IScsiDoDhcp (
}
//
+ // DHCP4 service allows only one of its children to be configured in
+ // the active state, If the DHCP4 D.O.R.A started by IP4 auto
+ // configuration and has not been completed, the Dhcp4 state machine
+ // will not be in the right state for the iSCSI to start a new round D.O.R.A.
+ // So, we need to switch it's policy to static.
+ //
+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2);
+ if (!EFI_ERROR (Status)) {
+ Status = IScsiSetIp4Policy (Ip4Config2);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ //
// Create a DHCP4 child instance and get the protocol.
//
Status = NetLibCreateServiceChild (