[edk2] [patch] NetworkPkg: Fix issue in dns driver when building DHCP packet.

2017-05-04 Thread Zhang Lubo
Currently, DNS driver configure the dhcp message type to inform
when building dhcp packet to get dns info from, but it not works
with dhcp server deployed on linux system. However it works well
when changed to request type.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/DnsDxe/DnsDhcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c
index c4add70..93779be 100644
--- a/NetworkPkg/DnsDxe/DnsDhcp.c
+++ b/NetworkPkg/DnsDxe/DnsDhcp.c
@@ -1,9 +1,9 @@
 /** @file
 Functions implementation related with DHCPv4/v6 for DNS driver.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -460,11 +460,11 @@ GetDns4ServerFromDhcp4 (
 goto ON_EXIT;
   }
   
   ParaList[0]->OpCode  = DHCP4_TAG_TYPE;
   ParaList[0]->Length  = 1;
-  ParaList[0]->Data[0] = DHCP4_MSG_INFORM;
+  ParaList[0]->Data[0] = DHCP4_MSG_REQUEST;
   
   ParaList[1] = AllocateZeroPool (sizeof (EFI_DHCP4_PACKET_OPTION));
   if (ParaList[1] == NULL) {
 Status = EFI_OUT_OF_RESOURCES;
 goto ON_EXIT;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Fix issue the iSCSI client can not send reset packet.

2017-04-27 Thread Zhang Lubo
if we already established a iSCSI connection from initiator to target
based on IPv4 stack, after using reconnect -r command, we can not rebuild
the session with the windows target, since the server thought the session
is still exist.  This issue is caused by wrong place of acquire ownership of
sock lock which lead the iSCSI can not reset the connection correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/TcpDxe/SockInterface.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/NetworkPkg/TcpDxe/SockInterface.c 
b/NetworkPkg/TcpDxe/SockInterface.c
index b4ba40a..0248cdf 100644
--- a/NetworkPkg/TcpDxe/SockInterface.c
+++ b/NetworkPkg/TcpDxe/SockInterface.c
@@ -167,22 +167,10 @@ SockDestroyChild (
   ProtoData = (TCP_PROTO_DATA *) Sock->ProtoReserved;
   Tcb   = ProtoData->TcpPcb;
 
   ASSERT (Tcb != NULL);
 
-  Status= EfiAcquireLockOrFail (&(Sock->Lock));
-  if (EFI_ERROR (Status)) {
-
-DEBUG (
-  (EFI_D_ERROR,
-  "SockDestroyChild: Get the lock to access socket failed with %r\n",
-  Status)
-  );
-
-return EFI_ACCESS_DENIED;
-  }
-
   //
   // Close the IP protocol.
   //
   gBS->CloseProtocol (
  Tcb->IpInfo->ChildHandle,
@@ -224,10 +212,23 @@ SockDestroyChild (
 TcpProtocolGuid,
 SockProtocol,
 NULL
 );
 
+
+  Status= EfiAcquireLockOrFail (&(Sock->Lock));
+  if (EFI_ERROR (Status)) {
+
+DEBUG (
+  (EFI_D_ERROR,
+  "SockDestroyChild: Get the lock to access socket failed with %r\n",
+  Status)
+  );
+
+return EFI_ACCESS_DENIED;
+  }
+
   //
   // force protocol layer to detach the PCB
   //
   Status = Sock->ProtoHandler (Sock, SOCK_DETACH, NULL);
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Fix bug in iSCSI mode ipv6 when enabling target DHCP.

2017-04-27 Thread Zhang Lubo
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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg: Fix issue the iSCSI client can not send reset packet correctly.

2017-04-27 Thread Zhang Lubo
if we already established a iSCSI connection from initiator to target
based on IPv4 stack, after using reconnect -r command, we can not rebuild
the session with the windows target, since the server thought the session
is still exist.  This issue is caused by wrong place of acquire ownership of
sock lock which lead the iSCSI can not reset the connection correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c 
b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
index f8b535c..bca4b02 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
@@ -160,19 +160,10 @@ SockDestroyChild (
   ProtoData = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
   Tcb   = ProtoData->TcpPcb;
 
   ASSERT (Tcb != NULL);
 
-  Status = EfiAcquireLockOrFail (&(Sock->Lock));
-  if (EFI_ERROR (Status)) {
-
-DEBUG ((EFI_D_ERROR, "SockDestroyChild: Get the lock to "
-  "access socket failed with %r\n", Status));
-
-return EFI_ACCESS_DENIED;
-  }
-
   //
   // Close the IP protocol.
   //
   gBS->CloseProtocol (
  Tcb->IpInfo->ChildHandle,
@@ -212,10 +203,19 @@ SockDestroyChild (
 &gEfiTcp4ProtocolGuid,
 SockProtocol,
 NULL
 );
 
+  Status = EfiAcquireLockOrFail (&(Sock->Lock));
+  if (EFI_ERROR (Status)) {
+
+DEBUG ((EFI_D_ERROR, "SockDestroyChild: Get the lock to "
+  "access socket failed with %r\n", Status));
+
+return EFI_ACCESS_DENIED;
+  }
+
   //
   // force protocol layer to detach the PCB
   //
   Status = Sock->ProtoHandler (Sock, SOCK_DETACH, NULL);
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] MdeModulePkg/Ip4Dxe: Fix the incorrect RemoveEntryList

2017-04-16 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Monday, April 17, 2017 11:34 AM
To: edk2-devel@lists.01.org
Cc: Subramanian Sriram ; Ye, Ting ; Fu, 
Siyuan ; Zhang, Lubo ; Wu, Jiaxin 

Subject: [Patch] MdeModulePkg/Ip4Dxe: Fix the incorrect RemoveEntryList

Cc: Subramanian Sriram 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
index 7512a00..d29d873 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
@@ -853,11 +853,11 @@ Ip4OnArpResolvedDpc (
 //
 InsertTailList (&Interface->SentFrames, &Token->Link);
 
 Status = Interface->Mnp->Transmit (Interface->Mnp, &Token->MnpToken);
 if (EFI_ERROR (Status)) {
-  RemoveEntryList (Entry);
+  RemoveEntryList (&Token->Link);
   Token->CallBack (Token->IpInstance, Token->Packet, Status, 0, 
Token->Context);
 
   Ip4FreeLinkTxToken (Token);
   continue;
 }
@@ -1079,11 +1079,11 @@ SEND_NOW:
   // Remove it if the returned status is not EFI_SUCCESS.
   //
   InsertTailList (&Interface->SentFrames, &Token->Link);
   Status = Interface->Mnp->Transmit (Interface->Mnp, &Token->MnpToken);
   if (EFI_ERROR (Status)) {
-RemoveEntryList (&Interface->SentFrames);
+RemoveEntryList (&Token->Link);
 goto ON_ERROR;
   }
 
   return EFI_SUCCESS;
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Add check logic for iSCSI driver.

2017-04-06 Thread Zhang Lubo
Need to check variable of mPrivate whether is
null before used and redefine the array length
of target address for keyword.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c| 30 ++--
 NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h |  2 +-
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 56a8685..a588403 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -742,28 +742,28 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (
   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)
+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'/';
-   }
+  *(IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr)) = L'/';
+ } 
+  }
 }
 
 /**
   Convert the IFR data to iSCSI configuration data.
 
diff --git a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h 
b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
index f89f320..22119ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
+++ b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
@@ -160,11 +160,11 @@ typedef struct {
   CHAR16  ISCSIIsId[ISID_CONFIGURABLE_STORAGE];
   CHAR16  ISCSIInitiatorIpAddress[IP4_STR_MAX_SIZE];
   CHAR16  ISCSIInitiatorNetmask[IP4_STR_MAX_SIZE];
   CHAR16  ISCSIInitiatorGateway[IP4_STR_MAX_SIZE];
   CHAR16  ISCSITargetName[ISCSI_NAME_MAX_SIZE];
-  CHAR16  ISCSITargetIpAddress[IP_STR_MAX_SIZE];
+  CHAR16  ISCSITargetIpAddress[ISCSI_TARGET_URI_MAX_SIZE];
   CHAR16  ISCSILun[ISCSI_LUN_STR_MAX_LEN];
   CHAR16  ISCSIChapUsername[ISCSI_CHAP_NAME_STORAGE];
   CHAR16  ISCSIChapSecret[ISCSI_CHAP_SECRET_STORAGE];
   CHAR16  ISCSIReverseChapUsername[ISCSI_CHAP_NAME_STORAGE];
   CHAR16  ISCSIReverseChapSecret[ISCSI_CHAP_SECRET_STORAGE];
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Fix bug related DAD issue in IP6 driver.

2017-04-06 Thread Zhang Lubo
If we set PXEv6 as the first boot option and reboot immediately
after the first successful boot, it will assert. the root cause is
when we set the policy from manual to automatic in PXE driver,
the ip6 Configure item size is already set to zero and other
structures are also released, So it is not needed to perform DAD call
back function which is invoked by Ip6ConfigSetMaunualAddress.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index bde5982..7575b79 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -782,10 +782,14 @@ Ip6ManualAddrDadCallback (
   Instance   = (IP6_CONFIG_INSTANCE *) Context;
   NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
   Item   = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
   ManualAddr = NULL;
 
+  if (Item->DataSize == 0) {
+return;
+  }
+
   for (Index = 0; Index < Item->DataSize / sizeof 
(EFI_IP6_CONFIG_MANUAL_ADDRESS); Index++) {
 //
 // Find the original tag used to place into the NET_MAP.
 //
 ManualAddr = Item->Data.ManualAddress + Index;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] ASSERT with PXE IPv6 boot.

2017-04-05 Thread Zhang, Lubo
Hi Naveen
   
 Thanks for the information, we have captured the assert issue as you 
mentioned.  I will debug more and let you know if anything updated.

Best regards
Lubo

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Monday, April 03, 2017 2:43 PM
To: Zhang, Lubo 
Cc: Ye, Ting ; edk2-devel@lists.01.org
Subject: Re: [edk2] ASSERT with PXE IPv6 boot.

Hi Lubo,

The issue can be reproduced when we set the PXE IPv6 as first boot 
option and let the system boot to it. Cancel when you get the windows Login 
page and it boots to PXE IPv6 again. In this case, ASSERT happens.

Note: we have a WDS server configured for deployment.

The issue CANNOT be reproduced when we boot to setup on every reboot 
and select the PXE IPv6 boot option.

Please see if you can reproduce with this environment. We will see from 
our side and provide you any useful information we find.

Thank you,
Naveen

-Original Message-
From: Santhapur Naveen 
Sent: Thursday, March 23, 2017 2:02 PM
To: 'Zhang, Lubo'
Cc: Ye, Ting; edk2-devel@lists.01.org
Subject: RE: ASSERT with PXE IPv6 boot.

Hi Lubo,

Thanks for the update.
I'll debug and see for more information and let you know.

Thanks,
Naveen

-Original Message-----
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Thursday, March 23, 2017 1:21 PM
To: Santhapur Naveen
Cc: Ye, Ting; edk2-devel@lists.01.org
Subject: RE: ASSERT with PXE IPv6 boot.

Hi Naveen

 I have made a quick test on Denlow platform following the steps to install 
windows 10, but cannot reproduce.


Thanks
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ye, Ting
Sent: Thursday, March 23, 2017 1:18 PM
To: Santhapur Naveen ; edk2-devel@lists.01.org
Subject: Re: [edk2] ASSERT with PXE IPv6 boot.

Hi Naveen,

Thanks for reporting this. We will have a try whether we could reproduce this 
issue.

Best Regards,
Ting

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Tuesday, March 21, 2017 11:08 PM
To: edk2-devel@lists.01.org
Subject: [edk2] ASSERT with PXE IPv6 boot.

Hello all,

I've a Windows Deployment Services PXE server supporting IPv6 with Windows 
10 installers present. I've been getting ASSERT with PXE IPv6 in the following 
scenario.
1) Enable IPv6 Support
2) PXE Boot to Win 10 installer
3) Cancel the install process (Causes system to reboot)
4) Attempt to PXE boot. Here the system hangs on the PXE boot screen.

and it ASSERTs at Ip6Dxe\Ip6ConfigImpl.c(797): Index != Item->DataSize / sizeof 
(EFI_IP6_CONFIG_MANUAL_ADDRESS).

Your suggestions is highly appreciated.

Best Regards,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] MdeModulePkg/DxeHttpLib: Avoid the pointless comparison of UINTN with zero

2017-03-31 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Saturday, April 01, 2017 8:22 AM
To: edk2-devel@lists.01.org
Cc: Bi, Dandan ; Zhang, Lubo ; Ye, 
Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [Patch] MdeModulePkg/DxeHttpLib: Avoid the pointless comparison of 
UINTN with zero

UINTN is unsigned integer, so it's pointless to compare it with zero.

Cc: Bi Dandan 
Cc: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 2 +-  
MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 8e29213..8421caa 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -734,11 +734,11 @@ HttpUrlGetPort (
 Index ++;
   }
 
   Status =  AsciiStrDecimalToUintnS (Url + 
Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
 
-  if (Data > HTTP_URI_PORT_MAX_NUM || Data < HTTP_URI_PORT_MIN_NUM) {
+  if (Data > HTTP_URI_PORT_MAX_NUM) {
 return EFI_INVALID_PARAMETER;
   }
 
   *Port = (UINT16) Data;
   return Status;
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
index 5ee0fdc..af82c16 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
@@ -48,11 +48,10 @@ Header file for HttpLib.
 #define   HTTP_URI_FIELD_USERINFO 5
 #define   HTTP_URI_FIELD_HOST 6
 #define   HTTP_URI_FIELD_PORT 7
 #define   HTTP_URI_FIELD_MAX  8
 
-#define   HTTP_URI_PORT_MIN_NUM   0
 #define   HTTP_URI_PORT_MAX_NUM   65535
 
 //
 // Structure to store the parse result of a HTTP URL.
 //
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of DNSv6

2017-03-29 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Friday, March 24, 2017 2:00 PM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo ; Ye, Ting ; Fu, 
Siyuan ; Wu, Jiaxin 
Subject: [Patch] NetworkPkg/DnsDxe: Fix zero StationIp configuration failure of 
DNSv6

According UEFI Spec, set to zero StationIp means to let the underlying
IPv6 driver choose a source address. But currently, DNSv6 always return 
EFI_NO_MAPPING. The issue is caused by below bugs in DnsDxe:
* Incorrect TPL(TPL_CALLBACK) usage during UDP configuration.
* Failed to create the timer used to get IPv6 mapping
* Doesn't check the Ip6Mode.IsStarted flag.

Cc: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/DnsDxe/DnsDriver.c   | 24 +++-
 NetworkPkg/DnsDxe/DnsImpl.c |  8 +---
 NetworkPkg/DnsDxe/DnsProtocol.c |  2 ++
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsDriver.c b/NetworkPkg/DnsDxe/DnsDriver.c 
index c000b5f..5dc9afe 100644
--- a/NetworkPkg/DnsDxe/DnsDriver.c
+++ b/NetworkPkg/DnsDxe/DnsDriver.c
@@ -1,9 +1,9 @@
 /** @file
 The driver binding and service binding protocol for DnsDxe driver.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at  
http://opensource.org/licenses/bsd-license.php
 
@@ -277,22 +277,20 @@ DnsCreateService (
 
   //
   // Create the timer used to time out the procedure which is used to
   // get the default IP address.
   //
-  if (DnsSb->IpVersion == IP_VERSION_4) {
-Status = gBS->CreateEvent (
-EVT_TIMER,
-TPL_CALLBACK,
-NULL,
-NULL,
-&DnsSb->TimerToGetMap
-);
-if (EFI_ERROR (Status)) {
-  FreePool (DnsSb);
-  return Status;
-}
+  Status = gBS->CreateEvent (
+  EVT_TIMER,
+  TPL_CALLBACK,
+  NULL,
+  NULL,
+  &DnsSb->TimerToGetMap
+  );
+  if (EFI_ERROR (Status)) {
+FreePool (DnsSb);
+return Status;
   }
   
   //
   // Create the timer to retransmit packets.
   //
diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c index 
794df1d..ea3d27d 100644
--- a/NetworkPkg/DnsDxe/DnsImpl.c
+++ b/NetworkPkg/DnsDxe/DnsImpl.c
@@ -1,9 +1,9 @@
 /** @file
 DnsDxe support functions implementation.
   
-Copyright (c) 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at  
http://opensource.org/licenses/bsd-license.php
 
@@ -641,13 +641,15 @@ Dns6GetMapping (
 
   if (Ip6Mode.IcmpTypeList != NULL) {
 FreePool (Ip6Mode.IcmpTypeList);
   }
 
-  if (Ip6Mode.IsConfigured) {
+  if (!Ip6Mode.IsStarted || Ip6Mode.IsConfigured) {
 Udp->Configure (Udp, NULL);
-return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);
+if (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS) {
+  return TRUE;
+}
   }
 }
   }
 
   return FALSE;
diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c 
index 0e7ed34..bd189ae 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -1104,11 +1104,13 @@ Dns6Configure (
 }
 
 //
 // Config UDP
 //
+gBS->RestoreTPL (OldTpl);
 Status = Dns6ConfigUdp (Instance, Instance->UdpIo);
+OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
 if (EFI_ERROR (Status)) {
   if (Instance->Dns6CfgData.DnsServerList != NULL) {
 FreePool (Instance->Dns6CfgData.DnsServerList);
 Instance->Dns6CfgData.DnsServerList = NULL;
   }
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] MdeModulePkg/DxeHttpLib: Fix the incorrect return status if URI port is invalid

2017-03-28 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Monday, March 27, 2017 2:48 PM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo ; Ye, Ting ; Fu, 
Siyuan ; Wu, Jiaxin 
Subject: [Patch] MdeModulePkg/DxeHttpLib: Fix the incorrect return status if 
URI port is invalid

Cc: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 +++  
MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h |  5 -
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 2ff04ff..8e29213 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -690,18 +690,22 @@ HttpUrlGetPort (
  OUT  UINT16 *Port
   )
 {
   CHAR8 *PortString;
   EFI_STATUSStatus;
+  UINTN Index;
   UINTN Data;
   UINT32ResultLength;
   HTTP_URL_PARSER  *Parser;
 
   if (Url == NULL || UrlParser == NULL || Port == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
+  *Port = 0;
+  Index = 0;
+
   Parser = (HTTP_URL_PARSER*) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) {
 return EFI_INVALID_PARAMETER;
   }
@@ -721,12 +725,23 @@ HttpUrlGetPort (
 return Status;
   }
 
   PortString[ResultLength] = '\0';
 
+  while (Index < ResultLength) {
+if (!NET_IS_DIGIT (PortString[Index])) {
+  return EFI_INVALID_PARAMETER;
+}
+Index ++;
+  }
+
   Status =  AsciiStrDecimalToUintnS (Url + 
Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
 
+  if (Data > HTTP_URI_PORT_MAX_NUM || Data < HTTP_URI_PORT_MIN_NUM) {
+return EFI_INVALID_PARAMETER;
+  }
+
   *Port = (UINT16) Data;
   return Status;
 }
 
 /**
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
index 0d0ad3d..5ee0fdc 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
@@ -1,9 +1,9 @@
 /** @file
 Header file for HttpLib.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights 
+ reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -48,10 +48,13 @@ Header file for HttpLib.
 #define   HTTP_URI_FIELD_USERINFO 5
 #define   HTTP_URI_FIELD_HOST 6
 #define   HTTP_URI_FIELD_PORT 7
 #define   HTTP_URI_FIELD_MAX  8
 
+#define   HTTP_URI_PORT_MIN_NUM   0
+#define   HTTP_URI_PORT_MAX_NUM   65535
+
 //
 // Structure to store the parse result of a HTTP URL.
 //
 typedef struct {
   UINT32  Offset;
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Fix some bugs related to iSCSI keyword configuration.

2017-03-24 Thread Zhang Lubo
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;
   CHAR16AttemptNameList[ATTEMPT_NAME_LIST_SIZE];
+  ISCSI_NIC_INFO*NicInfo;
+  CHAR16MacString[ISCSI_MAX_MAC_STRING_LEN];
   EFI_IP_ADDRESSIp;
   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;
   UINT8AttemptIndex;
   UINT8Index;
+  UINT8ChapSecretLen;
+  UINT8ReverseChapSecretLen;
   CHAR16   *AttemptName1;
   CHAR16   *AttemptName2;
   ISCSI_ATTEMPT_CONFIG_NVDATA  *SameNicAttempt;
   CHAR8LunString[ISCSI_LUN_STR_MAX_LEN];
   CHAR8IScsiName[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 = IScsiConfigGetAttemptByConfi

Re: [edk2] ASSERT with PXE IPv6 boot.

2017-03-23 Thread Zhang, Lubo
Hi Naveen

 I have made a quick test on Denlow platform following the steps to install 
windows 10, but cannot reproduce.


Thanks
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ye, Ting
Sent: Thursday, March 23, 2017 1:18 PM
To: Santhapur Naveen ; edk2-devel@lists.01.org
Subject: Re: [edk2] ASSERT with PXE IPv6 boot.

Hi Naveen,

Thanks for reporting this. We will have a try whether we could reproduce this 
issue.

Best Regards,
Ting

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Tuesday, March 21, 2017 11:08 PM
To: edk2-devel@lists.01.org
Subject: [edk2] ASSERT with PXE IPv6 boot.

Hello all,

I've a Windows Deployment Services PXE server supporting IPv6 with Windows 
10 installers present. I've been getting ASSERT with PXE IPv6 in the following 
scenario.
1) Enable IPv6 Support
2) PXE Boot to Win 10 installer
3) Cancel the install process (Causes system to reboot)
4) Attempt to PXE boot. Here the system hangs on the PXE boot screen.

and it ASSERTs at Ip6Dxe\Ip6ConfigImpl.c(797): Index != Item->DataSize / sizeof 
(EFI_IP6_CONFIG_MANUAL_ADDRESS).

Your suggestions is highly appreciated.

Best Regards,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling in DriverEntryPoint

2017-03-21 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jiaxin
> Wu
> Sent: Wednesday, March 22, 2017 9:33 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Zhang, Lubo ; Fu,
> Siyuan ; Wu, Jiaxin 
> Subject: [edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling 
> in
> DriverEntryPoint
> 
> Currently, error handling in IScsiDriverEntryPoint is incorrect. For example, 
> if
> IScsiCreateAttempts() return error due to the limited max variable size, 
> iSCSI will
> not unload the configuration entries.
> 
> Cc: Zhang Lubo 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  NetworkPkg/IScsiDxe/IScsiDriver.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c
> b/NetworkPkg/IScsiDxe/IScsiDriver.c
> index 269c1ae..2249919 100644
> --- a/NetworkPkg/IScsiDxe/IScsiDriver.c
> +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
> @@ -1811,11 +1811,11 @@ IScsiDriverEntryPoint (
>//
>// Create Keywords for all the Attempts.
>//
>Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber));
>if (EFI_ERROR (Status)) {
> -goto Error5;
> +goto Error6;
>}
> 
>//
>// There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If
> already exists,
>// do not produce the protocol instance.
> @@ -1838,17 +1838,20 @@ IScsiDriverEntryPoint (
>}
> 
>return EFI_SUCCESS;
> 
>  Error6:
> -  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
> +  IScsiCleanAttemptVariable ();
> 
>  Error5:
> -  IScsiCleanAttemptVariable ();
> +  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
> 
>  Error4:
> -  FreePool (mPrivate);
> +  if (mPrivate != NULL) {
> +FreePool (mPrivate);
> +mPrivate = NULL;
> +  }
> 
>  Error3:
>gBS->UninstallMultipleProtocolInterfaces (
>   ImageHandle,
>   &gEfiIScsiInitiatorNameProtocolGuid,
> --
> 1.9.5.msysgit.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] Nt32Pkg: Add NETWORK_IP6_ENABLE to use Max variableSize Pcd on Nt32.

2017-03-16 Thread Zhang Lubo
Update Nt32 platform to use the PcdMaxVariableSize when enabling
Ipv6 network stack.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ruiyu Ni 
Cc: Wu Jiaxin 
---
 Nt32Pkg/Nt32Pkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index 8927dcd..b11cb27 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -270,11 +270,11 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareVolume|L"..\\Fv\\Nt32.fd"
   gEfiNt32PkgTokenSpaceGuid.PcdWinNtFirmwareBlockSize|0x1
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
-!if $(SECURE_BOOT_ENABLE) == TRUE || $(TLS_ENABLE) == TRUE
+!if $(SECURE_BOOT_ENABLE) == TRUE || $(TLS_ENABLE) == TRUE || 
$(NETWORK_IP6_ENABLE) == TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
 !endif
 
 !if $(ALLOW_HTTP_CONNECTIONS) == TRUE
   gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg: Fix bug in DxeHttplib when converting port number.

2017-03-16 Thread Zhang Lubo
Http boot on X64 platform is faild, this is caused by the incorrect
type conversion when getting port number from Url.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index ccc20cc..2ff04ff 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -690,10 +690,11 @@ HttpUrlGetPort (
  OUT  UINT16 *Port
   )
 {
   CHAR8 *PortString;
   EFI_STATUSStatus;
+  UINTN Data;
   UINT32ResultLength;
   HTTP_URL_PARSER  *Parser;
 
   if (Url == NULL || UrlParser == NULL || Port == NULL) {
 return EFI_INVALID_PARAMETER;
@@ -720,11 +721,14 @@ HttpUrlGetPort (
 return Status;
   }
 
   PortString[ResultLength] = '\0';
 
-  return AsciiStrDecimalToUintnS (Url + 
Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, (UINTN *) Port);
+  Status =  AsciiStrDecimalToUintnS (Url + 
Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
+
+  *Port = (UINT16) Data;
+  return Status;
 }
 
 /**
   Get the Path from a HTTP URL.
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2] MdeModulePkg: Fix service binding issue in TCP4 and Ip4 dxe.

2017-03-15 Thread Zhang, Lubo
Go it, thanks for your comments

Best Regards
Lubo 

-Original Message-
From: Ye, Ting 
Sent: Thursday, March 16, 2017 1:31 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Wu, Jiaxin ; Fu, Siyuan 
Subject: RE: [PATCH V2] MdeModulePkg: Fix service binding issue in TCP4 and Ip4 
dxe.

Hi Lubo,

Please update the comment for IP4_STATE_DESTROY in Ip4Impl.h and other possible 
places, since the patch removed the value. 
Also update CopyRight year in SockImpl.h before check-in. Others are good to me.

Reviewed-by: Ye Ting 

Best Regards,
Ting


-Original Message-
From: Zhang, Lubo 
Sent: Wednesday, March 15, 2017 10:28 AM
To: edk2-devel@lists.01.org
Cc: Wu, Jiaxin ; Ye, Ting ; Fu, Siyuan 

Subject: [PATCH V2] MdeModulePkg: Fix service binding issue in TCP4 and Ip4 dxe.

v2: Handle error case in SockCreateChild and fix typo issue

when we destroy the socket Sock and its associated protocol control block, we 
need to first close the parent protocol, then remove the protocol from 
childHandle and last to free any data structures that allocated in CreateChild. 
But currently, we free the socket data (Socket ConfigureState) before removing 
the protocol form  the childhandle. So if the up layer want to send the tcp 
reset packet in it's driver binding stop function, it will failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c  | 10 +--
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c|  3 +-
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h|  5 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c  | 48 +---  
MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h  |  3 +-
 .../Universal/Network/Tcp4Dxe/SockInterface.c  | 88 --
 .../Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c | 12 +--
 7 files changed, 95 insertions(+), 74 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 642e453..792db5c 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -1,9 +1,9 @@
 /** @file
   The driver binding and service binding protocol for IP4 driver.
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
 
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at @@ -920,11 +920,10 
@@ Ip4ServiceBindingDestroyChild (
   EFI_STATUSStatus;
   IP4_SERVICE   *IpSb;
   IP4_PROTOCOL  *IpInstance;
   EFI_IP4_PROTOCOL  *Ip4;
   EFI_TPL   OldTpl;
-  INTN  State;
 
   if ((This == NULL) || (ChildHandle == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -958,17 +957,16 @@ Ip4ServiceBindingDestroyChild (
   // A child can be destroyed more than once. For example,
   // Ip4DriverBindingStop will destroy all of its children.
   // when UDP driver is being stopped, it will destroy all
   // the IP child it opens.
   //
-  if (IpInstance->State == IP4_STATE_DESTROY) {
+  if (IpInstance->InDestroy) {
 gBS->RestoreTPL (OldTpl);
 return EFI_SUCCESS;
   }
 
-  State = IpInstance->State;
-  IpInstance->State = IP4_STATE_DESTROY;
+  IpInstance->InDestroy = TRUE;
 
   //
   // Close the Managed Network protocol.
   //
   gBS->CloseProtocol (
@@ -1007,10 +1005,11 @@ Ip4ServiceBindingDestroyChild (
   &gEfiIp4ProtocolGuid,
   &IpInstance->Ip4Proto
   );
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
   if (EFI_ERROR (Status)) {
+IpInstance->InDestroy = FALSE;
 goto ON_ERROR;
   }
 
   Status = Ip4CleanProtocol (IpInstance);
   if (EFI_ERROR (Status)) {
@@ -1031,10 +1030,9 @@ Ip4ServiceBindingDestroyChild (
 
   FreePool (IpInstance);
   return EFI_SUCCESS;
 
 ON_ERROR:
-  IpInstance->State = State;
   gBS->RestoreTPL (OldTpl);
 
   return Status;
 }
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 91f1a67..23690ff 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at  
http://opensource.org/licenses/bsd-license.php
 
@

[edk2] [PATCH V2] NetworkPkg: Fix service binding issue in TCP dxe.

2017-03-14 Thread Zhang Lubo
v2: Handle error case in SockCreateChild and fix typo issue

when we destroy the socket Sock and its associated
protocol control block, we need to first close the
parent protocol, then remove the protocol from childHandle
and last to free any data structures that allocated in
CreateChild. But currently, we free the socket data (Socket ConfigureState)
before removing the protocol form  the childhandle. So if the up layer
perform the driverbing stop to abort tcp session and send the tcp reset
packet, it will failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/TcpDxe/SockImpl.c  |  56 +---
 NetworkPkg/TcpDxe/SockImpl.h  |   3 +-
 NetworkPkg/TcpDxe/SockInterface.c | 108 +++---
 NetworkPkg/TcpDxe/TcpDispatcher.c |  19 +--
 4 files changed, 104 insertions(+), 82 deletions(-)

diff --git a/NetworkPkg/TcpDxe/SockImpl.c b/NetworkPkg/TcpDxe/SockImpl.c
index 4eb42fb..c5fb176 100644
--- a/NetworkPkg/TcpDxe/SockImpl.c
+++ b/NetworkPkg/TcpDxe/SockImpl.c
@@ -1,9 +1,9 @@
 /** @file
   Implementation of the Socket.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -826,20 +826,12 @@ OnError:
 VOID
 SockDestroy (
   IN OUT SOCKET *Sock
   )
 {
-  VOID*SockProtocol;
-  EFI_GUID*TcpProtocolGuid;
-  EFI_STATUS  Status;
-
   ASSERT (SockStream == Sock->Type);
 
-  if (Sock->DestroyCallback != NULL) {
-Sock->DestroyCallback (Sock, Sock->Context);
-  }
-
   //
   // Flush the completion token buffered
   // by sock and rcv, snd buffer
   //
   if (!SOCK_IS_UNCONFIGURED (Sock)) {
@@ -870,56 +862,10 @@ SockDestroy (
   );
 
 Sock->Parent = NULL;
   }
 
-  //
-  // Set the protocol guid and driver binding handle
-  // in the light of Sock->SockType
-  //
-  if (Sock->IpVersion == IP_VERSION_4) {
-TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
-  } else {
-TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
-  }
-
-  //
-  // Retrieve the protocol installed on this sock
-  //
-  Status = gBS->OpenProtocol (
-  Sock->SockHandle,
-  TcpProtocolGuid,
-  &SockProtocol,
-  Sock->DriverBinding,
-  Sock->SockHandle,
-  EFI_OPEN_PROTOCOL_GET_PROTOCOL
-  );
-
-  if (EFI_ERROR (Status)) {
-
-DEBUG (
-  (EFI_D_ERROR,
-  "SockDestroy: Open protocol installed on socket failed with %r\n",
-  Status)
-  );
-
-goto FreeSock;
-  }
-
-  //
-  // Uninstall the protocol installed on this sock
-  // in the light of Sock->SockType
-  //
-  gBS->UninstallMultipleProtocolInterfaces (
-Sock->SockHandle,
-TcpProtocolGuid,
-SockProtocol,
-NULL
-);
-
-FreeSock:
-
   FreePool (Sock);
 }
 
 /**
   Flush the sndBuffer and rcvBuffer of socket.
diff --git a/NetworkPkg/TcpDxe/SockImpl.h b/NetworkPkg/TcpDxe/SockImpl.h
index 5a067de..80692b1 100644
--- a/NetworkPkg/TcpDxe/SockImpl.h
+++ b/NetworkPkg/TcpDxe/SockImpl.h
@@ -1,9 +1,9 @@
 /** @file
   The function declaration that provided for Socket Interface.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -15,10 +15,11 @@
 
 #ifndef _SOCK_IMPL_H_
 #define _SOCK_IMPL_H_
 
 #include "Socket.h"
+#include "TcpMain.h"
 
 /**
   Signal a event with the given status.
 
   @param[in] TokenThe token's event is to be signaled.
diff --git a/NetworkPkg/TcpDxe/SockInterface.c 
b/NetworkPkg/TcpDxe/SockInterface.c
index 21ce643..b4ba40a 100644
--- a/NetworkPkg/TcpDxe/SockInterface.c
+++ b/NetworkPkg/TcpDxe/SockInterface.c
@@ -1,9 +1,9 @@
 /** @file
   Interface function of the Socket.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -140,20 +140,37 @@ SockBufferToken (
 EFI_STATUS
 SockDestroyChild (
   IN OUT 

[edk2] [PATCH V2] MdeModulePkg: Fix service binding issue in TCP4 and Ip4 dxe.

2017-03-14 Thread Zhang Lubo
v2: Handle error case in SockCreateChild and fix typo issue

when we destroy the socket Sock and its associated
protocol control block, we need to first close the
parent protocol, then remove the protocol from childHandle
and last to free any data structures that allocated in
CreateChild. But currently, we free the socket data
(Socket ConfigureState) before removing the protocol
form  the childhandle. So if the up layer want to send the
tcp reset packet in it's driver binding stop function, it will failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Wu Jiaxin 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c  | 10 +--
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c|  3 +-
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h|  5 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c  | 48 +---
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h  |  3 +-
 .../Universal/Network/Tcp4Dxe/SockInterface.c  | 88 --
 .../Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c | 12 +--
 7 files changed, 95 insertions(+), 74 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 642e453..792db5c 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -1,9 +1,9 @@
 /** @file
   The driver binding and service binding protocol for IP4 driver.
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -920,11 +920,10 @@ Ip4ServiceBindingDestroyChild (
   EFI_STATUSStatus;
   IP4_SERVICE   *IpSb;
   IP4_PROTOCOL  *IpInstance;
   EFI_IP4_PROTOCOL  *Ip4;
   EFI_TPL   OldTpl;
-  INTN  State;
 
   if ((This == NULL) || (ChildHandle == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -958,17 +957,16 @@ Ip4ServiceBindingDestroyChild (
   // A child can be destroyed more than once. For example,
   // Ip4DriverBindingStop will destroy all of its children.
   // when UDP driver is being stopped, it will destroy all
   // the IP child it opens.
   //
-  if (IpInstance->State == IP4_STATE_DESTROY) {
+  if (IpInstance->InDestroy) {
 gBS->RestoreTPL (OldTpl);
 return EFI_SUCCESS;
   }
 
-  State = IpInstance->State;
-  IpInstance->State = IP4_STATE_DESTROY;
+  IpInstance->InDestroy = TRUE;
 
   //
   // Close the Managed Network protocol.
   //
   gBS->CloseProtocol (
@@ -1007,10 +1005,11 @@ Ip4ServiceBindingDestroyChild (
   &gEfiIp4ProtocolGuid,
   &IpInstance->Ip4Proto
   );
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
   if (EFI_ERROR (Status)) {
+IpInstance->InDestroy = FALSE;
 goto ON_ERROR;
   }
 
   Status = Ip4CleanProtocol (IpInstance);
   if (EFI_ERROR (Status)) {
@@ -1031,10 +1030,9 @@ Ip4ServiceBindingDestroyChild (
 
   FreePool (IpInstance);
   return EFI_SUCCESS;
 
 ON_ERROR:
-  IpInstance->State = State;
   gBS->RestoreTPL (OldTpl);
 
   return Status;
 }
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 91f1a67..23690ff 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -548,10 +548,11 @@ Ip4InitProtocol (
   ZeroMem (IpInstance, sizeof (IP4_PROTOCOL));
 
   IpInstance->Signature = IP4_PROTOCOL_SIGNATURE;
   CopyMem (&IpInstance->Ip4Proto, &mEfiIp4ProtocolTemplete, sizeof 
(IpInstance->Ip4Proto));
   IpInstance->State = IP4_STATE_UNCONFIGED;
+  IpInstance->InDestroy   = FALSE;
   IpInstance->Service   = IpSb;
 
   InitializeListHead (&IpInstance->Link);
   NetMapInit  (&IpInstance->RxTokens);
   NetMapInit  (&IpInstance->TxTokens);
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
index 7a7ad9d..eee38b7 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
@@ -1,9 +1,9 @@
 /** @file

Re: [edk2] ISCSI says "Session Doesn't Exist"

2017-03-13 Thread Zhang, Lubo
Hi Naveen

I mean that the patch will fix reconnect -r command but not reset command 
for next boot  iSCSI connection.


Thanks
Lubo

> -Original Message-
> From: Santhapur Naveen [mailto:nave...@amiindia.co.in]
> Sent: Tuesday, March 14, 2017 1:01 PM
> To: Zhang, Lubo 
> Cc: Ye, Ting ; edk2-devel@lists.01.org
> Subject: RE: ISCSI says "Session Doesn't Exist"
> 
> Hi Lubo,
> 
> Many thanks for your update.
> 
> You mean to say that this issue is because of the TCP Service and this can be
> fixed with the path you are yet to send. Am I right?
> 
> Warm Regards,
> Naveen
> 
> From: Zhang, Lubo [lubo.zh...@intel.com]
> Sent: Tuesday, March 14, 2017 7:24 AM
> To: Santhapur Naveen
> Cc: Ye, Ting; edk2-devel@lists.01.org
> Subject: RE: ISCSI says "Session Doesn't Exist"
> 
> Hi Naveen
> 
>  For this issue you mentioned, I have found the root cause. After we
> established the iSCSI connection between initiator and target server, if we 
> use
> the following command immediately
> 
> Reset command (system power off, will not perform driver binding stop, from
> my debug log) : we can rebuilt the iSCSI connection if the target is deployed 
> on
> Debain OS, but failed on windows server, this is the target server behavior. 
> Since
> we do not send the reset packet on my platform, so the windows target server
> think our session is still exist and reject the new session request.
> 
> Reconnect -r:  this command will execute the iSCSI driver binding stop 
> function
> and reset the TCP connection actively. But we cannot capture the reset packet
> either.  I debugged and find that before we reset the socket in 
> IScsiSessionAbort,
> the socket configured state has already been set as unconfigured in tcp driver
> binding stop , so we will not invoke the TCP dispatch to abort the connection 
> by
> sending a reset packet.
> 
> This is a Tcp service binding  destroy child issue, I will send a patch to 
> fix.
> 
> 
> Best regards
> Lubo
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ye,
> Ting
> Sent: Tuesday, February 28, 2017 4:53 PM
> To: Santhapur Naveen ; edk2-devel@lists.01.org
> Subject: Re: [edk2] ISCSI says "Session Doesn't Exist"
> 
> Hi Naveen,
> 
> Thanks for your info. We are able to reproduce the issue using Windows Server
> 2012 now. So far we are still not sure whether it is a particular issue in 
> Windows
> iSCSI target or UEFI iSCSI initiator.
> 
> Will update to you once we have further information later.
> 
> For your info: A link describes the know issues in Windows Server 2012 iSCSI
> target, https://technet.microsoft.com/en-us/library/jj863561(v=ws.11).aspx. It
> has a related issue but not the same one we met now.
> 
> Standard Login Key Negotiation
> RFC 3720, section 10.13.3, specifies the following:
> For a new session, the target MUST generate a non-zero TSIH and ONLY return it
> in the Login Final-Response.
> The behavior exhibited by ISCSI Target Server:
> When the iSCSI initiator performed a standard login and negotiated the login
> parameters, the iSCSI Target Server was observed to set the TSIH field in the 
> first
> Login Response PDU.
> 
> Thanks,
> Ting
> 
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Santhapur Naveen
> Sent: Tuesday, February 28, 2017 4:04 AM
> To: Ye, Ting ; edk2-devel@lists.01.org
> Subject: Re: [edk2] ISCSI says "Session Doesn't Exist"
> 
> Hello Ting,
> 
> I've configured iSCSI target in Windows Server 2012. And the procedure is 
> similar
> as in https://blogs.technet.microsoft.com/filecab/2012/05/21/introduction-of-
> iscsi-target-in-windows-server-2012/
> Please let me know if I had to make any changes to my iSCSI server.
> 
> Thank you,
> Naveen
> 
> From: Ye, Ting [ting...@intel.com]
> Sent: Monday, February 27, 2017 1:23 PM
> To: Santhapur Naveen; edk2-devel@lists.01.org
> Subject: RE: ISCSI says "Session Doesn't Exist"
> 
> Hi Naveen,
> 
> According to the table you shared (defined in RFC 3720), it seems when TSIH is
> ZERO, the target should not fail the login with "session does not exist".
> 
>+--+
>|new   | zero| any| instantiate a new session  |
>+--+
>|existing  | zero| any| do session reinstatement   |
>|   

Re: [edk2] [patch] NetworkPkg: Fix driver binding issue in TCP dxe.

2017-03-13 Thread Zhang, Lubo
Thanks for your comments, will send another patch to update this.


Best regards
Lubo

-Original Message-
From: Wu, Jiaxin 
Sent: Monday, March 13, 2017 3:44 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan 
Subject: RE: [edk2] [patch] NetworkPkg: Fix driver binding issue in TCP dxe.

My comments as below:

 1. SockDestroyChild: The sock should be locked to access first, then we can 
update it (close/uninstall).

 2. SockDestroyChild: Debug info should be "SockDestroyChild:" instead of 
"SockDestroy:"

 3. One concern in SockCreateChild: 
Since the " CloseProtocol/Uninstall" operation is removed  from 
SockDestroy, we need handle it alone while the ERROR may happened in in 
SockCreateChild. 

Thanks,
Jiaxin


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Zhang Lubo
> Sent: Friday, March 10, 2017 6:02 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan 
> Subject: [edk2] [patch] NetworkPkg: Fix driver binding issue in TCP dxe.
> 
> when we destroy the socket Sock and its associated protocol control 
> block, we need to first close the parent protocol, then remove the 
> protocol from childHandle and last to free any data structures that 
> allocated in CreateChild. But currently, we free the socket data 
> (Socket ConfigureState) before removing the protocol form  the 
> childhandle. So if the up layer want to send the tcp reset packet in 
> it's driver binding stop function, it will failed.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> ---
>  NetworkPkg/TcpDxe/SockImpl.c  | 56 +
>  NetworkPkg/TcpDxe/SockImpl.h  |  3 +-
>  NetworkPkg/TcpDxe/SockInterface.c | 66
> +--
>  NetworkPkg/TcpDxe/TcpDispatcher.c | 19 +--
>  4 files changed, 68 insertions(+), 76 deletions(-)
> 
> diff --git a/NetworkPkg/TcpDxe/SockImpl.c 
> b/NetworkPkg/TcpDxe/SockImpl.c index 4eb42fb..c5fb176 100644
> --- a/NetworkPkg/TcpDxe/SockImpl.c
> +++ b/NetworkPkg/TcpDxe/SockImpl.c
> @@ -1,9 +1,9 @@
>  /** @file
>Implementation of the Socket.
> 
> -  Copyright (c) 2009 - 2016, Intel Corporation. All rights 
> reserved.
> +  Copyright (c) 2009 - 2017, Intel Corporation. All rights 
> + reserved.
> 
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of 
> the BSD License
>which accompanies this distribution.  The full text of the license 
> may be found at
>http://opensource.org/licenses/bsd-license.php.
> @@ -826,20 +826,12 @@ OnError:
>  VOID
>  SockDestroy (
>IN OUT SOCKET *Sock
>)
>  {
> -  VOID*SockProtocol;
> -  EFI_GUID*TcpProtocolGuid;
> -  EFI_STATUS  Status;
> -
>ASSERT (SockStream == Sock->Type);
> 
> -  if (Sock->DestroyCallback != NULL) {
> -Sock->DestroyCallback (Sock, Sock->Context);
> -  }
> -
>//
>// Flush the completion token buffered
>// by sock and rcv, snd buffer
>//
>if (!SOCK_IS_UNCONFIGURED (Sock)) { @@ -870,56 +862,10 @@ 
> SockDestroy (
>);
> 
>  Sock->Parent = NULL;
>}
> 
> -  //
> -  // Set the protocol guid and driver binding handle
> -  // in the light of Sock->SockType
> -  //
> -  if (Sock->IpVersion == IP_VERSION_4) {
> -TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
> -  } else {
> -TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
> -  }
> -
> -  //
> -  // Retrieve the protocol installed on this sock
> -  //
> -  Status = gBS->OpenProtocol (
> -  Sock->SockHandle,
> -  TcpProtocolGuid,
> -  &SockProtocol,
> -  Sock->DriverBinding,
> -  Sock->SockHandle,
> -  EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -  );
> -
> -  if (EFI_ERROR (Status)) {
> -
> -DEBUG (
> -  (EFI_D_ERROR,
> -  "SockDestroy: Open protocol installed on socket failed with %r\n",
> -  Status)
> -  );
> -
> -goto FreeSock;
> -  }
> -
> -  //
> -  // Uninstall the protocol installed on this sock
> -  // in the light of Sock->SockType
> -  //
> -  gBS->UninstallMultipleProtocolInterfaces (
> -Sock->SockHandle,
> -TcpProtocolGuid,
> -SockProtocol,
> -NULL
> -);
> -
> -FreeSock:
> -
>FreePool (Sock);
>  }
> 
>  /**
>Flush the sndBuffer and rcvBuffer of socket.
> diff --git a/NetworkPkg/TcpDxe/SockImpl.h 
> b/Net

Re: [edk2] ISCSI says "Session Doesn't Exist"

2017-03-13 Thread Zhang, Lubo
Hi Naveen

 For this issue you mentioned, I have found the root cause. After we 
established the iSCSI connection between initiator and target server, if we use 
the following command immediately 

Reset command (system power off, will not perform driver binding stop, from my 
debug log) : we can rebuilt the iSCSI connection if the target is deployed on 
Debain OS, but failed on windows server, this is the target server behavior. 
Since we do not send the reset packet on my platform, so the windows target 
server think our session is still exist and reject the new session request.

Reconnect -r:  this command will execute the iSCSI driver binding stop function 
and reset the TCP connection actively. But we cannot capture the reset packet 
either.  I debugged and find that before we reset the socket in 
IScsiSessionAbort, the socket configured state has already been set as 
unconfigured in tcp driver binding stop , so we will not invoke the TCP 
dispatch to abort the connection by sending a reset packet.

This is a Tcp service binding  destroy child issue, I will send a patch to fix.


Best regards
Lubo

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ye, Ting
Sent: Tuesday, February 28, 2017 4:53 PM
To: Santhapur Naveen ; edk2-devel@lists.01.org
Subject: Re: [edk2] ISCSI says "Session Doesn't Exist"

Hi Naveen,

Thanks for your info. We are able to reproduce the issue using Windows Server 
2012 now. So far we are still not sure whether it is a particular issue in 
Windows iSCSI target or UEFI iSCSI initiator.

Will update to you once we have further information later. 

For your info: A link describes the know issues in Windows Server 2012 iSCSI 
target, https://technet.microsoft.com/en-us/library/jj863561(v=ws.11).aspx. It 
has a related issue but not the same one we met now. 

Standard Login Key Negotiation
RFC 3720, section 10.13.3, specifies the following:
For a new session, the target MUST generate a non-zero TSIH and ONLY return it 
in the Login Final-Response.
The behavior exhibited by ISCSI Target Server:
When the iSCSI initiator performed a standard login and negotiated the login 
parameters, the iSCSI Target Server was observed to set the TSIH field in the 
first Login Response PDU.

Thanks,
Ting


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Tuesday, February 28, 2017 4:04 AM
To: Ye, Ting ; edk2-devel@lists.01.org
Subject: Re: [edk2] ISCSI says "Session Doesn't Exist"

Hello Ting,

I've configured iSCSI target in Windows Server 2012. And the procedure is 
similar as in 
https://blogs.technet.microsoft.com/filecab/2012/05/21/introduction-of-iscsi-target-in-windows-server-2012/
Please let me know if I had to make any changes to my iSCSI server.

Thank you,
Naveen

From: Ye, Ting [ting...@intel.com]
Sent: Monday, February 27, 2017 1:23 PM
To: Santhapur Naveen; edk2-devel@lists.01.org
Subject: RE: ISCSI says "Session Doesn't Exist"

Hi Naveen,

According to the table you shared (defined in RFC 3720), it seems when TSIH is 
ZERO, the target should not fail the login with "session does not exist".

   +--+
   |new   | zero| any| instantiate a new session  |
   +--+
   |existing  | zero| any| do session reinstatement   |
   |  | || (see section 5.3.5)|
   +--+

I checked the latest code in NetworkPkg/IScsiDxe, the Tsih is always set to 
ZERO in IScsiSessionInit. The immediate reset will also trigger driver binding 
start so IScsiSessionInit will be executed.

It seems to me your iSCSI target does not comply with the rules defined in RFC 
documentation. If possible, would you please tell us which iSCSI target are you 
using?

Thanks,
Ting

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Friday, February 24, 2017 9:59 PM
To: edk2-devel@lists.01.org
Subject: [edk2] ISCSI says "Session Doesn't Exist"

Hello all,

I've a question about IScsi and any suggestions would be helpful

[Issue Summary]
If I add an ISCSI attempt and on the next reboot, a connection will be 
established in between the initiator and the target. Till now, it is fine. Now 
if I do an immediate reset with in 20 seconds, on the next boot, the initiator 
is trying to establish a session, but the target rejects saying "Session does 
not exist". If I reset after 20 seconds or so, the connection would have been 
established with the same login details.

To dive deeper, I've checked the RFC documentation on this and found the 
following information. But when I checked the wireshark capture, I found my 
TSIH is ZERO even for the immediat

[edk2] [patch] NetworkPkg: Fix driver binding issue in TCP dxe.

2017-03-10 Thread Zhang Lubo
when we destroy the socket Sock and its associated
protocol control block, we need to first close the
parent protocol, then remove the protocol from childHandle
and last to free any data structures that allocated in
CreateChild. But currently, we free the socket data (Socket ConfigureState)
before removing the protocol form  the childhandle. So if the up layer
want to send the tcp reset packet in it's driver binding stop
function, it will failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/TcpDxe/SockImpl.c  | 56 +
 NetworkPkg/TcpDxe/SockImpl.h  |  3 +-
 NetworkPkg/TcpDxe/SockInterface.c | 66 +--
 NetworkPkg/TcpDxe/TcpDispatcher.c | 19 +--
 4 files changed, 68 insertions(+), 76 deletions(-)

diff --git a/NetworkPkg/TcpDxe/SockImpl.c b/NetworkPkg/TcpDxe/SockImpl.c
index 4eb42fb..c5fb176 100644
--- a/NetworkPkg/TcpDxe/SockImpl.c
+++ b/NetworkPkg/TcpDxe/SockImpl.c
@@ -1,9 +1,9 @@
 /** @file
   Implementation of the Socket.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -826,20 +826,12 @@ OnError:
 VOID
 SockDestroy (
   IN OUT SOCKET *Sock
   )
 {
-  VOID*SockProtocol;
-  EFI_GUID*TcpProtocolGuid;
-  EFI_STATUS  Status;
-
   ASSERT (SockStream == Sock->Type);
 
-  if (Sock->DestroyCallback != NULL) {
-Sock->DestroyCallback (Sock, Sock->Context);
-  }
-
   //
   // Flush the completion token buffered
   // by sock and rcv, snd buffer
   //
   if (!SOCK_IS_UNCONFIGURED (Sock)) {
@@ -870,56 +862,10 @@ SockDestroy (
   );
 
 Sock->Parent = NULL;
   }
 
-  //
-  // Set the protocol guid and driver binding handle
-  // in the light of Sock->SockType
-  //
-  if (Sock->IpVersion == IP_VERSION_4) {
-TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
-  } else {
-TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
-  }
-
-  //
-  // Retrieve the protocol installed on this sock
-  //
-  Status = gBS->OpenProtocol (
-  Sock->SockHandle,
-  TcpProtocolGuid,
-  &SockProtocol,
-  Sock->DriverBinding,
-  Sock->SockHandle,
-  EFI_OPEN_PROTOCOL_GET_PROTOCOL
-  );
-
-  if (EFI_ERROR (Status)) {
-
-DEBUG (
-  (EFI_D_ERROR,
-  "SockDestroy: Open protocol installed on socket failed with %r\n",
-  Status)
-  );
-
-goto FreeSock;
-  }
-
-  //
-  // Uninstall the protocol installed on this sock
-  // in the light of Sock->SockType
-  //
-  gBS->UninstallMultipleProtocolInterfaces (
-Sock->SockHandle,
-TcpProtocolGuid,
-SockProtocol,
-NULL
-);
-
-FreeSock:
-
   FreePool (Sock);
 }
 
 /**
   Flush the sndBuffer and rcvBuffer of socket.
diff --git a/NetworkPkg/TcpDxe/SockImpl.h b/NetworkPkg/TcpDxe/SockImpl.h
index 5a067de..80692b1 100644
--- a/NetworkPkg/TcpDxe/SockImpl.h
+++ b/NetworkPkg/TcpDxe/SockImpl.h
@@ -1,9 +1,9 @@
 /** @file
   The function declaration that provided for Socket Interface.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -15,10 +15,11 @@
 
 #ifndef _SOCK_IMPL_H_
 #define _SOCK_IMPL_H_
 
 #include "Socket.h"
+#include "TcpMain.h"
 
 /**
   Signal a event with the given status.
 
   @param[in] TokenThe token's event is to be signaled.
diff --git a/NetworkPkg/TcpDxe/SockInterface.c 
b/NetworkPkg/TcpDxe/SockInterface.c
index 21ce643..5269c56 100644
--- a/NetworkPkg/TcpDxe/SockInterface.c
+++ b/NetworkPkg/TcpDxe/SockInterface.c
@@ -1,9 +1,9 @@
 /** @file
   Interface function of the Socket.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -140,20 +140,82 @@ SockBufferToken (
 EFI_STATUS
 SockDestroyChild (
   IN OUT SOCKET *Sock
   )
 {
-  EFI_STATUS  Status;
+  

[edk2] [patch] MdeModulePkg: Fix driver binding issue in TCP4 and Ip4 dxe.

2017-03-10 Thread Zhang Lubo
when we destroy the socket Sock and its associated
protocol control block, we need to first close the
parent protocol, then remove the protocol from childHandle
and last to free any data structures that allocated in
CreateChild. But currently, we free the socket data
(Socket ConfigureState) before removing the protocol
form  the childhandle. So if the up layer want to send the
tcp reset packet in it's driver binding stop function, it will failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c  | 10 ++--
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c|  3 +-
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h|  5 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c  | 48 +--
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h  |  3 +-
 .../Universal/Network/Tcp4Dxe/SockInterface.c  | 55 +-
 .../Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c | 12 +
 7 files changed, 66 insertions(+), 70 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 642e453..792db5c 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -1,9 +1,9 @@
 /** @file
   The driver binding and service binding protocol for IP4 driver.
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -920,11 +920,10 @@ Ip4ServiceBindingDestroyChild (
   EFI_STATUSStatus;
   IP4_SERVICE   *IpSb;
   IP4_PROTOCOL  *IpInstance;
   EFI_IP4_PROTOCOL  *Ip4;
   EFI_TPL   OldTpl;
-  INTN  State;
 
   if ((This == NULL) || (ChildHandle == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -958,17 +957,16 @@ Ip4ServiceBindingDestroyChild (
   // A child can be destroyed more than once. For example,
   // Ip4DriverBindingStop will destroy all of its children.
   // when UDP driver is being stopped, it will destroy all
   // the IP child it opens.
   //
-  if (IpInstance->State == IP4_STATE_DESTROY) {
+  if (IpInstance->InDestroy) {
 gBS->RestoreTPL (OldTpl);
 return EFI_SUCCESS;
   }
 
-  State = IpInstance->State;
-  IpInstance->State = IP4_STATE_DESTROY;
+  IpInstance->InDestroy = TRUE;
 
   //
   // Close the Managed Network protocol.
   //
   gBS->CloseProtocol (
@@ -1007,10 +1005,11 @@ Ip4ServiceBindingDestroyChild (
   &gEfiIp4ProtocolGuid,
   &IpInstance->Ip4Proto
   );
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
   if (EFI_ERROR (Status)) {
+IpInstance->InDestroy = FALSE;
 goto ON_ERROR;
   }
 
   Status = Ip4CleanProtocol (IpInstance);
   if (EFI_ERROR (Status)) {
@@ -1031,10 +1030,9 @@ Ip4ServiceBindingDestroyChild (
 
   FreePool (IpInstance);
   return EFI_SUCCESS;
 
 ON_ERROR:
-  IpInstance->State = State;
   gBS->RestoreTPL (OldTpl);
 
   return Status;
 }
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 91f1a67..23690ff 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -548,10 +548,11 @@ Ip4InitProtocol (
   ZeroMem (IpInstance, sizeof (IP4_PROTOCOL));
 
   IpInstance->Signature = IP4_PROTOCOL_SIGNATURE;
   CopyMem (&IpInstance->Ip4Proto, &mEfiIp4ProtocolTemplete, sizeof 
(IpInstance->Ip4Proto));
   IpInstance->State = IP4_STATE_UNCONFIGED;
+  IpInstance->InDestroy   = FALSE;
   IpInstance->Service   = IpSb;
 
   InitializeListHead (&IpInstance->Link);
   NetMapInit  (&IpInstance->RxTokens);
   NetMapInit  (&IpInstance->TxTokens);
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
index 7a7ad9d..eee38b7 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
@@ -1,9 +1,9 @@
 /** @file
   Ip4 internal functions and type defintions.
   
-Copyright (c) 20

[edk2] [patch] NetworkPkg: Fix potential bug if the iSCSI use dns protocol.

2017-03-09 Thread Zhang Lubo
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 FALSEThe 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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] ISCSI says "Session Doesn't Exist"

2017-02-28 Thread Zhang, Lubo
Hi Naveen

For the issue summary you mentioned, I take a test on iscsi target which 
deployed on Debian operating system, it works even if we do an immediate reset 
within 20 seconds after the first correct connection. But I am not quite sure 
it is a target server issue. 
Will investigate and inform you if we have future information later.

Thanks
Lubo

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Tuesday, February 28, 2017 4:04 AM
To: Ye, Ting ; edk2-devel@lists.01.org
Subject: Re: [edk2] ISCSI says "Session Doesn't Exist"

Hello Ting,

I've configured iSCSI target in Windows Server 2012. And the procedure is 
similar as in 
https://blogs.technet.microsoft.com/filecab/2012/05/21/introduction-of-iscsi-target-in-windows-server-2012/
Please let me know if I had to make any changes to my iSCSI server.

Thank you,
Naveen

From: Ye, Ting [ting...@intel.com]
Sent: Monday, February 27, 2017 1:23 PM
To: Santhapur Naveen; edk2-devel@lists.01.org
Subject: RE: ISCSI says "Session Doesn't Exist"

Hi Naveen,

According to the table you shared (defined in RFC 3720), it seems when TSIH is 
ZERO, the target should not fail the login with "session does not exist".

   +--+
   |new   | zero| any| instantiate a new session  |
   +--+
   |existing  | zero| any| do session reinstatement   |
   |  | || (see section 5.3.5)|
   +--+

I checked the latest code in NetworkPkg/IScsiDxe, the Tsih is always set to 
ZERO in IScsiSessionInit. The immediate reset will also trigger driver binding 
start so IScsiSessionInit will be executed.

It seems to me your iSCSI target does not comply with the rules defined in RFC 
documentation. If possible, would you please tell us which iSCSI target are you 
using?

Thanks,
Ting

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Friday, February 24, 2017 9:59 PM
To: edk2-devel@lists.01.org
Subject: [edk2] ISCSI says "Session Doesn't Exist"

Hello all,

I've a question about IScsi and any suggestions would be helpful

[Issue Summary]
If I add an ISCSI attempt and on the next reboot, a connection will be 
established in between the initiator and the target. Till now, it is fine. Now 
if I do an immediate reset with in 20 seconds, on the next boot, the initiator 
is trying to establish a session, but the target rejects saying "Session does 
not exist". If I reset after 20 seconds or so, the connection would have been 
established with the same login details.

To dive deeper, I've checked the RFC documentation on this and found the 
following information. But when I checked the wireshark capture, I found my 
TSIH is ZERO even for the immediate session. If I want to make my immediate 
session also into a successful one, what should I be doing? I'm aware that 
there's a function available IScsiSessionAbort(). Would it help me or provide 
your suggestions to get me going.


   +--+

   |ISID  | TSIH| CID| Target action  |

   +--+

   |new   | non-zero| any| fail the login |

   |  | || ("session does not exist") |

   +--+

   |new   | zero| any| instantiate a new session  |

   +--+

   |existing  | zero| any| do session reinstatement   |

   |  | || (see section 5.3.5)|

   +--+

   |existing  | non-zero| new| add a new connection to|

   |  | existing|| the session|

   +--+

   |existing  | non-zero|existing| do connection reinstatement|

   |  | existing||(see section 5.3.4) |

   +--+

   |existing  | non-zero| any| fail the login |

   |  | new || ("session does not exist") |

   +--+


Thanks,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel

[edk2] [PATCH V2] NetworkPkg: Add check logic for some variable in iSCSI driver.

2017-02-27 Thread Zhang Lubo
v2: need to check the global variable mPrivate before using it in
the Convert AttemptConfigData To IfrNvData by Keyword function.

Add check logic for some attempt variable to enhance code in iSCSI.

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 | 271 --
 NetworkPkg/IScsiDxe/IScsiConfig.h |   2 +-
 2 files changed, 143 insertions(+), 130 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index b169620..08a49d6 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -628,116 +628,123 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (
   ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;
   ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
   CHAR16AttemptNameList[ATTEMPT_NAME_LIST_SIZE];
   EFI_IP_ADDRESSIp;
   UINTN Index;
+  UINTN StringLen;
 
   ZeroMem (AttemptNameList, sizeof (AttemptNameList));
 
-  NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
-Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
-//
-// Normal session configuration parameters.
-//
-SessionConfigData = &Attempt->SessionConfigData;
-
-Index   = Attempt->AttemptConfigIndex - 1;
+  if ((mPrivate != NULL) && (mPrivate->AttemptCount != 0)) {
+NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
+  Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, 
Link);
+  //
+  // Normal session configuration parameters.
+  //
+  SessionConfigData = &Attempt->SessionConfigData;
 
-//
-// Save the attempt to AttemptNameList as Attempt:1 Attempt:2
-//
-AsciiStrToUnicodeStrS (
-  Attempt->AttemptName,
-  AttemptNameList + StrLen (AttemptNameList),
-  ATTEMPT_NAME_LIST_SIZE
-);
-*(AttemptNameList + StrLen (AttemptNameList) - 2) = L':';
-*(AttemptNameList + StrLen (AttemptNameList)) = L' ';
+  ASSERT ((Attempt->AttemptConfigIndex > 0) && 
(Attempt->AttemptConfigIndex <= FixedPcdGet8 (PcdMaxIScsiAttemptNumber)));
+  Index   = Attempt->AttemptConfigIndex - 1;
 
-AsciiStrToUnicodeStrS (
-  Attempt->AttemptName,
-  IfrNvData->ISCSIAttemptName  + ATTEMPT_NAME_SIZE * Index,
-  ATTEMPT_NAME_SIZE
-);
+  //
+  // Save the attempt to AttemptNameList as Attempt:1 Attempt:2
+  //
+  AsciiStrToUnicodeStrS (
+Attempt->AttemptName,
+AttemptNameList + StrLen (AttemptNameList),
+ATTEMPT_NAME_LIST_SIZE - StrLen (AttemptNameList)
+  );
 
-IfrNvData->ISCSIBootEnableList[Index]  = 
SessionConfigData->Enabled;
-IfrNvData->ISCSIIpAddressTypeList[Index]   = SessionConfigData->IpMode;
+  StringLen = StrLen (AttemptNameList);
+  ASSERT (StringLen > 2);
+  *(AttemptNameList + StringLen - 2) = L':';
+  *(AttemptNameList + StringLen) = L' ';
 
-IfrNvData->ISCSIInitiatorInfoViaDHCP[Index]= 
SessionConfigData->InitiatorInfoFromDhcp;
-IfrNvData->ISCSITargetInfoViaDHCP[Index]   = 
SessionConfigData->TargetInfoFromDhcp;
-IfrNvData->ISCSIConnectRetry[Index]= 
SessionConfigData->ConnectRetryCount;
-IfrNvData->ISCSIConnectTimeout[Index]  = 
SessionConfigData->ConnectTimeout;
-IfrNvData->ISCSITargetTcpPort[Index]   = 
SessionConfigData->TargetPort;
+  AsciiStrToUnicodeStrS (
+Attempt->AttemptName,
+IfrNvData->ISCSIAttemptName  + ATTEMPT_NAME_SIZE * Index,
+ATTEMPT_NAME_LIST_SIZE - ATTEMPT_NAME_SIZE * Index
+  );
 
-if (SessionConfigData->IpMode == IP_MODE_IP4) {
-  CopyMem (&Ip.v4, &SessionConfigData->LocalIp, sizeof (EFI_IPv4_ADDRESS));
-  IScsiIpToStr (&Ip, FALSE, 
IfrNvData->Keyword[Index].ISCSIInitiatorIpAddress);
-  CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof 
(EFI_IPv4_ADDRESS));
-  IScsiIpToStr (&Ip, FALSE, 
IfrNvData->Keyword[Index].ISCSIInitiatorNetmask);
-  CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS));
-  IScsiIpToStr (&Ip, FALSE, 
IfrNvData->Keyword[Index].ISCSIInitiatorGateway);
-  if (SessionConfigData->TargetIp.v4.Addr[0] != '\0') {
-CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof 
(EFI_IPv4_ADDRESS));
-IScsiIpToStr (&Ip, FALSE, 
IfrNvData->Keyword[Index].ISCSITargetIpAddress);
-  }
-} else if (SessionConfigData->IpMode == IP_MODE_IP6) {
-  ZeroMem (IfrNvData->Keyword[Index].ISCSITargetIpAddress, sizeof 
(IfrNvData->T

[edk2] [patch] NetworkPkg: Define the prompt and help information for new PCD.

2017-02-27 Thread Zhang Lubo
Define the prompt and help information for PcdMaxIScsiAttemptNumber.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/NetworkPkg.uni | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/NetworkPkg/NetworkPkg.uni b/NetworkPkg/NetworkPkg.uni
index d0e9b36..cdaee76 100644
--- a/NetworkPkg/NetworkPkg.uni
+++ b/NetworkPkg/NetworkPkg.uni
@@ -19,10 +19,13 @@
 #string STR_PACKAGE_ABSTRACT#language en-US "This package provides 
network modules that conform to UEFI 2.4 specification."
 
 #string STR_PACKAGE_DESCRIPTION #language en-US "This package provides 
network modules that conform to UEFI 2.4 specification."
 
 
+#string STR_gEfiNetworkPkgTokenSpaceGuid_PcdMaxIScsiAttemptNumber_PROMPT  
#language en-US "Max attempt number."
+
+#string STR_gEfiNetworkPkgTokenSpaceGuid_PcdMaxIScsiAttemptNumber_HELP  
#language en-US "Max attempt number created by iSCSI."
 
 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIpsecUefiCaFile_PROMPT  #language 
en-US "CA file."
 
 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIpsecUefiCaFile_HELP  #language 
en-US "CA certificate used by IPsec."
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Add check logic for some variable in iSCSI driver.

2017-02-23 Thread Zhang Lubo
Add check logic for some attempt variable to enhance code in iSCSI.

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 | 75 +--
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index b169620..f8c0a61 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -628,37 +628,42 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (
   ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;
   ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
   CHAR16AttemptNameList[ATTEMPT_NAME_LIST_SIZE];
   EFI_IP_ADDRESSIp;
   UINTN Index;
+  UINTN StringLen;
 
   ZeroMem (AttemptNameList, sizeof (AttemptNameList));
 
   NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
 Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
 //
 // Normal session configuration parameters.
 //
 SessionConfigData = &Attempt->SessionConfigData;
 
+ASSERT ((Attempt->AttemptConfigIndex > 0) && (Attempt->AttemptConfigIndex 
<= FixedPcdGet8 (PcdMaxIScsiAttemptNumber)));
 Index   = Attempt->AttemptConfigIndex - 1;
 
 //
 // Save the attempt to AttemptNameList as Attempt:1 Attempt:2
 //
 AsciiStrToUnicodeStrS (
   Attempt->AttemptName,
   AttemptNameList + StrLen (AttemptNameList),
-  ATTEMPT_NAME_LIST_SIZE
+  ATTEMPT_NAME_LIST_SIZE - StrLen (AttemptNameList)
 );
-*(AttemptNameList + StrLen (AttemptNameList) - 2) = L':';
-*(AttemptNameList + StrLen (AttemptNameList)) = L' ';
+
+StringLen = StrLen (AttemptNameList);
+ASSERT (StringLen > 2);
+*(AttemptNameList + StringLen - 2) = L':';
+*(AttemptNameList + StringLen) = L' ';
 
 AsciiStrToUnicodeStrS (
   Attempt->AttemptName,
   IfrNvData->ISCSIAttemptName  + ATTEMPT_NAME_SIZE * Index,
-  ATTEMPT_NAME_SIZE
+  ATTEMPT_NAME_LIST_SIZE - ATTEMPT_NAME_SIZE * Index
 );
 
 IfrNvData->ISCSIBootEnableList[Index]  = 
SessionConfigData->Enabled;
 IfrNvData->ISCSIIpAddressTypeList[Index]   = SessionConfigData->IpMode;
 
@@ -1199,10 +1204,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
   EFI_IP_ADDRESS   Gateway;
   EFI_INPUT_KEYKey;
   UINT64   Lun;
   EFI_STATUS   Status;
 
+  Attempt = NULL;
   ZeroMem (IScsiName, sizeof (IScsiName));
 
   if (OffSet < ATTEMPT_BOOTENABLE_VAR_OFFSET) {
 return EFI_SUCCESS;
 
@@ -1726,11 +1732,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (
 
 
   //
   // Record the user configuration information in NVR.
   //
-
+  ASSERT (Attempt != NULL);
   UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 
L"Attempt %d", Attempt->AttemptConfigIndex);
   return gRT->SetVariable (
 mPrivate->PortString,
 &gEfiIScsiInitiatorNameProtocolGuid,
 ISCSI_CONFIG_VAR_ATTR,
@@ -2705,10 +2711,11 @@ IScsiConfigProcessDefault (
   UINT8   *AttemptConfigOrder;
   UINTN   AttemptConfigOrderSize;
   UINTN   Index;
   EFI_INPUT_KEY   Key;
 
+  AttemptConfigData = NULL;
   //
   // Is User creating a new attempt?
   //
   NewAttempt = FALSE;
 
@@ -2749,41 +2756,40 @@ IScsiConfigProcessDefault (
L"InitialAttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
 
-if (AttemptConfigOrder != NULL) {
-
-  for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); 
Index++) {
-UnicodeSPrint (
-  mPrivate->PortString,
-  (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
-  L"Attempt %d",
-  (UINTN) AttemptConfigOrder[Index]
-  );
-GetVariable2 (
- mPrivate->PortString,
- &gEfiIScsiInitiatorNameProtocolGuid,
- (VOID**)&AttemptConfigData,
- NULL
- );
-if (AttemptConfigData == NULL || AttemptConfigData->Actived == 
ISCSI_ACTIVE_ENABLED) {
-  continue;
-}
-
-break;
-  }
+ASSERT (AttemptConfigOrder != NULL);
 
-  if (Index > PcdGet8 (PcdMaxIScsiAttemptNumber)) {
-CreatePopUp (
-  EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
-  &Key,
-  L"Can not create more attempts, Please configure the 
PcdMaxIScsiAttemptNumber if needed!",
-

[edk2] [patch] MdeModulePkg: Update the Ethernet interface name.

2017-02-22 Thread Zhang Lubo
Update the interface name from ethA ethB to
eth10, eth11 etc if port number more than 9.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Sriram Subramanian 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index a6a3da8..504f247 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -1493,11 +1493,11 @@ Ip4Config2InitIfInfo (
   )
 {
   UnicodeSPrint (
 IfInfo->Name,
 EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE,
-L"eth%x",
+L"eth%d",
 IpSb->Ip4Config2Instance.IfIndex
   );
 
   IfInfo->IfType= IpSb->SnpMode.IfType;
   IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Update the Ethernet interface name.

2017-02-22 Thread Zhang Lubo
Update the interface name from ethA ethB to
eth10, eth11 etc if port number more than 9.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Sriram Subramanian 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index e309b69..9287475 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -1439,11 +1439,11 @@ Ip6ConfigInitIfInfo (
   )
 {
   UnicodeSPrint (
 IfInfo->Name,
 sizeof (IfInfo->Name),
-L"eth%x",
+L"eth%d",
 IpSb->Ip6ConfigInstance.IfIndex
   );
 
   IfInfo->IfType= IpSb->SnpMode.IfType;
   IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2] SecurityPkg: Fix potential bug in Security Boot dxe.

2017-02-22 Thread Zhang Lubo
v2: update hash value in SecureBootConfig.vfr to keep
them consistent with macro definition in SecureBootConfigImpl.h

since we removed the sha-1 definition in Hash table
and related macro, but the macro definition HashAlg index
may be value 4 which is exceed the range of the Hash
table array.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Chao Zhang 
Cc: Long Qin 
Cc: Yao Jiewen 
---
 .../SecureBootConfigDxe/SecureBootConfig.vfr | 10 +-
 .../SecureBootConfigDxe/SecureBootConfigImpl.h   | 12 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
index 02ddf4a..6f46d91 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
@@ -457,17 +457,17 @@ formset
 
 oneof name = SignatureFormatInDbx,
   varid   = SECUREBOOT_CONFIGURATION.CertificateFormat,
   prompt  = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_PROMPT),
   help= STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_HELP),
-  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_SHA256), value 
= 0x2, flags = DEFAULT;
-  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_SHA384), value 
= 0x3, flags = 0;
-  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_SHA512), value 
= 0x4, flags = 0;
-  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_RAW), value = 
0x5, flags = 0;
+  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_SHA256), value 
= 0x1, flags = DEFAULT;
+  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_SHA384), value 
= 0x2, flags = 0;
+  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_SHA512), value 
= 0x3, flags = 0;
+  option text = STRING_TOKEN(STR_DBX_CERTIFICATE_FORMAT_RAW), value = 
0x4, flags = 0;
 endoneof;
 
-suppressif ideqval SECUREBOOT_CONFIGURATION.CertificateFormat == 5;
+suppressif ideqval SECUREBOOT_CONFIGURATION.CertificateFormat == 4;
 checkbox varid  = SECUREBOOT_CONFIGURATION.AlwaysRevocation,
prompt = STRING_TOKEN(STR_ALWAYS_CERTIFICATE_REVOCATION_PROMPT),
help   = STRING_TOKEN(STR_ALWAYS_CERTIFICATE_REVOCATION_HELP),
flags  = INTERACTIVE,
 endcheckbox;
diff --git 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
index bea9470..58030c4 100644
--- 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
+++ 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
@@ -89,16 +89,16 @@ extern  EFI_IFR_GUID_LABEL *mEndLabel;
 #define WIN_CERT_UEFI_RSA2048_SIZE   256
 
 //
 // Support hash types
 //
-#define HASHALG_SHA224 0x0001
-#define HASHALG_SHA256 0x0002
-#define HASHALG_SHA384 0x0003
-#define HASHALG_SHA512 0x0004
-#define HASHALG_RAW0x0005
-#define HASHALG_MAX0x0005
+#define HASHALG_SHA224 0x
+#define HASHALG_SHA256 0x0001
+#define HASHALG_SHA384 0x0002
+#define HASHALG_SHA512 0x0003
+#define HASHALG_RAW0x0004
+#define HASHALG_MAX0x0004
 
 
 typedef struct {
   UINTN Signature;
   LIST_ENTRYHead;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch] SecurityPkg: Fix potential bug in Security Boot dxe.

2017-02-22 Thread Zhang, Lubo
Thanks , I will update the HASH value definition  in VFR  to keep them 
consistent with macro definition  .

> -Original Message-
> From: Zhang, Chao B
> Sent: Wednesday, February 22, 2017 4:31 PM
> To: Zhang, Lubo ; edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Long, Qin 
> Subject: RE: [edk2] [patch] SecurityPkg: Fix potential bug in Security Boot 
> dxe.
> 
> Lubo:
> If you change HASH algo definition, please also update 
> SecureBootConfig.vfr
> accordingly.
> Or you may keep SHA1 algo definition & keep RAW & MAX unchanged
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang
> Lubo
> Sent: Tuesday, February 21, 2017 10:53 AM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Zhang, Chao B
> ; Long, Qin 
> Subject: [edk2] [patch] SecurityPkg: Fix potential bug in Security Boot dxe.
> 
> since we removed the sha-1 definition in Hash table and related macro, but the
> macro definition HashAlg index may be value 4 which is exceed the range of the
> Hash table array.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> Cc: Chao Zhang 
> Cc: Long Qin 
> Cc: Yao Jiewen 
> ---
>  .../SecureBootConfigDxe/SecureBootConfigImpl.h   | 12 
> ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git
> a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigI
> mpl.h
> b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigI
> mpl.h
> index bea9470..58030c4 100644
> ---
> a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigI
> mpl.h
> +++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootCo
> +++ nfigImpl.h
> @@ -89,16 +89,16 @@ extern  EFI_IFR_GUID_LABEL *mEndLabel;
>  #define WIN_CERT_UEFI_RSA2048_SIZE   256
> 
>  //
>  // Support hash types
>  //
> -#define HASHALG_SHA224 0x0001
> -#define HASHALG_SHA256 0x0002
> -#define HASHALG_SHA384 0x0003
> -#define HASHALG_SHA512 0x0004
> -#define HASHALG_RAW0x0005
> -#define HASHALG_MAX0x0005
> +#define HASHALG_SHA224 0x
> +#define HASHALG_SHA256 0x0001
> +#define HASHALG_SHA384 0x0002
> +#define HASHALG_SHA512 0x0003
> +#define HASHALG_RAW0x0004
> +#define HASHALG_MAX0x0004
> 
> 
>  typedef struct {
>UINTN Signature;
>LIST_ENTRYHead;
> --
> 1.9.5.msysgit.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] SecurityPkg: Fix potential bug in Security Boot dxe.

2017-02-20 Thread Zhang Lubo
since we removed the sha-1 definition in Hash table
and related macro, but the macro definition HashAlg index
may be value 4 which is exceed the range of the Hash
table array.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Chao Zhang 
Cc: Long Qin 
Cc: Yao Jiewen 
---
 .../SecureBootConfigDxe/SecureBootConfigImpl.h   | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
index bea9470..58030c4 100644
--- 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
+++ 
b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
@@ -89,16 +89,16 @@ extern  EFI_IFR_GUID_LABEL *mEndLabel;
 #define WIN_CERT_UEFI_RSA2048_SIZE   256
 
 //
 // Support hash types
 //
-#define HASHALG_SHA224 0x0001
-#define HASHALG_SHA256 0x0002
-#define HASHALG_SHA384 0x0003
-#define HASHALG_SHA512 0x0004
-#define HASHALG_RAW0x0005
-#define HASHALG_MAX0x0005
+#define HASHALG_SHA224 0x
+#define HASHALG_SHA256 0x0001
+#define HASHALG_SHA384 0x0002
+#define HASHALG_SHA512 0x0003
+#define HASHALG_RAW0x0004
+#define HASHALG_MAX0x0004
 
 
 typedef struct {
   UINTN Signature;
   LIST_ENTRYHead;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariable.

2017-02-16 Thread Zhang Lubo
V3: code clean up

prohibit Image SHA-1 hash option in SecureBootConfigDxe.
Timebased Auth Variable driver should ensure AuthAlgorithm
is SHA256 before further verification

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Chao Zhang 
Cc: Long Qin 
Cc: Yao Jiewen 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c  | 27 +-
 .../Library/AuthVariableLib/AuthServiceInternal.h  |  4 +++-
 .../SecureBootConfigDxe/SecureBootConfigImpl.c | 14 ---
 .../SecureBootConfigDxe/SecureBootConfigImpl.h |  8 ++-
 4 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index b013d42..1cdfadc 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -16,11 +16,11 @@
 
   VerifyTimeBasedPayloadAndUpdate() and VerifyCounterBasedPayload() are sub 
function to do verification.
   They will do basic validation for authentication data structure, then call 
crypto library
   to verify the signature.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -34,10 +34,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 //
 // Public Exponent of RSA Key.
 //
 CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
 
+CONST UINT8 mHash256OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 
0x02, 0x01 };
+
 //
 // Requirement for different signature type which have been defined in UEFI 
spec.
 // These data are used to perform SignatureList format check while setting 
PK/KEK variable.
 //
 EFI_SIGNATURE_ITEM mSupportSigItem[] = {
@@ -2243,10 +2245,33 @@ VerifyTimeBasedPayload (
   //
   SigData = CertData->AuthInfo.CertData;
   SigDataSize = CertData->AuthInfo.Hdr.dwLength - (UINT32) (OFFSET_OF 
(WIN_CERTIFICATE_UEFI_GUID, CertData));
 
   //
+  // SignedData.digestAlgorithms shall contain the digest algorithm used when 
preparing the
+  // signature. Only a digest algorithm of SHA-256 is accepted.
+  //
+  //According to PKCS#7 Definition:
+  //SignedData ::= SEQUENCE {
+  //version Version,
+  //digestAlgorithms DigestAlgorithmIdentifiers,
+  //contentInfo ContentInfo,
+  // }
+  //The DigestAlgorithmIdentifiers can be used to determine the hash 
algorithm 
+  //in VARIABLE_AUTHENTICATION_2 descriptor.
+  //This field has the fixed offset (+13) and be calculated based on two 
bytes of length encoding.
+  //
+  if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
+if (SigDataSize >= (13 + sizeof (mHash256OidValue))) {
+  if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) || 
+   (CompareMem (SigData + 13, &mHash256OidValue, sizeof 
(mHash256OidValue)) != 0)) {
+  return EFI_SECURITY_VIOLATION;
+}
+}
+  }
+
+  //
   // Find out the new data payload which follows Pkcs7 SignedData directly.
   //
   PayloadPtr = SigData + SigDataSize;
   PayloadSize = DataSize - OFFSET_OF_AUTHINFO2_CERT_DATA - (UINTN) SigDataSize;
 
diff --git a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h 
b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
index e7c4bf0..e9b7cf3 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
+++ b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
@@ -10,11 +10,11 @@
  The whole SMM authentication variable design relies on the integrity of 
flash part and SMM.
   which is assumed to be protected by platform.  All variable code and 
metadata in flash/SMM Memory
   may not be modified without authorization. If platform fails to protect 
these resources,
   the authentication service provided in this driver will be broken, and the 
behavior is undefined.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -35,10 +35,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 
 #include 
 #include 
 
+#define TWO_BYTE_ENCODE   0x82
+
 ///
 /// Struct to record signature requirement defined by UEFI spec.
 /// For SigHeaderSize and SigDataSize, ((UINT32) ~0) means NO exact length 
requirement for this field.
 ///
 

[edk2] [PATCH v2] NetworkPkg:Add scriptable configuration to iSCSI driver by

2017-02-16 Thread Zhang Lubo
v2:
Add error handling if can not create Attempts in driver entry point.
Since we support to define a macro be a PCD value, we enhance our code
by modifying the structure in IFR_NVDATA. This effect code logic mainly
in Creating Keywords,Convert IFR NvData To AttemptConfigData ByKeyword and
reverse function.
Fix typo errors and sync based on the latest code.

Enable iSCSI keywords configuration based on x-UEFI
name space. we introduce new PCD to control the attempt
numbers which will be created in non activated state, besides
the Attempt name is changed to READ_ONLY attribute in UI.
We can invoke KEYWORD HANDLER Protocol to configure
the related keywords.

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| 1744 +-
 NetworkPkg/IScsiDxe/IScsiConfig.h|   78 +-
 NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h |   67 +-
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni   |   28 +-
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr   |   46 +-
 NetworkPkg/IScsiDxe/IScsiDriver.c|   28 +-
 NetworkPkg/IScsiDxe/IScsiDriver.h|3 +-
 NetworkPkg/IScsiDxe/IScsiDxe.inf |5 +-
 NetworkPkg/IScsiDxe/IScsiMisc.c  |  815 +++-
 NetworkPkg/IScsiDxe/IScsiMisc.h  |   38 +
 NetworkPkg/NetworkPkg.dec|6 +-
 11 files changed, 2506 insertions(+), 352 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 40ea75a..d07bdcb 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -288,10 +288,102 @@ IScsiConvertIsIdToString (
 
   return EFI_SUCCESS;
 }
 
 /**
+  Get the Offset value specified by the input String.
+
+  @param[in]  Configuration  A null-terminated Unicode string in
+  format.
+  @param[in]  String The string is "&OFFSET=".
+  @param[out]  Value  The Offset value.
+
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary
+ structures.
+  @retval EFI_SUCCESSValue of  is outputted in Number
+ successfully.
+
+**/
+EFI_STATUS
+IScsiGetValue (
+  IN  CONST EFI_STRING Configuration,
+  IN  CHAR16   *String,
+  OUT UINTN*Value
+  )
+{
+  CHAR16   *StringPtr;
+  CHAR16   *TmpPtr;
+  CHAR16   *Str;
+  CHAR16   TmpStr[2];
+  UINTNLength;
+  UINTNLen;
+  UINTNIndex;
+  UINT8*Buf;
+  UINT8DigitUint8;
+  EFI_STATUS   Status;
+
+  //
+  // Get Value.
+  //
+  Buf = NULL;
+  StringPtr = StrStr (Configuration, String);
+  ASSERT(StringPtr != NULL);
+  StringPtr += StrLen (String);
+  TmpPtr = StringPtr;
+
+  while (*StringPtr != L'\0' && *StringPtr != L'&') {
+StringPtr ++;
+  }
+  Length = StringPtr - TmpPtr;
+  Len = Length + 1;
+
+  Str = AllocateZeroPool (Len * sizeof (CHAR16));
+  if (Str == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto Exit;
+  }
+
+  CopyMem (Str, TmpPtr, Len * sizeof (CHAR16));
+  *(Str + Length) = L'\0';
+
+  Len = (Len + 1) / 2;
+  Buf = (UINT8 *) AllocateZeroPool (Len);
+  if (Buf == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto Exit;
+  }
+
+  ZeroMem (TmpStr, sizeof (TmpStr));
+  for (Index = 0; Index < Length; Index ++) {
+TmpStr[0] = Str[Length - Index - 1];
+DigitUint8 = (UINT8) StrHexToUint64 (TmpStr);
+if ((Index & 1) == 0) {
+  Buf [Index/2] = DigitUint8;
+} else {
+  Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]);
+}
+  }
+
+  *Value = 0;
+  CopyMem (
+Value,
+Buf,
+(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
+);
+
+  FreePool (Buf);
+  Status = EFI_SUCCESS;
+
+Exit:
+  if (Str != NULL) {
+FreePool (Str);
+  }
+
+  return Status;
+}
+
+/**
   Get the attempt config data from global structure by the ConfigIndex.
 
   @param[in]  AttemptConfigIndex The unique index indicates the attempt.
 
   @return   Pointer to the attempt config data.
@@ -347,10 +439,68 @@ IScsiConfigGetAttemptByNic (
   }
 
   return NULL;
 }
 
+/**
+  Extract the Index of the attempt list.
+
+  @param[in]   AttemptNameList The Name list of the Attempts.
+  @param[out]  AttemptIndexListThe Index list of the Attempts.
+  @param[in]   IsAddAttempts   If TRUE, Indicates add one or more attempts.
+   If FALSE, Indicates delete attempts or 
change attempt order.
+
+  @retval EFI_SUCCESS  The Attempt list i

Re: [edk2] [patch] SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariable. 1. prohibit Image SHA-1 hash option in SecureBootConfigDxe. 2. Timebased Auth Variable driver should ensure Au

2017-02-15 Thread Zhang, Lubo
Thanks for your comments, I will update the patch.

Lubo

-Original Message-
From: Zhang, Chao B 
Sent: Thursday, February 16, 2017 1:12 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Long, Qin ; Yao, Jiewen 
Subject: RE: [patch] SecurityPkg: enhance secure boot Config Dxe & Time Based 
AuthVariable. 1. prohibit Image SHA-1 hash option in SecureBootConfigDxe. 2. 
Timebased Auth Variable driver should ensure AuthAlgorithm is SHA256 before 
further verification

Lubo:
   1. Please capitalize Hash256OidLength macro definition or simply use 
sizeof(mHash256OidValue). Others are good to me.
   2. Please run PatchCheck first. The title is too long to meet EDKII check-in 
log requirement
   

-Original Message-
From: Zhang, Lubo
Sent: Tuesday, February 14, 2017 10:56 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Chao B ; Long, Qin ; 
Yao, Jiewen 
Subject: [patch] SecurityPkg: enhance secure boot Config Dxe & Time Based 
AuthVariable. 1. prohibit Image SHA-1 hash option in SecureBootConfigDxe. 2. 
Timebased Auth Variable driver should ensure AuthAlgorithm is SHA256 before 
further verification

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Chao Zhang 
Cc: Long Qin 
Cc: Yao Jiewen 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c  | 27 +- 
 .../Library/AuthVariableLib/AuthServiceInternal.h  |  5 +++-
 .../SecureBootConfigDxe/SecureBootConfigImpl.c | 14 ---
 .../SecureBootConfigDxe/SecureBootConfigImpl.h |  8 ++-
 4 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index b013d42..75d2290 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -16,11 +16,11 @@
 
   VerifyTimeBasedPayloadAndUpdate() and VerifyCounterBasedPayload() are sub 
function to do verification.
   They will do basic validation for authentication data structure, then call 
crypto library
   to verify the signature.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  are licensed and made available 
under the terms and conditions of the BSD License  which accompanies this 
distribution.  The full text of the license may be found at  
http://opensource.org/licenses/bsd-license.php
 
@@ -34,10 +34,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 //
 // Public Exponent of RSA Key.
 //
 CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
 
+CONST UINT8 mHash256OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 
+0x04, 0x02, 0x01 };
+
 //
 // Requirement for different signature type which have been defined in UEFI 
spec.
 // These data are used to perform SignatureList format check while setting 
PK/KEK variable.
 //
 EFI_SIGNATURE_ITEM mSupportSigItem[] = { @@ -2243,10 +2245,33 @@ 
VerifyTimeBasedPayload (
   //
   SigData = CertData->AuthInfo.CertData;
   SigDataSize = CertData->AuthInfo.Hdr.dwLength - (UINT32) (OFFSET_OF 
(WIN_CERTIFICATE_UEFI_GUID, CertData));
 
   //
+  // SignedData.digestAlgorithms shall contain the digest algorithm 
+ used when preparing the  // signature. Only a digest algorithm of SHA-256 is 
accepted.
+  //
+  //According to PKCS#7 Definition:
+  //SignedData ::= SEQUENCE {
+  //version Version,
+  //digestAlgorithms DigestAlgorithmIdentifiers,
+  //contentInfo ContentInfo,
+  // }
+  //The DigestAlgorithmIdentifiers can be used to determine the hash 
algorithm 
+  //in VARIABLE_AUTHENTICATION_2 descriptor.
+  //This field has the fixed offset (+13) and be calculated based on two 
bytes of length encoding.
+  //
+  if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
+if (SigDataSize >= (13 + Hash256OidLength)) {
+  if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) || 
+   (CompareMem (SigData + 13, &mHash256OidValue, Hash256OidLength) != 
0)) {
+  return EFI_SECURITY_VIOLATION;
+}
+}
+  }
+
+  //
   // Find out the new data payload which follows Pkcs7 SignedData directly.
   //
   PayloadPtr = SigData + SigDataSize;
   PayloadSize = DataSize - OFFSET_OF_AUTHINFO2_CERT_DATA - (UINTN) SigDataSize;
 
diff --git a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h 
b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
index e7c4bf0..f1cf591 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
+++ b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
@@ -10,11 +10,11 @@
  The whole SMM authentication variable design relies on the integrity of 
flash part and SMM.
   which is assumed to be protected by platform.  All variable code and 
metadata in flash/SMM Memory
   may not be m

[edk2] [PATCH V2] SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariable.

2017-02-13 Thread Zhang Lubo
V2: Update  commit log.

prohibit Image SHA-1 hash option in SecureBootConfigDxe.
Timebased Auth Variable driver should ensure AuthAlgorithm is SHA256 before
further verification

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Chao Zhang 
Cc: Long Qin 
Cc: Yao Jiewen 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c  | 27 +-
 .../Library/AuthVariableLib/AuthServiceInternal.h  |  5 +++-
 .../SecureBootConfigDxe/SecureBootConfigImpl.c | 14 ---
 .../SecureBootConfigDxe/SecureBootConfigImpl.h |  8 ++-
 4 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index b013d42..75d2290 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -16,11 +16,11 @@
 
   VerifyTimeBasedPayloadAndUpdate() and VerifyCounterBasedPayload() are sub 
function to do verification.
   They will do basic validation for authentication data structure, then call 
crypto library
   to verify the signature.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -34,10 +34,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 //
 // Public Exponent of RSA Key.
 //
 CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
 
+CONST UINT8 mHash256OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 
0x02, 0x01 };
+
 //
 // Requirement for different signature type which have been defined in UEFI 
spec.
 // These data are used to perform SignatureList format check while setting 
PK/KEK variable.
 //
 EFI_SIGNATURE_ITEM mSupportSigItem[] = {
@@ -2243,10 +2245,33 @@ VerifyTimeBasedPayload (
   //
   SigData = CertData->AuthInfo.CertData;
   SigDataSize = CertData->AuthInfo.Hdr.dwLength - (UINT32) (OFFSET_OF 
(WIN_CERTIFICATE_UEFI_GUID, CertData));
 
   //
+  // SignedData.digestAlgorithms shall contain the digest algorithm used when 
preparing the
+  // signature. Only a digest algorithm of SHA-256 is accepted.
+  //
+  //According to PKCS#7 Definition:
+  //SignedData ::= SEQUENCE {
+  //version Version,
+  //digestAlgorithms DigestAlgorithmIdentifiers,
+  //contentInfo ContentInfo,
+  // }
+  //The DigestAlgorithmIdentifiers can be used to determine the hash 
algorithm 
+  //in VARIABLE_AUTHENTICATION_2 descriptor.
+  //This field has the fixed offset (+13) and be calculated based on two 
bytes of length encoding.
+  //
+  if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
+if (SigDataSize >= (13 + Hash256OidLength)) {
+  if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) || 
+   (CompareMem (SigData + 13, &mHash256OidValue, Hash256OidLength) != 
0)) {
+  return EFI_SECURITY_VIOLATION;
+}
+}
+  }
+
+  //
   // Find out the new data payload which follows Pkcs7 SignedData directly.
   //
   PayloadPtr = SigData + SigDataSize;
   PayloadSize = DataSize - OFFSET_OF_AUTHINFO2_CERT_DATA - (UINTN) SigDataSize;
 
diff --git a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h 
b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
index e7c4bf0..f1cf591 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
+++ b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
@@ -10,11 +10,11 @@
  The whole SMM authentication variable design relies on the integrity of 
flash part and SMM.
   which is assumed to be protected by platform.  All variable code and 
metadata in flash/SMM Memory
   may not be modified without authorization. If platform fails to protect 
these resources,
   the authentication service provided in this driver will be broken, and the 
behavior is undefined.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -35,10 +35,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 
 #include 
 #include 
 
+#define TWO_BYTE_ENCODE   0x82
+#define Hash256OidLength  9
+
 ///
 /// Struct to record signature requirement defined by UEFI spec.
 /// For SigHeaderSize and SigDataSize, ((UINT32) ~0) means NO exact length 
requi

[edk2] [patch] SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariable. 1. prohibit Image SHA-1 hash option in SecureBootConfigDxe. 2. Timebased Auth Variable driver should ensure AuthAl

2017-02-13 Thread Zhang Lubo
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Chao Zhang 
Cc: Long Qin 
Cc: Yao Jiewen 
---
 SecurityPkg/Library/AuthVariableLib/AuthService.c  | 27 +-
 .../Library/AuthVariableLib/AuthServiceInternal.h  |  5 +++-
 .../SecureBootConfigDxe/SecureBootConfigImpl.c | 14 ---
 .../SecureBootConfigDxe/SecureBootConfigImpl.h |  8 ++-
 4 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index b013d42..75d2290 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -16,11 +16,11 @@
 
   VerifyTimeBasedPayloadAndUpdate() and VerifyCounterBasedPayload() are sub 
function to do verification.
   They will do basic validation for authentication data structure, then call 
crypto library
   to verify the signature.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -34,10 +34,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 //
 // Public Exponent of RSA Key.
 //
 CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
 
+CONST UINT8 mHash256OidValue[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 
0x02, 0x01 };
+
 //
 // Requirement for different signature type which have been defined in UEFI 
spec.
 // These data are used to perform SignatureList format check while setting 
PK/KEK variable.
 //
 EFI_SIGNATURE_ITEM mSupportSigItem[] = {
@@ -2243,10 +2245,33 @@ VerifyTimeBasedPayload (
   //
   SigData = CertData->AuthInfo.CertData;
   SigDataSize = CertData->AuthInfo.Hdr.dwLength - (UINT32) (OFFSET_OF 
(WIN_CERTIFICATE_UEFI_GUID, CertData));
 
   //
+  // SignedData.digestAlgorithms shall contain the digest algorithm used when 
preparing the
+  // signature. Only a digest algorithm of SHA-256 is accepted.
+  //
+  //According to PKCS#7 Definition:
+  //SignedData ::= SEQUENCE {
+  //version Version,
+  //digestAlgorithms DigestAlgorithmIdentifiers,
+  //contentInfo ContentInfo,
+  // }
+  //The DigestAlgorithmIdentifiers can be used to determine the hash 
algorithm 
+  //in VARIABLE_AUTHENTICATION_2 descriptor.
+  //This field has the fixed offset (+13) and be calculated based on two 
bytes of length encoding.
+  //
+  if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
+if (SigDataSize >= (13 + Hash256OidLength)) {
+  if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) || 
+   (CompareMem (SigData + 13, &mHash256OidValue, Hash256OidLength) != 
0)) {
+  return EFI_SECURITY_VIOLATION;
+}
+}
+  }
+
+  //
   // Find out the new data payload which follows Pkcs7 SignedData directly.
   //
   PayloadPtr = SigData + SigDataSize;
   PayloadSize = DataSize - OFFSET_OF_AUTHINFO2_CERT_DATA - (UINTN) SigDataSize;
 
diff --git a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h 
b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
index e7c4bf0..f1cf591 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
+++ b/SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h
@@ -10,11 +10,11 @@
  The whole SMM authentication variable design relies on the integrity of 
flash part and SMM.
   which is assumed to be protected by platform.  All variable code and 
metadata in flash/SMM Memory
   may not be modified without authorization. If platform fails to protect 
these resources,
   the authentication service provided in this driver will be broken, and the 
behavior is undefined.
 
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -35,10 +35,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 
 #include 
 #include 
 
+#define TWO_BYTE_ENCODE   0x82
+#define Hash256OidLength  9
+
 ///
 /// Struct to record signature requirement defined by UEFI spec.
 /// For SigHeaderSize and SigDataSize, ((UINT32) ~0) means NO exact length 
requirement for this field.
 ///
 typedef struct {
diff --git 
a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c 
b/SecurityPkg/VariableAuthenticate

Re: [edk2] [PATCH v2 0/2] NetworkPkg/iScsiDxe: Update iScsiStart Policy

2017-02-13 Thread Zhang, Lubo
Series Reviewed-by: Zhang Lubo 

-Original Message-
From: hegdenag [mailto:nagaraj-p.he...@hpe.com] 
Sent: Monday, February 13, 2017 3:20 PM
To: edk2-devel@lists.01.org
Cc: Wu, Jiaxin ; Ye, Ting ; Zhang, Lubo 
; Fu, Siyuan ; srira...@hpe.com
Subject: [PATCH v2 0/2] NetworkPkg/iScsiDxe: Update iScsiStart Policy

v2: Updated list of reviewers.

Today, iSCSI driver checks whether there are AIP instances installed by iSCSI 
HBA adapter and if yes, the iSCSI driver will return EFI_ABORTED in its driver 
binding Start. 
We can not guarantee the existence of AIP instances always during iSCSI 
DBStart. Hence, we might end up doing a iScsiStart even if the intent of the 
customer was to use only iSCSI on HBA.
The series of patch will define a new PCD value for the PCD 
PcdIScsiAIPNetworkBootPolicy, "Always use iSCSI HBA and ignore UEFI iSCSI", 
update iScsiStart to check this PCD value and return EFI_ABORT in this case 
even before checking for AIP instances.

hegdenag (2):
  NetworkPkg/iSCSIDxe: Update the condition for IScsiStart Abort
  NetworkPkg/NetworkPkg.dec: Update comments for the PCD

 NetworkPkg/IScsiDxe/IScsiDriver.c |  8 +++-  
NetworkPkg/IScsiDxe/IScsiDriver.h | 19 +++
 NetworkPkg/NetworkPkg.dec |  5 +++--
 3 files changed, 21 insertions(+), 11 deletions(-)

--
2.8.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch] NetworkPkg:Generate the correct operational state of the interface.

2017-02-09 Thread Zhang, Lubo
Yes,  I just find the typo error.

Thanks
Lubo

-Original Message-
From: Wu, Jiaxin 
Sent: Friday, February 10, 2017 11:33 AM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Santhapur Naveen ; Ye, Ting ; 
Fu, Siyuan 
Subject: RE: [patch] NetworkPkg:Generate the correct operational state of the 
interface.

Need change the commit log, replace the 'ifconfig -l' with 'ifconfig6 -l' since 
it's the fix for IPv6.

Others is good to me.

Reviewed-by: Wu Jiaxin 

Thanks,
Jiaxin


> -Original Message-
> From: Zhang, Lubo
> Sent: Friday, February 10, 2017 11:18 AM
> To: edk2-devel@lists.01.org
> Cc: Santhapur Naveen ; Ye, Ting 
> ; Fu, Siyuan ; Wu, Jiaxin 
> 
> Subject: [patch] NetworkPkg:Generate the correct operational state of 
> the interface.
> 
> Currently, When there are more than 9 Ethernet ports available, 
> 'ifconfig -l' is not listing all the ports, only show the ports 0 to 9.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> Cc: Santhapur Naveen 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Wu Jiaxin 
> ---
>  NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
> b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
> index 4e881fd..e309b69 100644
> --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
> +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
> @@ -1436,15 +1436,16 @@ VOID
>  Ip6ConfigInitIfInfo (
>IN  IP6_SERVICE*IpSb,
>OUT EFI_IP6_CONFIG_INTERFACE_INFO  *IfInfo
>)
>  {
> -  IfInfo->Name[0] = L'e';
> -  IfInfo->Name[1] = L't';
> -  IfInfo->Name[2] = L'h';
> -  IfInfo->Name[3] = (CHAR16) (L'0' + 
> IpSb->Ip6ConfigInstance.IfIndex);
> -  IfInfo->Name[4] = 0;
> +  UnicodeSPrint (
> +IfInfo->Name,
> +sizeof (IfInfo->Name),
> +L"eth%x",
> +IpSb->Ip6ConfigInstance.IfIndex
> +  );
> 
>IfInfo->IfType= IpSb->SnpMode.IfType;
>IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;
>CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress,
> IfInfo->HwAddressSize);
>  }
> --
> 1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg:Generate the correct operational state of the interface.

2017-02-09 Thread Zhang Lubo
Currently, When there are more than 9 Ethernet ports available,
'ifconfig -l' is not listing all the ports, only show the ports 0 to 9.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Santhapur Naveen 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 131b03f..a6a3da8 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -1490,15 +1490,16 @@ VOID
 Ip4Config2InitIfInfo (
   IN  IP4_SERVICE*IpSb,
   OUT EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo
   )
 {
-  IfInfo->Name[0] = L'e';
-  IfInfo->Name[1] = L't';
-  IfInfo->Name[2] = L'h';
-  IfInfo->Name[3] = (CHAR16) (L'0' + IpSb->Ip4Config2Instance.IfIndex);
-  IfInfo->Name[4] = 0;
+  UnicodeSPrint (
+IfInfo->Name,
+EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE,
+L"eth%x",
+IpSb->Ip4Config2Instance.IfIndex
+  );
 
   IfInfo->IfType= IpSb->SnpMode.IfType;
   IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;
   CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, 
IfInfo->HwAddressSize);
 }
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg:Generate the correct operational state of the interface.

2017-02-09 Thread Zhang Lubo
Currently, When there are more than 9 Ethernet ports available,
'ifconfig -l' is not listing all the ports, only show the ports 0 to 9.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Santhapur Naveen 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 4e881fd..e309b69 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -1436,15 +1436,16 @@ VOID
 Ip6ConfigInitIfInfo (
   IN  IP6_SERVICE*IpSb,
   OUT EFI_IP6_CONFIG_INTERFACE_INFO  *IfInfo
   )
 {
-  IfInfo->Name[0] = L'e';
-  IfInfo->Name[1] = L't';
-  IfInfo->Name[2] = L'h';
-  IfInfo->Name[3] = (CHAR16) (L'0' + IpSb->Ip6ConfigInstance.IfIndex);
-  IfInfo->Name[4] = 0;
+  UnicodeSPrint (
+IfInfo->Name,
+sizeof (IfInfo->Name),
+L"eth%x",
+IpSb->Ip6ConfigInstance.IfIndex
+  );
 
   IfInfo->IfType= IpSb->SnpMode.IfType;
   IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;
   CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, 
IfInfo->HwAddressSize);
 }
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Fix protocol handler service in HttpDxe.

2017-01-21 Thread Zhang Lubo
When we create a HTTP driver service binding private
instance, there may be different DriverBindingHandle
for Ipv4 or Ipv6, so it is essential to distinguish
the HttpService image which will be used in open
protocol or close protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Sriram Subramanian 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpDns.c| 18 
 NetworkPkg/HttpDxe/HttpDriver.c | 21 +-
 NetworkPkg/HttpDxe/HttpImpl.c   | 11 --
 NetworkPkg/HttpDxe/HttpProto.c  | 48 -
 NetworkPkg/HttpDxe/HttpProto.h  |  5 +++--
 5 files changed, 55 insertions(+), 48 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpDns.c b/NetworkPkg/HttpDxe/HttpDns.c
index 0f5fe18..59cd7b3 100644
--- a/NetworkPkg/HttpDxe/HttpDns.c
+++ b/NetworkPkg/HttpDxe/HttpDns.c
@@ -1,9 +1,9 @@
 /** @file
   Routines for HttpDxe driver to perform DNS resolution based on UEFI DNS 
protocols.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -86,11 +86,11 @@ HttpDns4 (
   //
   // Create a DNS child instance and get the protocol.
   //
   Status = NetLibCreateServiceChild (
  Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip4DriverBindingHandle,
  &gEfiDns4ServiceBindingProtocolGuid,
  &Dns4Handle
  );
   if (EFI_ERROR (Status)) {
 goto Exit;
@@ -98,11 +98,11 @@ HttpDns4 (
 
   Status = gBS->OpenProtocol (
   Dns4Handle,
   &gEfiDns4ProtocolGuid,
   (VOID **) &Dns4,
-  Service->ImageHandle,
+  Service->Ip4DriverBindingHandle,
   Service->ControllerHandle,
   EFI_OPEN_PROTOCOL_BY_DRIVER
   );
   if (EFI_ERROR (Status)) {
 goto Exit;
@@ -194,19 +194,19 @@ Exit:
 Dns4->Configure (Dns4, NULL);
 
 gBS->CloseProtocol (
Dns4Handle,
&gEfiDns4ProtocolGuid,
-   Service->ImageHandle,
+   Service->Ip4DriverBindingHandle,
Service->ControllerHandle
);
   }
 
   if (Dns4Handle != NULL) {
 NetLibDestroyServiceChild (
   Service->ControllerHandle,
-  Service->ImageHandle,
+  Service->Ip4DriverBindingHandle,
   &gEfiDns4ServiceBindingProtocolGuid,
   Dns4Handle
   );
   }
 
@@ -288,11 +288,11 @@ HttpDns6 (
   //
   // Create a DNSv6 child instance and get the protocol.
   //
   Status = NetLibCreateServiceChild (
  Service->ControllerHandle,
- Service->ImageHandle,
+ Service->Ip6DriverBindingHandle,
  &gEfiDns6ServiceBindingProtocolGuid,
  &Dns6Handle
  );
   if (EFI_ERROR (Status)) {
 goto Exit;
@@ -300,11 +300,11 @@ HttpDns6 (
   
   Status = gBS->OpenProtocol (
   Dns6Handle,
   &gEfiDns6ProtocolGuid,
   (VOID **) &Dns6,
-  Service->ImageHandle,
+  Service->Ip6DriverBindingHandle,
   Service->ControllerHandle,
   EFI_OPEN_PROTOCOL_BY_DRIVER
   );
   if (EFI_ERROR (Status)) {
 goto Exit;
@@ -391,19 +391,19 @@ Exit:
 Dns6->Configure (Dns6, NULL);
 
 gBS->CloseProtocol (
Dns6Handle,
&gEfiDns6ProtocolGuid,
-   Service->ImageHandle,
+   Service->Ip6DriverBindingHandle,
Service->ControllerHandle
);
   }
 
   if (Dns6Handle != NULL) {
 NetLibDestroyServiceChild (
   Service->ControllerHandle,
-  Service->ImageHandle,
+  Service->Ip6DriverBindingHandle,
   &gEfiDns6ServiceBindingProtocolGuid,
   Dns6Handle
   );
   }
 
diff --git a/NetworkPkg/HttpDxe/HttpDriver.c b/NetworkPkg/HttpDxe/HttpDriver.c
index de27635..5727526 100644
--- a/NetworkPkg/HttpDxe/HttpDriver.c
+++ b/NetworkPkg/HttpDxe/HttpDriver.c
@@ -1,9 +1,9 @@
 /** @file
   The driver binding and service binding protocol for HttpDxe driver.
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at

[edk2] [patch] MdePkg: Update FTP4 command token structure in Ftp4.h

2017-01-19 Thread Zhang Lubo
Replace FTP4 data callback pointer-to-function-pointer with
regular function pointer, This definition keep consistent with
other function pointer usage

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 MdePkg/Include/Protocol/Ftp4.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Protocol/Ftp4.h b/MdePkg/Include/Protocol/Ftp4.h
index 1c4a5db..cdc9802 100644
--- a/MdePkg/Include/Protocol/Ftp4.h
+++ b/MdePkg/Include/Protocol/Ftp4.h
@@ -5,11 +5,11 @@
   of the EFI FTPv4 Protocol child protocol driver that can use the underlying
   communication device.
   The definitions in this file are defined in UEFI Specification 2.3, which 
have
   not been verified by one implementation yet.
 
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -202,11 +202,11 @@ struct _EFI_FTP4_COMMAND_TOKEN {
   /// function is called to supply additional data to be transmitted. The 
   /// size of additional data to be transmitted is indicated in 
   /// DataBufferSize, again. If there is no data remained, 
   /// DataBufferSize should be set to 0.
   /// 
-  EFI_FTP4_DATA_CALLBACK*DataCallback;
+  EFI_FTP4_DATA_CALLBACKDataCallback;
   /// 
   /// Pointer to the parameter for DataCallback.
   /// 
   VOID  *Context;
   /// 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 1/1] ShellPkg/Ifconfig6: Address ASSERT because of a missing NULL check

2017-01-11 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

> -Original Message-
> From: hegdenag [mailto:nagaraj-p.he...@hpe.com]
> Sent: Thursday, January 12, 2017 11:40 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin ; Carsey, Jaben ;
> Ni, Ruiyu ; Zhang, Lubo ; sriram-
> s...@hpe.com
> Subject: [PATCH v1 1/1] ShellPkg/Ifconfig6: Address ASSERT because of a
> missing NULL check
> 
> When we issue 'ifconfig6 -s  auto' system hangs with an ASSERT in
> StrLen. in IfConfig6SetInterfaceInfo, for 'auto' case we added checks to rule 
> out
> the invalid inputs like 'host', 'gw'
> and 'dns'. To parse through this, we do a VarArg = VarArg->Next but we dont
> check new VarArg before calling StrCmp. Fix with a check in this patch.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hegde Nagaraj P 
> ---
>  ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 27
> ++--
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> index d71688e..72aaee4 100644
> --- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> +++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> @@ -1317,20 +1317,21 @@ IfConfig6SetInterfaceInfo (
> 
>VarArg= VarArg->Next;
> 
> -  if (StrCmp (VarArg->Arg, L"host") == 0) {
> -ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
> -ShellStatus = SHELL_INVALID_PARAMETER;
> -goto ON_EXIT;
> -  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
> -ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle,
> Status);
> -ShellStatus = SHELL_INVALID_PARAMETER;
> -goto ON_EXIT;
> -  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
> -ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle,
> Status);
> -ShellStatus = SHELL_INVALID_PARAMETER;
> -goto ON_EXIT;
> +  if (VarArg != NULL) {
> +if (StrCmp (VarArg->Arg, L"host") == 0) {
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
> +  ShellStatus = SHELL_INVALID_PARAMETER;
> +  goto ON_EXIT;
> +} else if (StrCmp (VarArg->Arg, L"gw") == 0) {
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +  ShellStatus = SHELL_INVALID_PARAMETER;
> +  goto ON_EXIT;
> +} else if (StrCmp (VarArg->Arg, L"dns") == 0) {
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +  ShellStatus = SHELL_INVALID_PARAMETER;
> +  goto ON_EXIT;
> +}
>}
> -
>  } else if (StrCmp (VarArg->Arg, L"man") == 0) {
>//
>// Set manual config policy.
> --
> 2.8.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH V2] NetworkPkg: Add dns support for target URL configuration in ISCSI.

2017-01-11 Thread Zhang Lubo
v2:
*1. Add IScsiDnsIsConfigured function in IScsiSupported to check
attempt using DNS protocol or not.2. Fix wrongs typos in IScsiDns.c 
and .uni file.3. define a macro for the length of target URL.4.
update the Copyright to 2017.

Add DNS support for target URL directly configuration in UI.

Besides, When we enable the option (Get target info via DHCP) ,
the dhcp server will return target info include the  rootpath,
like the format
"iscsi:"":"":"":"":"
According to the RFC 4173,the server name region is expressed as
IPv4(192.168.10.20 )or IPv6 ([2000:::3]) or domain name,
but currently we only support the IP address format.
To enable this feature, we can support both.

Another enhancement is that we can deal with the data received from
the iSCSI login response with an target redirection status,
in which contains the Target Address in the format
domainname[:port][,portal-group-tag] required by RFC 3720.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c|  78 +++--
 NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h |  10 +-
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni   |   5 +-
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr   |  10 +-
 NetworkPkg/IScsiDxe/IScsiDhcp.c  |  23 +-
 NetworkPkg/IScsiDxe/IScsiDhcp6.c |  25 +-
 NetworkPkg/IScsiDxe/IScsiDns.c   | 435 +++
 NetworkPkg/IScsiDxe/IScsiDns.h   |  59 
 NetworkPkg/IScsiDxe/IScsiDriver.c|  22 +-
 NetworkPkg/IScsiDxe/IScsiDxe.inf |  22 +-
 NetworkPkg/IScsiDxe/IScsiImpl.h  |   8 +-
 NetworkPkg/IScsiDxe/IScsiMisc.c  |  90 +-
 NetworkPkg/IScsiDxe/IScsiMisc.h  |  21 +-
 NetworkPkg/IScsiDxe/IScsiProto.c |  59 +++-
 14 files changed, 794 insertions(+), 73 deletions(-)
 create mode 100644 NetworkPkg/IScsiDxe/IScsiDns.c
 create mode 100644 NetworkPkg/IScsiDxe/IScsiDns.h

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 57571ad..40ea75a 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1,9 +1,9 @@
 /** @file
   Helper functions for configuring or getting the parameters relating to iSCSI.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -364,17 +364,19 @@ IScsiConvertAttemptConfigDataToIfrNvData (
   )
 {
   ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;
   ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
   EFI_IP_ADDRESSIp;
+  BOOLEAN   DnsMode;
 
   //
   // Normal session configuration parameters.
   //
   SessionConfigData = &Attempt->SessionConfigData;
   IfrNvData->Enabled= SessionConfigData->Enabled;
   IfrNvData->IpMode = SessionConfigData->IpMode;
+  DnsMode   = SessionConfigData->DnsMode;
 
   IfrNvData->InitiatorInfoFromDhcp  = SessionConfigData->InitiatorInfoFromDhcp;
   IfrNvData->TargetInfoFromDhcp = SessionConfigData->TargetInfoFromDhcp;
   IfrNvData->TargetPort = SessionConfigData->TargetPort;
 
@@ -383,23 +385,37 @@ IScsiConvertAttemptConfigDataToIfrNvData (
 IScsiIpToStr (&Ip, FALSE, IfrNvData->LocalIp);
 CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof 
(EFI_IPv4_ADDRESS));
 IScsiIpToStr (&Ip, FALSE, IfrNvData->SubnetMask);
 CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS));
 IScsiIpToStr (&Ip, FALSE, IfrNvData->Gateway);
-CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
-IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
+if (SessionConfigData->TargetIp.v4.Addr[0] != '\0') {
+  CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof 
(EFI_IPv4_ADDRESS));
+  IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
+}
+
   } else if (IfrNvData->IpMode == IP_MODE_IP6) {
 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
-IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp);
-IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp);
+if (SessionConfigData->TargetIp.v6.Addr[0] != '\0') {
+  IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp);
+  IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp);
+}
   }
 
   AsciiStrToUnicodeStrS (
 SessionConfigData->TargetName,
   

[edk2] [patch] ShellPkg: Add check logic for the gateway validity.

2017-01-06 Thread Zhang Lubo
if we set a static IP using command
'ifconfig -s eth0 static 192.168.0.121 255.255.255.0 0.0.0.0'
The system says 'Failed to set address.' but using
'ifconfig -l', the static IP can be assigned successfully.
so we need to check the gateway validity before setting manual
address to keep the ifconfig -s command more consistent.

Signed-off-by: Zhang Lubo 
Cc: Santhapur Naveen 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 .../Library/UefiShellNetwork1CommandsLib/Ifconfig.c   | 19 ++-
 .../UefiShellNetwork1CommandsLib.uni  |  3 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 5e243d5..4db07b2 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1,10 +1,10 @@
 /** @file
   The implementation for Shell command ifconfig based on IP4Config2 protocol.
 
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -835,10 +835,12 @@ IfConfigSetInterfaceInfo (
 
   EFI_IP4_CONFIG2_POLICY   Policy;
   EFI_IP4_CONFIG2_MANUAL_ADDRESS   ManualAddress;
   UINTNDataSize;
   EFI_IPv4_ADDRESS Gateway;
+  IP4_ADDR SubnetMask;
+  IP4_ADDR TempGateway;
   EFI_IPv4_ADDRESS *Dns;
   ARG_LIST *Tmp;
   UINTNIndex;
 
   CONST CHAR16* TempString;
@@ -1017,10 +1019,25 @@ IfConfigSetInterfaceInfo (
 ShellStatus = SHELL_INVALID_PARAMETER;
 goto ON_EXIT;
   }
 
   //
+  // Need to check the gateway validity before set Manual Address.
+  // In case we can set manual address but fail to configure Gateway.
+  //
+  CopyMem (&SubnetMask, &ManualAddress.SubnetMask, sizeof (IP4_ADDR));
+  CopyMem (&TempGateway, &Gateway, sizeof (IP4_ADDR));
+  SubnetMask  = NTOHL (SubnetMask);
+  TempGateway = NTOHL (TempGateway);
+  if ((SubnetMask != 0) &&
+  !NetIp4IsUnicast (TempGateway, SubnetMask)) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg->Arg);
+ShellStatus = SHELL_INVALID_PARAMETER;
+goto ON_EXIT;
+  }
+
+  //
   // Set manual config policy.
   //
   Policy = Ip4Config2PolicyStatic;
   Status = IfCb->IfCfg->SetData (
   IfCb->IfCfg,
diff --git 
a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 4566cd1..d9bbb20 100644
--- 
a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
@@ -1,9 +1,9 @@
 // /**
 //
 // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
-// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. 
+// Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. 
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD 
License
 // which accompanies this distribution. The full text of the license may be 
found at
 // http://opensource.org/licenses/bsd-license.php
 //
@@ -64,10 +64,11 @@
 #string STR_IFCONFIG_LACK_OPTION  #language en-US"Flags lack. 
Please type 'ifConfig -?' for help info.\n"
 #string STR_IFCONFIG_LACK_INTERFACE   #language en-US"Lack 
interface name.\n"
 #string STR_IFCONFIG_LACK_COMMAND #language en-US"Lack 
interface config option.\n"
 #string STR_IFCONFIG_INVALID_INTERFACE#language en-US"Invalid 
interface name.\n"
 #string STR_IFCONFIG_INVALID_IPADDRESS#language en-US"Invalid ipv4 
address: '%H%s%N'\n"
+#string STR_IFCONFIG_INVALID_GATEWAY  #language en-US"Invalid 
gateway address: '%H%s%N'\n"
 #string STR_IFCONFIG_DUPLICATE_COMMAND#language en-US"Duplicate 
commands. Bad command %H%s%N is skipped.\n"
 #string STR_IFCONFIG_CONFLICT_COMMAND #language en-US"Conflict 
commands. Bad command %H%s%N is skipped.\n"
 #string STR_IFCONFIG_UNKNOWN_COMMAND 

Re: [edk2] [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe

2016-12-22 Thread Zhang, Lubo
Looks good to me.

Reviewed-by: Zhang Lubo 

> -Original Message-
> From: Wu, Jiaxin
> Sent: Thursday, December 08, 2016 8:55 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Zhang,
> Lubo ; Wu, Jiaxin 
> Subject: [Patch] NetworkPkg/DnsDxe: Fixed the assert issue in DnsDxe
> 
> Fix the DnsDxe assert issue when the incorrect answer message received.
> 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Zhang Lubo 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  NetworkPkg/DnsDxe/DnsImpl.c | 21 +
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c
> index 74deaa4..794df1d 100644
> --- a/NetworkPkg/DnsDxe/DnsImpl.c
> +++ b/NetworkPkg/DnsDxe/DnsImpl.c
> @@ -1328,13 +1328,16 @@ ParseDnsResponse (
>//
>// Processing AnswerSection.
>//
>while (AnswerSectionNum < DnsHeader->AnswersNum) {
>  //
> -// Answer name should be PTR.
> +// Answer name should be PTR, else EFI_UNSUPPORTED returned.
>  //
> -ASSERT ((*(UINT8 *) AnswerName & 0xC0) == 0xC0);
> +if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) {
> +  Status = EFI_UNSUPPORTED;
> +  goto ON_EXIT;
> +}
> 
>  //
>  // Get Answer section.
>  //
>  AnswerSection = (DNS_ANSWER_SECTION *) (AnswerName + sizeof
> (UINT16)); @@ -1406,11 +1409,16 @@ ParseDnsResponse (
>switch (AnswerSection->Type) {
>case DNS_TYPE_A:
>  //
>  // This is address entry, get Data.
>  //
> -ASSERT (Dns4TokenEntry != NULL && AnswerSection->DataLength == 4);
> +ASSERT (Dns4TokenEntry != NULL);
> +
> +if (AnswerSection->DataLength != 4) {
> +  Status = EFI_ABORTED;
> +  goto ON_EXIT;
> +}
> 
>  HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList;
>  AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
>  CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS));
> 
> @@ -1460,11 +1468,16 @@ ParseDnsResponse (
>  break;
>case DNS_TYPE_:
>  //
>  // This is address entry, get Data.
>  //
> -ASSERT (Dns6TokenEntry != NULL && AnswerSection->DataLength == 16);
> +ASSERT (Dns6TokenEntry != NULL);
> +
> +if (AnswerSection->DataLength != 16) {
> +  Status = EFI_ABORTED;
> +  goto ON_EXIT;
> +}
> 
>  HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList;
>  AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection);
>  CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS));
> 
> --
> 1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Add dns support for target URL configuration in ISCSI.

2016-12-18 Thread Zhang Lubo
Add DNS support for target URL directly configuration in UI.

Besides, When we enable the option (Get target info via DHCP) ,
the dhcp server will return target info include the  rootpath,
like the format
"iscsi:"":"":"":"":"
According to the RFC 4173,the server name region is expressed as
IPv4(192.168.10.20 )or IPv6 ([2000:::3]) or domain name,
but currently we only support the IP address format.
To enable this feature, we can support both.

Another enhancement is that we can deal with the data received from
the iSCSI login response with an target redirection status,
in which contains the Target Address in the format
domainname[:port][,portal-group-tag] required by RFC 3720.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c|  76 +++--
 NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h |   4 +-
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni   |   5 +-
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr   |  10 +-
 NetworkPkg/IScsiDxe/IScsiDhcp.c  |  18 +-
 NetworkPkg/IScsiDxe/IScsiDhcp6.c |  20 +-
 NetworkPkg/IScsiDxe/IScsiDns.c   | 435 +++
 NetworkPkg/IScsiDxe/IScsiDns.h   |  59 
 NetworkPkg/IScsiDxe/IScsiDriver.c|  18 +-
 NetworkPkg/IScsiDxe/IScsiDxe.inf |  18 +-
 NetworkPkg/IScsiDxe/IScsiImpl.h  |   6 +
 NetworkPkg/IScsiDxe/IScsiMisc.h  |   4 +
 NetworkPkg/IScsiDxe/IScsiProto.c |  67 -
 13 files changed, 682 insertions(+), 58 deletions(-)
 create mode 100644 NetworkPkg/IScsiDxe/IScsiDns.c
 create mode 100644 NetworkPkg/IScsiDxe/IScsiDns.h

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 57571ad..bf4947b 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -364,17 +364,19 @@ IScsiConvertAttemptConfigDataToIfrNvData (
   )
 {
   ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;
   ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
   EFI_IP_ADDRESSIp;
+  BOOLEAN   DnsMode;
 
   //
   // Normal session configuration parameters.
   //
   SessionConfigData = &Attempt->SessionConfigData;
   IfrNvData->Enabled= SessionConfigData->Enabled;
   IfrNvData->IpMode = SessionConfigData->IpMode;
+  DnsMode   = SessionConfigData->DnsMode;
 
   IfrNvData->InitiatorInfoFromDhcp  = SessionConfigData->InitiatorInfoFromDhcp;
   IfrNvData->TargetInfoFromDhcp = SessionConfigData->TargetInfoFromDhcp;
   IfrNvData->TargetPort = SessionConfigData->TargetPort;
 
@@ -383,23 +385,37 @@ IScsiConvertAttemptConfigDataToIfrNvData (
 IScsiIpToStr (&Ip, FALSE, IfrNvData->LocalIp);
 CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof 
(EFI_IPv4_ADDRESS));
 IScsiIpToStr (&Ip, FALSE, IfrNvData->SubnetMask);
 CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS));
 IScsiIpToStr (&Ip, FALSE, IfrNvData->Gateway);
-CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
-IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
+if (SessionConfigData->TargetIp.v4.Addr[0] != '\0') {
+  CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof 
(EFI_IPv4_ADDRESS));
+  IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
+}
+
   } else if (IfrNvData->IpMode == IP_MODE_IP6) {
 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
-IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp);
-IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp);
+if (SessionConfigData->TargetIp.v6.Addr[0] != '\0') {
+  IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp);
+  IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp);
+}
   }
 
   AsciiStrToUnicodeStrS (
 SessionConfigData->TargetName,
 IfrNvData->TargetName,
 sizeof (IfrNvData->TargetName) / sizeof (IfrNvData->TargetName[0])
 );
+
+  if (DnsMode) {
+AsciiStrToUnicodeStrS (
+  SessionConfigData->TargetUrl,
+  IfrNvData->TargetIp,
+  sizeof (IfrNvData->TargetIp) / sizeof (IfrNvData->TargetIp[0])
+  );
+  }
+
   IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun);
   IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId);
 
   IfrNvData->ConnectRetryCount = SessionConfigData->ConnectRetryCount;
   IfrNvData->ConnectTimeout= SessionConfigData->ConnectTimeout;
@@ -557,18 +573,30 @@ IScsiConvertIfrNvDataToAttemptConfigData (
 }
 //
 // Validate target configuration if DHCP isn't deployed.
 //
 if (!A

Re: [edk2] [PATCH] ShellPkg: Assign the correct value to ShellStatus

2016-12-06 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Gary Lin [mailto:g...@suse.com] 
Sent: Wednesday, December 07, 2016 11:41 AM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo ; Ye, Ting ; Fu, 
Siyuan ; Wu, Jiaxin 
Subject: [PATCH] ShellPkg: Assign the correct value to ShellStatus

Since the type of ShellStatus is SHELL_STATUS, we should use 
SHELL_INVALID_PARAMETER instead of EFI_INVALID_PARAMETER.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gary Lin 
Cc: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
index fb308cc3b6..d71688ed66 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
@@ -1319,15 +1319,15 @@ IfConfig6SetInterfaceInfo (
 
   if (StrCmp (VarArg->Arg, L"host") == 0) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
-ShellStatus = EFI_INVALID_PARAMETER;
+ShellStatus = SHELL_INVALID_PARAMETER;
 goto ON_EXIT;
   } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status);
-ShellStatus = EFI_INVALID_PARAMETER;
+ShellStatus = SHELL_INVALID_PARAMETER;
 goto ON_EXIT;
   } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status);
-ShellStatus = EFI_INVALID_PARAMETER;
+ShellStatus = SHELL_INVALID_PARAMETER;
 goto ON_EXIT;
   }
 
--
2.11.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg: Fix assert in iSCSI.

2016-11-30 Thread Zhang Lubo
The bug is caused by using already freed memory.
If there is already an attempt and execute
'reconnect -r' command, all the ConfigFormEntry structure
will be freed in IScsiDriverBindingStop, but the
mCallbackInfo->Current is not configured as null and
this pointer will be used again in IScsiFormExtractConfig.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c 
b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
index 77ccd67..ea727af 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
@@ -1074,10 +1074,11 @@ IScsiConfigUpdateForm (
 ASSERT (EntryExisted);
 
 mNumberOfIScsiDevices--;
 RemoveEntryList (&ConfigFormEntry->Link);
 FreePool (ConfigFormEntry);
+mCallbackInfo->Current = NULL;
   }
   //
   // Allocate space for creation of Buffer
   //
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Correct one typo error in PXE driver.

2016-11-30 Thread Zhang Lubo
Correct the typo
from Private->Icmp6Token.Status = EFI_NOT_READY to
Private->IcmpToken.Status = EFI_NOT_READY
when start the PXE over IPv4.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 0552174..5d63064 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -191,11 +191,11 @@ EfiPxeBcStart (
 }
 
 //
 // Create event and set status for token to capture ICMP error message.
 //
-Private->Icmp6Token.Status = EFI_NOT_READY;
+Private->IcmpToken.Status = EFI_NOT_READY;
 Status = gBS->CreateEvent (
 EVT_NOTIFY_SIGNAL,
 TPL_NOTIFY,
 PxeBcIcmpErrorUpdate,
 Private,
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused buf

2016-11-29 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Wednesday, November 30, 2016 10:26 AM
To: edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Ye, Ting ; Zhang, Lubo 

Subject: [Patch] NetworkPkg/IpSecDxe: correct one comment and remove the unused 
buf

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/IpSecDxe/Ikev2/Payload.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/Ikev2/Payload.c 
b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
index 675ecf6..f32b3a8 100644
--- a/NetworkPkg/IpSecDxe/Ikev2/Payload.c
+++ b/NetworkPkg/IpSecDxe/Ikev2/Payload.c
@@ -655,11 +655,10 @@ Ikev2CertGenerateAuthPayload (
   )
 {
   UINT8  *Digest;
   UINTN  DigestSize;
   PRF_DATA_FRAGMENT  Fragments[3];
-  UINT8  *KeyBuf;
   IKE_PAYLOAD*AuthPayload;
   IKEV2_AUTH *PayloadBuf;
   EFI_STATUS Status;
   UINT8  *Signature;
   UINTN  SigSize;
@@ -680,11 +679,10 @@ Ikev2CertGenerateAuthPayload (
   //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   //
   //
   // Initial point
   //
-  KeyBuf  = NULL;
   AuthPayload = NULL;
   Digest  = NULL;
   Signature   = NULL;
   SigSize = 0;
 
@@ -696,21 +694,10 @@ Ikev2CertGenerateAuthPayload (
   if (Digest == NULL) {
 return NULL;
   }
 
   //
-  // Store the AuthKey into KeyBuf
-  //
-  KeyBuf  = AllocateZeroPool (DigestSize);
-  if (KeyBuf == NULL) {
-Status = EFI_OUT_OF_RESOURCES;
-goto EXIT;
-  }
-  
-  CopyMem (KeyBuf, Digest, DigestSize);
-
-  //
   // Calculate Prf(SK_Pi/r, IDi/r)
   //
   Fragments[0].Data = IdPayload->PayloadBuf + sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
   Fragments[0].DataSize = IdPayload->PayloadSize - sizeof 
(IKEV2_COMMON_PAYLOAD_HEADER);
 
@@ -861,13 +848,10 @@ Ikev2CertGenerateAuthPayload (
   //
   AuthPayload->PayloadBuf   = (UINT8 *) PayloadBuf;
   AuthPayload->PayloadType  = IKEV2_PAYLOAD_TYPE_AUTH;
 
 EXIT:
-  if (KeyBuf != NULL) {
-FreePool (KeyBuf);
-  }
   if (Digest != NULL) {
 FreePool (Digest);
   }
   if (Signature != NULL) {
 FreePool (Signature);
@@ -1490,11 +1474,11 @@ Ikev2ParserNotifyCookiePayload (
   @param[in]  CertificateLenThe length of Certificate in byte.
   @param[in]  EncodeTypeSpecified the Certificate Encodeing which is 
defined
 in RFC 4306.
   @param[in]  IsRequest To indicate create Certificate Payload or 
Certificate
 Request Payload. If it is TURE, create 
Certificate
-Payload. Otherwise, create Certificate Request 
Payload.
+Request Payload. Otherwise, create Certificate 
Payload.
 
   @retval  a Pointer to IKE Payload whose payload buffer containing the 
Certificate
payload or Certificated Request payload.
 
 **/
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 command.

2016-11-28 Thread Zhang, Lubo
Thank you for reminding.

Lubo

-Original Message-
From: Hegde, Nagaraj P [mailto:nagaraj-p.he...@hpe.com] 
Sent: Tuesday, November 29, 2016 11:59 AM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: RE: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 
command.

Spelling correction in the uni file for STR_IFCONFIG6_ERR_MAN_GW. Should be 
"Gateway" instead of "Getway".
Reviewed-by: Hegde, Nagaraj P 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang 
Lubo
Sent: Tuesday, November 29, 2016 8:28 AM
To: edk2-devel@lists.01.org
Cc: Ye Ting ; Fu Siyuan ; Wu Jiaxin 

Subject: [edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 
command.

v2: update the prompt message more readable.

It should display error prompt message when Ifconfig6 can not configure 
correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 15 +++
 .../UefiShellNetwork2CommandsLib.uni  |  9 +
 2 files changed, 24 insertions(+)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
index 32dd284..fb308cc 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
@@ -1315,10 +1315,24 @@ IfConfig6SetInterfaceInfo (
 goto ON_EXIT;
   }
 
   VarArg= VarArg->Next;
 
+  if (StrCmp (VarArg->Arg, L"host") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  }
+
 } else if (StrCmp (VarArg->Arg, L"man") == 0) {
   //
   // Set manual config policy.
   //
   Policy = Ip6ConfigPolicyManual;
@@ -1509,10 +1523,11 @@ IfConfig6SetInterfaceInfo (
   CfgAddr
   );
 
   if (EFI_ERROR (Status)) {
 ShellStatus = SHELL_ACCESS_DENIED;
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
+ (STR_IFCONFIG6_ERR_MAN_GW), gShellNetwork2HiiHandle, Status);
 goto ON_EXIT;
   }
 
 } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
   //
diff --git 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
index c3445bb..79af7f9 100644
--- 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
+++ mandsLib.uni
@@ -75,10 +75,19 @@
 #string STR_IFCONFIG6_ERR_LACK_ARGUMENTS   #language en-US"Lack 
arguments. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_LACK_OPTION  #language en-US"Lack 
options.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_MAN_HOST #language en-US"Manual 
address configuration failed. Please retry.\r\n"
+
+#string STR_IFCONFIG6_ERR_MAN_GW   #language en-US"Getway 
address configuration failed. Please check the argument.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_IP_CONFIG#language en-US"The IP 
address is not configurable when the policy is Ip6ConfigPolicyAutomatic.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_GW_CONFIG#language en-US"The gateway 
address is not configurable when the policy is Ip6ConfigPolicyAutomatic.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG   #language en-US"The DNS 
server address is not configurable when the policy is 
Ip6ConfigPolicyAutomatic.\r\n"
+
 #string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND#language en-US"Duplicate 
commands. Bad command %H%s%N is skipped.\r\n"

[edk2] [PATCH v2] ShellPkg: Add error prompt message in Ifconfig6 command.

2016-11-28 Thread Zhang Lubo
v2: update the prompt message more readable.

It should display error prompt message when Ifconfig6 can
not configure correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 15 +++
 .../UefiShellNetwork2CommandsLib.uni  |  9 +
 2 files changed, 24 insertions(+)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
index 32dd284..fb308cc 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
@@ -1315,10 +1315,24 @@ IfConfig6SetInterfaceInfo (
 goto ON_EXIT;
   }
 
   VarArg= VarArg->Next;
 
+  if (StrCmp (VarArg->Arg, L"host") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  }
+
 } else if (StrCmp (VarArg->Arg, L"man") == 0) {
   //
   // Set manual config policy.
   //
   Policy = Ip6ConfigPolicyManual;
@@ -1509,10 +1523,11 @@ IfConfig6SetInterfaceInfo (
   CfgAddr
   );
 
   if (EFI_ERROR (Status)) {
 ShellStatus = SHELL_ACCESS_DENIED;
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_MAN_GW), gShellNetwork2HiiHandle, Status);
 goto ON_EXIT;
   }
 
 } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
   //
diff --git 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
index c3445bb..79af7f9 100644
--- 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
@@ -75,10 +75,19 @@
 #string STR_IFCONFIG6_ERR_LACK_ARGUMENTS   #language en-US"Lack 
arguments. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_LACK_OPTION  #language en-US"Lack 
options.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_MAN_HOST #language en-US"Manual 
address configuration failed. Please retry.\r\n"
+
+#string STR_IFCONFIG6_ERR_MAN_GW   #language en-US"Getway 
address configuration failed. Please check the argument.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_IP_CONFIG#language en-US"The IP 
address is not configurable when the policy is Ip6ConfigPolicyAutomatic.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_GW_CONFIG#language en-US"The gateway 
address is not configurable when the policy is Ip6ConfigPolicyAutomatic.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG   #language en-US"The DNS 
server address is not configurable when the policy is 
Ip6ConfigPolicyAutomatic.\r\n"
+
 #string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND#language en-US"Duplicate 
commands. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_CONFLICT_COMMAND #language en-US"Conflict 
commands. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_UNKNOWN_COMMAND  #language en-US"Unknown 
commands. Bad command %H%s%N is skipped.\r\n"
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch] ShellPkg: Add error prompt message in Ifconfig6 command.

2016-11-27 Thread Zhang, Lubo
Yes, it seems more readable. I will send updated patch later

Thanks
Lubo


> -Original Message-
> From: Ye, Ting
> Sent: Monday, November 28, 2016 3:03 PM
> To: Zhang, Lubo ; edk2-devel@lists.01.org
> Cc: Fu, Siyuan ; Wu, Jiaxin 
> Subject: RE: [edk2] [patch] ShellPkg: Add error prompt message in Ifconfig6
> command.
> 
> Hi Lubo,
> 
> I suggest to change below error messages to be more user friendly:
> Don't support to change the IP address manual if the policy is set to auto. 
> Set IP
> address fail.
> Don't support to change the IP address manual if the policy is set to auto. 
> Set
> Getway fail.\ Don't support to change the IP address manual if the policy is 
> set
> to auto. Set DNS fail.
> 
> For example, update to:
> The gateway address is not configurable when the policy is
> Ip6ConfigPolicyAutomatic.
> 
> Best Regards,
> Ting
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang
> Lubo
> Sent: Monday, November 28, 2016 1:43 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin
> 
> Subject: [edk2] [patch] ShellPkg: Add error prompt message in Ifconfig6
> command.
> 
> It should display error prompt message when Ifconfig6 can not configure
> correctly.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Wu Jiaxin 
> ---
>  ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 15
> +++
>  .../UefiShellNetwork2CommandsLib.uni  |  9 +
>  2 files changed, 24 insertions(+)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> index 32dd284..fb308cc 100644
> --- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> +++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
> @@ -1315,10 +1315,24 @@ IfConfig6SetInterfaceInfo (
>  goto ON_EXIT;
>}
> 
>VarArg= VarArg->Next;
> 
> +  if (StrCmp (VarArg->Arg, L"host") == 0) {
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
> +ShellStatus = EFI_INVALID_PARAMETER;
> +goto ON_EXIT;
> +  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +ShellStatus = EFI_INVALID_PARAMETER;
> +goto ON_EXIT;
> +  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle,
> Status);
> +ShellStatus = EFI_INVALID_PARAMETER;
> +goto ON_EXIT;
> +  }
> +
>  } else if (StrCmp (VarArg->Arg, L"man") == 0) {
>//
>// Set manual config policy.
>//
>Policy = Ip6ConfigPolicyManual;
> @@ -1509,10 +1523,11 @@ IfConfig6SetInterfaceInfo (
>CfgAddr
>);
> 
>if (EFI_ERROR (Status)) {
>  ShellStatus = SHELL_ACCESS_DENIED;
> +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> + (STR_IFCONFIG6_ERR_MAN_GW), gShellNetwork2HiiHandle, Status);
>  goto ON_EXIT;
>}
> 
>  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
>//
> diff --git
> a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comma
> ndsLib.uni
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comma
> ndsLib.uni
> index c3445bb..66ff05c 100644
> ---
> a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comma
> ndsLib.uni
> +++
> b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Com
> +++ mandsLib.uni
> @@ -75,10 +75,19 @@
>  #string STR_IFCONFIG6_ERR_LACK_ARGUMENTS   #language en-US"Lack
> arguments. Bad command %H%s%N is skipped.\r\n"
>"Hint: 
> Please type 'IfConfig6 -?' for help
> info.\r\n"
>  #string STR_IFCONFIG6_ERR_LACK_OPTION  #language en-US"Lack
> options.\r\n"
>"Hint: 
> Please type 'IfConfig6 -?' for help
> info.\r\n"
>  #string STR_IFCONFIG6_ERR_MAN_HOST #language en-US"Manual
> address configuration failed. Please retry.\

[edk2] [patch] ShellPkg: Add error prompt message in Ifconfig6 command.

2016-11-27 Thread Zhang Lubo
It should display error prompt message when Ifconfig6 can
not configure correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 15 +++
 .../UefiShellNetwork2CommandsLib.uni  |  9 +
 2 files changed, 24 insertions(+)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
index 32dd284..fb308cc 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
@@ -1315,10 +1315,24 @@ IfConfig6SetInterfaceInfo (
 goto ON_EXIT;
   }
 
   VarArg= VarArg->Next;
 
+  if (StrCmp (VarArg->Arg, L"host") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"gw") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status);
+ShellStatus = EFI_INVALID_PARAMETER;
+goto ON_EXIT;
+  }
+
 } else if (StrCmp (VarArg->Arg, L"man") == 0) {
   //
   // Set manual config policy.
   //
   Policy = Ip6ConfigPolicyManual;
@@ -1509,10 +1523,11 @@ IfConfig6SetInterfaceInfo (
   CfgAddr
   );
 
   if (EFI_ERROR (Status)) {
 ShellStatus = SHELL_ACCESS_DENIED;
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_MAN_GW), gShellNetwork2HiiHandle, Status);
 goto ON_EXIT;
   }
 
 } else if (StrCmp (VarArg->Arg, L"dns") == 0) {
   //
diff --git 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
index c3445bb..66ff05c 100644
--- 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
@@ -75,10 +75,19 @@
 #string STR_IFCONFIG6_ERR_LACK_ARGUMENTS   #language en-US"Lack 
arguments. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_LACK_OPTION  #language en-US"Lack 
options.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_MAN_HOST #language en-US"Manual 
address configuration failed. Please retry.\r\n"
+
+#string STR_IFCONFIG6_ERR_MAN_GW   #language en-US"Getway 
address configuration failed. Please check the argument.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_IP_CONFIG#language en-US"Don't 
support to change the IP address manual if the policy is set to auto. Set IP 
address fail.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_GW_CONFIG#language en-US"Don't 
support to change the IP address manual if the policy is set to auto. Set 
Getway fail.\r\n"
+
+#string STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG   #language en-US"Don't 
support to change the IP address manual if the policy is set to auto. Set DNS 
fail.\r\n"
+
 #string STR_IFCONFIG6_ERR_DUPLICATE_COMMAND#language en-US"Duplicate 
commands. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_CONFLICT_COMMAND #language en-US"Conflict 
commands. Bad command %H%s%N is skipped.\r\n"
   "Hint: 
Please type 'IfConfig6 -?' for help info.\r\n"
 #string STR_IFCONFIG6_ERR_UNKNOWN_COMMAND  #language en-US"Unknown 
commands. Bad command %H%s%N is skipped.\r\n"
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case

2016-11-25 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Friday, November 25, 2016 2:16 PM
To: edk2-devel@lists.01.org
Cc: Zhang, Lubo ; Fu, Siyuan ; Ye, 
Ting 
Subject: [Patch] MdeModulePkg/NetLib: Handle an invalid IPv6 address case

Handle an invalid IPv6 address in NetLibAsciiStrToIp6(), like '2000:::1com'.

Cc: Zhang Lubo 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 MdeModulePkg/Include/Library/NetLib.h  |  1 +
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 11 +++
 2 files changed, 12 insertions(+)

diff --git a/MdeModulePkg/Include/Library/NetLib.h 
b/MdeModulePkg/Include/Library/NetLib.h
index 26709af..09ead09 100644
--- a/MdeModulePkg/Include/Library/NetLib.h
+++ b/MdeModulePkg/Include/Library/NetLib.h
@@ -521,10 +521,11 @@ extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
 
 
 extern EFI_IPv4_ADDRESS  mZeroIp4Addr;
 
 #define NET_IS_DIGIT(Ch)(('0' <= (Ch)) && ((Ch) <= '9'))
+#define NET_IS_HEX(Ch)  ((('0' <= (Ch)) && ((Ch) <= '9')) || (('A' 
<= (Ch)) && ((Ch) <= 'F')) || (('a' <= (Ch)) && ((Ch) <= 'f')))
 #define NET_ROUNDUP(size, unit) (((size) + (unit) - 1) & (~((unit) - 1)))
 #define NET_IS_LOWER_CASE_CHAR(Ch)  (('a' <= (Ch)) && ((Ch) <= 'z'))  #define 
NET_IS_UPPER_CASE_CHAR(Ch)  (('A' <= (Ch)) && ((Ch) <= 'Z'))
 
 #define TICKS_PER_MS1U
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 0804052..0a7117c 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -2830,10 +2830,21 @@ NetLibAsciiStrToIp6 (
 
   for (Index = 0; Index < 15; Index = (UINT8) (Index + 2)) {
 TempStr = Ip6Str;
 
 while ((*Ip6Str != '\0') && (*Ip6Str != ':')) {
+  if (Index != 14 && !NET_IS_HEX (*Ip6Str)) {
+return EFI_INVALID_PARAMETER;
+  }
+  
+  //
+  // Allow the IPv6 with prefix case, e.g. 2000:::10/24 
+  //
+  if (Index == 14 && !NET_IS_HEX (*Ip6Str) && *Ip6Str != '/') {
+return EFI_INVALID_PARAMETER;
+  }
+  
   Ip6Str++;
 }
 
 if ((*Ip6Str == '\0') && (Index != 14)) {
   return EFI_INVALID_PARAMETER;
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg:Add scriptable configuration to iSCSI driver by leveraging x-UEFI.

2016-11-25 Thread Zhang Lubo
Enable iSCSI keywords configuration based on x-UEFI
name space. we introduce new PCD to control the attempt
numbers which will be created in non activated state, besides
the Attempt name is changed to READ_ONLY attribute in UI.
We can invoke KEYWORD HANDLER Protocol to configure
the related keywords.

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| 1769 +-
 NetworkPkg/IScsiDxe/IScsiConfig.h|   78 +-
 NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h |   75 +-
 NetworkPkg/IScsiDxe/IScsiConfigStrings.uni   |   30 +-
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr   |   48 +-
 NetworkPkg/IScsiDxe/IScsiDriver.c|   21 +-
 NetworkPkg/IScsiDxe/IScsiDriver.h|1 -
 NetworkPkg/IScsiDxe/IScsiDxe.inf |   21 +-
 NetworkPkg/IScsiDxe/IScsiImpl.h  |1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c  |  759 ++-
 NetworkPkg/IScsiDxe/IScsiMisc.h  |   28 +
 NetworkPkg/NetworkPkg.dec|5 +
 12 files changed, 2479 insertions(+), 357 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 57571ad..0f7b30d 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -288,10 +288,102 @@ IScsiConvertIsIdToString (
 
   return EFI_SUCCESS;
 }
 
 /**
+  Get the Offset value specified by the input String.
+
+  @param[in]  Configuration  A null-terminated Unicode string in
+  format.
+  @param[in]  String The string is "&OFFSET=".
+  @param[in]  Value  The Offset value.
+
+  @retval EFI_OUT_OF_RESOURCES   Insufficient resources to store neccessary
+ structures.
+  @retval EFI_SUCCESSValue of  is outputted in Number
+ successfully.
+
+**/
+EFI_STATUS
+IScsiGetValue (
+  IN  CONST EFI_STRING Configuration,
+  IN  CHAR16   *String,
+  OUT UINTN*Value
+  )
+{
+  CHAR16   *StringPtr;
+  CHAR16   *TmpPtr;
+  CHAR16   *Str;
+  CHAR16   TmpStr[2];
+  UINTNLength;
+  UINTNLen;
+  UINTNIndex;
+  UINT8*Buf;
+  UINT8DigitUint8;
+  EFI_STATUS   Status;
+
+  //
+  // Get Value.
+  //
+  Buf = NULL;
+  StringPtr = StrStr (Configuration, String);
+  ASSERT(StringPtr != NULL);
+  StringPtr += StrLen (String);
+  TmpPtr = StringPtr;
+
+  while (*StringPtr != L'\0' && *StringPtr != L'&') {
+StringPtr ++;
+  }
+  Length = StringPtr - TmpPtr;
+  Len = Length + 1;
+
+  Str = AllocateZeroPool (Len * sizeof (CHAR16));
+  if (Str == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto Exit;
+  }
+
+  CopyMem (Str, TmpPtr, Len * sizeof (CHAR16));
+  *(Str + Length) = L'\0';
+
+  Len = (Len + 1) / 2;
+  Buf = (UINT8 *) AllocateZeroPool (Len);
+  if (Buf == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto Exit;
+  }
+
+  ZeroMem (TmpStr, sizeof (TmpStr));
+  for (Index = 0; Index < Length; Index ++) {
+TmpStr[0] = Str[Length - Index - 1];
+DigitUint8 = (UINT8) StrHexToUint64 (TmpStr);
+if ((Index & 1) == 0) {
+  Buf [Index/2] = DigitUint8;
+} else {
+  Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]);
+}
+  }
+
+  *Value = 0;
+  CopyMem (
+Value,
+Buf,
+(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
+);
+
+  FreePool (Buf);
+  Status = EFI_SUCCESS;
+
+Exit:
+  if (Str != NULL) {
+FreePool (Str);
+  }
+
+  return Status;
+}
+
+/**
   Get the attempt config data from global structure by the ConfigIndex.
 
   @param[in]  AttemptConfigIndex The unique index indicates the attempt.
 
   @return   Pointer to the attempt config data.
@@ -347,10 +439,68 @@ IScsiConfigGetAttemptByNic (
   }
 
   return NULL;
 }
 
+/**
+  Extract the Index of the attempt list.
+
+  @param[in]   AttemptNameList The Name list of the Attempts.
+  @param[out]  AttemptIndexListThe Index list of the Attempts.
+  @param[in]   IsAddAttempts   If TRUE, Indicates add one or more attempts.
+   If FALSE, Indicates delete attempts or 
change attempt order.
+
+  @retval EFI_SUCCESS  The Attempt list is valid.
+  @retval EFI_INVALID_PARAMETERS   The Attempt List is invalid.
+
+**/
+EFI_STATUS
+IScsiGetAttemptIndexList (
+  IN   CHAR16*AttemptNameList,
+  IN  OUT  UINT8 *AttemptIndexList,
+  IN   BOOLEAN   IsAddAttempts
+)
+{
+  ISCSI_ATTEMPT_CONFIG_N

[edk2] [patch] ShellPkg: update ping6 to use timer service instead of timer arch protocol .

2016-11-08 Thread Zhang Lubo
This patch update the shell ping command to use timer service to calculate the
RTT time, instead of using the timer arch protocol.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ni Ruiyu 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 .../Library/UefiShellNetwork2CommandsLib/Ping6.c   | 241 ++---
 .../UefiShellNetwork2CommandsLib.inf   |   1 +
 .../UefiShellNetwork2CommandsLib.uni   |   4 +-
 3 files changed, 170 insertions(+), 76 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
index 90a2604..a30c064 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
@@ -17,45 +17,44 @@
 
 #define PING6_DEFAULT_TIMEOUT  5000
 #define PING6_MAX_SEND_NUMBER  1
 #define PING6_MAX_BUFFER_SIZE  32768
 #define PING6_ONE_SECOND   1000
-
-//
-// A similar amount of time that passes in femtoseconds
-// for each increment of TimerValue. It is for NT32 only.
-//
-#define NTTIMERPERIOD358049
+#define STALL_1_MILLI_SECOND  1000
 
 #pragma pack(1)
 
 typedef struct _ICMP6_ECHO_REQUEST_REPLY {
   UINT8   Type;
   UINT8   Code;
   UINT16  Checksum;
   UINT16  Identifier;
   UINT16  SequenceNum;
-  UINT64  TimeStamp;
+  UINT32  TimeStamp;
   UINT8   Data[1];
 } ICMP6_ECHO_REQUEST_REPLY;
 
 #pragma pack()
 
 typedef struct _PING6_ICMP6_TX_INFO {
   LIST_ENTRY  Link;
   UINT16  SequenceNum;
-  UINT64  TimeStamp;
+  UINT32  TimeStamp;
   EFI_IP6_COMPLETION_TOKEN*Token;
 } PING6_ICMP6_TX_INFO;
 
 typedef struct _PING6_PRIVATE_DATA {
   EFI_HANDLE  ImageHandle;
   EFI_HANDLE  NicHandle;
   EFI_HANDLE  Ip6ChildHandle;
   EFI_IP6_PROTOCOL*Ip6;
   EFI_EVENT   Timer;
 
+  UINT32  TimerPeriod;
+  UINT32  RttTimerTick;   
+  EFI_EVENT   RttTimer;
+
   EFI_STATUS  Status;
   LIST_ENTRY  TxList;
   EFI_IP6_COMPLETION_TOKENRxToken;
   UINT16  RxCount;
   UINT16  TxCount;
@@ -97,100 +96,193 @@ SHELL_PARAM_ITEMPing6ParamList[] = {
 //
 // Global Variables in Ping6 application.
 //
 CONST CHAR16*mIp6DstString;
 CONST CHAR16*mIp6SrcString;
-UINT64  mFrequency = 0;
-UINT64  mIp6CurrentTick = 0;
 EFI_CPU_ARCH_PROTOCOL   *Cpu = NULL;
 
+/**
+  RTT timer tick routine.
 
+  @param[in]EventA EFI_EVENT type event.
+  @param[in]Context  The pointer to Context.
+
+**/
+VOID
+EFIAPI
+Ping6RttTimerTickRoutine (
+  IN EFI_EVENTEvent,
+  IN VOID *Context
+  )
+{
+  UINT32 *RttTimerTick;
+
+  RttTimerTick = (UINT32*) Context;
+  (*RttTimerTick)++;
+}
 
 /**
-  Reads and returns the current value of the Time.
+  Get the timer period of the system.
+
+  This function tries to get the system timer period by creating
+  an 1ms period timer.
 
-  @return The current tick value.
+  @return System timer period in MS, or 0 if operation failed.
 
 **/
-UINT64
-Ping6ReadTime ()
+UINT32
+Ping6GetTimerPeriod(
+  VOID
+  )
 {
-  UINT64 TimerPeriod;
-  EFI_STATUS Status;
+  EFI_STATUS Status;
+  UINT32 RttTimerTick;
+  EFI_EVENT  TimerEvent;
+  UINT32 StallCounter;
+  EFI_TPLOldTpl;
 
-  ASSERT (Cpu != NULL);
+  RttTimerTick = 0;
+  StallCounter   = 0;
 
-  Status = Cpu->GetTimerValue (Cpu, 0, &mIp6CurrentTick, &TimerPeriod);
+  Status = gBS->CreateEvent (
+  EVT_TIMER | EVT_NOTIFY_SIGNAL,
+  TPL_NOTIFY,
+  Ping6RttTimerTickRoutine,
+  &RttTimerTick,
+  &TimerEvent
+  );
   if (EFI_ERROR (Status)) {
-//
-// The WinntGetTimerValue will return EFI_UNSUPPORTED. Set the
-// TimerPeriod by ourselves.
-//
-mIp6CurrentTick += 100;
+return 0;
+  }
+
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  Status = gBS->SetTimer (
+  TimerEvent,
+  TimerPeriodic,
+  TICKS_PER_MS
+  );
+  if (EFI_ERROR (Status)) {
+gBS->CloseEvent (TimerEvent);
+return 0;
+  }
+
+  while (RttTimerTick < 10) {
+gBS->Stall (STALL_1_MILLI_SECOND);
+++StallCounter;
   }
 
-  return mIp6CurrentTick;
+  gBS->RestoreTPL (OldTpl);
+
+  gBS->SetTimer (TimerEvent, TimerCancel, 0);
+  gBS->CloseEvent (TimerEvent);
+
+  return StallCounter / RttTimerTick;
 }
 
+
 /**
-  Get and cal

[edk2] [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool

2016-10-27 Thread Zhang Lubo
Add error handling logic if failed to apply new memory.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index 45377e3..eba8e1d 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -1296,12 +1296,13 @@ PxeBcSelectDhcp6Offer (
 /**
   Handle the DHCPv6 offer packet.
 
   @param[in]  Private The pointer to PXEBC_PRIVATE_DATA.
 
-  @retval EFI_SUCCESS Handled the DHCPv6 offer packet successfully.
-  @retval EFI_NO_RESPONSE No response to the following request packet.
+  @retval EFI_SUCCESS   Handled the DHCPv6 offer packet 
successfully.
+  @retval EFI_NO_RESPONSE   No response to the following request 
packet.
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resources.
 
 **/
 EFI_STATUS
 PxeBcHandleDhcp6Offer (
   IN PXEBC_PRIVATE_DATA*Private
@@ -1323,10 +1324,13 @@ PxeBcHandleDhcp6Offer (
   //
   // First try to cache DNS server address if DHCP6 offer provides.
   //
   if (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] != NULL) {
 Private->DnsServer = AllocateZeroPool (NTOHS 
(Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen));
+if (Private->DnsServer == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 CopyMem (Private->DnsServer, 
Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS));
   }
 
   if (Cache6->OfferType == PxeOfferTypeDhcpBinl) {
 //
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT

2016-10-14 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Ye, Ting 
Sent: Thursday, September 29, 2016 1:59 PM
To: edk2-devel@lists.01.org
Cc: Subramanian; Sriram ; Fu, Siyuan ; 
Zhang, Lubo 
Subject: [Patch] NetworkPkg: Record user configured TargetIP/Port in iBFT

Current ISCSI driver records redirected iSCSI targetIP/Port in iBFT once 
redirection occurs, which removes the possibility of the OS to reconnect to the 
configured IP for load balancing. The behavior is not explicitly described in 
IBFT spec, though the MSFT expert confirm we should record original user 
setting rather than publish the redirected IP.

Thanks Sriram for reviewing and validating this patch in his test-bed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ye Ting 
Cc: Subramanian, Sriram 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
---
 NetworkPkg/IScsiDxe/IScsiDriver.c | 19 +++
 NetworkPkg/IScsiDxe/IScsiMisc.c   | 10 +-
 NetworkPkg/IScsiDxe/IScsiMisc.h   |  7 ++-
 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 c3ab2c9..279f1c0 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -356,10 +356,11 @@ IScsiStart (
   CHAR16  MacString[ISCSI_MAX_MAC_STRING_LEN];
   BOOLEAN NeedUpdate;
   VOID*Interface;
   EFI_GUID*ProtocolGuid;
   UINT8   NetworkBootPolicy;
+  ISCSI_SESSION_CONFIG_NVDATA *NvData;
 
   //
   // Test to see if iSCSI driver supports the given controller.
   //
 
@@ -699,10 +700,28 @@ IScsiStart (
   Status = IScsiSessionLogin (Session);
 } else if (Status == EFI_NOT_READY) {
   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;
   // in multi-path mode, all the attempt entries in MPIO will be recorded 
in iBFT.
   //
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c 
index a39c268..64bb2ad 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1186,15 +1186,15 @@ IScsiGetConfigData (
   MacString,
   (UINTN) AttemptConfigOrder[Index]
   );
 
 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 1bcaeb8..912a871 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.h
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.h
@@ -48,13 +48,18 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
   CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];
   EFI_IP_ADDRESSTargetIp;
   UINT8 PrefixLength;
   UINT8 BootLun[8];
 
-  UINT16ConnectTimeout; ///< timout value in milliseconds
+  UINT16ConnectTimeout; ///< timout value in milliseconds.
   UINT8 ConnectRetryCount;
   UINT8 IsId[6];
+
+  BOOLEAN   RedirectFlag;
+  UINT16OriginalTargetPort; // The port of proxy/virtual 
target.
+  EFI_IP_ADDRESSOriginalTargetIp;   // The address of proxy/virtual 
target.
+  
 } ISCSI_SESSION_CONFIG_NVDATA;
 #pragma pack()
 
 /**
   Calculate the prefix length of the IPv4 subnet mask.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c
index 5092365..88d9bdd 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -1067,24 +1067,26 @@ IScsiUpdateTargetAddress (
   IN OUT ISCSI_SESSION *Session,
   IN CHAR8 *Data,
   IN UINT32Len
   )
 {
-  LIST_ENTRY  *KeyValueList;
-  CHAR8   *TargetAddress;
-  CHAR8   *IpStr;
-  EFI_S

[edk2] [patch] NetworkPkg: Add dns support for pxe boot based on IPv6.

2016-10-14 Thread Zhang Lubo
The BootFileURL option (59) in dhcpv6 is used to deliver
the next server address with bootfile name, as an example
"tftp://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]/BOOTFILE_NAME;
mode=octet", it can also be “tftp://domain_name/BOOTFILE_NAME;
mode=octet”, this patch is to support this case.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c  |  18 ++-
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 269 +++
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h |   5 +-
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h  |   3 +
 NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf |   4 +-
 5 files changed, 261 insertions(+), 38 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
index 8eff13c..fc50a82 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
@@ -619,31 +619,33 @@ PxeBcDhcp6BootInfo (
   }
 
   ASSERT (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] != NULL);
 
   //
+  // Set the station address to IP layer.
+  //
+  Status = PxeBcSetIp6Address (Private);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+
+  //
   // Parse (m)tftp server ip address and bootfile name.
   //
   Status = PxeBcExtractBootFileUrl (
+ Private,
  &Private->BootFileName,
  &Private->ServerIp.v6,
  (CHAR8 *) (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
  NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)
  );
   if (EFI_ERROR (Status)) {
 return Status;
   }
 
   //
-  // Set the station address to IP layer.
-  //
-  Status = PxeBcSetIp6Address (Private);
-  if (EFI_ERROR (Status)) {
-return Status;
-  }
-  
-  //
   // Parse the value of boot file size.
   //
   if (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_PARAM] != NULL) {
 //
 // Parse it out if have the boot file parameter option.
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index 41d3d30..45377e3 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -91,14 +91,15 @@ PxeBcBuildDhcp6Options (
 
   //
   // Append client option request option
   //
   OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
-  OptList[Index]->OpLen  = HTONS (4);
+  OptList[Index]->OpLen  = HTONS (6);
   OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data;
   OptEnt.Oro->OpCode[0]  = HTONS(DHCP6_OPT_BOOT_FILE_URL);
   OptEnt.Oro->OpCode[1]  = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
+  OptEnt.Oro->OpCode[2]  = HTONS(DHCP6_OPT_DNS_SERVERS);
   Index++;
   OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
 
   //
   // Append client network device interface option
@@ -214,14 +215,177 @@ PxeBcFreeBootFileOption (
 RemoveEntryList (Entry);
 FreePool (Node);
   }
 }
 
+/**
+  Retrieve the boot server address using the EFI_DNS6_PROTOCOL.
+
+  @param[in]  Private Pointer to PxeBc private data.
+  @param[in]  HostNamePointer to buffer containing hostname.
+  @param[out] IpAddress   On output, pointer to buffer containing IPv6 
address.
+
+  @retval EFI_SUCCESS Operation succeeded.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate needed resources.
+  @retval EFI_DEVICE_ERRORAn unexpected network error occurred.
+  @retval Others  Other errors as indicated.
+  
+**/
+EFI_STATUS
+PxeBcDns6 (
+  IN PXEBC_PRIVATE_DATA   *Private,
+  IN CHAR16   *HostName,
+ OUT EFI_IPv6_ADDRESS *IpAddress
+  )
+{
+  EFI_STATUS  Status;
+  EFI_DNS6_PROTOCOL   *Dns6;
+  EFI_DNS6_CONFIG_DATADns6ConfigData;
+  EFI_DNS6_COMPLETION_TOKEN   Token;
+  EFI_HANDLE  Dns6Handle;
+  EFI_IPv6_ADDRESS*DnsServerList;
+  BOOLEAN IsDone;
+  
+  Dns6= NULL;
+  Dns6Handle  = NULL;
+  DnsServerList   = Private->DnsServer;
+  ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN));
+
+  //
+  // Create a DNSv6 child instance and get the protocol.
+  //
+  Status = NetLibCreateServiceChild (
+ Private->Controller,
+ Private->Image,
+ &gEfiDns6ServiceBindingProtocolGuid,
+ &Dns6Handle
+ );
+  if (EFI_ERROR (Status)) {
+goto Exit;
+  } 
+  
+  Status = gBS->OpenProtocol (
+  Dns6Handle,
+  &gEfiDns6ProtocolGuid,
+  (VOID **) &Dns6,
+  Private->Image,
+  Private->Controller,
+  EFI_OPEN_PROTOCOL_BY_DRIVER
+  );
+  if (EFI_ERROR (Status))

[edk2] [patch] NetworkPkg: Enhance the code in DNS driver.

2016-10-13 Thread Zhang Lubo
There may be an error happens when we use the
configure function to set or change the configuration
data for the DNS6 instance, So we will free the
DnsServerList without configured to NULL. If we reset
the instance with the parameter DnsConfigData to NULL, the
DnsServerList will be freed twice.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/DnsDxe/DnsProtocol.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c
index 64fca6a..6d117b2 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -285,10 +285,11 @@ Dns4Configure (
 //
 Status = Dns4ConfigUdp (Instance, Instance->UdpIo);
 if (EFI_ERROR (Status)) {
   if (Instance->Dns4CfgData.DnsServerList != NULL) {
 FreePool (Instance->Dns4CfgData.DnsServerList);
+Instance->Dns4CfgData.DnsServerList = NULL;
   }
   goto ON_EXIT;
 }
 
 //
@@ -296,10 +297,11 @@ Dns4Configure (
 //
 Status = AddDns4ServerIp (&mDriverData->Dns4ServerList, 
Instance->SessionDnsServer.v4);
 if (EFI_ERROR (Status)) {
   if (Instance->Dns4CfgData.DnsServerList != NULL) {
 FreePool (Instance->Dns4CfgData.DnsServerList);
+Instance->Dns4CfgData.DnsServerList = NULL;
   }
   goto ON_EXIT;
 }
 
 Instance->State = DNS_STATE_CONFIGED;
@@ -1106,10 +1108,11 @@ Dns6Configure (
 //
 Status = Dns6ConfigUdp (Instance, Instance->UdpIo);
 if (EFI_ERROR (Status)) {
   if (Instance->Dns6CfgData.DnsServerList != NULL) {
 FreePool (Instance->Dns6CfgData.DnsServerList);
+Instance->Dns6CfgData.DnsServerList = NULL;
   }
   goto ON_EXIT;
 }
 
 //
@@ -1117,10 +1120,11 @@ Dns6Configure (
 //
 Status = AddDns6ServerIp (&mDriverData->Dns6ServerList, 
Instance->SessionDnsServer.v6);
 if (EFI_ERROR (Status)) {
   if (Instance->Dns6CfgData.DnsServerList != NULL) {
 FreePool (Instance->Dns6CfgData.DnsServerList);
+Instance->Dns6CfgData.DnsServerList = NULL;
   }
   goto ON_EXIT;
 }
 
 Instance->State = DNS_STATE_CONFIGED;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Support bracketed IPv6 address during a redirection in iSCSI

2016-10-13 Thread Zhang Lubo
According to RFC 3720, the TargetAddress provided in a redirection
might be a DNS host name, a dotted-decimal IPv4 address, or a
bracketed IPv6 address. Current ISCSI driver in Networkpkg only
supports dotted-decimal IPv4 address, so we need add IPv6 address
support since it is a combo driver supporting dual stack.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiProto.c | 51 ++--
 NetworkPkg/IScsiDxe/IScsiProto.h |  5 +++-
 2 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c
index 5092365..a9bf491 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -1087,26 +1087,53 @@ IScsiUpdateTargetAddress (
 TargetAddress = IScsiGetValueByKeyFromList (KeyValueList, 
ISCSI_KEY_TARGET_ADDRESS);
 if (TargetAddress == NULL) {
   break;
 }
 
-if (!NET_IS_DIGIT (TargetAddress[0])) {
+//
+// RFC 3720 defines format of the 
TargetAddress=domainname[:port][,portal-group-tag]
+// The domainname can be specified as either a DNS host name, 
adotted-decimal IPv4 address,
+// or a bracketed IPv6 address as specified in [RFC2732].
+//
+if (NET_IS_DIGIT (TargetAddress[0])) {
   //
-  // The domainname of the target may be presented in three formats: a DNS 
host name,
-  // a dotted-decimal IPv4 address, or a bracketed IPv6 address. Only 
accept dotted
-  // IPv4 address.
+  // The domainname of the target is presented in a dotted-decimal IPv4 
address format.
   //
-  continue;
-}
-
-IpStr = TargetAddress;
+  IpStr = TargetAddress;
 
-while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress 
!= ',')) {
+  while ((*TargetAddress != '\0') && (*TargetAddress != ':') && 
(*TargetAddress != ',')) {
+//
+// NULL, ':', or ',' ends the IPv4 string.
+//
+TargetAddress++;
+  }
+  
+} else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER){
   //
-  // NULL, ':', or ',' ends the IPv4 string.
+  // The domainname of the target is presented in a bracketed IPv6 address 
format.
   //
-  TargetAddress++;
+  TargetAddress ++;
+  IpStr = TargetAddress;
+  while ((*TargetAddress != '\0') && (*TargetAddress != 
ISCSI_REDIRECT_ADDR_END_DELIMITER)) {
+//
+// ']' ends the IPv6 string.
+//
+TargetAddress++;
+  }
+
+  if (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER) {
+continue;
+  }
+
+  *TargetAddress = '\0';
+  TargetAddress ++;
+
+} else {
+  //
+  // The domainname of the target is presented in the format of a DNS host 
name.
+  // Temporary not supported.
+  continue;
 }
 
 if (*TargetAddress == ',') {
   //
   // Comma and the portal group tag MUST be ommitted if the TargetAddress 
is sent
@@ -1124,11 +1151,11 @@ IScsiUpdateTargetAddress (
   } else {
 Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;
   }
 } else {
   //
-  // The string only contains the IPv4 address. Use the well-known port.
+  // The string only contains the Target address. Use the well-known port.
   //
   Session->ConfigData->SessionConfigData.TargetPort = 
ISCSI_WELL_KNOWN_PORT;
 }
 //
 // Update the target IP address.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.h b/NetworkPkg/IScsiDxe/IScsiProto.h
index 8099f34..367914d 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.h
+++ b/NetworkPkg/IScsiDxe/IScsiProto.h
@@ -1,9 +1,9 @@
 /** @file
   The header file of iSCSI Protocol that defines many specific data structures.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -38,10 +38,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define DEFAULT_MAX_OUTSTANDING_R2T 1
 
 #define ISCSI_VERSION_MAX   0x00
 #define ISCSI_VERSION_MIN   0x00
 
+#define ISCSI_REDIRECT_ADDR_START_DELIMITER '['
+#define ISCSI_REDIRECT_ADDR_END_DELIMITER   ']'
+
 #define ISCSI_KEY_AUTH_METHOD   "AuthMethod"
 #define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"
 #define ISCSI_KEY_DATA_DIGEST 

[edk2] [patch 3/3] MdePkg:Correct the comment for the DEBUG_NET.

2016-09-22 Thread Zhang Lubo
Generalize the comment for the DEBUG_NET
#define DEBUG_NET  0x4000  // SNP Driver
to Network IO Driver.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Hegde Nagaraj P 
Cc: Subramanian Sriram 
Cc: Fu Siyuan 
Cc: Ye Ting 
---
 MdePkg/Include/Library/DebugLib.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index 803872c..8190432 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -6,11 +6,11 @@
 
   Note that a reserved macro named MDEPKG_NDEBUG is introduced for the 
intention
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
   defined, then debug and assert related macros wrapped by it are the NULL 
implementations.
 
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
under 
 the terms and conditions of the BSD License that accompanies this 
distribution.  
 The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php.
 
@@ -44,11 +44,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define DEBUG_INFO  0x0040  // Informational debug messages
 #define DEBUG_DISPATCH  0x0080  // PEI/DXE/SMM Dispatchers
 #define DEBUG_VARIABLE  0x0100  // Variable
 #define DEBUG_BM0x0400  // Boot Manager
 #define DEBUG_BLKIO 0x1000  // BlkIo Driver
-#define DEBUG_NET   0x4000  // SNP Driver
+#define DEBUG_NET   0x4000  // Network Io Driver
 #define DEBUG_UNDI  0x0001  // UNDI Driver
 #define DEBUG_LOADFILE  0x0002  // LoadFile
 #define DEBUG_EVENT 0x0008  // Event messages
 #define DEBUG_GCD   0x0010  // Global Coherency Database changes
 #define DEBUG_CACHE 0x0020  // Memory range cachability changes
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 2/3] MdeModulePkg:TcpDriver need to use EFI_D_NET for DEBUG maessage.

2016-09-22 Thread Zhang Lubo
Tcp driver need to use EFI_D_NET to log DEBUG message,
So it becomes easy to separate/filter out debug messages
from network stack versus generic EFI_D_INFO debugs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Hegde Nagaraj P 
Cc: Subramanian Sriram 
Cc: Fu Siyuan 
Cc: Ye Ting 
---
 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c  | 46 +++---
 .../Universal/Network/Tcp4Dxe/SockInterface.c  |  2 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c | 32 +++
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c  |  8 ++--
 .../Universal/Network/Tcp4Dxe/Tcp4Output.c |  6 +--
 5 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c 
b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
index 2e31643..3025790 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
@@ -1,9 +1,9 @@
 /** @file
   Implementation of the Socket.
 
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -31,11 +31,11 @@ UINT32
 SockTcpDataToRcv (
   IN SOCK_BUFFER*SockBuffer,
  OUT BOOLEAN*IsUrg,
   IN UINT32 BufLen
   );
-  
+
 /**
   Process the send token.
 
   @param  Sock  Pointer to the socket.
 
@@ -47,11 +47,11 @@ SockProcessSndToken (
 
 /**
   Supporting function for both SockImpl and SockInterface.
 
   @param Event The Event this notify function registered to, 
ignored.
-  
+
 **/
 VOID
 EFIAPI
 SockFreeFoo (
   IN EFI_EVENT Event
@@ -320,11 +320,11 @@ SockProcessTcpSndData (
 /**
   Flush the tokens in the specific token list.
 
   @param  Sock  Pointer to the socket.
   @param  PendingTokenList  Pointer to the token list to be flushed.
-  
+
 **/
 VOID
 SockFlushPendingToken (
   IN SOCKET *Sock,
   IN LIST_ENTRY *PendingTokenList
@@ -350,11 +350,11 @@ SockFlushPendingToken (
   }
 }
 
 
 /**
-  Wake up the connection token while the connection is successfully 
established, 
+  Wake up the connection token while the connection is successfully 
established,
   then try to process any pending send token.
 
   @param  Sock  Pointer to the socket.
 
 **/
@@ -411,11 +411,11 @@ SockWakeListenToken (
 FreePool (SockToken);
 
 RemoveEntryList (&Sock->ConnectionList);
 
 Parent->ConnCnt--;
-DEBUG ((EFI_D_INFO, "SockWakeListenToken: accept a socket, now conncnt is 
%d", Parent->ConnCnt));
+DEBUG ((EFI_D_NET, "SockWakeListenToken: accept a socket, now conncnt is 
%d", Parent->ConnCnt));
 
 Sock->Parent = NULL;
   }
 }
 
@@ -662,11 +662,11 @@ SockCreate (
 // if the Parent->ConnCnt < Parent->BackLog
 //
 Parent->ConnCnt++;
 
 DEBUG (
-  (EFI_D_INFO,
+  (EFI_D_NET,
   "SockCreate: Create a new socket and add to parent, now conncnt is %d\n",
   Parent->ConnCnt)
   );
 
 InsertTailList (&Parent->ConnectionList, &Sock->ConnectionList);
@@ -751,11 +751,11 @@ SockDestroy (
 
 RemoveEntryList (&(Sock->ConnectionList));
 (Sock->Parent->ConnCnt)--;
 
 DEBUG (
-  (EFI_D_INFO,
+  (EFI_D_NET,
   "SockDestroy: Delete a unaccepted socket from parent"
   "now conncnt is %d\n",
   Sock->Parent->ConnCnt)
   );
 
@@ -931,14 +931,14 @@ SockClone (
   return ClonedSock;
 }
 
 
 /**
-  Called by the low layer protocol to indicate the socket a connection is 
-  established. 
-  
-  This function just changes the socket's state to SO_CONNECTED 
+  Called by the low layer protocol to indicate the socket a connection is
+  established.
+
+  This function just changes the socket's state to SO_CONNECTED
   and signals the token used for connection establishment.
 
   @param  Sock  Pointer to the socket associated with the
 established connection.
 **/
@@ -962,17 +962,17 @@ SockConnEstablished (
 }
 
 
 /**
   Called by the low layer protocol to indicate the connection is closed.
-  
-  This function flushes the socket, sets the state to SO_CLOSED and signals 
+
+  This function flushes the socket, sets the state to SO_CLOSED and signals
   the close token.
 
   @param  Sock  Pointer to the socket associated with the 
closed
 connection.
-
+
 **/
 VOID
 SockConnClosed (
   IN OUT SOCKET *Sock
   )
@@ -992,12 +992,12 @@ SockConnClosed (
 }
 
 
 /**
   Called by l

[edk2] [patch 0/3] TcpDriver use EFI_D_NET for DEBUG maessage

2016-09-22 Thread Zhang Lubo
Zhang Lubo (3):
  NetworkPkg: TcpDriver use EFI_D_NET for DEBUG maessage.
  MdeModulePkg:TcpDriver need to use EFI_D_NET for DEBUG maessage.
  MdePkg:Correct the comment for the DEBUG_NET.

 MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c  | 46 +++---
 .../Universal/Network/Tcp4Dxe/SockInterface.c  |  2 +-
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c | 32 +++
 MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c  |  8 ++--
 .../Universal/Network/Tcp4Dxe/Tcp4Output.c |  6 +--
 MdePkg/Include/Library/DebugLib.h  |  4 +-
 NetworkPkg/TcpDxe/SockImpl.c   |  4 +-
 NetworkPkg/TcpDxe/SockInterface.c  |  2 +-
 NetworkPkg/TcpDxe/TcpInput.c   | 32 +++
 NetworkPkg/TcpDxe/TcpMisc.c|  6 +--
 NetworkPkg/TcpDxe/TcpOutput.c  |  8 ++--
 11 files changed, 75 insertions(+), 75 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch 1/3] NetworkPkg: TcpDriver use EFI_D_NET for DEBUG maessage.

2016-09-22 Thread Zhang Lubo
Tcp driver need to use EFI_D_NET to log DEBUG message,
So it becomes easy to separate/filter out debug messages
from network stack versus generic EFI_D_INFO debugs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Hegde Nagaraj P 
Cc: Subramanian Sriram 
Cc: Fu Siyuan 
Cc: Ye Ting 
---
 NetworkPkg/TcpDxe/SockImpl.c  |  4 ++--
 NetworkPkg/TcpDxe/SockInterface.c |  2 +-
 NetworkPkg/TcpDxe/TcpInput.c  | 32 
 NetworkPkg/TcpDxe/TcpMisc.c   |  6 +++---
 NetworkPkg/TcpDxe/TcpOutput.c |  8 
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/NetworkPkg/TcpDxe/SockImpl.c b/NetworkPkg/TcpDxe/SockImpl.c
index 5addbd1..4eb42fb 100644
--- a/NetworkPkg/TcpDxe/SockImpl.c
+++ b/NetworkPkg/TcpDxe/SockImpl.c
@@ -520,11 +520,11 @@ SockWakeListenToken (
 
 RemoveEntryList (&Sock->ConnectionList);
 
 Parent->ConnCnt--;
 DEBUG (
-  (EFI_D_INFO,
+  (EFI_D_NET,
   "SockWakeListenToken: accept a socket, now conncnt is %d",
   Parent->ConnCnt)
   );
 
 Sock->Parent = NULL;
@@ -774,11 +774,11 @@ SockCreate (
 // if the Parent->ConnCnt < Parent->BackLog
 //
 Parent->ConnCnt++;
 
 DEBUG (
-  (EFI_D_INFO,
+  (EFI_D_NET,
   "SockCreate: Create a new socket and add to parent, now conncnt is %d\n",
   Parent->ConnCnt)
   );
 
 InsertTailList (&Parent->ConnectionList, &Sock->ConnectionList);
diff --git a/NetworkPkg/TcpDxe/SockInterface.c 
b/NetworkPkg/TcpDxe/SockInterface.c
index 1ae0c64..21ce643 100644
--- a/NetworkPkg/TcpDxe/SockInterface.c
+++ b/NetworkPkg/TcpDxe/SockInterface.c
@@ -468,11 +468,11 @@ SockAccept (
   ASSERT (Socket->Parent != NULL);
 
   Socket->Parent->ConnCnt--;
 
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "SockAccept: Accept a socket, now conncount is %d",
 Socket->Parent->ConnCnt)
 );
   Socket->Parent = NULL;
 
diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c
index 3115c52..04c8a82 100644
--- a/NetworkPkg/TcpDxe/TcpInput.c
+++ b/NetworkPkg/TcpDxe/TcpInput.c
@@ -72,11 +72,11 @@ TcpFastRecover (
 //
 TcpRetransmit (Tcb, Tcb->SndUna);
 Tcb->CWnd = Tcb->Ssthresh + 3 * Tcb->SndMss;
 
 DEBUG (
-  (EFI_D_INFO,
+  (EFI_D_NET,
   "TcpFastRecover: enter fast retransmission for TCB %p, recover point is 
%d\n",
   Tcb,
   Tcb->Recover)
   );
 return;
@@ -95,11 +95,11 @@ TcpFastRecover (
 // Step 4 is skipped here only to be executed later
 // by TcpToSendData
 //
 Tcb->CWnd += Tcb->SndMss;
 DEBUG (
-  (EFI_D_INFO,
+  (EFI_D_NET,
   "TcpFastRecover: received another duplicated ACK (%d) for TCB %p\n",
   Seg->Ack,
   Tcb)
   );
 
@@ -119,11 +119,11 @@ TcpFastRecover (
 
   Tcb->CWnd = MIN (Tcb->Ssthresh, FlightSize + Tcb->SndMss);
 
   Tcb->CongestState = TCP_CONGEST_OPEN;
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "TcpFastRecover: received a full ACK(%d) for TCB %p, exit fast 
recovery\n",
 Seg->Ack,
 Tcb)
 );
 
@@ -148,11 +148,11 @@ TcpFastRecover (
   }
 
   Tcb->CWnd -= Acked;
 
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "TcpFastRecover: received a partial ACK(%d) for TCB %p\n",
 Seg->Ack,
 Tcb)
 );
 
@@ -186,11 +186,11 @@ TcpFastLossRecover (
   //
   Tcb->LossTimes= 0;
   Tcb->CongestState = TCP_CONGEST_OPEN;
 
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "TcpFastLossRecover: received a full ACK(%d) for TCB %p\n",
 Seg->Ack,
 Tcb)
 );
 
@@ -200,11 +200,11 @@ TcpFastLossRecover (
   // Partial ACK:
   // fast retransmit the first unacknowledge field.
   //
   TcpRetransmit (Tcb, Seg->Ack);
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "TcpFastLossRecover: received a partial ACK(%d) for TCB %p\n",
 Seg->Ack,
 Tcb)
 );
 }
@@ -262,11 +262,11 @@ TcpComputeRtt (
 Tcb->Rto = TCP_RTO_MAX;
 
   }
 
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "TcpComputeRtt: new RTT for TCB %p computed SRTT: %d RTTVAR: %d RTO: %d\n",
 Tcb,
 Tcb->SRtt,
 Tcb->RttVar,
 Tcb->Rto)
@@ -453,11 +453,11 @@ TcpDeliverData (
 NetbufFree (Nbuf);
 return -1;
   }
 
   DEBUG (
-(EFI_D_INFO,
+(EFI_D_NET,
 "TcpDeliverData: processing FIN from peer of TCB %p\n",
 Tcb)
 );
 
   switch (Tcb->State) {
@@ -748,19 +748,19 @@ TcpInput (
 
   Head= (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
   ASSERT (Head != NULL);
   
   if (Nbuf->TotalSize

Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

2016-08-29 Thread Zhang, Lubo
What do you mean control goes to next boot option?  Will it go to PXE boot when 
you select the 2nd http boot. If was, you just need to update the whole edk2 
code. This issue related to the BDS and we already fixed long before,

Best regards
Lubo 

-Original Message-
From: Santhapur Naveen [mailto:nave...@amiindia.co.in] 
Sent: Monday, August 29, 2016 2:27 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

I've taken the source from the location you have specified and checked. 
But I still get the same failure. When I select the same HTTP boot option the 
2nd time, control goes to next boot option available. I guess the problem could 
be on my side only. I'll look into it.

Thank you very much for your time and effort.

Thanks,
Naveen

-Original Message-----
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Thursday, August 25, 2016 3:19 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

  Yes, the SVN version number I provide is not consistent with you. 
  The attachment is latest patch log details of the GitHub, you can make a  
contrast when you download the code. And then do some test.
  
Best Regards
Lubo
 
  

-Original Message-
From: Santhapur Naveen [mailto:nave...@amiindia.co.in] 
Sent: Thursday, August 25, 2016 5:09 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

I believe the way we refer the version numbers seem different. I use 
tortoise SVN to get the details of the edk2. When I checked the revision 
numbers 22104 and 21740 for HttpBootDxe and HttpDxe drivers respectively, I 
couldn't find anything. Please refer the attachments. By any means is it 
possible for you to provide the way you refer the revision details?

However, I've downloaded the latest source from the URL you have 
provided and I'm trying to verify the same now. Will update you my result.

Thank you,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Thursday, August 25, 2016 7:19 AM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
   I update the  SVN and now the revision is 22467.
   The HttpBootDxe revision is 22104,patch is - Fix IPv6 HTTPClient vendor 
class data
   The HttpDxe revision is 21740, patch is - NetworkPkg: Fix typos in 
comments.
   But I suggest you to download  the https://github.com/tianocore/edk2, it 
is latest edk2 code.

Best Regards
Lubo

-Original Message-
From: Santhapur Naveen [mailto:nave...@amiindia.co.in] 
Sent: Wednesday, August 24, 2016 7:10 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Can you please provide me any reference revision number to download and 
check the same?

Thank you,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 4:23 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
  I have checked the issue you mentioned. On my side, I updated the code to 
latest and do some test on NT32 and Denlow platform, both the first http boot 
and 2nd are successful. 
  Until now , we have fixed few bugs which may lead the 2nd http boot fail. 
As for the patch you mentioned is one case to fix the bug, So I suggest you to 
update the code firstly and at least make sure the HttpDxe , HttpBootDxe and 
DxeHttpLib are latest. 
   
 If any result, Pls let me know.

Best Regards
Lubo 
 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 4:53 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Please find the following details that may help.

NetworkPkg:Fix a bug the 2nd httpboot fail issue.

Httpboot over Ipv4 or Ipv6 stack,for both Identity and chunked transfer 
mode,when the last data has been parsed by HttpLib, the HttpInstance->NextMsg 
pointer should point a correct location.Now after the first  successful 
httpboot for ipv4 or ipv6,the HttpInstance->NextMsgpoint the character after 
the last byte, it may be a bad buffer if we don't receive another HttpHeader, 
so if call a 2nd httpboot, the wrong NextMsg pointer will cause the httpboot 
fail, so we need to check this case in HttpBodyParserCallback function in the 
first http boot process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
R

Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

2016-08-25 Thread Zhang, Lubo
  Yes, the SVN version number I provide is not consistent with you. 
  The attachment is latest patch log details of the GitHub, you can make a  
contrast when you download the code. And then do some test.
  
Best Regards
Lubo
 
  

-Original Message-
From: Santhapur Naveen [mailto:nave...@amiindia.co.in] 
Sent: Thursday, August 25, 2016 5:09 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

I believe the way we refer the version numbers seem different. I use 
tortoise SVN to get the details of the edk2. When I checked the revision 
numbers 22104 and 21740 for HttpBootDxe and HttpDxe drivers respectively, I 
couldn't find anything. Please refer the attachments. By any means is it 
possible for you to provide the way you refer the revision details?

However, I've downloaded the latest source from the URL you have 
provided and I'm trying to verify the same now. Will update you my result.

Thank you,
Naveen

-Original Message-----
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Thursday, August 25, 2016 7:19 AM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
   I update the  SVN and now the revision is 22467.
   The HttpBootDxe revision is 22104,patch is - Fix IPv6 HTTPClient vendor 
class data
   The HttpDxe revision is 21740, patch is - NetworkPkg: Fix typos in 
comments.
   But I suggest you to download  the https://github.com/tianocore/edk2, it 
is latest edk2 code.

Best Regards
Lubo

-Original Message-
From: Santhapur Naveen [mailto:nave...@amiindia.co.in] 
Sent: Wednesday, August 24, 2016 7:10 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Can you please provide me any reference revision number to download and 
check the same?

Thank you,
Naveen

-Original Message-----
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 4:23 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
  I have checked the issue you mentioned. On my side, I updated the code to 
latest and do some test on NT32 and Denlow platform, both the first http boot 
and 2nd are successful. 
  Until now , we have fixed few bugs which may lead the 2nd http boot fail. 
As for the patch you mentioned is one case to fix the bug, So I suggest you to 
update the code firstly and at least make sure the HttpDxe , HttpBootDxe and 
DxeHttpLib are latest. 
   
 If any result, Pls let me know.

Best Regards
Lubo 
 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 4:53 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Please find the following details that may help.

NetworkPkg:Fix a bug the 2nd httpboot fail issue.

Httpboot over Ipv4 or Ipv6 stack,for both Identity and chunked transfer 
mode,when the last data has been parsed by HttpLib, the HttpInstance->NextMsg 
pointer should point a correct location.Now after the first  successful 
httpboot for ipv4 or ipv6,the HttpInstance->NextMsgpoint the character after 
the last byte, it may be a bad buffer if we don't receive another HttpHeader, 
so if call a 2nd httpboot, the wrong NextMsg pointer will cause the httpboot 
fail, so we need to check this case in HttpBodyParserCallback function in the 
first http boot process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
Reviewed-by: Ye Ting 
Reviewed-by: Wu Jiaxin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19423 
6f19259b-4bc3-4df7-8a09-765794883524


Thanks,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 2:13 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
 Could you list the patch name or Git SHA value which fixed the 2nd 
HttpBootfail issue. On my side, the SVN version 24729 is not exist.

Thanks 
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 3:40 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hello,

  Revision 24729 of edk2 says 2nd HttpBoot fail issue has been fixed. 
So, I have taken the changes from the file NetworkPkg/HttpDxe/HttpImpl.c of the 
revsision 24729 and still the 2nd  HttpBoot fails. Please let me know if I have 
missed any.

P.S: T

Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

2016-08-24 Thread Zhang, Lubo
Hi Naveen
   I update the  SVN and now the revision is 22467.
   The HttpBootDxe revision is 22104,patch is - Fix IPv6 HTTPClient vendor 
class data
   The HttpDxe revision is 21740, patch is - NetworkPkg: Fix typos in 
comments.
   But I suggest you to download  the https://github.com/tianocore/edk2, it 
is latest edk2 code.

Best Regards
Lubo

-Original Message-
From: Santhapur Naveen [mailto:nave...@amiindia.co.in] 
Sent: Wednesday, August 24, 2016 7:10 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Can you please provide me any reference revision number to download and 
check the same?

Thank you,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 4:23 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
  I have checked the issue you mentioned. On my side, I updated the code to 
latest and do some test on NT32 and Denlow platform, both the first http boot 
and 2nd are successful. 
  Until now , we have fixed few bugs which may lead the 2nd http boot fail. 
As for the patch you mentioned is one case to fix the bug, So I suggest you to 
update the code firstly and at least make sure the HttpDxe , HttpBootDxe and 
DxeHttpLib are latest. 
   
 If any result, Pls let me know.

Best Regards
Lubo 
 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 4:53 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Please find the following details that may help.

NetworkPkg:Fix a bug the 2nd httpboot fail issue.

Httpboot over Ipv4 or Ipv6 stack,for both Identity and chunked transfer 
mode,when the last data has been parsed by HttpLib, the HttpInstance->NextMsg 
pointer should point a correct location.Now after the first  successful 
httpboot for ipv4 or ipv6,the HttpInstance->NextMsgpoint the character after 
the last byte, it may be a bad buffer if we don't receive another HttpHeader, 
so if call a 2nd httpboot, the wrong NextMsg pointer will cause the httpboot 
fail, so we need to check this case in HttpBodyParserCallback function in the 
first http boot process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
Reviewed-by: Ye Ting 
Reviewed-by: Wu Jiaxin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19423 
6f19259b-4bc3-4df7-8a09-765794883524


Thanks,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 2:13 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
 Could you list the patch name or Git SHA value which fixed the 2nd 
HttpBootfail issue. On my side, the SVN version 24729 is not exist.

Thanks 
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 3:40 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hello,

  Revision 24729 of edk2 says 2nd HttpBoot fail issue has been fixed. 
So, I have taken the changes from the file NetworkPkg/HttpDxe/HttpImpl.c of the 
revsision 24729 and still the 2nd  HttpBoot fails. Please let me know if I have 
missed any.

P.S: The first http boot happens successfully though. (downloading a Shell.efi)

Thanks,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

2016-08-24 Thread Zhang, Lubo
Hi Naveen
  I have checked the issue you mentioned. On my side, I updated the code to 
latest and do some test on NT32 and Denlow platform, both the first http boot 
and 2nd are successful. 
  Until now , we have fixed few bugs which may lead the 2nd http boot fail. 
As for the patch you mentioned is one case to fix the bug, So I suggest you to 
update the code firstly and at least make sure the HttpDxe , HttpBootDxe and 
DxeHttpLib are latest. 
   
 If any result, Pls let me know.

Best Regards
Lubo 
 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 4:53 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Please find the following details that may help.

NetworkPkg:Fix a bug the 2nd httpboot fail issue.

Httpboot over Ipv4 or Ipv6 stack,for both Identity and chunked transfer 
mode,when the last data has been parsed by HttpLib, the HttpInstance->NextMsg 
pointer should point a correct location.Now after the first  successful 
httpboot for ipv4 or ipv6,the HttpInstance->NextMsgpoint the character after 
the last byte, it may be a bad buffer if we don't receive another HttpHeader, 
so if call a 2nd httpboot, the wrong NextMsg pointer will cause the httpboot 
fail, so we need to check this case in HttpBodyParserCallback function in the 
first http boot process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
Reviewed-by: Ye Ting 
Reviewed-by: Wu Jiaxin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19423 
6f19259b-4bc3-4df7-8a09-765794883524


Thanks,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 2:13 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
 Could you list the patch name or Git SHA value which fixed the 2nd 
HttpBootfail issue. On my side, the SVN version 24729 is not exist.

Thanks 
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 3:40 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hello,

  Revision 24729 of edk2 says 2nd HttpBoot fail issue has been fixed. 
So, I have taken the changes from the file NetworkPkg/HttpDxe/HttpImpl.c of the 
revsision 24729 and still the 2nd  HttpBoot fails. Please let me know if I have 
missed any.

P.S: The first http boot happens successfully though. (downloading a Shell.efi)

Thanks,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

2016-08-24 Thread Zhang, Lubo
Thanks  Naveen. I will check it first and any progress I will inform you.

Best Regards
Lubo

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 4:53 PM
To: Zhang, Lubo 
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Lubo,

Please find the following details that may help.

NetworkPkg:Fix a bug the 2nd httpboot fail issue.

Httpboot over Ipv4 or Ipv6 stack,for both Identity and chunked transfer 
mode,when the last data has been parsed by HttpLib, the HttpInstance->NextMsg 
pointer should point a correct location.Now after the first  successful 
httpboot for ipv4 or ipv6,the HttpInstance->NextMsgpoint the character after 
the last byte, it may be a bad buffer if we don't receive another HttpHeader, 
so if call a 2nd httpboot, the wrong NextMsg pointer will cause the httpboot 
fail, so we need to check this case in HttpBodyParserCallback function in the 
first http boot process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
Reviewed-by: Ye Ting 
Reviewed-by: Wu Jiaxin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19423 
6f19259b-4bc3-4df7-8a09-765794883524


Thanks,
Naveen

-Original Message-
From: Zhang, Lubo [mailto:lubo.zh...@intel.com] 
Sent: Wednesday, August 24, 2016 2:13 PM
To: Santhapur Naveen
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hi Naveen
 Could you list the patch name or Git SHA value which fixed the 2nd 
HttpBootfail issue. On my side, the SVN version 24729 is not exist.

Thanks 
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 3:40 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hello,

  Revision 24729 of edk2 says 2nd HttpBoot fail issue has been fixed. 
So, I have taken the changes from the file NetworkPkg/HttpDxe/HttpImpl.c of the 
revsision 24729 and still the 2nd  HttpBoot fails. Please let me know if I have 
missed any.

P.S: The first http boot happens successfully though. (downloading a Shell.efi)

Thanks,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

2016-08-24 Thread Zhang, Lubo
Hi Naveen
 Could you list the patch name or Git SHA value which fixed the 2nd 
HttpBootfail issue. On my side, the SVN version 24729 is not exist.

Thanks 
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Santhapur Naveen
Sent: Wednesday, August 24, 2016 3:40 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] 2nd HttpBoot fails even after upgrading to revision 24729

Hello,

  Revision 24729 of edk2 says 2nd HttpBoot fail issue has been fixed. 
So, I have taken the changes from the file NetworkPkg/HttpDxe/HttpImpl.c of the 
revsision 24729 and still the 2nd  HttpBoot fails. Please let me know if I have 
missed any.

P.S: The first http boot happens successfully though. (downloading a Shell.efi)

Thanks,
Naveen
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg:Fix bug in function AsciiStrToIp4.

2016-08-19 Thread Zhang Lubo
If a FQDN contains 3 dots '.' like "a.b.c.com", the AsciiStrToIp4
will return success as the HostName has a valid IP address. So we
need to check if it is a decimal character before using AsciiStrDecimalToUintn.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Cc: Hegde Nagaraj P 
---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index ef19439..f4376e9 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -2724,10 +2724,13 @@ NetLibAsciiStrToIp4 (
 
   for (Index = 0; Index < 4; Index++) {
 TempStr = Ip4Str;
 
 while ((*Ip4Str != '\0') && (*Ip4Str != '.')) {
+  if (!NET_IS_DIGIT(*Ip4Str)) {
+return EFI_INVALID_PARAMETER;
+  }
   Ip4Str++;
 }
 
 //
 // The IPv4 address is X.X.X.X
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch] MdeModulePkg: Refine codes of iSCSI driver

2016-08-11 Thread Zhang, Lubo
Hi Eric
Do you have any comments for this patch.

Best regards
Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang 
Lubo
Sent: Thursday, August 11, 2016 10:28 AM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Dong, Eric 

Subject: [edk2] [patch] MdeModulePkg: Refine codes of iSCSI driver

The RSDT is only used when the bios need to support ACPI 1.0 version. When 
change PcdAcpiExposedTableVersions to 0x3C, it will not support ACPI 1.0. The 
default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 .../Universal/Network/IScsiDxe/IScsiIbft.c | 35 --
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c 
b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
index e5f685f..45d89a6 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
@@ -434,42 +434,42 @@ IScsiPublishIbft (
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   UINTN HandleCount;
   EFI_HANDLE*HandleBuffer;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
+
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID 
**)&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
 
   //
   // Find ACPI table RSD_PTR from system table
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID 
+ **) &Rsdp);  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, 
+ (VOID **) &Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;  
+ } else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
 
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey @@ -504,11 +504,16 @@ 
IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);  } 
+ else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);  }
+
   IScsiInitControlSection (Table, HandleCount);
   IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]);
   IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch] NetworkPkg: Refine codes of iSCSI driver

2016-08-11 Thread Zhang, Lubo
Ok, I will update the log.

Thanks
Lubo 

-Original Message-
From: Ye, Ting 
Sent: Thursday, August 11, 2016 3:11 PM
To: Zhang, Lubo ; Dong, Eric 
Cc: Fu, Siyuan ; edk2-devel@lists.01.org
Subject: RE: [patch] NetworkPkg: Refine codes of iSCSI driver

So how about adding your below sentences to the log message when you check in? 
I think it is more clear why we introduce the change to iSCSI. 
Others are good to me.

Reviewed-by: Ye Ting  

-Original Message-
From: Zhang, Lubo
Sent: Thursday, August 11, 2016 3:01 PM
To: Ye, Ting ; Dong, Eric 
Cc: Fu, Siyuan ; edk2-devel@lists.01.org
Subject: RE: [patch] NetworkPkg: Refine codes of iSCSI driver

  From my understanding, the default PcdAcpiExposedTableVersions is 0x3E, 
it can support ACPI table above version 1.0.but when changing the PCD to 0x3C, 
table 1.0 will not be installed and supported . However  the original code 
   Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress 
..
   IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
   always assume the Rsdt is not NULL which is used for table 1.0. So we 
should distinguish which table version we find. If table version above 1.0, we 
use the Rsdp->XsdtAddress instead of Rsdp->RsdtAddress.


Best Regards
Lubo 

-Original Message-
From: Ye, Ting
Sent: Thursday, August 11, 2016 2:14 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Dong, Eric ; Fu, Siyuan 
Subject: RE: [patch] NetworkPkg: Refine codes of iSCSI driver

Hi Lubo,

Could you please describe the changes introduced by this patch in your log 
message?

Thanks,
Ting

-Original Message-
From: Zhang, Lubo
Sent: Thursday, August 11, 2016 10:27 AM
To: edk2-devel@lists.01.org
Cc: Dong, Eric ; Ye, Ting ; Fu, Siyuan 

Subject: [patch] NetworkPkg: Refine codes of iSCSI driver

The RSDT is only used when the bios need to support ACPI 1.0 version. When 
change PcdAcpiExposedTableVersions to 0x3C, it will not support ACPI 1.0. The 
default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiIbft.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c 
index 3c179bf..27d098d 100644
--- a/NetworkPkg/IScsiDxe/IScsiIbft.c
+++ b/NetworkPkg/IScsiDxe/IScsiIbft.c
@@ -454,42 +454,42 @@ IScsiPublishIbft (
   EFI_STATUSStatus;
   EFI_ACPI_TABLE_PROTOCOL   *AcpiTableProtocol;
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
 
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) 
&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
   //
   // Find ACPI table RSD_PTR from the system table.
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID
+ **) &Rsdp);  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, 
+ (VOID **) &Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; } 
+ else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
+
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
   );
@@ -518,11 +518,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of t

Re: [edk2] [patch] NetworkPkg: Refine codes of iSCSI driver

2016-08-11 Thread Zhang, Lubo
  From my understanding, the default PcdAcpiExposedTableVersions is 0x3E, 
it can support ACPI table above version 1.0.but when changing the PCD to 0x3C, 
table 1.0 will not be installed and supported . However  the original code 
   Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress 
..
   IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
   always assume the Rsdt is not NULL which is used for table 1.0. So we 
should distinguish which table version we find. If table version above 1.0, we 
use the Rsdp->XsdtAddress instead of Rsdp->RsdtAddress.


Best Regards
Lubo 

-Original Message-
From: Ye, Ting 
Sent: Thursday, August 11, 2016 2:14 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Dong, Eric ; Fu, Siyuan 
Subject: RE: [patch] NetworkPkg: Refine codes of iSCSI driver

Hi Lubo,

Could you please describe the changes introduced by this patch in your log 
message?

Thanks,
Ting

-Original Message-
From: Zhang, Lubo
Sent: Thursday, August 11, 2016 10:27 AM
To: edk2-devel@lists.01.org
Cc: Dong, Eric ; Ye, Ting ; Fu, Siyuan 

Subject: [patch] NetworkPkg: Refine codes of iSCSI driver

The RSDT is only used when the bios need to support ACPI 1.0 version. When 
change PcdAcpiExposedTableVersions to 0x3C, it will not support ACPI 1.0. The 
default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiIbft.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c 
index 3c179bf..27d098d 100644
--- a/NetworkPkg/IScsiDxe/IScsiIbft.c
+++ b/NetworkPkg/IScsiDxe/IScsiIbft.c
@@ -454,42 +454,42 @@ IScsiPublishIbft (
   EFI_STATUSStatus;
   EFI_ACPI_TABLE_PROTOCOL   *AcpiTableProtocol;
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
 
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) 
&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
   //
   // Find ACPI table RSD_PTR from the system table.
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID
+ **) &Rsdp);  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, 
+ (VOID **) &Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; } 
+ else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
+
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
   );
@@ -518,11 +518,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);  } 
+ else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);  }
+
   IScsiInitControlSection (Table);
   IScsiFillInitiatorSection (Table, &Heap);
   IScsiFillNICAndTargetSections (Table, &Heap);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg: Refine codes of iSCSI driver

2016-08-10 Thread Zhang Lubo
The RSDT is only used when the bios need to support ACPI 1.0
version. When change PcdAcpiExposedTableVersions to 0x3C, it
will not support ACPI 1.0. The default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 .../Universal/Network/IScsiDxe/IScsiIbft.c | 35 --
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c 
b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
index e5f685f..45d89a6 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
@@ -434,42 +434,42 @@ IScsiPublishIbft (
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   UINTN HandleCount;
   EFI_HANDLE*HandleBuffer;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
+
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID 
**)&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
 
   //
   // Find ACPI table RSD_PTR from system table
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) 
&Rsdp);
+  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) 
&Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
+  } else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
 
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
@@ -504,11 +504,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);
+  } else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  }
+
   IScsiInitControlSection (Table, HandleCount);
   IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]);
   IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Refine codes of iSCSI driver

2016-08-10 Thread Zhang Lubo
The RSDT is only used when the bios need to support ACPI 1.0
version. When change PcdAcpiExposedTableVersions to 0x3C, it
will not support ACPI 1.0. The default is 0x3E.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
---
 NetworkPkg/IScsiDxe/IScsiIbft.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiIbft.c b/NetworkPkg/IScsiDxe/IScsiIbft.c
index 3c179bf..27d098d 100644
--- a/NetworkPkg/IScsiDxe/IScsiIbft.c
+++ b/NetworkPkg/IScsiDxe/IScsiIbft.c
@@ -454,42 +454,42 @@ IScsiPublishIbft (
   EFI_STATUSStatus;
   EFI_ACPI_TABLE_PROTOCOL   *AcpiTableProtocol;
   EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
   EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
   EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
   UINT8 *Heap;
   UINT8 Checksum;
-  UINTN Index;
 
+  Rsdt = NULL;
+  Xsdt = NULL;
 
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) 
&AcpiTableProtocol);
   if (EFI_ERROR (Status)) {
 return ;
   }
 
   //
   // Find ACPI table RSD_PTR from the system table.
   //
-  for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) {
-if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi20TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpi10TableGuid) ||
-  CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), 
&gEfiAcpiTableGuid)
-  ) {
-  //
-  // A match was found.
-  //
-  Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) 
gST->ConfigurationTable[Index].VendorTable;
-  break;
-}
+  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) 
&Rsdp);
+  if (EFI_ERROR (Status)) {
+Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) 
&Rsdp);
   }
 
-  if (Rsdp == NULL) {
+  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
 return ;
-  } else {
+  } else if (Rsdp->Revision >= 
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 
0) {
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
+  } else if (Rsdp->RsdtAddress != 0) {
 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
   }
 
+  if ((Xsdt == NULL) && (Rsdt == NULL)) {
+return ;
+  }
+
   if (mIbftInstalled) {
 Status = AcpiTableProtocol->UninstallAcpiTable (
   AcpiTableProtocol,
   mTableKey
   );
@@ -518,11 +518,16 @@ IScsiPublishIbft (
   Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
 
   //
   // Fill in the various section of the iSCSI Boot Firmware Table.
   //
-  IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) 
{
+IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);
+  } else {
+IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
+  }
+
   IScsiInitControlSection (Table);
   IScsiFillInitiatorSection (Table, &Heap);
   IScsiFillNICAndTargetSections (Table, &Heap);
 
   Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] NetworkPkg: Fix assert issue in iSCSI driver

2016-08-01 Thread Zhang Lubo
The bug is caused by using already freed memory.
If there is already an attempt and execute
'reconnect -r' command, all the AttemptConfig structure
will be freed, but the mCallbackInfo->Current is not
configured as null and this pointer will be used again in
IScsiFormExtractConfig.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiMisc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index deebf5d..a39c268 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -898,10 +898,12 @@ IScsiCleanDriverData (
 
 EXIT:
 
   gBS->CloseEvent (Private->ExitBootServiceEvent);
 
+  mCallbackInfo->Current = NULL;
+
   FreePool (Private);
   return Status;
 }
 
 /**
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] Fix IPv6 HTTPClient vendor class data

2016-07-21 Thread Zhang, Lubo
If no other comments, I will ask jiaxin to help you check in your patch.

Reviewed-by: Zhang Lubo 

Thanks
Lubo
> -Original Message-
> From: Michael Chang [mailto:mch...@suse.com]
> Sent: Thursday, July 21, 2016 4:20 PM
> To: Zhang, Lubo 
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH] Fix IPv6 HTTPClient vendor class data
> 
> On Thu, Jul 21, 2016 at 02:40:35AM +, Zhang, Lubo wrote:
> > Yes,  the wrong length definition of the ClassIdentifier lead to a wrong
> location CopyMem for system architecture when we build the vendor class
> option. Thanks for your correction.
> >  Do you have access to check in the code?
> 
> No. I don't. I also do not know other alternatives like sending pull request 
> to
> the git repo instead of sending patch to the list. I am absoutely fine to 
> follow
> any instrctions here to get the fix committed, just tell me (could via the
> private mails or so) for any other procedures I should take.
> 
> >
> > Best Regards
> > Lubo
> >
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Michael Chang
> > Sent: Thursday, July 21, 2016 9:59 AM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] [PATCH] Fix IPv6 HTTPClient vendor class data
> >
> > The size of the ClassIdentifier is apparently wrong in the structure. In my
> testing it caused the vendor class data to be displayed as bogus
> "HTTPClient:Arch00016x:UNDI00300". After correcting the size the vendor
> class data is "HTTPClient:Arch00016:UNDI003000" which looks good to me.
> 
> Gary reminded me missed out the necessary tags contributing the patch to
> the project so here it is. :)
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Chang 
> 
> >
> > ---
> >  NetworkPkg/HttpBootDxe/HttpBootDhcp6.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
> > b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
> > index f9eec9d..14d6db0 100644
> > --- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
> > +++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
> > @@ -50,7 +50,7 @@ typedef struct {
> >  } HTTP_BOOT_DHCP6_OPTION_ARCH;
> >
> >  typedef struct {
> > -  UINT8 ClassIdentifier[10];
> > +  UINT8 ClassIdentifier[11];
> >UINT8 ArchitecturePrefix[5];
> >UINT8 ArchitectureType[5];
> >UINT8 Lit3[1];
> > --
> > 2.6.6
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] Fix IPv6 HTTPClient vendor class data

2016-07-20 Thread Zhang, Lubo
Yes,  the wrong length definition of the ClassIdentifier lead to a wrong 
location CopyMem for system architecture when we build the vendor class option. 
Thanks for your correction.
 Do you have access to check in the code?

Best Regards
Lubo

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Michael 
Chang
Sent: Thursday, July 21, 2016 9:59 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH] Fix IPv6 HTTPClient vendor class data

The size of the ClassIdentifier is apparently wrong in the structure. In my 
testing it caused the vendor class data to be displayed as bogus 
"HTTPClient:Arch00016x:UNDI00300". After correcting the size the vendor class 
data is "HTTPClient:Arch00016:UNDI003000" which looks good to me.

---
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h 
b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
index f9eec9d..14d6db0 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
@@ -50,7 +50,7 @@ typedef struct {
 } HTTP_BOOT_DHCP6_OPTION_ARCH;
 
 typedef struct {
-  UINT8 ClassIdentifier[10];
+  UINT8 ClassIdentifier[11];
   UINT8 ArchitecturePrefix[5];
   UINT8 ArchitectureType[5];
   UINT8 Lit3[1];
--
2.6.6

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] ShellPkg: Fix issue about Ifconfig6 -r command.

2016-07-13 Thread Zhang Lubo
Follow the Shell Spec, when the interface name is Specified,
we need to refresh the Ipv6 configuration.

Cc: Hegde Nagaraj P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 .../UefiShellNetwork2CommandsLib/Ifconfig6.c   | 30 +++---
 .../UefiShellNetwork2CommandsLib.uni   |  2 ++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
index 371b368..42c972e 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c
@@ -1055,58 +1055,80 @@ IfConfig6ShowInterfaceInfo (
 
 Entry = Entry->ForwardLink;
   }
 
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_BREAK), 
gShellNetwork2HiiHandle);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_NEWLINE), 
gShellNetwork2HiiHandle);
 
   return SHELL_SUCCESS;
 }
 
 /**
   The clean process of the IfConfig6 application.
 
   @param[in]   IfListThe pointer of IfList(interface list).
+  @param[in]   IfNameThe pointer of interface name.
 
   @retval SHELL_SUCCESS  The IfConfig6 clean processed successfully.
   @retval others The IfConfig6 clean process failed.
 
 **/
 SHELL_STATUS
 IfConfig6ClearInterfaceInfo (
-  IN LIST_ENTRY*IfList
+  IN LIST_ENTRY*IfList,
+  IN CHAR16*IfName
   )
 {
   EFI_STATUSStatus;
   SHELL_STATUS  ShellStatus;
   LIST_ENTRY*Entry;
   IFCONFIG6_INTERFACE_CB*IfCb;
   EFI_IP6_CONFIG_POLICY Policy;
 
-  Policy = Ip6ConfigPolicyAutomatic;
   Entry  = IfList->ForwardLink;
   Status = EFI_SUCCESS;
   ShellStatus = SHELL_SUCCESS;
 
   if (IsListEmpty (IfList)) {
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_IFCONFIG6_ERR_INVALID_INTERFACE), gShellNetwork2HiiHandle);
   }
 
   //
-  // Go through the interface list.
+  // Go through the interface list.If the interface name is specified, then
+  // need to refresh the configuration.
   //
   while (Entry != IfList) {
 
 IfCb = BASE_CR (Entry, IFCONFIG6_INTERFACE_CB, Link);
 
+if ((IfName != NULL) && (StrCmp (IfName, IfCb->IfInfo->Name) == 0)) {
+  Policy = Ip6ConfigPolicyManual;
+
+  Status = IfCb->IfCfg->SetData (
+  IfCb->IfCfg,
+  Ip6ConfigDataTypePolicy,
+  sizeof (EFI_IP6_CONFIG_POLICY),
+  &Policy
+  );
+  if (EFI_ERROR (Status)) {
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), 
gShellNetwork2HiiHandle, L"ifconfig6");
+ShellStatus = SHELL_ACCESS_DENIED;
+break;
+  }
+}
+
+Policy = Ip6ConfigPolicyAutomatic;
+
 Status = IfCb->IfCfg->SetData (
 IfCb->IfCfg,
 Ip6ConfigDataTypePolicy,
 sizeof (EFI_IP6_CONFIG_POLICY),
 &Policy
 );
 
 if (EFI_ERROR (Status)) {
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), 
gShellNetwork2HiiHandle, L"ifconfig6");
   ShellStatus = SHELL_ACCESS_DENIED;
   break;
 }
 
 Entry  = Entry->ForwardLink;
@@ -1614,11 +1636,11 @@ IfConfig6 (
   case IfConfig6OpList:
 ShellStatus = IfConfig6ShowInterfaceInfo (&Private->IfList);
 break;
 
   case IfConfig6OpClear:
-ShellStatus = IfConfig6ClearInterfaceInfo (&Private->IfList);
+ShellStatus = IfConfig6ClearInterfaceInfo (&Private->IfList, 
Private->IfName);
 break;
 
   case IfConfig6OpSet:
 ShellStatus = IfConfig6SetInterfaceInfo (&Private->IfList, 
Private->VarArg);
 break;
diff --git 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
index 40e0284..ef441e1 100644
--- 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
@@ -21,10 +21,12 @@
String definitions for UEFI Shell 2.0 network 2 commands
 **/
 
 #langdef   en-US "english"
 
+#string STR_GEN_ERR_AD #language en-US  "%H%s%N: Access 
denied.\r\n"
+
 #string STR_PING6_INVALID_IP   #language en-US  "%Ping6: Invalid 
IP6 address, %s\r\n"
 #string STR_PING6_INVALID_INPUT#language en-US  "%Ping6: Invalid 
input, please type 'Ping6 -?'for help\r\n"
 #string STR_PING6_INVALID_SEND_NUMBER  #language en-US  "%Ping6: Invalid 
send number, %s\r\n"
 #string STR_PING6_INVALID_BUFFER_SIZE 

[edk2] [patch] NetworkPkg: Fix Assert issue in iSCSI driver.

2016-07-08 Thread Zhang Lubo
The bug existed in replacing AsciiStrToUnicodeStr with AsciiStrToUnicodeStrS,
since MacString now is a pointer, the value sizeof(MacString)/sizeof 
(MacString[0])
is not correct here as the third parameter.

Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 8015e3d..3631e72 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -685,11 +685,11 @@ IScsiConvertIfrNvDataToAttemptConfigData (
   MacString = (CHAR16 *) AllocateZeroPool (ISCSI_MAX_MAC_STRING_LEN * sizeof 
(CHAR16));
   if (MacString == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
-  AsciiStrToUnicodeStrS (Attempt->MacString, MacString, sizeof (MacString) / 
sizeof (MacString[0]));
+  AsciiStrToUnicodeStrS (Attempt->MacString, MacString, 
ISCSI_MAX_MAC_STRING_LEN);
 
   UnicodeSPrint (
 mPrivate->PortString,
 (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
 L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s",
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] MdeModulePkg: Fix IPv4 stack potential disappeared issue

2016-07-05 Thread Zhang, Lubo
The patch is good to me, already tested.
Reviewed-by: Zhang Lubo 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jiaxin Wu
Sent: Thursday, June 30, 2016 3:59 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Zhang, Lubo ; Fu, 
Siyuan 
Subject: [edk2] [Patch] MdeModulePkg: Fix IPv4 stack potential disappeared issue

IP4_CONFIG2_INSTANCE->DataItem is used to save the configuration data to NV 
variable. When the policy is changed from static to DHCP, DnsServers info will 
be cleaned from DataItem first (See Ip4Config2SetPolicy), it's correct because 
DnsServers info should not be saved to NV variable.
But if there is any DnsServers info received from DHCP message, it will be 
reset to DataItem again (See Ip4Config2SetDnsServerWorker), which may cause the 
NV variable contain the DnsServers info while the policy is DHCP (See 
Ip4Config2WriteConfigData).
Then, while the platform is reset, the issue happened. Because 
Ip4Config2DataTypeDnsServer is set under DHCP policy, which is not allowed by 
UEFI Spec and error returned.

This patch is used to resolve this potential issue.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 12 +++-  
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h |  1 +
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c  |  4 
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 028c61d..f91a935 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -1058,11 +1058,10 @@ Ip4Config2GetIfInfo (
   IN IP4_CONFIG2_INSTANCE *Instance,
   IN OUT UINTN*DataSize,
   IN VOID *Data  OPTIONAL
   )
 {
-
   IP4_SERVICE*IpSb;
   UINTN  Length;
   IP4_CONFIG2_DATA_ITEM  *Item;
   EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
   IP4_ADDR   Address;
@@ -1177,10 +1176,11 @@ Ip4Config2SetPolicy (
 FreePool (DataItem->Data.Ptr);
   }
   DataItem->Data.Ptr = NULL;
   DataItem->DataSize = 0;
   DataItem->Status   = EFI_NOT_FOUND;
+  SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_VOLATILE);
   NetMapIterate (&DataItem->EventMap, Ip4Config2SignalEvent, NULL);
 } else {
   //
   // The policy is changed from dhcp to static. Stop the DHCPv4 process
   // and destroy the DHCPv4 child.
@@ -1457,14 +1457,24 @@ Ip4Config2SetDnsServer (
   IN IP4_CONFIG2_INSTANCE *Instance,
   IN UINTNDataSize,
   IN VOID *Data
   )
 {
+  IP4_CONFIG2_DATA_ITEM *Item;
+
+  Item = NULL;
+
   if (Instance->Policy != Ip4Config2PolicyStatic) {
 return EFI_WRITE_PROTECTED;
   }
 
+  Item = &Instance->DataItem[Ip4Config2DataTypeDnsServer];
+
+  if (DATA_ATTRIB_SET (Item->Attribute, DATA_ATTRIB_VOLATILE)) {
+REMOVE_DATA_ATTRIB (Item->Attribute, DATA_ATTRIB_VOLATILE);  }
+
   return Ip4Config2SetDnsServerWorker (Instance, DataSize, Data);  }
 
 /**
   Generate the operational state of the interface this IP4 config2 instance 
manages diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
index b2665bd..b6da11f 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
@@ -25,10 +25,11 @@
 #define DATA_ATTRIB_SIZE_FIXED  0x1
 #define DATA_ATTRIB_VOLATILE0x2
 
 #define DATA_ATTRIB_SET(Attrib, Bits)   (BOOLEAN)((Attrib) & (Bits))
 #define SET_DATA_ATTRIB(Attrib, Bits)   ((Attrib) |= (Bits))
+#define REMOVE_DATA_ATTRIB(Attrib, Bits)((Attrib) &= (~Bits))
 
 typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;
 
 #define IP4_CONFIG2_INSTANCE_FROM_PROTOCOL(Proto) \
   CR ((Proto), \
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index fcd3ccb..20bc21f 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -596,10 +596,14 @@ Ip4DriverBindingStart (
   DataItem->Data.Ptr
   );
   if (EFI_ERROR(Status)) {
 goto UNINSTALL_PROTOCOL;
   }
+  
+  if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == 
Ip4Config2PolicyDhcp)) {
+break;
+  }
 }
   }
  
   //
   // Ready to go: start the receiving and timer.
--
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
__

[edk2] [patch] ShellPkg: Update the error prompt for ping6 command.

2016-06-30 Thread Zhang Lubo
when we use the ping6 command without configuring the network
interface, it should give correct prompt to users.

Cc: Hegde Nagaraj P 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c   | 2 +-
 .../UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
index e4ae977..4496802 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
@@ -824,11 +824,11 @@ Ping6CreateIpInstance (
   //
   // No exact interface address matched.
   //
 
   if (HandleIndex == HandleNum) {
-ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_SOURCE_NOT_FOUND), 
gShellNetwork2HiiHandle, mIp6SrcString);
+ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PING6_CONFIGD_NIC_NF), 
gShellNetwork2HiiHandle);
 Status = EFI_NOT_FOUND;
 goto ON_ERROR;
   }
 
   Private->NicHandle = HandleBuffer[HandleIndex];
diff --git 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
index fb2bfab..40e0284 100644
--- 
a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
@@ -29,11 +29,11 @@
 #string STR_PING6_INVALID_BUFFER_SIZE  #language en-US  "%Ping6: Invalid 
buffer size, %s\r\n"
 #string STR_PING6_INVALID_SOURCE   #language en-US  "%Ping6: Require 
source interface option\r\n"
 #string STR_PING6_IP6_CONFIG   #language en-US  "%Ping6: The 
process of Ip6 Configure %r\r\n"
 #string STR_PING6_IP6CFG_GETDATA   #language en-US  "%Ping6: Get data 
of the interface information %r\r\n"
 #string STR_PING6_SEND_REQUEST #language en-US  "Echo request 
sequence %d fails.\r\n"
-#string STR_PING6_SOURCE_NOT_FOUND #language en-US  "Source %s not 
found.\r\n"
+#string STR_PING6_CONFIGD_NIC_NF   #language en-US  "%Ping6: No 
configured interfaces were found.\r\n"
 #string STR_PING6_NOSOURCE_INDOMAIN#language en-US  "No sources in 
%s's multicast domain.\r\n"
 #string STR_PING6_START#language en-US  "Ping %s %d data 
bytes\r\n"
 #string STR_PING6_TIMEOUT  #language en-US  "Echo request 
sequence %d timeout.\r\n"
 #string STR_PING6_REPLY_INFO   #language en-US  "%d bytes from %s 
: icmp_seq=%d ttl=%d time%c%dms\r\n"
 #string STR_PING6_STAT #language en-US  "\n%d packets 
transmitted, %d received, %d%% packet loss, time %dms\r\n"
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch 1/2] MdeModulePkg: Update PXE driver to follow edk2 coding standards.

2016-06-29 Thread Zhang, Lubo
Series Reviewed-by: Zhang Lubo 

-Original Message-
From: Fu, Siyuan 
Sent: Thursday, June 30, 2016 10:08 AM
To: edk2-devel@lists.01.org
Cc: Wu, Jiaxin ; Zhang, Lubo 
Subject: [Patch 1/2] MdeModulePkg: Update PXE driver to follow edk2 coding 
standards.

Cc: Wu Jiaxin 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
---
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 4 ++--  
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
index 79c9a67..a20fdb7 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
@@ -42,7 +42,7 @@ PxeBcCommonNotify (
   @param  SubnetMask Pointer to the subnetmask of the station ip address.
   @param  GatewayPointer to the gateway ip address.
   @param  SrcPortPointer to the srouce port of the station.
-  @param  TTLThe time to live field of the IP header. 
+  @param  TtlThe time to live field of the IP header. 
   @param  ToSThe type of service field of the IP header.
 
   @retval EFI_SUCCESS   The configuration settings were set, changed, 
or reset successfully.
@@ -68,7 +68,7 @@ PxeBcConfigureUdpWriteInstance (
   IN EFI_IPv4_ADDRESS   *SubnetMask,
   IN EFI_IPv4_ADDRESS   *Gateway,
   IN OUT UINT16 *SrcPort,
-  IN UINT8  TTL,
+  IN UINT8  Ttl,
   IN UINT8  ToS
   )
 {
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
index 1082b3a..16ac05e 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
@@ -38,7 +38,7 @@ PxeBcCommonNotify (
   @param  SubnetMask Pointer to the subnetmask of the station ip address.
   @param  GatewayPointer to the gateway ip address.
   @param  SrcPortPointer to the srouce port of the station.
-  @param  TTLThe time to live field of the IP header. 
+  @param  TtlThe time to live field of the IP header. 
   @param  ToSThe type of service field of the IP header.
 
   @retval EFI_SUCCESS   The configuration settings were set, changed, 
or reset successfully.
@@ -64,7 +64,7 @@ PxeBcConfigureUdpWriteInstance (
   IN EFI_IPv4_ADDRESS   *SubnetMask,
   IN EFI_IPv4_ADDRESS   *Gateway,
   IN OUT UINT16 *SrcPort,
-  IN UINT8  TTL,
+  IN UINT8  Ttl,
   IN UINT8  ToS
   );
 /**
--
2.7.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.

2016-06-21 Thread Zhang, Lubo
Okay, I will update the information. 
Thanks for your comment.

Best regards
Lubo


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Hegde, 
Nagaraj P
Sent: Tuesday, June 21, 2016 6:00 PM
To: Subramanian, Sriram (EG Servers Platform SW) ; Fu, Siyuan 
; Zhang, Lubo ; 
edk2-devel@lists.01.org
Cc: Ye, Ting ; Wu, Jiaxin ; Gao, Liming 

Subject: Re: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 and 
Dhcpv6 configuration.

Hi Lubo,

I see this patch is not committed yet. Can you please add the following #define 
into IndustryStandard/Dhcp.h during your commit?

#define DHCP4_TAG_USER_CLASS_ID  77   /// User class identifier

Also, I think it would be good to rename the following #define

#define DHCP4_TAG_CLASS_ID   60   /// Vendor class identifier

to

#define DHCP4_TAG_VENDOR_CLASS_ID60   /// Vendor class identifier

Regards,
Nagaraj.

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
Subramanian, Sriram (EG Servers Platform SW)
Sent: Friday, June 17, 2016 1:14 PM
To: Fu, Siyuan ; Zhang, Lubo ; 
edk2-devel@lists.01.org
Cc: Ye, Ting ; Wu, Jiaxin ; Gao, Liming 

Subject: Re: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 and 
Dhcpv6 configuration.

Sounds good!

-Original Message-
From: Fu, Siyuan [mailto:siyuan...@intel.com]
Sent: Friday, June 17, 2016 1:09 PM
To: Subramanian, Sriram (EG Servers Platform SW) 
mailto:srira...@hpe.com>>; Zhang, Lubo 
mailto:lubo.zh...@intel.com>>; 
edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Cc: Ye, Ting mailto:ting...@intel.com>>; Wu, Jiaxin 
mailto:jiaxin...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>
Subject: RE: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 and 
Dhcpv6 configuration.

Sriram,

I vote for adding them to the IndustryStandard header, but I think we'd better 
to also keep the existing macros in PxeBaseCode.h. So we won't need to update 
all the C files to include the new header file.

Best Regards
Siyuan

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Subramanian, Sriram (EG Servers Platform SW)
> Sent: Friday, June 17, 2016 3:29 PM
> To: Zhang, Lubo mailto:lubo.zh...@intel.com>>; 
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Ye, Ting mailto:ting...@intel.com>>; Fu, Siyuan 
> mailto:siyuan...@intel.com>>;
> Wu, Jiaxin mailto:jiaxin...@intel.com>>; Gao, 
> Liming mailto:liming@intel.com>>
> Subject: Re: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 
> and
> Dhcpv6 configuration.
>
> OK, in that case how about move those macros from 
> MdePkg/Include/Protocol/PxeBaseCode.h to this 
> MdePkg/Include/IndustryStandard/? Because these are defined in RFCs 
> and assignments controlled by IANA, so more wider scope and not 
> specific to the UEFI protocols.
>
> What do you think Ting/Siyuan?
>
> Thanks,
> Sriram.
>
> -Original Message-
> From: Zhang, Lubo [mailto:lubo.zh...@intel.com]
> Sent: Friday, June 17, 2016 12:43 PM
> To: Subramanian, Sriram (EG Servers Platform SW) 
> mailto:srira...@hpe.com>>;
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Ye, Ting mailto:ting...@intel.com>>; Fu, Siyuan 
> mailto:siyuan...@intel.com>>;
> Wu, Jiaxin mailto:jiaxin...@intel.com>>; Gao, 
> Liming mailto:liming@intel.com>>
> Subject: RE: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 
> and
> Dhcpv6 configuration.
>
> Hi Sriram
>
>  I intend to add more arch for PXE boot ones according to your 
> comments, but I find in Pxe driver, the macro 
> EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE is already defined in PxeBaseCode.h 
> under mdepkg\include\protocol, so I think it is on need to redefine these 
> arch,  how do you think.
>
>
> thanks
> lubo
>
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Subramanian, Sriram (EG Servers Platform SW)
> Sent: Friday, June 17, 2016 11:57 AM
> To: Zhang, Lubo mailto:lubo.zh...@intel.com>>; 
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Ye, Ting mailto:ting...@intel.com>>; Fu, Siyuan 
> mailto:siyuan...@intel.com>>;
> Wu, Jiaxin mailto:jiaxin...@intel.com>>; Gao, 
> Liming mailto:liming@intel.com>>
> Subject: Re: [edk2] [patch 3/3] MdePkg: Refine codes related to Dhcpv4 
> and
> Dhcpv6 configuration.
>
> Hi Lubo,
>
> For these:
> +/// Processor Architecture Types
> +/// These identifiers are defined by IETF:
> +///
> +http://www.ietf.org/assignments/dhcpv6-parameters/dhcpv6-
> parameters.xml
> +///

Re: [edk2] [PATCH v2] NetworkPkg: Replace ASSERT with error handling in DnsDxe

2016-06-20 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

-Original Message-
From: Wu, Jiaxin 
Sent: Monday, June 20, 2016 9:46 AM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Zhang, Lubo 

Subject: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in DnsDxe

v2:
*Use goto to simplify code logic.

This patch is used to replace ASSERT with error handling in DnsDxe driver.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/DnsDxe/DnsProtocol.c | 56 -
 1 file changed, 38 insertions(+), 18 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsProtocol.c b/NetworkPkg/DnsDxe/DnsProtocol.c 
index e9101d6..64fca6a 100644
--- a/NetworkPkg/DnsDxe/DnsProtocol.c
+++ b/NetworkPkg/DnsDxe/DnsProtocol.c
@@ -86,23 +86,22 @@ Dns4GetModeData (
 
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
 
   Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This);
   if (Instance->State == DNS_STATE_UNCONFIGED) {
-gBS->RestoreTPL (OldTpl);
-return  EFI_NOT_STARTED;
+Status = EFI_NOT_STARTED;
+goto ON_EXIT;
   }
   
   ZeroMem (DnsModeData, sizeof (EFI_DNS4_MODE_DATA));
 
   //
   // Get the current configuration data of this instance. 
   //
   Status = Dns4CopyConfigure (&DnsModeData->DnsConfigData, 
&Instance->Dns4CfgData);
   if (EFI_ERROR (Status)) {
-gBS->RestoreTPL (OldTpl);
-return Status;
+goto ON_EXIT;
   }
 
   //
   // Get the DnsServerCount and DnsServerList
   //
@@ -110,11 +109,16 @@ Dns4GetModeData (
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) {
 Index++;
   }
   DnsModeData->DnsServerCount = (UINT32) Index;
   ServerList = AllocatePool (sizeof (EFI_IPv4_ADDRESS) * 
DnsModeData->DnsServerCount);
-  ASSERT (ServerList != NULL);
+  if (ServerList == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+Dns4CleanConfigure (&DnsModeData->DnsConfigData);
+goto ON_EXIT;
+  }
+  
   Index = 0;
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) {
 ServerItem = NET_LIST_USER_STRUCT (Entry, DNS4_SERVER_IP, AllServerLink);
 CopyMem (ServerList + Index, &ServerItem->Dns4ServerIp, sizeof 
(EFI_IPv4_ADDRESS));
 Index++;
@@ -128,22 +132,28 @@ Dns4GetModeData (
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
 Index++;
   }
   DnsModeData->DnsCacheCount = (UINT32) Index;
   CacheList = AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY) * 
DnsModeData->DnsCacheCount);
-  ASSERT (CacheList != NULL);
+  if (CacheList == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+Dns4CleanConfigure (&DnsModeData->DnsConfigData);
+FreePool (ServerList);
+goto ON_EXIT;
+  }
+  
   Index =0;
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {
 CacheItem = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);
 CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof 
(EFI_DNS4_CACHE_ENTRY));
 Index++;
   }
   DnsModeData->DnsCacheList = CacheList;
 
+ON_EXIT:
   gBS->RestoreTPL (OldTpl);
-
-  return EFI_SUCCESS;
+  return Status;
 }
 
 /**
   Configure this DNS instance.
 
@@ -907,23 +917,22 @@ Dns6GetModeData (
 
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
 
   Instance  = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This);
   if (Instance->State == DNS_STATE_UNCONFIGED) {
-gBS->RestoreTPL (OldTpl);
-return  EFI_NOT_STARTED;
+Status =  EFI_NOT_STARTED;
+goto ON_EXIT;
   }
 
   ZeroMem (DnsModeData, sizeof (EFI_DNS6_MODE_DATA));
 
   //
   // Get the current configuration data of this instance. 
   //
-  Status = Dns6CopyConfigure(&DnsModeData->DnsConfigData, 
&Instance->Dns6CfgData);
+  Status = Dns6CopyConfigure (&DnsModeData->DnsConfigData, 
+ &Instance->Dns6CfgData);
   if (EFI_ERROR (Status)) {
-gBS->RestoreTPL (OldTpl);
-return Status;
+goto ON_EXIT;
   }
   
   //
   // Get the DnsServerCount and DnsServerList
   //
@@ -931,11 +940,16 @@ Dns6GetModeData (
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) {
 Index++;
   }
   DnsModeData->DnsServerCount = (UINT32) Index;
   ServerList = AllocatePool (sizeof(EFI_IPv6_ADDRESS) * 
DnsModeData->DnsServerCount);
-  ASSERT (ServerList != NULL);
+  if (ServerList == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+Dns6CleanConfigure (&DnsModeData->DnsConfigData);
+goto ON_EXIT;
+  }
+  
   Index = 0;
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) {
 ServerItem = NET_LIST_USER_STRUCT (Entry, DNS6_SERVER_IP, AllServerLink);
 CopyMem (ServerList + Index, &ServerItem->Dns6ServerIp, sizeof 
(EFI_IPv6_ADDRESS));
 Index++;
@@ -949,22 +963,28 @@ Dns6GetModeData (
   NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {
 Index++;
   }
   DnsModeData->DnsCache

Re: [edk2] [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http boot and IScsi

2016-06-20 Thread Zhang, Lubo
Got it ,  I will update it when to check in.

Thanks
lubo

-Original Message-
From: Ye, Ting 
Sent: Tuesday, June 21, 2016 9:29 AM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Wu, Jiaxin 
Subject: RE: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http 
boot and IScsi

In my opinion, when AttemptConfigData->AttemptTitleHelpToken equals to 0, the 
system is running out of resources. So we 'd better to return the error now 
instead of continue processing.

Best Regards,
Ye Ting

-Original Message-
From: Zhang, Lubo 
Sent: Monday, June 20, 2016 5:57 PM
To: Ye, Ting ; edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Wu, Jiaxin 
Subject: RE: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http 
boot and IScsi

Do you mean that if we already find an attempt from the Variable and configure 
some parameters, but finally get string Id AttemptTitleHelpToken failed. If we 
continue, this attempt will not be added to global link list which will be used 
frequently and lead to a wrong code  logic later, so we should return error 
status.

Thanks 
lubo

-Original Message-
From: Ye, Ting 
Sent: Monday, June 20, 2016 5:01 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Wu, Jiaxin 
Subject: RE: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http 
boot and IScsi

Hi Lubo,

I recommend to return EFI_OUT_OF_RESOURCES instead of continue to process the 
attempts in below codes. What do  you think?

EFI_STATUS
 IScsiGetConfigData (
   IN ISCSI_DRIVER_DATA  *Private
@@ -1290,11 +1291,13 @@ IScsiGetConfigData (
  
mCallbackInfo->RegisteredHandle,
  0,
  mPrivate->PortString,
  NULL
  );
-ASSERT (AttemptConfigData->AttemptTitleHelpToken != 0);
+if (AttemptConfigData->AttemptTitleHelpToken == 0) {
+  continue;
+}

Best Regards,
Ye Ting

-Original Message-----
From: Zhang, Lubo 
Sent: Monday, June 20, 2016 1:57 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http boot 
and IScsi

v2:
*Fix some memory leak issue.

This patch is used to replace ASSERT with error handling in Http boot Driver 
and IScsi driver.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/HttpBootDxe/HttpBootConfig.c |  5 +++--  
NetworkPkg/HttpBootDxe/HttpBootDhcp6.c  |  5 -
 NetworkPkg/IScsiDxe/IScsiConfig.c   |  8 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c   |  1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c |  5 -
 NetworkPkg/IScsiDxe/IScsiProto.c| 17 +
 6 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c 
b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
index 04c2f3e..3708995 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
@@ -271,11 +271,13 @@ HttpBootFormExtractConfig (
 // followed by "&OFFSET=0&WIDTH=" followed by a 
Null-terminator
 //
 ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, 
mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 ConfigRequest = AllocateZeroPool (Size);
-ASSERT (ConfigRequest != NULL);
+if (ConfigRequest == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 AllocatedRequest = TRUE;
 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
ConfigRequestHdr, (UINT64)BufferSize);
 FreePool (ConfigRequestHdr);
   }
 
@@ -462,11 +464,10 @@ HttpBootFormCallback (
   case KEY_INITIATOR_URI:
 //
 // Get user input URI string
 //
 Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
-ASSERT (Uri != NULL);
 if (Uri == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c 
b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
index 0157095..9ea421d 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
@@ -399,10 +399,11 @@ HttpBootCacheDhcp6Offer (
 
   @retval EFI_SUCCESS   Told the EFI DHCPv6 Protocol driver to 
continue the DHCP process.
   @retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI 
DHCPv6 Protocol
 driver will continue to wait for more packets.
   @retval EFI_ABORTED   Told the EFI DHCPv6 Protocol driver to abort 
the current process.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources.
 
 **/
 EFI_STATUS
 EFIAPI
 HttpBootDhcp6CallBack (
@@ -4

Re: [edk2] [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http boot and IScsi

2016-06-20 Thread Zhang, Lubo
Do you mean that if we already find an attempt from the Variable and configure 
some parameters, but finally get string Id AttemptTitleHelpToken failed. If we 
continue, this attempt will not be added to global link list which will be used 
frequently and lead to a wrong code  logic later, so we should return error 
status.

Thanks 
lubo

-Original Message-
From: Ye, Ting 
Sent: Monday, June 20, 2016 5:01 PM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Fu, Siyuan ; Wu, Jiaxin 
Subject: RE: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http 
boot and IScsi

Hi Lubo,

I recommend to return EFI_OUT_OF_RESOURCES instead of continue to process the 
attempts in below codes. What do  you think?

EFI_STATUS
 IScsiGetConfigData (
   IN ISCSI_DRIVER_DATA  *Private
@@ -1290,11 +1291,13 @@ IScsiGetConfigData (
  
mCallbackInfo->RegisteredHandle,
  0,
  mPrivate->PortString,
  NULL
  );
-ASSERT (AttemptConfigData->AttemptTitleHelpToken != 0);
+if (AttemptConfigData->AttemptTitleHelpToken == 0) {
+  continue;
+}

Best Regards,
Ye Ting

-Original Message-
From: Zhang, Lubo 
Sent: Monday, June 20, 2016 1:57 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http boot 
and IScsi

v2:
*Fix some memory leak issue.

This patch is used to replace ASSERT with error handling in Http boot Driver 
and IScsi driver.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/HttpBootDxe/HttpBootConfig.c |  5 +++--  
NetworkPkg/HttpBootDxe/HttpBootDhcp6.c  |  5 -
 NetworkPkg/IScsiDxe/IScsiConfig.c   |  8 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c   |  1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c |  5 -
 NetworkPkg/IScsiDxe/IScsiProto.c| 17 +
 6 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c 
b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
index 04c2f3e..3708995 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
@@ -271,11 +271,13 @@ HttpBootFormExtractConfig (
 // followed by "&OFFSET=0&WIDTH=" followed by a 
Null-terminator
 //
 ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, 
mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 ConfigRequest = AllocateZeroPool (Size);
-ASSERT (ConfigRequest != NULL);
+if (ConfigRequest == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 AllocatedRequest = TRUE;
 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
ConfigRequestHdr, (UINT64)BufferSize);
 FreePool (ConfigRequestHdr);
   }
 
@@ -462,11 +464,10 @@ HttpBootFormCallback (
   case KEY_INITIATOR_URI:
 //
 // Get user input URI string
 //
 Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
-ASSERT (Uri != NULL);
 if (Uri == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c 
b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
index 0157095..9ea421d 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
@@ -399,10 +399,11 @@ HttpBootCacheDhcp6Offer (
 
   @retval EFI_SUCCESS   Told the EFI DHCPv6 Protocol driver to 
continue the DHCP process.
   @retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI 
DHCPv6 Protocol
 driver will continue to wait for more packets.
   @retval EFI_ABORTED   Told the EFI DHCPv6 Protocol driver to abort 
the current process.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources.
 
 **/
 EFI_STATUS
 EFIAPI
 HttpBootDhcp6CallBack (
@@ -449,11 +450,13 @@ HttpBootDhcp6CallBack (
Status = EFI_ABORTED;
  } else {
ASSERT (NewPacket != NULL);
SelectAd   = &Private->OfferBuffer[Private->SelectIndex - 
1].Dhcp6.Packet.Offer;
*NewPacket = AllocateZeroPool (SelectAd->Size);
-   ASSERT (*NewPacket != NULL);
+   if (*NewPacket == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+   }
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
  }
  break;
  
default:
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 69a4003..8f06a07 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1,9 +1,9 @@
 /** @file
   Helper functions for configuring or getting the param

[edk2] [PATCH v2 2/2] NetworkPkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.

2016-06-20 Thread Zhang Lubo
v2:
*Since we have redefined the name of arch types in Dhcp.h for http boot,
it need to change corresponding codes.

Add a new head file Dhcp.h in Mde/Include/IndustryStandard, normalize the
universal option numbers and other network number tags.

Cc: Sriram Subramanian 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h| 128 +
 NetworkPkg/HttpBootDxe/HttpBootDhcp4.c |  82 ++---
 NetworkPkg/HttpBootDxe/HttpBootDhcp4.h |  51 ++---
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.c |  30 
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.h |  27 +--
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |   1 +
 NetworkPkg/IScsiDxe/IScsiDhcp.c|  10 +--
 NetworkPkg/IScsiDxe/IScsiDhcp.h|   9 +--
 NetworkPkg/IScsiDxe/IScsiDhcp6.c   |   8 +--
 NetworkPkg/IScsiDxe/IScsiDhcp6.h   |  11 +--
 NetworkPkg/IScsiDxe/IScsiImpl.h|   4 +-
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c  |   6 +-
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h  |   2 -
 NetworkPkg/Ip6Dxe/Ip6Impl.h|   4 +-
 NetworkPkg/Ip6Dxe/Ip6Nd.c  |   4 +-
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c   |  98 -
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h   |  42 +--
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c   |  28 
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h   |  25 +--
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h|   3 +-
 20 files changed, 155 insertions(+), 418 deletions(-)

diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
index e3e7553..86ef8af 100644
--- a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
@@ -1,9 +1,9 @@
 /** @file
   Dhcp6 internal data structure and definition declaration.
 
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -17,10 +17,12 @@
 #define __EFI_DHCP6_IMPL_H__
 
 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
 #include 
 #include 
@@ -48,70 +50,10 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
 #include "Dhcp6Driver.h"
 
 #define DHCP6_SERVICE_SIGNATURE   SIGNATURE_32 ('D', 'H', '6', 'S')
 #define DHCP6_INSTANCE_SIGNATURE  SIGNATURE_32 ('D', 'H', '6', 'I')
 
-//
-// Transmit parameters of solicit message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_SOL_MAX_DELAY   1
-#define DHCP6_SOL_IRT 1
-#define DHCP6_SOL_MRC 0
-#define DHCP6_SOL_MRT 120
-#define DHCP6_SOL_MRD 0
-//
-// Transmit parameters of request message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_REQ_IRT 1
-#define DHCP6_REQ_MRC 10
-#define DHCP6_REQ_MRT 30
-#define DHCP6_REQ_MRD 0
-//
-// Transmit parameters of confirm message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_CNF_MAX_DELAY   1
-#define DHCP6_CNF_IRT 1
-#define DHCP6_CNF_MRC 0
-#define DHCP6_CNF_MRT 4
-#define DHCP6_CNF_MRD 10
-//
-// Transmit parameters of renew message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_REN_IRT 10
-#define DHCP6_REN_MRC 0
-#define DHCP6_REN_MRT 600
-#define DHCP6_REN_MRD 0
-//
-// Transmit parameters of rebind message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_REB_IRT 10
-#define DHCP6_REB_MRC 0
-#define DHCP6_REB_MRT 600
-#define DHCP6_REB_MRD 0
-//
-// Transmit parameters of information request message, refers to section-5.5 
of rfc-3315.
-//
-#define DHCP6_INF_MAX_DELAY   1
-#define DHCP6_INF_IRT 1
-#define DHCP6_INF_MRC 0
-#define DHCP6_INF_MRT 120
-#define DHCP6_INF_MRD 0
-//
-// Transmit parameters of release message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_REL_IRT 1
-#define DHCP6_REL_MRC 5
-#define DHCP6_REL_MRT 0
-#define DHCP6_REL_MRD 0
-//
-// Transmit parameters of decline message, refers to section-5.5 of rfc-3315.
-//
-#define DHCP6_DEC_IRT 1
-#define DHCP6_DEC_MRC 5
-#define DHCP6_DEC_MRT 0
-#define DHCP6_DEC_MRD 0
-
 #define DHCP6_PACKET_ALL  0
 #define DHCP6_PACKET_STATEFUL 1
 #define DHCP6_PACKET_STATELESS2
 
 #define DHCP6_BASE_PACKET_SIZE1024
@@ -125,74 +67,10 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
 extern EFI_IPv6_ADDRESS   mAllDhcp

[edk2] [PATCH v2 1/2] MdePkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.

2016-06-19 Thread Zhang Lubo
v2:
*add some new arch types for PXE boot.
refine the definition of arch types for http boot

Add a new head file Dhcp.h in Mde/Include/IndustryStandard, normalize the
universal option numbers and other network number tags.

Cc: Sriram Subramanian 
Cc: Liming Gao 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 MdePkg/Include/IndustryStandard/Dhcp.h | 281 +
 1 file changed, 281 insertions(+)
 create mode 100644 MdePkg/Include/IndustryStandard/Dhcp.h

diff --git a/MdePkg/Include/IndustryStandard/Dhcp.h 
b/MdePkg/Include/IndustryStandard/Dhcp.h
new file mode 100644
index 000..f33f2e4
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Dhcp.h
@@ -0,0 +1,281 @@
+/** @file
+  This file contains the DHCPv4 and DHCPv6 option definitions and other 
configuration.
+  They are used to carry additional information and parameters in DHCP 
messages.
+
+  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#ifndef _DHCP_H_
+#define _DHCP_H_
+
+///
+/// Dynamic Host Configuration Protocol for IPv4 (DHCPv4)
+///
+/// Dhcpv4 Options, definitions from RFC 2132
+///
+#define DHCP4_TAG_PAD0/// Pad Option
+#define DHCP4_TAG_EOP255  /// End Option
+#define DHCP4_TAG_NETMASK1/// Subnet Mask
+#define DHCP4_TAG_TIME_OFFSET2/// Time Offset from UTC
+#define DHCP4_TAG_ROUTER 3/// Router option,
+#define DHCP4_TAG_TIME_SERVER4/// Time Server
+#define DHCP4_TAG_NAME_SERVER5/// Name Server
+#define DHCP4_TAG_DNS_SERVER 6/// Domain Name Server
+#define DHCP4_TAG_LOG_SERVER 7/// Log Server
+#define DHCP4_TAG_COOKIE_SERVER  8/// Cookie Server
+#define DHCP4_TAG_LPR_SERVER 9/// LPR Print Server
+#define DHCP4_TAG_IMPRESS_SERVER 10   /// Impress Server
+#define DHCP4_TAG_RL_SERVER  11   /// Resource Location Server
+#define DHCP4_TAG_HOSTNAME   12   /// Host Name
+#define DHCP4_TAG_BOOTFILE_LEN   13   /// Boot File Size
+#define DHCP4_TAG_DUMP   14   /// Merit Dump File
+#define DHCP4_TAG_DOMAINNAME 15   /// Domain Name
+#define DHCP4_TAG_SWAP_SERVER16   /// Swap Server
+#define DHCP4_TAG_ROOTPATH   17   /// Root path
+#define DHCP4_TAG_EXTEND_PATH18   /// Extensions Path
+#define DHCP4_TAG_IPFORWARD  19   /// IP Forwarding Enable/Disable
+#define DHCP4_TAG_NONLOCAL_SRR   20   /// on-Local Source Routing 
Enable/Disable
+#define DHCP4_TAG_POLICY_SRR 21   /// Policy Filter
+#define DHCP4_TAG_EMTU   22   /// Maximum Datagram Reassembly Size
+#define DHCP4_TAG_TTL23   /// Default IP Time-to-live
+#define DHCP4_TAG_PATHMTU_AGE24   /// Path MTU Aging Timeout
+#define DHCP4_TAG_PATHMTU_PLATEAU25   /// Path MTU Plateau Table
+#define DHCP4_TAG_IFMTU  26   /// Interface MTU
+#define DHCP4_TAG_SUBNET_LOCAL   27   /// All Subnets are Local
+#define DHCP4_TAG_BROADCAST  28   /// Broadcast Address
+#define DHCP4_TAG_DISCOVER_MASK  29   /// Perform Mask Discovery
+#define DHCP4_TAG_SUPPLY_MASK30   /// Mask Supplier
+#define DHCP4_TAG_DISCOVER_ROUTE 31   /// Perform Router Discovery
+#define DHCP4_TAG_ROUTER_SOLICIT 32   /// Router Solicitation Address
+#define DHCP4_TAG_STATIC_ROUTE   33   /// Static Route
+#define DHCP4_TAG_TRAILER34   /// Trailer Encapsulation
+#define DHCP4_TAG_ARPAGE 35   /// ARP Cache Timeout
+#define DHCP4_TAG_ETHER_ENCAP36   /// Ethernet Encapsulation
+#define DHCP4_TAG_TCP_TTL37   /// TCP Default TTL
+#define DHCP4_TAG_KEEP_INTERVAL  38   /// TCP Keepalive Interval
+#define DHCP4_TAG_KEEP_GARBAGE   39   /// TCP Keepalive Garbage
+#define DHCP4_TAG_NIS_DOMAIN 40   /// Network Information Service 
Domain
+#define DHCP4_TAG_NIS_SERVER 41   /// Network Information Servers
+#define DHCP4_TAG_NTP_SERVER 42   /// Network Time Protocol Servers
+#define DHCP4_TAG_VENDOR 43   /// Vendor Specific Information
+#define DHCP4_TAG_NBNS   44   /// NetBIOS over TCP/IP Name Server
+#define DHCP4_TAG_NBDD   45   /// NetBIOS Datagram Distribution 
Server
+#define DHCP4_TAG_NBTYPE 46   /// NetBIOS over TCP/IP Node Type
+#define DHCP4_TAG_NBSCOPE47   /// NetBIOS over TCP/IP Scope
+#define DHCP4_TAG_XFONT  48   /// X Window S

[edk2] [PATCH v2 0/2] Refine codes related to Dhcpv4 and Dhcpv6 configuration.

2016-06-19 Thread Zhang Lubo
v2:
*add some new arch types for PXE boot.
refine the definition of arch types for http boot

Add a new head file Dhcp.h in Mde/Include/IndustryStandard, normalize the
universal Dhcp option numbers and other network number tags.

Zhang Lubo (2):
  MdePkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.
  NetworkPkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.

 MdePkg/Include/IndustryStandard/Dhcp.h | 281 +
 NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h| 128 +--
 NetworkPkg/HttpBootDxe/HttpBootDhcp4.c |  82 +-
 NetworkPkg/HttpBootDxe/HttpBootDhcp4.h |  51 +-
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.c |  30 ++--
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.h |  27 +---
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |   1 +
 NetworkPkg/IScsiDxe/IScsiDhcp.c|  10 +-
 NetworkPkg/IScsiDxe/IScsiDhcp.h|   9 +-
 NetworkPkg/IScsiDxe/IScsiDhcp6.c   |   8 +-
 NetworkPkg/IScsiDxe/IScsiDhcp6.h   |  11 +-
 NetworkPkg/IScsiDxe/IScsiImpl.h|   4 +-
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c  |   6 +-
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h  |   2 -
 NetworkPkg/Ip6Dxe/Ip6Impl.h|   4 +-
 NetworkPkg/Ip6Dxe/Ip6Nd.c  |   4 +-
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c   |  98 ++--
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h   |  42 +
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c   |  28 ++--
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h   |  25 +--
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h|   3 +-
 21 files changed, 436 insertions(+), 418 deletions(-)
 create mode 100644 MdePkg/Include/IndustryStandard/Dhcp.h

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2] NetworkPkg: Replace ASSERT with error handling in Http boot and IScsi

2016-06-19 Thread Zhang Lubo
v2:
*Fix some memory leak issue.

This patch is used to replace ASSERT with error handling in Http boot
Driver and IScsi driver.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/HttpBootDxe/HttpBootConfig.c |  5 +++--
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.c  |  5 -
 NetworkPkg/IScsiDxe/IScsiConfig.c   |  8 ++--
 NetworkPkg/IScsiDxe/IScsiDriver.c   |  1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c |  5 -
 NetworkPkg/IScsiDxe/IScsiProto.c| 17 +
 6 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c 
b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
index 04c2f3e..3708995 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
@@ -271,11 +271,13 @@ HttpBootFormExtractConfig (
 // followed by "&OFFSET=0&WIDTH=" followed by a 
Null-terminator
 //
 ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, 
mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 ConfigRequest = AllocateZeroPool (Size);
-ASSERT (ConfigRequest != NULL);
+if (ConfigRequest == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 AllocatedRequest = TRUE;
 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
ConfigRequestHdr, (UINT64)BufferSize);
 FreePool (ConfigRequestHdr);
   }
 
@@ -462,11 +464,10 @@ HttpBootFormCallback (
   case KEY_INITIATOR_URI:
 //
 // Get user input URI string
 //
 Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
-ASSERT (Uri != NULL);
 if (Uri == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c 
b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
index 0157095..9ea421d 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
@@ -399,10 +399,11 @@ HttpBootCacheDhcp6Offer (
 
   @retval EFI_SUCCESS   Told the EFI DHCPv6 Protocol driver to 
continue the DHCP process.
   @retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI 
DHCPv6 Protocol
 driver will continue to wait for more packets.
   @retval EFI_ABORTED   Told the EFI DHCPv6 Protocol driver to abort 
the current process.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources.
 
 **/
 EFI_STATUS
 EFIAPI
 HttpBootDhcp6CallBack (
@@ -449,11 +450,13 @@ HttpBootDhcp6CallBack (
Status = EFI_ABORTED;
  } else {
ASSERT (NewPacket != NULL);
SelectAd   = &Private->OfferBuffer[Private->SelectIndex - 
1].Dhcp6.Packet.Offer;
*NewPacket = AllocateZeroPool (SelectAd->Size);
-   ASSERT (*NewPacket != NULL);
+   if (*NewPacket == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+   }
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
  }
  break;
  
default:
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 69a4003..8f06a07 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1,9 +1,9 @@
 /** @file
   Helper functions for configuring or getting the parameters relating to iSCSI.
 
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -1957,11 +1957,15 @@ IScsiFormExtractConfig (
 // followed by "&OFFSET=0&WIDTH=" followed by a 
Null-terminator
 //
 ConfigRequestHdr = HiiConstructConfigHdr (&gIScsiConfigGuid, 
mVendorStorageName, Private->DriverHandle);
 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 ConfigRequest = AllocateZeroPool (Size);
-ASSERT (ConfigRequest != NULL);
+if (ConfigRequest == NULL) {
+  FreePool (IfrNvData);
+  FreePool (InitiatorName);
+  return EFI_OUT_OF_RESOURCES;
+}
 AllocatedRequest = TRUE;
 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
ConfigRequestHdr, (UINT64)BufferSize);
 FreePool (ConfigRequestHdr);
   }
 
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c 
b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 5a121ce..285f151 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -321,10 +321,11 @@ IScsiSupported (
   @retval EFI_SUCCESThis driver was started.
   @retval EFI_ALREADY_STARTED   This driver is already running on this device.
 

Re: [edk2] [patch] NetworkPkg: Replace ASSERT with error handling in Http boot and IScsi

2016-06-19 Thread Zhang, Lubo
Yes , you are right,  thanks for your comments.

Lubo

-Original Message-
From: Wu, Jiaxin 
Sent: Monday, June 20, 2016 11:48 AM
To: Zhang, Lubo ; edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan 
Subject: RE: [edk2] [patch] NetworkPkg: Replace ASSERT with error handling in 
Http boot and IScsi

Hi Lubo,
Two comments as below:

1. In IScsiFormExtractConfig(), you need  free IfrNvData and InitiatorName pool 
first before return EFI_OUT_OF_RESOURCES.

2. In IScsiGetConfigData(),  returning EFI_OUT_OF_RESOURCES may be incorrect 
after HiiSetString() failed? Should be "continue"?

Thanks.
Jiaxin


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Zhang Lubo
> Sent: Friday, June 17, 2016 4:46 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; 
> Wu, Jiaxin 
> Subject: [edk2] [patch] NetworkPkg: Replace ASSERT with error handling 
> in Http boot and IScsi
> 
> This patch is used to replace ASSERT with error handling in Http boot 
> Driver and IScsi driver.
> 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Wu Jiaxin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo 
> ---
>  NetworkPkg/HttpBootDxe/HttpBootConfig.c |  5 +++-- 
> NetworkPkg/HttpBootDxe/HttpBootDhcp6.c  |  5 -
>  NetworkPkg/IScsiDxe/IScsiConfig.c   |  6 --
>  NetworkPkg/IScsiDxe/IScsiDriver.c   |  1 +
>  NetworkPkg/IScsiDxe/IScsiMisc.c |  5 -
>  NetworkPkg/IScsiDxe/IScsiProto.c| 17 +
>  6 files changed, 29 insertions(+), 10 deletions(-)
> 
> diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
> b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
> index 04c2f3e..3708995 100644
> --- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
> +++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
> @@ -271,11 +271,13 @@ HttpBootFormExtractConfig (
>  // followed by "&OFFSET=0&WIDTH="
> followed by a Null-terminator
>  //
>  ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, 
> mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
>  Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
>  ConfigRequest = AllocateZeroPool (Size);
> -ASSERT (ConfigRequest != NULL);
> +if (ConfigRequest == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
>  AllocatedRequest = TRUE;
>  UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
> ConfigRequestHdr, (UINT64)BufferSize);
>  FreePool (ConfigRequestHdr);
>}
> 
> @@ -462,11 +464,10 @@ HttpBootFormCallback (
>case KEY_INITIATOR_URI:
>  //
>  // Get user input URI string
>  //
>  Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
> -ASSERT (Uri != NULL);
>  if (Uri == NULL) {
>return EFI_UNSUPPORTED;
>  }
> 
>  //
> diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
> b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
> index 0157095..9ea421d 100644
> --- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
> +++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
> @@ -399,10 +399,11 @@ HttpBootCacheDhcp6Offer (
> 
>@retval EFI_SUCCESS   Told the EFI DHCPv6 Protocol driver to 
> continue
> the DHCP process.
>@retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The 
> EFI
> DHCPv6 Protocol
>  driver will continue to wait for more 
> packets.
>@retval EFI_ABORTED   Told the EFI DHCPv6 Protocol driver to abort 
> the
> current process.
> +  @retval EFI_OUT_OF_RESOURCES  There are not enough resources.
> 
>  **/
>  EFI_STATUS
>  EFIAPI
>  HttpBootDhcp6CallBack (
> @@ -449,11 +450,13 @@ HttpBootDhcp6CallBack (
> Status = EFI_ABORTED;
>   } else {
> ASSERT (NewPacket != NULL);
> SelectAd   = &Private->OfferBuffer[Private->SelectIndex -
> 1].Dhcp6.Packet.Offer;
> *NewPacket = AllocateZeroPool (SelectAd->Size);
> -   ASSERT (*NewPacket != NULL);
> +   if (*NewPacket == NULL) {
> + return EFI_OUT_OF_RESOURCES;
> +   }
> CopyMem (*NewPacket, SelectAd, SelectAd->Size);
>   }
>   break;
> 
> default:
> diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c
> b/NetworkPkg/IScsiDxe/IScsiConfig.c
> index 69a4003..bd24de2 100644
> --- a/NetworkPkg/IScsiDxe/IScsiConfig.c
> +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
> @@ -1,9 +1,9 @@
>  /** @file
>Helper functions for configuring or getting the parameters relating to 
> iSCSI.
> 
> -Copyright (c) 2004 - 2015, Intel Corporation. All rights 
> reserved.
> +Copyright (c)

[edk2] [patch] NetworkPkg: Replace ASSERT with error handling in Http boot and IScsi

2016-06-17 Thread Zhang Lubo
This patch is used to replace ASSERT with error handling in Http boot
Driver and IScsi driver.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wu Jiaxin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
---
 NetworkPkg/HttpBootDxe/HttpBootConfig.c |  5 +++--
 NetworkPkg/HttpBootDxe/HttpBootDhcp6.c  |  5 -
 NetworkPkg/IScsiDxe/IScsiConfig.c   |  6 --
 NetworkPkg/IScsiDxe/IScsiDriver.c   |  1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c |  5 -
 NetworkPkg/IScsiDxe/IScsiProto.c| 17 +
 6 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c 
b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
index 04c2f3e..3708995 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
@@ -271,11 +271,13 @@ HttpBootFormExtractConfig (
 // followed by "&OFFSET=0&WIDTH=" followed by a 
Null-terminator
 //
 ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, 
mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 ConfigRequest = AllocateZeroPool (Size);
-ASSERT (ConfigRequest != NULL);
+if (ConfigRequest == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 AllocatedRequest = TRUE;
 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
ConfigRequestHdr, (UINT64)BufferSize);
 FreePool (ConfigRequestHdr);
   }
 
@@ -462,11 +464,10 @@ HttpBootFormCallback (
   case KEY_INITIATOR_URI:
 //
 // Get user input URI string
 //
 Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
-ASSERT (Uri != NULL);
 if (Uri == NULL) {
   return EFI_UNSUPPORTED;
 }
 
 //
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c 
b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
index 0157095..9ea421d 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
@@ -399,10 +399,11 @@ HttpBootCacheDhcp6Offer (
 
   @retval EFI_SUCCESS   Told the EFI DHCPv6 Protocol driver to 
continue the DHCP process.
   @retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI 
DHCPv6 Protocol
 driver will continue to wait for more packets.
   @retval EFI_ABORTED   Told the EFI DHCPv6 Protocol driver to abort 
the current process.
+  @retval EFI_OUT_OF_RESOURCES  There are not enough resources.
 
 **/
 EFI_STATUS
 EFIAPI
 HttpBootDhcp6CallBack (
@@ -449,11 +450,13 @@ HttpBootDhcp6CallBack (
Status = EFI_ABORTED;
  } else {
ASSERT (NewPacket != NULL);
SelectAd   = &Private->OfferBuffer[Private->SelectIndex - 
1].Dhcp6.Packet.Offer;
*NewPacket = AllocateZeroPool (SelectAd->Size);
-   ASSERT (*NewPacket != NULL);
+   if (*NewPacket == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+   }
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
  }
  break;
  
default:
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 69a4003..bd24de2 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1,9 +1,9 @@
 /** @file
   Helper functions for configuring or getting the parameters relating to iSCSI.
 
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -1957,11 +1957,13 @@ IScsiFormExtractConfig (
 // followed by "&OFFSET=0&WIDTH=" followed by a 
Null-terminator
 //
 ConfigRequestHdr = HiiConstructConfigHdr (&gIScsiConfigGuid, 
mVendorStorageName, Private->DriverHandle);
 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 ConfigRequest = AllocateZeroPool (Size);
-ASSERT (ConfigRequest != NULL);
+if (ConfigRequest == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 AllocatedRequest = TRUE;
 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", 
ConfigRequestHdr, (UINT64)BufferSize);
 FreePool (ConfigRequestHdr);
   }
 
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c 
b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 5a121ce..285f151 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -321,10 +321,11 @@ IScsiSupported (
   @retval EFI_SUCCESThis driver was started.
   @retval EFI_ALREADY_STARTED   This driver is already running on this device.
   @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
   @retval EFI_NOT_FOUND Th

  1   2   3   >