NetworkPkg: Fix potential bug if the iSCSI use dns protocol.

Since we use the Attempt and index as the attempt variable name instead of
the MAC address plus index, we need to update this to check the whether
the Controller handle is configured to use DNS protocol

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
Zhang, Lubo 2017-03-09 16:17:56 +08:00 committed by Jiaxin Wu
parent 2d67f2bae3
commit df077b3e07
1 changed files with 7 additions and 4 deletions

View File

@ -1778,7 +1778,7 @@ IScsiDhcpIsConfigured (
} }
/** /**
Check wheather the Controller handle is configured to use DNS protocol. Check whether the Controller handle is configured to use DNS protocol.
@param[in] Controller The handle of the controller. @param[in] Controller The handle of the controller.
@ -1799,6 +1799,7 @@ IScsiDnsIsConfigured (
EFI_MAC_ADDRESS MacAddr; EFI_MAC_ADDRESS MacAddr;
UINTN HwAddressSize; UINTN HwAddressSize;
UINT16 VlanId; UINT16 VlanId;
CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];
CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
@ -1828,10 +1829,10 @@ IScsiDnsIsConfigured (
UnicodeSPrint ( UnicodeSPrint (
AttemptName, AttemptName,
(UINTN) 128, (UINTN) 128,
L"%s%d", L"Attempt %d",
MacString,
(UINTN) AttemptConfigOrder[Index] (UINTN) AttemptConfigOrder[Index]
); );
Status = GetVariable2 ( Status = GetVariable2 (
AttemptName, AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid, &gEfiIScsiInitiatorNameProtocolGuid,
@ -1844,7 +1845,9 @@ IScsiDnsIsConfigured (
ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex); ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex);
if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) { AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));
if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp (MacString, AttemptMacString)) {
FreePool (AttemptTmp); FreePool (AttemptTmp);
continue; continue;
} }