summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2017-05-10 23:30:57 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2017-05-11 10:52:50 +0800
commitef810bc807188224a752ffbcf5e7f4b651291cee (patch)
tree439b53194877c7a1b6d3c5d0f94434d973e875e0
parentdf5914993c9d4db87e4132bcc3b88efb48db5c6e (diff)
downloadedk2-ef810bc807188224a752ffbcf5e7f4b651291cee.tar.gz
edk2-ef810bc807188224a752ffbcf5e7f4b651291cee.tar.bz2
edk2-ef810bc807188224a752ffbcf5e7f4b651291cee.zip
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>
-rw-r--r--NetworkPkg/IScsiDxe/IScsiDhcp.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c
index 43ae50bbff..6587a05993 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/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 (