* [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
@ 2016-09-29 5:59 Ye Ting
2016-09-29 6:10 ` Ye, Ting
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Ye Ting @ 2016-09-29 5:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Subramanian, Sriram, Fu Siyuan, Zhang Lubo
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 <ting.ye@intel.com>
Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
---
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/IScsiDriver.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;
//
// Test to see if iSCSI driver supports the given controller.
//
@@ -699,10 +700,28 @@ IScsiStart (
Status = IScsiSessionLogin (Session);
} else if (Status == EFI_NOT_READY) {
Status = IScsiSessionReLogin (Session);
}
+ //
+ // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region.
+ //
+ NvData = &AttemptConfigData->SessionConfigData;
+ if (NvData->RedirectFlag) {
+ NvData->TargetPort = NvData->OriginalTargetPort;
+ CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS));
+ NvData->RedirectFlag = 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 recorded in iBFT.
//
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index a39c268..64bb2ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1186,15 +1186,15 @@ IScsiGetConfigData (
MacString,
(UINTN) AttemptConfigOrder[Index]
);
GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
if (AttemptConfigData == NULL) {
continue;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.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];
- 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 target.
+ EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
/**
Calculate the prefix length of the IPv4 subnet mask.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.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;
KeyValueList = IScsiBuildKeyValueList (Data, Len);
if (KeyValueList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_NOT_FOUND;
-
+ NvData = &Session->ConfigData->SessionConfigData;
+
while (TRUE) {
TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ADDRESS);
if (TargetAddress == NULL) {
break;
}
@@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress (
// IPv4 address.
//
continue;
}
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ NvData->OriginalTargetPort = NvData->TargetPort;
+
IpStr = TargetAddress;
while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
//
// NULL, ':', or ',' ends the IPv4 string.
@@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress (
Number = AsciiStrDecimalToUintn (TargetAddress);
if (Number > 0xFFFF) {
continue;
} else {
- Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;
+ NvData->TargetPort = (UINT16) Number;
}
} else {
//
// The string only contains the IPv4 address. Use the well-known port.
//
- Session->ConfigData->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT;
+ NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof (EFI_IP_ADDRESS));
+
//
// Update the target IP address.
//
- if (Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
- IpMode = Session->ConfigData->SessionConfigData.IpMode;
+ if (NvData->IpMode < IP_MODE_AUTOCONFIG) {
+ IpMode = NvData->IpMode;
} else {
IpMode = Session->ConfigData->AutoConfigureMode;
}
Status = IScsiAsciiStrToIp (
@@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress (
);
if (EFI_ERROR (Status)) {
continue;
} else {
+ NvData->RedirectFlag = TRUE;
break;
}
}
IScsiFreeKeyValueList (KeyValueList);
--
1.9.0.msysgit.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
2016-09-29 5:59 [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Ye Ting
@ 2016-09-29 6:10 ` Ye, Ting
2016-10-10 2:26 ` Ye, Ting
2016-09-29 16:12 ` Subramanian, Sriram (EG Servers Platform SW)
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Ye, Ting @ 2016-09-29 6:10 UTC (permalink / raw)
To: edk2-devel@lists.01.org,
Subramanian, Sriram (System FW, HP Servers) (sriram-s@hpe.com)
Cc: Zhang, Lubo, Fu, Siyuan
Correct the email address for Sriram.
For the EDKII iSCSI users: Since this patch introduces incompatible changes to iBFT, please help to validate the patch in your scenario to guarantee it does not break any existing functionalities. This patch impacts the iSCSI boot using redirecting iSCSI target.
Best Regards,
Ye Ting
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ye Ting
Sent: Thursday, September 29, 2016 1:59 PM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo <lubo.zhang@intel.com>; Subramanian@ml01.01.org; Fu, Siyuan <siyuan.fu@intel.com>
Subject: [edk2] [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 <ting.ye@intel.com>
Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
---
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/IScsiDriver.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;
//
// Test to see if iSCSI driver supports the given controller.
//
@@ -699,10 +700,28 @@ IScsiStart (
Status = IScsiSessionLogin (Session);
} else if (Status == EFI_NOT_READY) {
Status = IScsiSessionReLogin (Session);
}
+ //
+ // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region.
+ //
+ NvData = &AttemptConfigData->SessionConfigData;
+ if (NvData->RedirectFlag) {
+ NvData->TargetPort = NvData->OriginalTargetPort;
+ CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS));
+ NvData->RedirectFlag = 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 recorded in iBFT.
//
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index a39c268..64bb2ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1186,15 +1186,15 @@ IScsiGetConfigData (
MacString,
(UINTN) AttemptConfigOrder[Index]
);
GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
if (AttemptConfigData == NULL) {
continue;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.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];
- 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 target.
+ EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
/**
Calculate the prefix length of the IPv4 subnet mask.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.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;
KeyValueList = IScsiBuildKeyValueList (Data, Len);
if (KeyValueList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_NOT_FOUND;
-
+ NvData = &Session->ConfigData->SessionConfigData;
+
while (TRUE) {
TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ADDRESS);
if (TargetAddress == NULL) {
break;
}
@@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress (
// IPv4 address.
//
continue;
}
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ NvData->OriginalTargetPort = NvData->TargetPort;
+
IpStr = TargetAddress;
while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
//
// NULL, ':', or ',' ends the IPv4 string.
@@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress (
Number = AsciiStrDecimalToUintn (TargetAddress);
if (Number > 0xFFFF) {
continue;
} else {
- Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;
+ NvData->TargetPort = (UINT16) Number;
}
} else {
//
// The string only contains the IPv4 address. Use the well-known port.
//
- Session->ConfigData->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT;
+ NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof
+ (EFI_IP_ADDRESS));
+
//
// Update the target IP address.
//
- if (Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
- IpMode = Session->ConfigData->SessionConfigData.IpMode;
+ if (NvData->IpMode < IP_MODE_AUTOCONFIG) {
+ IpMode = NvData->IpMode;
} else {
IpMode = Session->ConfigData->AutoConfigureMode;
}
Status = IScsiAsciiStrToIp (
@@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress (
);
if (EFI_ERROR (Status)) {
continue;
} else {
+ NvData->RedirectFlag = TRUE;
break;
}
}
IScsiFreeKeyValueList (KeyValueList);
--
1.9.0.msysgit.0
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
2016-09-29 5:59 [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Ye Ting
2016-09-29 6:10 ` Ye, Ting
@ 2016-09-29 16:12 ` Subramanian, Sriram (EG Servers Platform SW)
2016-10-14 2:11 ` Fu, Siyuan
2016-10-14 7:54 ` Zhang, Lubo
3 siblings, 0 replies; 6+ messages in thread
From: Subramanian, Sriram (EG Servers Platform SW) @ 2016-09-29 16:12 UTC (permalink / raw)
To: Ye Ting, edk2-devel@lists.01.org; +Cc: Fu Siyuan, Zhang Lubo
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
-----Original Message-----
From: Ye Ting [mailto:ting.ye@intel.com]
Sent: Thursday, September 29, 2016 11:29 AM
To: edk2-devel@lists.01.org
Cc: Subramanian@domain.invalid; Subramanian, Sriram (EG Servers Platform SW) <sriram-s@hpe.com>; Fu Siyuan <siyuan.fu@intel.com>; Zhang Lubo <lubo.zhang@intel.com>
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 <ting.ye@intel.com>
Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
---
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/IScsiDriver.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;
//
// Test to see if iSCSI driver supports the given controller.
//
@@ -699,10 +700,28 @@ IScsiStart (
Status = IScsiSessionLogin (Session);
} else if (Status == EFI_NOT_READY) {
Status = IScsiSessionReLogin (Session);
}
+ //
+ // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region.
+ //
+ NvData = &AttemptConfigData->SessionConfigData;
+ if (NvData->RedirectFlag) {
+ NvData->TargetPort = NvData->OriginalTargetPort;
+ CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS));
+ NvData->RedirectFlag = 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 recorded in iBFT.
//
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index a39c268..64bb2ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1186,15 +1186,15 @@ IScsiGetConfigData (
MacString,
(UINTN) AttemptConfigOrder[Index]
);
GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
if (AttemptConfigData == NULL) {
continue;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.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];
- 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 target.
+ EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
/**
Calculate the prefix length of the IPv4 subnet mask.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.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;
KeyValueList = IScsiBuildKeyValueList (Data, Len);
if (KeyValueList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_NOT_FOUND;
-
+ NvData = &Session->ConfigData->SessionConfigData;
+
while (TRUE) {
TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ADDRESS);
if (TargetAddress == NULL) {
break;
}
@@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress (
// IPv4 address.
//
continue;
}
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ NvData->OriginalTargetPort = NvData->TargetPort;
+
IpStr = TargetAddress;
while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
//
// NULL, ':', or ',' ends the IPv4 string.
@@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress (
Number = AsciiStrDecimalToUintn (TargetAddress);
if (Number > 0xFFFF) {
continue;
} else {
- Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;
+ NvData->TargetPort = (UINT16) Number;
}
} else {
//
// The string only contains the IPv4 address. Use the well-known port.
//
- Session->ConfigData->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT;
+ NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof (EFI_IP_ADDRESS));
+
//
// Update the target IP address.
//
- if (Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
- IpMode = Session->ConfigData->SessionConfigData.IpMode;
+ if (NvData->IpMode < IP_MODE_AUTOCONFIG) {
+ IpMode = NvData->IpMode;
} else {
IpMode = Session->ConfigData->AutoConfigureMode;
}
Status = IScsiAsciiStrToIp (
@@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress (
);
if (EFI_ERROR (Status)) {
continue;
} else {
+ NvData->RedirectFlag = TRUE;
break;
}
}
IScsiFreeKeyValueList (KeyValueList);
--
1.9.0.msysgit.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
2016-09-29 6:10 ` Ye, Ting
@ 2016-10-10 2:26 ` Ye, Ting
0 siblings, 0 replies; 6+ messages in thread
From: Ye, Ting @ 2016-10-10 2:26 UTC (permalink / raw)
To: Ye, Ting, edk2-devel@lists.01.org,
Subramanian, Sriram (System FW, HP Servers) (sriram-s@hpe.com)
Cc: Zhang, Lubo, Fu, Siyuan
Hi All,
If there is no objection, I will check in the patch before 5 pm on Oct 14th, (UTC+08:00) Beijing Time. Let me know if you have any concern about that.
Best Regards,
Ye Ting
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ye, Ting
Sent: Thursday, September 29, 2016 2:10 PM
To: edk2-devel@lists.01.org; Subramanian, Sriram (System FW, HP Servers) (sriram-s@hpe.com) <sriram-s@hpe.com>
Cc: Zhang, Lubo <lubo.zhang@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>
Subject: Re: [edk2] [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
Correct the email address for Sriram.
For the EDKII iSCSI users: Since this patch introduces incompatible changes to iBFT, please help to validate the patch in your scenario to guarantee it does not break any existing functionalities. This patch impacts the iSCSI boot using redirecting iSCSI target.
Best Regards,
Ye Ting
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ye Ting
Sent: Thursday, September 29, 2016 1:59 PM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo <lubo.zhang@intel.com>; Subramanian@ml01.01.org; Fu, Siyuan <siyuan.fu@intel.com>
Subject: [edk2] [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 <ting.ye@intel.com>
Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
---
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/IScsiDriver.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;
//
// Test to see if iSCSI driver supports the given controller.
//
@@ -699,10 +700,28 @@ IScsiStart (
Status = IScsiSessionLogin (Session);
} else if (Status == EFI_NOT_READY) {
Status = IScsiSessionReLogin (Session);
}
+ //
+ // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region.
+ //
+ NvData = &AttemptConfigData->SessionConfigData;
+ if (NvData->RedirectFlag) {
+ NvData->TargetPort = NvData->OriginalTargetPort;
+ CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS));
+ NvData->RedirectFlag = 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 recorded in iBFT.
//
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index a39c268..64bb2ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1186,15 +1186,15 @@ IScsiGetConfigData (
MacString,
(UINTN) AttemptConfigOrder[Index]
);
GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
if (AttemptConfigData == NULL) {
continue;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.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];
- 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 target.
+ EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
/**
Calculate the prefix length of the IPv4 subnet mask.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.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;
KeyValueList = IScsiBuildKeyValueList (Data, Len);
if (KeyValueList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_NOT_FOUND;
-
+ NvData = &Session->ConfigData->SessionConfigData;
+
while (TRUE) {
TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ADDRESS);
if (TargetAddress == NULL) {
break;
}
@@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress (
// IPv4 address.
//
continue;
}
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ NvData->OriginalTargetPort = NvData->TargetPort;
+
IpStr = TargetAddress;
while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
//
// NULL, ':', or ',' ends the IPv4 string.
@@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress (
Number = AsciiStrDecimalToUintn (TargetAddress);
if (Number > 0xFFFF) {
continue;
} else {
- Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;
+ NvData->TargetPort = (UINT16) Number;
}
} else {
//
// The string only contains the IPv4 address. Use the well-known port.
//
- Session->ConfigData->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT;
+ NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof
+ (EFI_IP_ADDRESS));
+
//
// Update the target IP address.
//
- if (Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
- IpMode = Session->ConfigData->SessionConfigData.IpMode;
+ if (NvData->IpMode < IP_MODE_AUTOCONFIG) {
+ IpMode = NvData->IpMode;
} else {
IpMode = Session->ConfigData->AutoConfigureMode;
}
Status = IScsiAsciiStrToIp (
@@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress (
);
if (EFI_ERROR (Status)) {
continue;
} else {
+ NvData->RedirectFlag = TRUE;
break;
}
}
IScsiFreeKeyValueList (KeyValueList);
--
1.9.0.msysgit.0
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
2016-09-29 5:59 [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Ye Ting
2016-09-29 6:10 ` Ye, Ting
2016-09-29 16:12 ` Subramanian, Sriram (EG Servers Platform SW)
@ 2016-10-14 2:11 ` Fu, Siyuan
2016-10-14 7:54 ` Zhang, Lubo
3 siblings, 0 replies; 6+ messages in thread
From: Fu, Siyuan @ 2016-10-14 2:11 UTC (permalink / raw)
To: Ye, Ting, edk2-devel@lists.01.org; +Cc: Sriram, Zhang, Lubo
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
> -----Original Message-----
> From: Ye, Ting
> Sent: Thursday, September 29, 2016 1:59 PM
> To: edk2-devel@lists.01.org
> Cc: Subramanian; Sriram <sriram-s@hpe.com>; Fu, Siyuan
> <siyuan.fu@intel.com>; Zhang, Lubo <lubo.zhang@intel.com>
> 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 <ting.ye@intel.com>
> Cc: Subramanian, Sriram <sriram-s@hpe.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Zhang Lubo <lubo.zhang@intel.com>
> ---
> 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/IScsiDriver.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;
>
> //
> // Test to see if iSCSI driver supports the given controller.
> //
>
> @@ -699,10 +700,28 @@ IScsiStart (
> Status = IScsiSessionLogin (Session);
> } else if (Status == EFI_NOT_READY) {
> Status = IScsiSessionReLogin (Session);
> }
>
> + //
> + // Restore the origial user setting which specifies the proxy/virtual
> iSCSI target to NV region.
> + //
> + NvData = &AttemptConfigData->SessionConfigData;
> + if (NvData->RedirectFlag) {
> + NvData->TargetPort = NvData->OriginalTargetPort;
> + CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof
> (EFI_IP_ADDRESS));
> + NvData->RedirectFlag = 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
> recorded in iBFT.
> //
> diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c
> b/NetworkPkg/IScsiDxe/IScsiMisc.c
> index a39c268..64bb2ad 100644
> --- a/NetworkPkg/IScsiDxe/IScsiMisc.c
> +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
> @@ -1186,15 +1186,15 @@ IScsiGetConfigData (
> MacString,
> (UINTN) AttemptConfigOrder[Index]
> );
>
> GetVariable2 (
> - mPrivate->PortString,
> - &gEfiIScsiInitiatorNameProtocolGuid,
> - (VOID**)&AttemptConfigData,
> - NULL
> - );
> + mPrivate->PortString,
> + &gEfiIScsiInitiatorNameProtocolGuid,
> + (VOID**)&AttemptConfigData,
> + NULL
> + );
>
> if (AttemptConfigData == NULL) {
> continue;
> }
>
> diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h
> b/NetworkPkg/IScsiDxe/IScsiMisc.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];
>
> - 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
> target.
> + EFI_IP_ADDRESS OriginalTargetIp; // The address of
> proxy/virtual target.
> +
> } ISCSI_SESSION_CONFIG_NVDATA;
> #pragma pack()
>
> /**
> Calculate the prefix length of the IPv4 subnet mask.
> diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c
> b/NetworkPkg/IScsiDxe/IScsiProto.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;
>
> KeyValueList = IScsiBuildKeyValueList (Data, Len);
> if (KeyValueList == NULL) {
> return EFI_OUT_OF_RESOURCES;
> }
>
> Status = EFI_NOT_FOUND;
> -
> + NvData = &Session->ConfigData->SessionConfigData;
> +
> while (TRUE) {
> TargetAddress = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_TARGET_ADDRESS);
> if (TargetAddress == NULL) {
> break;
> }
> @@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress (
> // IPv4 address.
> //
> continue;
> }
>
> + //
> + // Save the origial user setting which specifies the proxy/virtual
> iSCSI target.
> + //
> + NvData->OriginalTargetPort = NvData->TargetPort;
> +
> IpStr = TargetAddress;
>
> while ((*TargetAddress != 0) && (*TargetAddress != ':') &&
> (*TargetAddress != ',')) {
> //
> // NULL, ':', or ',' ends the IPv4 string.
> @@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress (
>
> Number = AsciiStrDecimalToUintn (TargetAddress);
> if (Number > 0xFFFF) {
> continue;
> } else {
> - Session->ConfigData->SessionConfigData.TargetPort = (UINT16)
> Number;
> + NvData->TargetPort = (UINT16) Number;
> }
> } else {
> //
> // The string only contains the IPv4 address. Use the well-known
> port.
> //
> - Session->ConfigData->SessionConfigData.TargetPort =
> ISCSI_WELL_KNOWN_PORT;
> + NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
> }
> +
> + //
> + // Save the origial user setting which specifies the proxy/virtual
> iSCSI target.
> + //
> + CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof
> (EFI_IP_ADDRESS));
> +
> //
> // Update the target IP address.
> //
> - if (Session->ConfigData->SessionConfigData.IpMode <
> IP_MODE_AUTOCONFIG) {
> - IpMode = Session->ConfigData->SessionConfigData.IpMode;
> + if (NvData->IpMode < IP_MODE_AUTOCONFIG) {
> + IpMode = NvData->IpMode;
> } else {
> IpMode = Session->ConfigData->AutoConfigureMode;
> }
>
> Status = IScsiAsciiStrToIp (
> @@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress (
> );
>
> if (EFI_ERROR (Status)) {
> continue;
> } else {
> + NvData->RedirectFlag = TRUE;
> break;
> }
> }
>
> IScsiFreeKeyValueList (KeyValueList);
> --
> 1.9.0.msysgit.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT
2016-09-29 5:59 [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Ye Ting
` (2 preceding siblings ...)
2016-10-14 2:11 ` Fu, Siyuan
@ 2016-10-14 7:54 ` Zhang, Lubo
3 siblings, 0 replies; 6+ messages in thread
From: Zhang, Lubo @ 2016-10-14 7:54 UTC (permalink / raw)
To: Ye, Ting, edk2-devel@lists.01.org; +Cc: Sriram, Fu, Siyuan
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
-----Original Message-----
From: Ye, Ting
Sent: Thursday, September 29, 2016 1:59 PM
To: edk2-devel@lists.01.org
Cc: Subramanian; Sriram <sriram-s@hpe.com>; Fu, Siyuan <siyuan.fu@intel.com>; Zhang, Lubo <lubo.zhang@intel.com>
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 <ting.ye@intel.com>
Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
---
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/IScsiDriver.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;
//
// Test to see if iSCSI driver supports the given controller.
//
@@ -699,10 +700,28 @@ IScsiStart (
Status = IScsiSessionLogin (Session);
} else if (Status == EFI_NOT_READY) {
Status = IScsiSessionReLogin (Session);
}
+ //
+ // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region.
+ //
+ NvData = &AttemptConfigData->SessionConfigData;
+ if (NvData->RedirectFlag) {
+ NvData->TargetPort = NvData->OriginalTargetPort;
+ CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS));
+ NvData->RedirectFlag = 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 recorded in iBFT.
//
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index a39c268..64bb2ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1186,15 +1186,15 @@ IScsiGetConfigData (
MacString,
(UINTN) AttemptConfigOrder[Index]
);
GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
+ mPrivate->PortString,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ (VOID**)&AttemptConfigData,
+ NULL
+ );
if (AttemptConfigData == NULL) {
continue;
}
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.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];
- 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 target.
+ EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target.
+
} ISCSI_SESSION_CONFIG_NVDATA;
#pragma pack()
/**
Calculate the prefix length of the IPv4 subnet mask.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.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;
KeyValueList = IScsiBuildKeyValueList (Data, Len);
if (KeyValueList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_NOT_FOUND;
-
+ NvData = &Session->ConfigData->SessionConfigData;
+
while (TRUE) {
TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ADDRESS);
if (TargetAddress == NULL) {
break;
}
@@ -1096,10 +1098,15 @@ IScsiUpdateTargetAddress (
// IPv4 address.
//
continue;
}
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ NvData->OriginalTargetPort = NvData->TargetPort;
+
IpStr = TargetAddress;
while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
//
// NULL, ':', or ',' ends the IPv4 string.
@@ -1120,23 +1127,29 @@ IScsiUpdateTargetAddress (
Number = AsciiStrDecimalToUintn (TargetAddress);
if (Number > 0xFFFF) {
continue;
} else {
- Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;
+ NvData->TargetPort = (UINT16) Number;
}
} else {
//
// The string only contains the IPv4 address. Use the well-known port.
//
- Session->ConfigData->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT;
+ NvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
}
+
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof
+ (EFI_IP_ADDRESS));
+
//
// Update the target IP address.
//
- if (Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {
- IpMode = Session->ConfigData->SessionConfigData.IpMode;
+ if (NvData->IpMode < IP_MODE_AUTOCONFIG) {
+ IpMode = NvData->IpMode;
} else {
IpMode = Session->ConfigData->AutoConfigureMode;
}
Status = IScsiAsciiStrToIp (
@@ -1146,10 +1159,11 @@ IScsiUpdateTargetAddress (
);
if (EFI_ERROR (Status)) {
continue;
} else {
+ NvData->RedirectFlag = TRUE;
break;
}
}
IScsiFreeKeyValueList (KeyValueList);
--
1.9.0.msysgit.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-10-14 7:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29 5:59 [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT Ye Ting
2016-09-29 6:10 ` Ye, Ting
2016-10-10 2:26 ` Ye, Ting
2016-09-29 16:12 ` Subramanian, Sriram (EG Servers Platform SW)
2016-10-14 2:11 ` Fu, Siyuan
2016-10-14 7:54 ` Zhang, Lubo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox