Line 1: |
Line 1: |
− | This page describes how we handle established TCP connections | + | This page describes how we handle established TCP connections. |
| | | |
| == TCP repair mode in kernel == | | == TCP repair mode in kernel == |
| | | |
− | The sockoption called TCP_REPAIR was recently added to the kernel and helps with doing C/R for TCP sockets. | + | The <code>TCP_REPAIR</code> socket option was added to the kernel 3.5 to help with C/R for TCP sockets. |
| | | |
− | When set this option turn the socket into a special state in which any action performed on it doesn't | + | When this option is used, a socket is switched into a special mode, in which any action performed on it |
− | result in any defined by protocol actions, but instead directly puts the socket into a state, which | + | does not result in anything defined by an appropriate protocol actions, but rather directly puts the socket |
− | should be at the end of the successfully finished operation.
| + | into a state, in which the socket is expected to 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.
| + | For example, calling <code>connect()</code> on a repaired socket just changes its state to <code>ESTABLISHED</code>, |
− | The bind() call forcibly binds the socket to a given address (ignoring any potential conflicts). Close()-ing the | + | with the peer address set as requested. |
− | socket under repair happens without any transient FIN_WAIT/TIME_WAIT/etc states. Socket is silently killed. | + | The <code>bind()</code> call forcibly binds the socket to a given address (ignoring any potential conflicts). |
| + | The <code>close()</code> call closes the socket without any transient <code>FIN_WAIT</code>/<code>TIME_WAIT</code>/etc states, |
| + | socket is silently killed. |
| | | |
| === Sequences === | | === Sequences === |
| | | |
− | In order to restore the connection properly only binding and connecting it is not enough. One also needs to restore the
| + | To restore the connection properly, bind() and connect() is not enough. One also needs to restore the |
− | TCP sequence numbers. To do so the TCP_REPAIR_QUEUE and TCP_QUEUE_SEQ options were introduced. | + | TCP sequence numbers. To do so, the <code>TCP_REPAIR_QUEUE</code> and <code>TCP_QUEUE_SEQ</code> options were introduced. |
| | | |
− | The former one selects which queue (input or output) will be repaired and the latter gets/sets the sequence. Note, that | + | 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. | | setting the sequence is only possible on CLOSE-d socket. |
| | | |