From e828864811e7251a76dac1b1fd7a0bef973b3bf4 Mon Sep 17 00:00:00 2001 From: bol-van Date: Fri, 12 Dec 2025 20:18:55 +0300 Subject: [PATCH] nfqws2: cancel reasm if server window size is smaller than expected reasm size --- docs/changes.txt | 1 + nfq2/desync.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index eff94bb..8e714b7 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -94,3 +94,4 @@ v0.7 v0.7.1 * init.d: fix non-working incoming redirect +* nfqws2: cancel reasm if server window size is smaller than expected reasm size diff --git a/nfq2/desync.c b/nfq2/desync.c index 2122cea..b9bcc02 100644 --- a/nfq2/desync.c +++ b/nfq2/desync.c @@ -410,6 +410,15 @@ static bool reasm_start(t_ctrack *ctrack, t_reassemble *reasm, uint8_t proto, ui static bool reasm_client_start(t_ctrack *ctrack, uint8_t proto, size_t sz, size_t szMax, const uint8_t *data_payload, size_t len_payload) { if (!ctrack) return false; + if (proto==IPPROTO_TCP && ctrack->pos.server.winsize_calc < szMax) + { + // this is rare but possible situation + // server gave us too small tcp window + // client will not send all pieces of reasm + // if we drop packets and wait for next pieces we will see nothing but retransmissions + DLOG("reasm cancelled because server window size %u is smaller than expected reasm size %u\n", ctrack->pos.server.winsize_calc, sz); + return false; + } return reasm_start(ctrack, &ctrack->reasm_client, proto, (proto == IPPROTO_TCP) ? ctrack->pos.client.seq_last : 0, sz, szMax, data_payload, len_payload); } static bool reasm_feed(t_ctrack *ctrack, t_reassemble *reasm, uint8_t proto, uint32_t seq, const uint8_t *data_payload, size_t len_payload)