From nobody Sat Nov 2 08:35:17 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1494430391160684.9045149546993; Wed, 10 May 2017 08:33:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2E71121A0BAA8; Wed, 10 May 2017 08:33:07 -0700 (PDT) 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 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 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,320,1491289200"; d="scan'208";a="1128657669" From: Jiaxin Wu To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Fu Siyuan Reviewed-by: Ye Ting =20 --- 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 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; + }=20 + } + + 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.=20 + // So, we need to switch it's policy to static. + // + Status =3D gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid,= (VOID **) &Ip4Config2); + if (!EFI_ERROR (Status)) { + Status =3D IScsiSetIp4Policy (Ip4Config2); + if (EFI_ERROR (Status)) { + return Status; + } + } + + // // Create a DHCP4 child instance and get the protocol. // Status =3D NetLibCreateServiceChild ( Controller, Image, --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel