[tcp] Send TCP keepalives on idle established connections

In some circumstances, intermediate devices may lose state in a way
that temporarily prevents the successful delivery of packets from a
TCP peer.  For example, a firewall may drop a NAT forwarding table
entry.

Since iPXE spends most of its time downloading files (and hence purely
receiving data, sending only TCP ACKs), this can easily happen in a
situation in which there is no reason for iPXE's TCP stack to generate
any retransmissions.  The temporary loss of connectivity can therefore
effectively become permanent.

Work around this problem by sending TCP keepalives after a period of
inactivity on an established connection.

TCP keepalives usually send a single garbage byte in sequence number
space that has already been ACKed by the peer.  Since we do not need
to elicit a response from the peer, we instead send pure ACKs (with no
garbage data) in order to keep the transmit code path simple.

Originally-implemented-by: Ladi Prosek <lprosek@redhat.com>
Debugged-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2016-06-10 17:27:06 +01:00
parent 5c2a959a72
commit 188789eb3c
2 changed files with 46 additions and 0 deletions

View File

@@ -378,6 +378,14 @@ struct tcp_options {
*/
#define TCP_MSL ( 2 * 60 * TICKS_PER_SEC )
/**
* TCP keepalive period
*
* We send keepalive ACKs after this period of inactivity has elapsed
* on an established connection.
*/
#define TCP_KEEPALIVE_DELAY ( 15 * TICKS_PER_SEC )
/**
* TCP maximum header length
*