From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on070a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe40::70a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0D7D61A1E3B for ; Thu, 29 Sep 2016 09:12:50 -0700 (PDT) Received: from DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM (10.162.192.143) by DF4PR84MB0042.NAMPRD84.PROD.OUTLOOK.COM (10.162.192.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Thu, 29 Sep 2016 16:12:47 +0000 Received: from DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM ([10.162.192.143]) by DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM ([10.162.192.143]) with mapi id 15.01.0649.017; Thu, 29 Sep 2016 16:12:47 +0000 From: "Subramanian, Sriram (EG Servers Platform SW)" To: Ye Ting , "edk2-devel@lists.01.org" CC: Fu Siyuan , Zhang Lubo Thread-Topic: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Thread-Index: AQHSGhbDDBkjLyy1xk2wYqXe0nOFM6CQpCaQ Date: Thu, 29 Sep 2016 16:12:47 +0000 Message-ID: References: <20160929055911.22972-1-ting.ye@intel.com> In-Reply-To: <20160929055911.22972-1-ting.ye@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sriram-s@hpe.com; x-originating-ip: [49.207.55.73] x-ms-office365-filtering-correlation-id: 4c085364-c378-49f9-6dc9-08d3e8837456 x-microsoft-exchange-diagnostics: 1; DF4PR84MB0042; 7:x5JZNBjdxiQGgWdqQlUi0ZwisK+qv56UyHlDRRPk+ATuzjJCB9u5tAMGqOAUouxWgrqFIEjd/kGDdy5QyVbrvVvOVFrtvbiy3zDVzgyRMYEksPqOrVJUf/7HfiJ9NfEpZ4b/6/kHsHra0rspb0vd0t3s/jUCU/3ST1bxcAus8iZrCHLiv9w3ELVoT6jOXTG2+dxxX3X2lRxhMy6cDtHFnR50jDjBol5J5SwgcagZvhHCSlfNRxJf4Jq/0KiOMuIZ8DZTcZKlpoSVH6blGxpfu+iy0ukB4gAx4v1MrOQET07InCZWz73jsufw82mOCFUpBsXgFLtj/ZUkiejMiP6v2A== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DF4PR84MB0042; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:DF4PR84MB0042; BCL:0; PCL:0; RULEID:; SRVR:DF4PR84MB0042; x-forefront-prvs: 00808B16F3 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(377454003)(199003)(189002)(13464003)(10400500002)(8936002)(7696004)(122556002)(2950100002)(9686002)(11100500001)(68736007)(3280700002)(5660300001)(3660700001)(19580395003)(19580405001)(4326007)(8676002)(81156014)(81166006)(66066001)(2906002)(5002640100001)(33656002)(305945005)(77096005)(106356001)(106116001)(7846002)(2900100001)(101416001)(54356999)(50986999)(74316002)(92566002)(97736004)(5001770100001)(76176999)(7736002)(86362001)(586003)(6116002)(87936001)(3846002)(2501003)(105586002)(189998001)(102836003)(99286002); DIR:OUT; SFP:1102; SCL:1; SRVR:DF4PR84MB0042; H:DF4PR84MB0041.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2016 16:12:47.7521 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0042 Subject: Re: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Sep 2016 16:12:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Sriram Subramanian -----Original Message----- From: Ye Ting [mailto:ting.ye@intel.com]=20 Sent: Thursday, September 29, 2016 11:29 AM To: edk2-devel@lists.01.org Cc: Subramanian@domain.invalid; Subramanian, Sriram (EG Servers Platform SW= ) ; Fu Siyuan ; Zhang Lubo Subject: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Current ISCSI driver records redirected iSCSI targetIP/Port in iBFT once redirection occurs, which removes the possibility of the OS to reconnect to the configured IP for load balancing. The behavior is not explicitly described in IBFT spec, though the MSFT expert confirm we should record original user setting rather than publish the redirected IP. Thanks Sriram for reviewing and validating this patch in his test-bed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ye Ting Cc: Subramanian, Sriram Cc: Fu Siyuan Cc: Zhang Lubo --- NetworkPkg/IScsiDxe/IScsiDriver.c | 19 +++++++++++++++++++ NetworkPkg/IScsiDxe/IScsiMisc.c | 10 +++++----- NetworkPkg/IScsiDxe/IScsiMisc.h | 7 ++++++- NetworkPkg/IScsiDxe/IScsiProto.c | 36 +++++++++++++++++++++++++----------= - 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiD= river.c index c3ab2c9..279f1c0 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.c +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c @@ -356,10 +356,11 @@ IScsiStart ( CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; BOOLEAN NeedUpdate; VOID *Interface; EFI_GUID *ProtocolGuid; UINT8 NetworkBootPolicy; + ISCSI_SESSION_CONFIG_NVDATA *NvData; =20 // // Test to see if iSCSI driver supports the given controller. // =20 @@ -699,10 +700,28 @@ IScsiStart ( Status =3D IScsiSessionLogin (Session); } else if (Status =3D=3D EFI_NOT_READY) { Status =3D IScsiSessionReLogin (Session); } =20 + // + // Restore the origial user setting which specifies the proxy/virtual = iSCSI target to NV region. + // + NvData =3D &AttemptConfigData->SessionConfigData; + if (NvData->RedirectFlag) { + NvData->TargetPort =3D NvData->OriginalTargetPort; + CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_I= P_ADDRESS)); + NvData->RedirectFlag =3D FALSE; + + gRT->SetVariable ( + mPrivate->PortString, + &gEfiIScsiInitiatorNameProtocolGuid, + ISCSI_CONFIG_VAR_ATTR, + sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA), + AttemptConfigData + ); + } + if (EFI_ERROR (Status)) { // // In Single path mode, only the successful attempt will be recorded= in iBFT; // in multi-path mode, all the attempt entries in MPIO will be recor= ded in iBFT. // diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMis= c.c index a39c268..64bb2ad 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -1186,15 +1186,15 @@ IScsiGetConfigData ( MacString, (UINTN) AttemptConfigOrder[Index] ); =20 GetVariable2 ( - mPrivate->PortString, - &gEfiIScsiInitiatorNameProtocolGuid, - (VOID**)&AttemptConfigData, - NULL - ); + mPrivate->PortString, + &gEfiIScsiInitiatorNameProtocolGuid, + (VOID**)&AttemptConfigData, + NULL + ); =20 if (AttemptConfigData =3D=3D NULL) { continue; } =20 diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMis= c.h index 1bcaeb8..912a871 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.h +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h @@ -48,13 +48,18 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA { CHAR8 TargetName[ISCSI_NAME_MAX_SIZE]; EFI_IP_ADDRESS TargetIp; UINT8 PrefixLength; UINT8 BootLun[8]; =20 - UINT16 ConnectTimeout; ///< timout value in milliseconds + UINT16 ConnectTimeout; ///< timout value in milliseconds. UINT8 ConnectRetryCount; UINT8 IsId[6]; + + BOOLEAN RedirectFlag; + UINT16 OriginalTargetPort; // The port of proxy/virtual t= arget. + EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtua= l target. + =20 } ISCSI_SESSION_CONFIG_NVDATA; #pragma pack() =20 /** Calculate the prefix length of the IPv4 subnet mask. diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiPr= oto.c index 5092365..88d9bdd 100644 --- a/NetworkPkg/IScsiDxe/IScsiProto.c +++ b/NetworkPkg/IScsiDxe/IScsiProto.c @@ -1067,24 +1067,26 @@ IScsiUpdateTargetAddress ( IN OUT ISCSI_SESSION *Session, IN CHAR8 *Data, IN UINT32 Len ) { - LIST_ENTRY *KeyValueList; - CHAR8 *TargetAddress; - CHAR8 *IpStr; - EFI_STATUS Status; - UINTN Number; - UINT8 IpMode; + LIST_ENTRY *KeyValueList; + CHAR8 *TargetAddress; + CHAR8 *IpStr; + EFI_STATUS Status; + UINTN Number; + UINT8 IpMode; + ISCSI_SESSION_CONFIG_NVDATA *NvData; =20 KeyValueList =3D IScsiBuildKeyValueList (Data, Len); if (KeyValueList =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 Status =3D EFI_NOT_FOUND; - + NvData =3D &Session->ConfigData->SessionConfigData; +=20 while (TRUE) { TargetAddress =3D IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_= TARGET_ADDRESS); if (TargetAddress =3D=3D NULL) { break; } @@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress ( // IPv4 address. // continue; } =20 + // + // Save the origial user setting which specifies the proxy/virtual iSC= SI target. + // + NvData->OriginalTargetPort =3D NvData->TargetPort; + IpStr =3D TargetAddress; =20 while ((*TargetAddress !=3D 0) && (*TargetAddress !=3D ':') && (*Targe= tAddress !=3D ',')) { // // NULL, ':', or ',' ends the IPv4 string. @@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress ( =20 Number =3D AsciiStrDecimalToUintn (TargetAddress); if (Number > 0xFFFF) { continue; } else { - Session->ConfigData->SessionConfigData.TargetPort =3D (UINT16) Num= ber; + NvData->TargetPort =3D (UINT16) Number; } } else { // // The string only contains the IPv4 address. Use the well-known por= t. // - Session->ConfigData->SessionConfigData.TargetPort =3D ISCSI_WELL_KNO= WN_PORT; + NvData->TargetPort =3D ISCSI_WELL_KNOWN_PORT; } + + // + // Save the origial user setting which specifies the proxy/virtual iSC= SI target. + // =20 + CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof (EFI_IP_= ADDRESS)); + // // Update the target IP address. // - if (Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG= ) { - IpMode =3D Session->ConfigData->SessionConfigData.IpMode; + if (NvData->IpMode < IP_MODE_AUTOCONFIG) { + IpMode =3D NvData->IpMode; } else { IpMode =3D Session->ConfigData->AutoConfigureMode; } =20 Status =3D IScsiAsciiStrToIp ( @@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress ( ); =20 if (EFI_ERROR (Status)) { continue; } else { + NvData->RedirectFlag =3D TRUE; break; } } =20 IScsiFreeKeyValueList (KeyValueList); --=20 1.9.0.msysgit.0