]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add wnd scale check before shrinking window.
authorFu Siyuan <siyuan.fu@intel.com>
Wed, 3 May 2017 07:21:23 +0000 (15:21 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Tue, 9 May 2017 00:45:33 +0000 (08:45 +0800)
Moving Right window edge to the left on sender side without additional check
can lead to the TCP deadlock, when receiver ACKs proper segment, while sender
discards it for future ACK. To prevent this add check if usable window (or
shrink amount in this case) is bigger then receiver's window scale factor.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrey Tepin <atepin@kraftway.ru>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c

index 1000538f87446f1ac08482d4500e4b3b7d16112d..72955c6c5e488159981deb71269243d728283e5c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TCP input process routines.\r
 \r
 /** @file\r
   TCP input process routines.\r
 \r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -703,7 +703,8 @@ TcpInput (
   TCP_SEG     *Seg;\r
   TCP_SEQNO   Right;\r
   TCP_SEQNO   Urg;\r
   TCP_SEG     *Seg;\r
   TCP_SEQNO   Right;\r
   TCP_SEQNO   Urg;\r
-\r
+  INT32       Usable;\r
+  \r
   NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);\r
 \r
   Parent  = NULL;\r
   NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);\r
 \r
   Parent  = NULL;\r
@@ -1187,9 +1188,27 @@ TcpInput (
       }\r
 \r
       if (TCP_SEQ_LT (Right, Tcb->SndNxt)) {\r
       }\r
 \r
       if (TCP_SEQ_LT (Right, Tcb->SndNxt)) {\r
-\r
-        Tcb->SndNxt = Right;\r
-\r
+        //\r
+        // Check for Window Retraction in RFC7923 section 2.4.\r
+        // The lower n bits of the peer's actual receive window is wiped out if TCP\r
+        // window scale is enabled, it will look like the peer is shrinking the window.\r
+        // Check whether the SndNxt is out of the advertised receive window by more than\r
+        // 2^Rcv.Wind.Shift before moving the SndNxt to the left.\r
+        //\r
+        DEBUG (\r
+          (EFI_D_WARN,\r
+          "TcpInput: peer advise negative useable window for connected TCB %p\n",\r
+          Tcb)\r
+          );\r
+        Usable = TCP_SUB_SEQ (Tcb->SndNxt, Right);\r
+        if ((Usable >> Tcb->SndWndScale) > 0) {\r
+          DEBUG (\r
+            (EFI_D_WARN,\r
+            "TcpInput: SndNxt is out of window by more than window scale for TCB %p\n",\r
+            Tcb)\r
+            );\r
+          Tcb->SndNxt = Right;\r
+        }\r
         if (Right == Tcb->SndUna) {\r
 \r
           TcpClearTimer (Tcb, TCP_TIMER_REXMIT);\r
         if (Right == Tcb->SndUna) {\r
 \r
           TcpClearTimer (Tcb, TCP_TIMER_REXMIT);\r