]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
MdeModulePkg: Addressing TCP Window Retraction when window scale factor is used.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Output.c
index 0eec8f07b922741cccae4471b2b199f4966761ad..5a3d837e1dab37e34e79b3074d4a4fe627a1d19e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TCP output 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
@@ -671,17 +671,39 @@ TcpRetransmit (
   // 2. must in the current send window\r
   // 3. will not change the boundaries of queued segments.\r
   //\r
-  if (TCP_SEQ_LT (Tcb->SndWl2 + Tcb->SndWnd, Seq)) {\r
-    DEBUG ((EFI_D_WARN, "TcpRetransmit: retransmission cancelled "\r
-      "because send window too small for TCB %p\n", Tcb));\r
+\r
+  //\r
+  // Handle the Window Retraction if TCP window scale is enabled according to RFC7323:\r
+  //   On first retransmission, or if the sequence number is out of\r
+  //   window by less than 2^Rcv.Wind.Shift, then do normal\r
+  //   retransmission(s) without regard to the receiver window as long\r
+  //   as the original segment was in window when it was sent.\r
+  //\r
+  if ((Tcb->SndWndScale != 0) &&\r
+      (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax) || TCP_SEQ_BETWEEN (Tcb->SndWl2 + Tcb->SndWnd, Seq, Tcb->SndWl2 + Tcb->SndWnd + (1 << Tcb->SndWndScale)))) {\r
+    Len = TCP_SUB_SEQ (Tcb->SndNxt, Seq);\r
+    DEBUG (\r
+      (EFI_D_WARN,\r
+      "TcpRetransmit: retransmission without regard to the receiver window for TCB %p\n",\r
+      Tcb)\r
+      );\r
+    \r
+  } else if (TCP_SEQ_GEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq)) {\r
+    Len = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);\r
+    \r
+  } else {\r
+    DEBUG (\r
+      (EFI_D_WARN,\r
+      "TcpRetransmit: retransmission cancelled because send window too small for TCB %p\n",\r
+      Tcb)\r
+      );\r
 \r
     return 0;\r
   }\r
+  \r
+  Len = MIN (Len, Tcb->SndMss);\r
 \r
-  Len   = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);\r
-  Len   = MIN (Len, Tcb->SndMss);\r
-\r
-  Nbuf  = TcpGetSegmentSndQue (Tcb, Seq, Len);\r
+  Nbuf = TcpGetSegmentSndQue (Tcb, Seq, Len);\r
   if (Nbuf == NULL) {\r
     return -1;\r
   }\r
@@ -691,6 +713,10 @@ TcpRetransmit (
   if (TcpTransmitSegment (Tcb, Nbuf) != 0) {\r
     goto OnError;\r
   }\r
+  \r
+  if (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax)) {\r
+    Tcb->RetxmitSeqMax = Seq;\r
+  }\r
 \r
   //\r
   // The retransmitted buffer may be on the SndQue,\r