From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 7474E802AE for ; Thu, 9 Mar 2017 00:17:59 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 00:17:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,267,1486454400"; d="scan'208";a="74591389" Received: from shwdeopenpsi116.ccr.corp.intel.com ([10.239.9.8]) by fmsmga006.fm.intel.com with ESMTP; 09 Mar 2017 00:17:57 -0800 From: Zhang Lubo To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Jiaxin Date: Thu, 9 Mar 2017 16:17:56 +0800 Message-Id: <1489047476-14804-1-git-send-email-lubo.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] NetworkPkg: Fix potential bug if the iSCSI use dns protocol. 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, 09 Mar 2017 08:17:59 -0000 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 Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin --- NetworkPkg/IScsiDxe/IScsiMisc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index 7b4044f..2c93590 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -1776,11 +1776,11 @@ IScsiDhcpIsConfigured ( FreePool (AttemptConfigOrder); return FALSE; } /** - 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. @retval TRUE The handle of the controller need the Dns protocol. @retval FALSE The handle of the controller does not need the Dns protocol. @@ -1797,10 +1797,11 @@ IScsiDnsIsConfigured ( UINTN Index; EFI_STATUS Status; EFI_MAC_ADDRESS MacAddr; UINTN HwAddressSize; UINT16 VlanId; + CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; AttemptConfigOrder = IScsiGetVariableAndSize ( L"AttemptOrder", @@ -1826,14 +1827,14 @@ IScsiDnsIsConfigured ( for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { UnicodeSPrint ( AttemptName, (UINTN) 128, - L"%s%d", - MacString, + L"Attempt %d", (UINTN) AttemptConfigOrder[Index] ); + Status = GetVariable2 ( AttemptName, &gEfiIScsiInitiatorNameProtocolGuid, (VOID**)&AttemptTmp, NULL @@ -1842,11 +1843,13 @@ IScsiDnsIsConfigured ( continue; } 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); continue; } if (AttemptTmp->SessionConfigData.DnsMode) { -- 1.9.5.msysgit.1