]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/net/tcp.h
tcp: Stalling connections: Fix timeout calculation routine
[linux-beck.git] / include / net / tcp.h
index e2d2ca2509be29abbe81c531aeef0a7207fdc952..e54bd85d9d40fb283b6a6aef3541ca50c4449df1 100644 (file)
@@ -1265,14 +1265,20 @@ static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_bu
  * TCP connection after "boundary" unsucessful, exponentially backed-off
  * retransmissions with an initial RTO of TCP_RTO_MIN.
  */
-static inline bool retransmits_timed_out(const struct sock *sk,
+static inline bool retransmits_timed_out(struct sock *sk,
                                         unsigned int boundary)
 {
        unsigned int timeout, linear_backoff_thresh;
+       unsigned int start_ts;
 
        if (!inet_csk(sk)->icsk_retransmits)
                return false;
 
+       if (unlikely(!tcp_sk(sk)->retrans_stamp))
+               start_ts = TCP_SKB_CB(tcp_write_queue_head(sk))->when;
+       else
+               start_ts = tcp_sk(sk)->retrans_stamp;
+
        linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
 
        if (boundary <= linear_backoff_thresh)
@@ -1281,7 +1287,7 @@ static inline bool retransmits_timed_out(const struct sock *sk,
                timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN +
                          (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
 
-       return (tcp_time_stamp - tcp_sk(sk)->retrans_stamp) >= timeout;
+       return (tcp_time_stamp - start_ts) >= timeout;
 }
 
 static inline struct sk_buff *tcp_send_head(struct sock *sk)