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

Zhang Lubo posted 1 patch 7 years, 6 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
[edk2] [patch] MdeModulePkg: Fix issue the iSCSI client can not send reset packet correctly.
Posted by Zhang Lubo 7 years, 6 months ago
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 <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
---
 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: Fix issue the iSCSI client can not send reset packet correctly.
Posted by Wu, Jiaxin 7 years, 6 months ago
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


Thanks,
Jiaxin

> -----Original Message-----
> From: Zhang, Lubo
> Sent: Friday, April 28, 2017 2:41 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Fu, Siyuan
> <siyuan.fu@intel.com>
> Subject: [patch] MdeModulePkg: Fix issue the iSCSI client can not send reset
> packet correctly.
> 
> 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 <lubo.zhang@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> ---
>  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: Fix issue the iSCSI client can not send reset packet correctly.
Posted by Ye, Ting 7 years, 6 months ago
Reviewed-by: Ye Ting <ting.ye@intel.com> 

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Zhang Lubo
Sent: Friday, April 28, 2017 2:41 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [edk2] [patch] MdeModulePkg: Fix issue the iSCSI client can not send reset packet correctly.

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 <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
---
 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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel