diff options
-rw-r--r-- | NetworkPkg/IScsiDxe/IScsiDriver.c | 19 | ||||
-rw-r--r-- | NetworkPkg/IScsiDxe/IScsiMisc.c | 10 | ||||
-rw-r--r-- | NetworkPkg/IScsiDxe/IScsiMisc.h | 7 | ||||
-rw-r--r-- | 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 c3ab2c9288..279f1c0496 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.c +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c @@ -358,6 +358,7 @@ IScsiStart ( VOID *Interface;
EFI_GUID *ProtocolGuid;
UINT8 NetworkBootPolicy;
+ ISCSI_SESSION_CONFIG_NVDATA *NvData;
//
// Test to see if iSCSI driver supports the given controller.
@@ -701,6 +702,24 @@ IScsiStart ( 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;
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index a39c268d65..64bb2ade7b 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -1188,11 +1188,11 @@ IScsiGetConfigData ( );
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 1bcaeb8bcc..912a8711fa 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.h +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h @@ -50,9 +50,14 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA { 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()
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c index 5092365464..88d9bdd8f0 100644 --- a/NetworkPkg/IScsiDxe/IScsiProto.c +++ b/NetworkPkg/IScsiDxe/IScsiProto.c @@ -1069,12 +1069,13 @@ IScsiUpdateTargetAddress ( 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) {
@@ -1082,7 +1083,8 @@ IScsiUpdateTargetAddress ( }
Status = EFI_NOT_FOUND;
-
+ NvData = &Session->ConfigData->SessionConfigData;
+
while (TRUE) {
TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ADDRESS);
if (TargetAddress == NULL) {
@@ -1098,6 +1100,11 @@ IScsiUpdateTargetAddress ( continue;
}
+ //
+ // Save the origial user setting which specifies the proxy/virtual iSCSI target.
+ //
+ NvData->OriginalTargetPort = NvData->TargetPort;
+
IpStr = TargetAddress;
while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) {
@@ -1122,19 +1129,25 @@ IScsiUpdateTargetAddress ( 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;
}
@@ -1148,6 +1161,7 @@ IScsiUpdateTargetAddress ( if (EFI_ERROR (Status)) {
continue;
} else {
+ NvData->RedirectFlag = TRUE;
break;
}
}
|