summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid van Moolenbroek <david@minix3.org>2016-09-19 11:33:34 +0000
committersg <goldsimon@gmx.de>2016-10-04 22:06:05 +0200
commit9ba9dee2aa809624eda0e96c96abd8abff29539e (patch)
treeb180bbff3d511be0971defdcd57590ce6bed8f4f
parent95754ba95abe2a243531a983cda34e043c5d4e9f (diff)
downloadlwip-9ba9dee2aa809624eda0e96c96abd8abff29539e.tar.gz
tcp: advance next seq nr for zero window probes
It is possible that the byte sent as a zero window probe is accepted and acknowledged by the receiver side without the window being opened. In that case, the stream has effectively advanced by one byte, and since lwIP did not take this into account on the sender side, the result was a desynchronization between the sender and the receiver. That situation could occur even on a lwIP loopback device, after filling up the receiver side's receive buffer, and resulted in an ACK storm. This patch corrects the problem by advancing the sender's next sequence number by one as needed when sending a zero window probe.
-rw-r--r--src/core/tcp_out.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index 70bdfea..78ff0a1 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -1537,6 +1537,7 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
struct tcp_seg *seg;
u16_t len;
u8_t is_fin;
+ u32_t snd_nxt;
struct netif *netif;
LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: sending ZERO WINDOW probe to "));
@@ -1581,6 +1582,12 @@ tcp_zero_window_probe(struct tcp_pcb *pcb)
pbuf_copy_partial(seg->p, d, 1, seg->p->tot_len - seg->len);
}
+ /* The byte may be acknowledged without the window being opened. */
+ snd_nxt = ntohl(seg->tcphdr->seqno) + 1;
+ if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) {
+ pcb->snd_nxt = snd_nxt;
+ }
+
netif = ip_route(&pcb->local_ip, &pcb->remote_ip);
if (netif == NULL) {
err = ERR_RTE;