From b7e5de389e8c5265be6eceb8d85dca1c9271d78a Mon Sep 17 00:00:00 2001 From: Jakub Schmidtke Date: Fri, 8 Sep 2017 16:06:49 -0400 Subject: [PATCH] Fixed removing unneeded TCP SACKs TCP SACKs were removed after some changes in the ooseq queue, but before all unneeded packets were removed from it. Because of that, we would sometimes include SACKs for data already delivered in-order. Signed-off-by: goldsimon --- src/core/tcp_in.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 006bdf37..3f5c1e11 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -1501,19 +1501,6 @@ tcp_receive(struct tcp_pcb *pcb) } pcb->ooseq = next; } - -#if LWIP_TCP_SACK_OUT - if (pcb->flags & TF_SACK) { - if (pcb->ooseq != NULL) { - /* Some segments may have been removed from ooseq, let's remove all SACKs that - describe anything before the new beginning of that list. */ - tcp_remove_sacks_lt(pcb, pcb->ooseq->tcphdr->seqno); - } else { - /* ooseq has been cleared. Nothing to SACK */ - memset(pcb->rcv_sacks, 0, sizeof(pcb->rcv_sacks)); - } - } -#endif /* LWIP_TCP_SACK_OUT */ } #endif /* TCP_QUEUE_OOSEQ */ @@ -1586,6 +1573,18 @@ tcp_receive(struct tcp_pcb *pcb) pcb->ooseq = cseg->next; tcp_seg_free(cseg); } +#if LWIP_TCP_SACK_OUT + if (pcb->flags & TF_SACK) { + if (pcb->ooseq != NULL) { + /* Some segments may have been removed from ooseq, let's remove all SACKs that + describe anything before the new beginning of that list. */ + tcp_remove_sacks_lt(pcb, pcb->ooseq->tcphdr->seqno); + } else if (LWIP_TCP_SACK_VALID(pcb, 0)) { + /* ooseq has been cleared. Nothing to SACK */ + memset(pcb->rcv_sacks, 0, sizeof(pcb->rcv_sacks)); + } + } +#endif /* LWIP_TCP_SACK_OUT */ #endif /* TCP_QUEUE_OOSEQ */