aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_timer.c')
-rw-r--r--net/ipv4/tcp_timer.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 074de38bafbd..bcc2f5783e57 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -159,7 +159,20 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
159 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); 159 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
160} 160}
161 161
162 162static unsigned int tcp_model_timeout(struct sock *sk,
163 unsigned int boundary,
164 unsigned int rto_base)
165{
166 unsigned int linear_backoff_thresh, timeout;
167
168 linear_backoff_thresh = ilog2(TCP_RTO_MAX / rto_base);
169 if (boundary <= linear_backoff_thresh)
170 timeout = ((2 << boundary) - 1) * rto_base;
171 else
172 timeout = ((2 << linear_backoff_thresh) - 1) * rto_base +
173 (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
174 return jiffies_to_msecs(timeout);
175}
163/** 176/**
164 * retransmits_timed_out() - returns true if this connection has timed out 177 * retransmits_timed_out() - returns true if this connection has timed out
165 * @sk: The current socket 178 * @sk: The current socket
@@ -177,23 +190,15 @@ static bool retransmits_timed_out(struct sock *sk,
177 unsigned int boundary, 190 unsigned int boundary,
178 unsigned int timeout) 191 unsigned int timeout)
179{ 192{
180 const unsigned int rto_base = TCP_RTO_MIN; 193 unsigned int start_ts;
181 unsigned int linear_backoff_thresh, start_ts;
182 194
183 if (!inet_csk(sk)->icsk_retransmits) 195 if (!inet_csk(sk)->icsk_retransmits)
184 return false; 196 return false;
185 197
186 start_ts = tcp_sk(sk)->retrans_stamp; 198 start_ts = tcp_sk(sk)->retrans_stamp;
187 if (likely(timeout == 0)) { 199 if (likely(timeout == 0))
188 linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base); 200 timeout = tcp_model_timeout(sk, boundary, TCP_RTO_MIN);
189 201
190 if (boundary <= linear_backoff_thresh)
191 timeout = ((2 << boundary) - 1) * rto_base;
192 else
193 timeout = ((2 << linear_backoff_thresh) - 1) * rto_base +
194 (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
195 timeout = jiffies_to_msecs(timeout);
196 }
197 return (s32)(tcp_time_stamp(tcp_sk(sk)) - start_ts - timeout) >= 0; 202 return (s32)(tcp_time_stamp(tcp_sk(sk)) - start_ts - timeout) >= 0;
198} 203}
199 204