tcp: do not keep sending SYNs when getting ACKs

If a locally generated TCP SYN packet is replied to with an ACK
packet, lwIP immediately sends a RST packet followed by resending the
SYN packet.  This is expected, but on loopback interfaces the resent
SYN packet may immediately get another ACK reply, typically when the
other endpoint is in TIME_WAIT state (which ignores the RSTs).  The
result is an endless loop of SYN, ACK, RST packets.

This patch applies the normal SYN retransmission limit in this
scenario, such that the endless loop is limited to a brief storm.

(cherry picked from commit 5827c168c2)
This commit is contained in:
David van Moolenbroek 2017-03-08 19:43:15 +00:00 committed by goldsimon
parent 2452bc9336
commit 66db517a28

View File

@ -810,10 +810,13 @@ tcp_process(struct tcp_pcb *pcb)
tcp_rst(ackno, seqno + tcplen, ip_current_dest_addr(),
ip_current_src_addr(), tcphdr->dest, tcphdr->src);
/* Resend SYN immediately (don't wait for rto timeout) to establish
connection faster */
connection faster, but do not send more SYNs than we otherwise would
have, or we might get caught in a loop on loopback interfaces. */
if (pcb->nrtx < TCP_SYNMAXRTX) {
pcb->rtime = 0;
tcp_rexmit_rto(pcb);
}
}
break;
case SYN_RCVD:
if (flags & TCP_ACK) {