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 0CD2521A16E57 for ; Wed, 10 May 2017 18:33:08 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 May 2017 18:33:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,322,1491289200"; d="scan'208";a="1146417336" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 10 May 2017 18:33:06 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 May 2017 18:33:06 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 10 May 2017 18:33:06 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Thu, 11 May 2017 09:33:04 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" Thread-Topic: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP Thread-Index: AQHSyaK8P1V/bVv+E0uYM6Ml9JFpFKHuWaHw Date: Thu, 11 May 2017 01:33:03 +0000 Message-ID: References: <1494430381-8064-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1494430381-8064-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Thu, 11 May 2017 01:33:08 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting =20 -----Original Message----- From: Wu, Jiaxin=20 Sent: Wednesday, May 10, 2017 11:33 PM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jia= xin Subject: [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to St= atic before DHCP DHCP4 service allows only one of its children to be configured in the activ= e 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/IScsiDhc= p.c index 43ae50b..6587a05 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp.c +++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c @@ -369,10 +369,54 @@ IScsiParseDhcpAck ( FreePool (OptionList); =20 return Status; } =20 +/** + This function will switch the IP4 configuration policy to Static. + + @param[in] Ip4Config2 Pointer to the IP4 configuration protoco= l. + + @retval EFI_SUCCESS The policy is already configured to stat= ic. + @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 =3D sizeof (EFI_IP4_CONFIG2_POLICY); Status =3D=20 + Ip4Config2->GetData ( + Ip4Config2, + Ip4Config2DataTypePolicy, + &DataSize, + &Policy + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (Policy !=3D Ip4Config2PolicyStatic) { + Policy =3D Ip4Config2PolicyStatic; + Status=3D Ip4Config2->SetData ( + Ip4Config2, + Ip4Config2DataTypePolicy, + sizeof (EFI_IP4_CONFIG2_POLICY), + &Policy + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + return EFI_SUCCESS; +} =20 /** Parse the DHCP ACK to get the address configuration and DNS information. =20 @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; =20 Dhcp4Handle =3D NULL; + Ip4Config2 =3D NULL; Dhcp4 =3D NULL; ParaList =3D NULL; =20 // // Check media status before doing DHCP. @@ -412,10 +458,25 @@ IScsiDoDhcp ( if (!MediaPresent) { return EFI_NO_MEDIA; } =20 // + // DHCP4 service allows only one of its children to be configured in =20 + // the active state, If the DHCP4 D.O.R.A started by IP4 auto //=20 + configuration and has not been completed, the Dhcp4 state machine //=20 + 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 =3D gBS->HandleProtocol (Controller,=20 + &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); if (!EFI_ERROR (Sta= tus)) { + Status =3D IScsiSetIp4Policy (Ip4Config2); + if (EFI_ERROR (Status)) { + return Status; + } + } + + // // Create a DHCP4 child instance and get the protocol. // Status =3D NetLibCreateServiceChild ( Controller, Image, -- 1.9.5.msysgit.1