From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 014D18044D for ; Fri, 24 Mar 2017 01:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490344987; x=1521880987; h=from:to:cc:subject:date:message-id; bh=85PXUIIYmbbWdI4mah11LZKfl2rIb9Dss6RQXhrvheA=; b=cjNj+8UP7qDmh7pnkIZal1agfxJ6NLaZj1c4RPDJrRCrb83Ci+Jx4PCO O1uj56iFmZJUhKp+m7aS2/xsZSZiJw==; Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Mar 2017 01:43:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,214,1486454400"; d="scan'208";a="64457972" Received: from shwdeopenpsi116.ccr.corp.intel.com ([10.239.9.16]) by orsmga002.jf.intel.com with ESMTP; 24 Mar 2017 01:43:05 -0700 From: Zhang Lubo To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Jiaxin Date: Fri, 24 Mar 2017 16:43:04 +0800 Message-Id: <1490344984-28132-1-git-send-email-lubo.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] NetworkPkg: Fix some bugs related to iSCSI keyword configuration. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 08:43:07 -0000 Add check logic and error message for some keywords validity. show target address in URL format and MAC address correctly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin --- NetworkPkg/IScsiDxe/IScsiConfig.c | 78 +++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiConfig.c index 1fe279e..56a8685 100644 --- a/NetworkPkg/IScsiDxe/IScsiConfig.c +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c @@ -626,14 +626,17 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( LIST_ENTRY *Entry; ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData; ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData; CHAR16 AttemptNameList[ATTEMPT_NAME_LIST_SIZE]; + ISCSI_NIC_INFO *NicInfo; + CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; EFI_IP_ADDRESS Ip; UINTN Index; UINTN StringLen; + NicInfo = NULL; ZeroMem (AttemptNameList, sizeof (AttemptNameList)); if ((mPrivate != NULL) && (mPrivate->AttemptCount != 0)) { NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) { Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link); @@ -700,12 +703,12 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( ); if (SessionConfigData->DnsMode) { AsciiStrToUnicodeStrS ( SessionConfigData->TargetUrl, - IfrNvData->TargetIp, - sizeof (IfrNvData->TargetIp) / sizeof (IfrNvData->TargetIp[0]) + IfrNvData->Keyword[Index].ISCSITargetIpAddress, + sizeof (IfrNvData->Keyword[Index].ISCSITargetIpAddress) / sizeof (IfrNvData->Keyword[Index].ISCSITargetIpAddress[0]) ); } IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->Keyword[Index].ISCSILun); IScsiConvertIsIdToString (IfrNvData->Keyword[Index].ISCSIIsId, SessionConfigData->IsId); @@ -738,13 +741,29 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( IfrNvData->Keyword[Index].ISCSIReverseChapSecret, ISCSI_CHAP_SECRET_STORAGE ); } } - CopyMem(IfrNvData->ISCSIDisplayAttemptList, AttemptNameList, ATTEMPT_NAME_LIST_SIZE); } + + NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { + NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); + IScsiMacAddrToStr ( + &NicInfo->PermanentAddress, + NicInfo->HwAddressSize, + NicInfo->VlanId, + MacString + ); + CopyMem ( + IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr), + MacString, + StrLen (MacString) * sizeof (CHAR16) + ); + + *(IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr)) = L'/'; + } } /** Convert the IFR data to iSCSI configuration data. @@ -1193,10 +1212,12 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( ) { ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; UINT8 AttemptIndex; UINT8 Index; + UINT8 ChapSecretLen; + UINT8 ReverseChapSecretLen; CHAR16 *AttemptName1; CHAR16 *AttemptName2; ISCSI_ATTEMPT_CONFIG_NVDATA *SameNicAttempt; CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN]; CHAR8 IScsiName[ISCSI_NAME_MAX_SIZE]; @@ -1342,38 +1363,45 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CONNECT_RETRY_VAR_OFFSET) + 1); Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); if (Attempt == NULL) { return EFI_INVALID_PARAMETER; } - Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1]; - if (Attempt->SessionConfigData.ConnectRetryCount == 0) { - Attempt->SessionConfigData.ConnectRetryCount = CONNECT_MIN_RETRY; + + if (IfrNvData->ISCSIConnectRetry[AttemptIndex - 1] > CONNECT_MAX_RETRY) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"The minimum value is 0 and the maximum is 16. 0 means no retry.", + NULL + ); + return EFI_INVALID_PARAMETER; } + Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1]; } else if ((OffSet >= ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET)) { AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) / 2 + 1); Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); if (Attempt == NULL) { return EFI_INVALID_PARAMETER; } + + if ((IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] < CONNECT_MIN_TIMEOUT) || + (IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TIMEOUT)) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"The minimum value is 100 milliseconds and the maximum is 20 seconds.", + NULL + ); + return EFI_INVALID_PARAMETER; + } + Attempt->SessionConfigData.ConnectTimeout = IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1]; if (Attempt->SessionConfigData.ConnectTimeout == 0) { Attempt->SessionConfigData.ConnectTimeout = CONNECT_DEFAULT_TIMEOUT; } - if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { - if (Attempt->SessionConfigData.ConnectTimeout < CONNECT_MIN_TIMEOUT) { - CreatePopUp ( - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, - &Key, - L"Connection Establishing Timeout is less than minimum value 100ms.", - NULL - ); - return EFI_INVALID_PARAMETER; - } - } - } else if ((OffSet >= ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET)) { AttemptIndex = (UINT8) ((OffSet - ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) + 1); Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); if (Attempt == NULL) { return EFI_INVALID_PARAMETER; @@ -1621,11 +1649,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( Attempt->AuthConfigData.CHAP.CHAPName, ISCSI_CHAP_NAME_STORAGE ); if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { - if (IfrNvData->CHAPName[0] == L'\0') { + if (IfrNvData->Keyword[Index].ISCSIChapUsername[0] == L'\0') { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"CHAP Name is invalid!", NULL @@ -1643,22 +1671,23 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( return EFI_INVALID_PARAMETER; } } else if ((OffSet >= ATTEMPT_CHAR_SECRET_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET)) { if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) { + ChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIChapSecret); UnicodeStrToAsciiStrS ( IfrNvData->Keyword[Index].ISCSIChapSecret, Attempt->AuthConfigData.CHAP.CHAPSecret, ISCSI_CHAP_SECRET_STORAGE ); if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { - if (IfrNvData->CHAPSecret[0] == L'\0') { + if ((ChapSecretLen < ISCSI_CHAP_SECRET_MIN_LEN) || (ChapSecretLen > ISCSI_CHAP_SECRET_MAX_LEN)) { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, - L"CHAP Secret is invalid!", + L"The Chap Secret minimum length is 12 bytes and the maximum length is 16 bytes.", NULL ); return EFI_INVALID_PARAMETER; } } @@ -1678,11 +1707,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( IfrNvData->Keyword[Index].ISCSIReverseChapUsername, Attempt->AuthConfigData.CHAP.ReverseCHAPName, ISCSI_CHAP_NAME_STORAGE ); if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { - if (IfrNvData->ReverseCHAPName[0] == L'\0') { + if (IfrNvData->Keyword[Index].ISCSIReverseChapUsername[0] == L'\0') { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Reverse CHAP Name is invalid!", NULL @@ -1700,22 +1729,23 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( return EFI_INVALID_PARAMETER; } } else if (OffSet >= ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) { if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) { + ReverseChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIReverseChapSecret); UnicodeStrToAsciiStrS ( IfrNvData->Keyword[Index].ISCSIReverseChapSecret, Attempt->AuthConfigData.CHAP.ReverseCHAPSecret, ISCSI_CHAP_SECRET_STORAGE ); if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { - if (IfrNvData->ReverseCHAPSecret[0] == L'\0') { + if ((ReverseChapSecretLen < ISCSI_CHAP_SECRET_MIN_LEN) || (ReverseChapSecretLen > ISCSI_CHAP_SECRET_MAX_LEN)) { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, - L"Reverse CHAP Secret is invalid!", + L"The Reverse CHAP Secret minimum length is 12 bytes and the maximum length is 16 bytes.", NULL ); return EFI_INVALID_PARAMETER; } } -- 1.9.5.msysgit.1