]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Addressing TCP Window Retraction when window scale factor is used.
authorFu Siyuan <siyuan.fu@intel.com>
Wed, 3 May 2017 06:30:36 +0000 (14:30 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Tue, 9 May 2017 00:48:00 +0000 (08:48 +0800)
The RFC1323 which defines the TCP window scale option has been obsoleted by RFC7323.
This patch is to follow the RFC7323 to address the TCP window retraction problem
when a non-zero scale factor is used.
The changes has been test in high packet loss rate network by using HTTP boot and
iSCSI file read/write.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
NetworkPkg/TcpDxe/TcpMisc.c
NetworkPkg/TcpDxe/TcpOutput.c
NetworkPkg/TcpDxe/TcpProto.h

index a8592c968956a26fd1037751e943de47954aa751..44350362855f761a86b60e79b0940686255e338a 100644 (file)
@@ -2,7 +2,7 @@
   Misc support routines for TCP driver.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\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
@@ -86,6 +86,7 @@ TcpInitTcbLocal (
   // First window size is never scaled\r
   //\r
   Tcb->RcvWndScale  = 0;\r
+  Tcb->RetxmitSeqMax = 0;\r
 \r
   Tcb->ProbeTimerOn = FALSE;\r
 }\r
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
index ee351348339e0b7919bbe1fa89693c28cee8d884..81397d704d13eaafb99641a95e6908ef9c271062 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TCP protocol header file.\r
 \r
-  Copyright (c) 2009 - 2012, 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
@@ -315,6 +315,12 @@ struct _TCP_CONTROL_BLOCK {
   UINT8             LossTimes;    ///< Number of retxmit timeouts in a row.\r
   TCP_SEQNO         LossRecover;  ///< Recover point for retxmit.\r
 \r
+  //\r
+  // RFC7323\r
+  // Addressing Window Retraction for TCP Window Scale Option.\r
+  //\r
+  TCP_SEQNO         RetxmitSeqMax;       ///< Max Seq number in previous retransmission.\r
+\r
   //\r
   // configuration parameters, for EFI_TCP4_PROTOCOL specification\r
   //\r