This page describes how we handle established TCP connections
== TCP repair mode in kernel ==
sockoption called TCP_REPAIR was recently added to the kernel and helps with doing C/R for TCP sockets.
set this option turn the socket into a special state in which any action performed on it doesn'tresult in any defined by protocol actions, but instead directly puts the socket into a state, which should be at the end of the successfully finished operation.
E.g. calling connect() on a repaired socket just switches one to the ESTABLISHED state with the peer set as requested.The bind() call forcibly binds the socket to a given address (ignoring any potential conflicts). Close() -ing thesocket under repair happens without any transient FIN_WAIT/TIME_WAIT/etc states . Socket is silently killed.
=== Sequences ===
In order to restore the connection properly only binding and connecting it is not enough. One also needs to restore theTCP sequence numbers. To do so the TCP_REPAIR_QUEUE and TCP_QUEUE_SEQ options were introduced.
The former one selects which queue (input or output) will be repaired and the latter gets/sets the sequence. Note
setting the sequence is only possible on CLOSE-d socket.