summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2017-05-03 15:22:08 +0800
committerFu Siyuan <siyuan.fu@intel.com>2017-05-17 11:26:53 +0800
commite136824a6a2fd27488e0d88d63d2c78c4101392b (patch)
tree3b3fd8d29430f7fe655f54a7bcd681616093ab75
parent2a8abcd1f981a462df68ada7d473003a199355ae (diff)
downloadedk2-e136824a6a2fd27488e0d88d63d2c78c4101392b.tar.gz
MdeModulePkg: Addressing TCP Window Retraction when window scale factor is used.
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> (cherry picked from commit ca12a0c83b7b889fc807cb2dd47356f0fd1253d6)
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c5
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c40
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h8
3 files changed, 43 insertions, 10 deletions
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
index 95f47f91bc..ceffd37a35 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
@@ -1,7 +1,7 @@
/** @file
Misc support routines for tcp.
-Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -78,7 +78,8 @@ TcpInitTcbLocal (
// First window size is never scaled
//
Tcb->RcvWndScale = 0;
-
+ Tcb->RetxmitSeqMax = 0;
+
Tcb->ProbeTimerOn = FALSE;
}
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
index b44e851b26..5b0048addc 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
@@ -1,7 +1,7 @@
/** @file
TCP output process routines.
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -671,15 +671,37 @@ TcpRetransmit (
// 2. must in the current send window
// 3. will not change the boundaries of queued segments.
//
- if (TCP_SEQ_LT (Tcb->SndWl2 + Tcb->SndWnd, Seq)) {
- DEBUG ((EFI_D_WARN, "TcpRetransmit: retransmission cancelled "
- "because send window too small for TCB %p\n", Tcb));
+
+ //
+ // Handle the Window Retraction if TCP window scale is enabled according to RFC7323:
+ // On first retransmission, or if the sequence number is out of
+ // window by less than 2^Rcv.Wind.Shift, then do normal
+ // retransmission(s) without regard to the receiver window as long
+ // as the original segment was in window when it was sent.
+ //
+ if ((Tcb->SndWndScale != 0) &&
+ (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax) || TCP_SEQ_BETWEEN (Tcb->SndWl2 + Tcb->SndWnd, Seq, Tcb->SndWl2 + Tcb->SndWnd + (1 << Tcb->SndWndScale)))) {
+ Len = TCP_SUB_SEQ (Tcb->SndNxt, Seq);
+ DEBUG (
+ (EFI_D_WARN,
+ "TcpRetransmit: retransmission without regard to the receiver window for TCB %p\n",
+ Tcb)
+ );
+
+ } else if (TCP_SEQ_GEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq)) {
+ Len = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);
+
+ } else {
+ DEBUG (
+ (EFI_D_WARN,
+ "TcpRetransmit: retransmission cancelled because send window too small for TCB %p\n",
+ Tcb)
+ );
return 0;
}
-
- Len = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq);
- Len = MIN (Len, Tcb->SndMss);
+
+ Len = MIN (Len, Tcb->SndMss);
Nbuf = TcpGetSegmentSndQue (Tcb, Seq, Len);
if (Nbuf == NULL) {
@@ -691,6 +713,10 @@ TcpRetransmit (
if (TcpTransmitSegment (Tcb, Nbuf) != 0) {
goto OnError;
}
+
+ if (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax)) {
+ Tcb->RetxmitSeqMax = Seq;
+ }
//
// The retransmitted buffer may be on the SndQue,
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
index 01d6034b13..49d8a1da3b 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
@@ -1,7 +1,7 @@
/** @file
Tcp Protocol header file.
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -251,6 +251,12 @@ struct _TCP_CB {
UINT32 ConnectTimeout; ///< The connect establishment time out
//
+ // RFC7323
+ // Addressing Window Retraction for TCP Window Scale Option.
+ //
+ TCP_SEQNO RetxmitSeqMax; ///< Max Seq number in previous retransmission.
+
+ //
// configuration for tcp provided by user
//
BOOLEAN UseDefaultAddr;