[edk2] [PATCH v2 1/2] NetworkPkg/TcpDxe: Add wnd scale check before shrinking window

atepin@kraftway.ru posted 2 patches 7 years, 6 months ago
[edk2] [PATCH v2 1/2] NetworkPkg/TcpDxe: Add wnd scale check before shrinking window
Posted by atepin@kraftway.ru 7 years, 6 months ago
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel