diff options
Diffstat (limited to 'net/ipv4/tcp_timer.c')
| -rw-r--r-- | net/ipv4/tcp_timer.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 8353a538cd4c..8816a20c2597 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
| @@ -132,6 +132,35 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) | |||
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* This function calculates a "timeout" which is equivalent to the timeout of a | ||
| 136 | * TCP connection after "boundary" unsucessful, exponentially backed-off | ||
| 137 | * retransmissions with an initial RTO of TCP_RTO_MIN. | ||
| 138 | */ | ||
| 139 | static bool retransmits_timed_out(struct sock *sk, | ||
| 140 | unsigned int boundary) | ||
| 141 | { | ||
| 142 | unsigned int timeout, linear_backoff_thresh; | ||
| 143 | unsigned int start_ts; | ||
| 144 | |||
| 145 | if (!inet_csk(sk)->icsk_retransmits) | ||
| 146 | return false; | ||
| 147 | |||
| 148 | if (unlikely(!tcp_sk(sk)->retrans_stamp)) | ||
| 149 | start_ts = TCP_SKB_CB(tcp_write_queue_head(sk))->when; | ||
| 150 | else | ||
| 151 | start_ts = tcp_sk(sk)->retrans_stamp; | ||
| 152 | |||
| 153 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); | ||
| 154 | |||
| 155 | if (boundary <= linear_backoff_thresh) | ||
| 156 | timeout = ((2 << boundary) - 1) * TCP_RTO_MIN; | ||
| 157 | else | ||
| 158 | timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN + | ||
| 159 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; | ||
| 160 | |||
| 161 | return (tcp_time_stamp - start_ts) >= timeout; | ||
| 162 | } | ||
| 163 | |||
| 135 | /* A write timeout has occurred. Process the after effects. */ | 164 | /* A write timeout has occurred. Process the after effects. */ |
| 136 | static int tcp_write_timeout(struct sock *sk) | 165 | static int tcp_write_timeout(struct sock *sk) |
| 137 | { | 166 | { |
