From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5879F21A13496 for ; Wed, 10 May 2017 08:33:05 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 May 2017 08:33:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,320,1491289200"; d="scan'208";a="1128657669" Received: from dayinwan-mobl1.ccr.corp.intel.com (HELO JIAXINWU-MOBL2.ccr.corp.intel.com) ([10.254.212.75]) by orsmga001.jf.intel.com with ESMTP; 10 May 2017 08:33:03 -0700 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Jiaxin Date: Wed, 10 May 2017 23:33:01 +0800 Message-Id: <1494430381-8064-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 May 2017 15:33:05 -0000 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 Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/IScsiDxe/IScsiDhcp.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c index 43ae50b..6587a05 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp.c +++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c @@ -369,10 +369,54 @@ IScsiParseDhcpAck ( FreePool (OptionList); 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. @param[in] Image The handle of the driver image. @@ -391,18 +435,20 @@ IScsiDoDhcp ( IN EFI_HANDLE Controller, IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData ) { EFI_HANDLE Dhcp4Handle; + EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; EFI_DHCP4_PROTOCOL *Dhcp4; EFI_STATUS Status; EFI_DHCP4_PACKET_OPTION *ParaList; EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData; ISCSI_SESSION_CONFIG_NVDATA *NvData; BOOLEAN MediaPresent; Dhcp4Handle = NULL; + Ip4Config2 = NULL; Dhcp4 = NULL; ParaList = NULL; // // Check media status before doing DHCP. @@ -412,10 +458,25 @@ IScsiDoDhcp ( if (!MediaPresent) { 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. // Status = NetLibCreateServiceChild ( Controller, Image, -- 1.9.5.msysgit.1