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 v2 1/2] NetworkPkg/TcpDxe: Add wnd scale check before shrinking window
Date: Thu, 20 Apr 2017 09:30:37 +0000	[thread overview]
Message-ID: <5efa583cfa4ddaecd9b1dcf8ac6999b4368e12e8.1492679770.git.atepin@kraftway.ru> (raw)
In-Reply-To: <cover.1492679770.git.atepin@kraftway.ru>

Moving Right window edge to the left on sender side without additional
check can lead to the TCP deadlock, when receiver ACKs proper segment,
while sender discards it for future ACK. To prevent this add check if
usable window (or shrink amount in this case) is bigger then receiver's
window scale factor.

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

diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c
index 04c8a82..74ea02b 100644
--- a/NetworkPkg/TcpDxe/TcpInput.c
+++ b/NetworkPkg/TcpDxe/TcpInput.c
@@ -1306,8 +1306,21 @@ TcpInput (
       }
 
       if (TCP_SEQ_LT (Right, Tcb->SndNxt)) {
+        DEBUG (
+          (EFI_D_WARN,
+          "TcpInput: peer advise negative useable window for connected TCB %p\n",
+          Tcb)
+          );
 
-        Tcb->SndNxt = Right;
+        INT32 Usable = Tcb->SndNxt - Right;
+        if ((Usable >> Tcb->SndWndScale) > 0) {
+          DEBUG (
+            (EFI_D_WARN,
+            "TcpInput: SndNxt is out of window by more than window scale for TCB %p\n",
+            Tcb)
+            );
+          Tcb->SndNxt = Right;
+        }
 
         if (Right == Tcb->SndUna) {
 
-- 
2.7.4


  parent reply	other threads:[~2017-04-20  9:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20  9:30 [PATCH v2 0/2] Add wnd scale check before shrinking window atepin
2017-04-20  9:30 ` [PATCH v2 2/2] MdeModulePkg/Tcp4Dxe: " atepin
2017-04-20  9:30 ` atepin [this message]
2017-04-20  9:39 ` [PATCH v2 0/2] " atepin
2017-05-05  2:43 ` Fu, Siyuan

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=5efa583cfa4ddaecd9b1dcf8ac6999b4368e12e8.1492679770.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