public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "atepin@kraftway.ru" <atepin@kraftway.ru>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: [PATCH 2/2] NetworkPkg/TcpDxe: Fix unconditional window shrinking
Date: Tue, 28 Mar 2017 07:20:26 +0000	[thread overview]
Message-ID: <abaea732db86fa399c3b4c4663eaa07910901e01.1490617399.git.atepin@kraftway.ru> (raw)
In-Reply-To: <de1fbe46a5db36715da70c9823f2ee85e65b8ae2.1490617399.git.atepin@kraftway.ru>

Moving Right window edge to the left on sender side without additional
checks leads to the situation when sender assumes the receiver shrunk
its rcv buffer, when, in fact, it only reduced window size. This is a
TCP deadlock situation. Receiver ACKs proper segment, while sender
discards it for future ACK. Add check for negative usable window to
prevent erroneous window shrinking.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrey Tepin <atepin@kraftway.ru>
---
 NetworkPkg/TcpDxe/TcpInput.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c
index 04c8a82..11b3eb8 100644
--- a/NetworkPkg/TcpDxe/TcpInput.c
+++ b/NetworkPkg/TcpDxe/TcpInput.c
@@ -738,6 +738,7 @@ TcpInput (
   TCP_SEQNO   Right;
   TCP_SEQNO   Urg;
   UINT16      Checksum;
+  INT32       UsableWnd;
 
   ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6));
 
@@ -1307,7 +1308,10 @@ TcpInput (
 
       if (TCP_SEQ_LT (Right, Tcb->SndNxt)) {
 
-        Tcb->SndNxt = Right;
+        UsableWnd = Tcb->SndUna + Tcb->SndWnd - Tcb->SndNxt;
+        if (UsableWnd < 0) {
+          Tcb->SndNxt = Right;
+        }
 
         if (Right == Tcb->SndUna) {
 
-- 
1.9.1


  reply	other threads:[~2017-03-28  7:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28  7:20 [PATCH 1/2] MdeModulePkg/Tcp4Dxe: Fix unconditional window shrinking atepin
2017-03-28  7:20 ` atepin [this message]
2017-04-05  9:47   ` [PATCH 2/2] NetworkPkg/TcpDxe: " Fu, Siyuan
2017-04-06 15:34     ` atepin
2017-04-12 10:48       ` Fu, Siyuan
2017-04-13 14:33         ` atepin
2017-04-14  1:03           ` Fu, Siyuan
2017-04-14  9:00           ` Fu, Siyuan
2017-04-14 13:31             ` atepin
2017-04-17  2:41               ` Fu, Siyuan
2017-04-17 14:40                 ` atepin
2017-04-18  3:55                   ` Fu, Siyuan
2017-04-18  8:06                     ` atepin
2017-04-18  8:46                       ` Fu, Siyuan
2017-04-18  9:57                         ` atepin
2017-03-29  6:56 ` [PATCH 1/2] MdeModulePkg/Tcp4Dxe: " Tian, Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abaea732db86fa399c3b4c4663eaa07910901e01.1490617399.git.atepin@kraftway.ru \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox