]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/TcpDxe/TcpOutput.c
NetworkPkg: Addressing TCP Window Retraction when window scale factor is used.
[mirror_edk2.git] / NetworkPkg / TcpDxe / TcpOutput.c
index a46cb6099ea8ab72050c9d9bca35f9fa0763d172..a7e59f0ed6e0e60aa97aa2e755f0be4222eccd38 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TCP output process routines.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -664,7 +664,27 @@ 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
+\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
@@ -674,10 +694,9 @@ TcpRetransmit (
     return 0;\r
   }\r
 \r
-  Len   = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);\r
-  Len   = MIN (Len, Tcb->SndMss);\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
@@ -688,6 +707,10 @@ TcpRetransmit (
     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
   // trim TCP head because all the buffers on SndQue\r