diff options
-rw-r--r-- | include/net/tcp.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index e5319495f15e..df50bc40b5fd 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -1252,22 +1252,27 @@ static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_bu | |||
1252 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ | 1252 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ |
1253 | skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) | 1253 | skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) |
1254 | 1254 | ||
1255 | /* This function calculates a "timeout" which is equivalent to the timeout of a | ||
1256 | * TCP connection after "boundary" unsucessful, exponentially backed-off | ||
1257 | * retransmissions with an initial RTO of TCP_RTO_MIN. | ||
1258 | */ | ||
1255 | static inline bool retransmits_timed_out(const struct sock *sk, | 1259 | static inline bool retransmits_timed_out(const struct sock *sk, |
1256 | unsigned int boundary) | 1260 | unsigned int boundary) |
1257 | { | 1261 | { |
1258 | int limit, K; | 1262 | unsigned int timeout, linear_backoff_thresh; |
1263 | |||
1259 | if (!inet_csk(sk)->icsk_retransmits) | 1264 | if (!inet_csk(sk)->icsk_retransmits) |
1260 | return false; | 1265 | return false; |
1261 | 1266 | ||
1262 | K = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); | 1267 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); |
1263 | 1268 | ||
1264 | if (boundary <= K) | 1269 | if (boundary <= linear_backoff_thresh) |
1265 | limit = ((2 << boundary) - 1) * TCP_RTO_MIN; | 1270 | timeout = ((2 << boundary) - 1) * TCP_RTO_MIN; |
1266 | else | 1271 | else |
1267 | limit = ((2 << K) - 1) * TCP_RTO_MIN + | 1272 | timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN + |
1268 | (boundary - K) * TCP_RTO_MAX; | 1273 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; |
1269 | 1274 | ||
1270 | return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= limit; | 1275 | return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= timeout; |
1271 | } | 1276 | } |
1272 | 1277 | ||
1273 | static inline struct sk_buff *tcp_send_head(struct sock *sk) | 1278 | static inline struct sk_buff *tcp_send_head(struct sock *sk) |