From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 5E4D82195406F for ; Thu, 27 Apr 2017 23:40:33 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP; 27 Apr 2017 23:40:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,387,1488873600"; d="scan'208";a="81666241" Received: from shwdeopenpsi116.ccr.corp.intel.com ([10.239.9.5]) by orsmga004.jf.intel.com with ESMTP; 27 Apr 2017 23:40:31 -0700 From: Zhang Lubo To: edk2-devel@lists.01.org Cc: Wu Jiaxin , Ye Ting , Fu Siyuan Date: Fri, 28 Apr 2017 14:40:22 +0800 Message-Id: <1493361622-7604-1-git-send-email-lubo.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] NetworkPkg: Fix bug in iSCSI mode ipv6 when enabling target DHCP. 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, 28 Apr 2017 06:40:33 -0000 if the server name expressed as a site local address begain with FEC0 when retrieving from dhcpv6 option 59 boot file url, it incorrectly process it as a dns name. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Cc: Wu Jiaxin Cc: Ye Ting Cc: Fu Siyuan --- NetworkPkg/IScsiDxe/IScsiDhcp6.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c b/NetworkPkg/IScsiDxe/IScsiDhcp6.c index d3535d5..06c634c 100644 --- a/NetworkPkg/IScsiDxe/IScsiDhcp6.c +++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.c @@ -48,11 +48,11 @@ IScsiDhcp6ExtractRootPath ( ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData; EFI_IP_ADDRESS Ip; UINT8 IpMode; ConfigNvData = &ConfigData->SessionConfigData; - + ConfigNvData->DnsMode = FALSE; // // "iscsi:"":"":"":"":" // IScsiRootPathIdLen = (UINT16) AsciiStrLen (ISCSI_ROOT_PATH_ID); @@ -80,27 +80,40 @@ IScsiDhcp6ExtractRootPath ( // // Extract SERVERNAME field in the Root Path option. // if (TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_START_DELIMITER) { - Status = EFI_INVALID_PARAMETER; - goto ON_EXIT; + // + // The servername is expressed as domain name. + // + ConfigNvData->DnsMode = TRUE; } else { Index++; } Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index]; - while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER) && (Index < Length)) { - Index++; - } + if (!ConfigNvData->DnsMode) { + while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER)&& (Index < Length)) { + Index++; + } - // - // Skip ']' and ':'. - // - TmpStr[Index] = '\0'; - Index += 2; + // + // Skip ']' and ':'. + // + TmpStr[Index] = '\0'; + Index += 2; + } else { + while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) { + Index++; + } + // + // Skip ':'. + // + TmpStr[Index] = '\0'; + Index += 1; + } Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8) AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str); // // Extract others fields in the Root Path option string. @@ -151,12 +164,11 @@ IScsiDhcp6ExtractRootPath ( } // // Server name is expressed as domain name, just save it. // - if ((!NET_IS_DIGIT (*(Field->Str))) && (*(Field->Str) != '[')) { - ConfigNvData->DnsMode = TRUE; + if (ConfigNvData->DnsMode) { if (Field->Len > sizeof (ConfigNvData->TargetUrl)) { return EFI_INVALID_PARAMETER; } CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); ConfigNvData->TargetUrl[Field->Len + 1] = '\0'; -- 1.9.5.msysgit.1