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>
This commit is contained in:
Jiaxin Wu 2017-05-10 23:30:57 +08:00
parent df5914993c
commit ef810bc807
1 changed files with 61 additions and 0 deletions

View File

@ -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;
@ -413,6 +459,21 @@ IScsiDoDhcp (
return EFI_NO_MEDIA;
}
//
// 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.
//