diff options
Diffstat (limited to 'net/ipv4/tcp_timer.c')
-rw-r--r-- | net/ipv4/tcp_timer.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index df90cd1ce37f..9b21ae8b2e31 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -52,7 +52,7 @@ static void tcp_write_err(struct sock *sk) | |||
52 | * limit. | 52 | * limit. |
53 | * 2. If we have strong memory pressure. | 53 | * 2. If we have strong memory pressure. |
54 | */ | 54 | */ |
55 | static int tcp_out_of_resources(struct sock *sk, int do_reset) | 55 | static int tcp_out_of_resources(struct sock *sk, bool do_reset) |
56 | { | 56 | { |
57 | struct tcp_sock *tp = tcp_sk(sk); | 57 | struct tcp_sock *tp = tcp_sk(sk); |
58 | int shift = 0; | 58 | int shift = 0; |
@@ -72,7 +72,7 @@ static int tcp_out_of_resources(struct sock *sk, int do_reset) | |||
72 | if ((s32)(tcp_time_stamp - tp->lsndtime) <= TCP_TIMEWAIT_LEN || | 72 | if ((s32)(tcp_time_stamp - tp->lsndtime) <= TCP_TIMEWAIT_LEN || |
73 | /* 2. Window is closed. */ | 73 | /* 2. Window is closed. */ |
74 | (!tp->snd_wnd && !tp->packets_out)) | 74 | (!tp->snd_wnd && !tp->packets_out)) |
75 | do_reset = 1; | 75 | do_reset = true; |
76 | if (do_reset) | 76 | if (do_reset) |
77 | tcp_send_active_reset(sk, GFP_ATOMIC); | 77 | tcp_send_active_reset(sk, GFP_ATOMIC); |
78 | tcp_done(sk); | 78 | tcp_done(sk); |
@@ -135,10 +135,9 @@ static bool retransmits_timed_out(struct sock *sk, | |||
135 | if (!inet_csk(sk)->icsk_retransmits) | 135 | if (!inet_csk(sk)->icsk_retransmits) |
136 | return false; | 136 | return false; |
137 | 137 | ||
138 | if (unlikely(!tcp_sk(sk)->retrans_stamp)) | 138 | start_ts = tcp_sk(sk)->retrans_stamp; |
139 | start_ts = TCP_SKB_CB(tcp_write_queue_head(sk))->when; | 139 | if (unlikely(!start_ts)) |
140 | else | 140 | start_ts = tcp_skb_timestamp(tcp_write_queue_head(sk)); |
141 | start_ts = tcp_sk(sk)->retrans_stamp; | ||
142 | 141 | ||
143 | if (likely(timeout == 0)) { | 142 | if (likely(timeout == 0)) { |
144 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base); | 143 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base); |
@@ -181,7 +180,7 @@ static int tcp_write_timeout(struct sock *sk) | |||
181 | 180 | ||
182 | retry_until = sysctl_tcp_retries2; | 181 | retry_until = sysctl_tcp_retries2; |
183 | if (sock_flag(sk, SOCK_DEAD)) { | 182 | if (sock_flag(sk, SOCK_DEAD)) { |
184 | const int alive = (icsk->icsk_rto < TCP_RTO_MAX); | 183 | const int alive = icsk->icsk_rto < TCP_RTO_MAX; |
185 | 184 | ||
186 | retry_until = tcp_orphan_retries(sk, alive); | 185 | retry_until = tcp_orphan_retries(sk, alive); |
187 | do_reset = alive || | 186 | do_reset = alive || |
@@ -271,40 +270,41 @@ static void tcp_probe_timer(struct sock *sk) | |||
271 | struct inet_connection_sock *icsk = inet_csk(sk); | 270 | struct inet_connection_sock *icsk = inet_csk(sk); |
272 | struct tcp_sock *tp = tcp_sk(sk); | 271 | struct tcp_sock *tp = tcp_sk(sk); |
273 | int max_probes; | 272 | int max_probes; |
273 | u32 start_ts; | ||
274 | 274 | ||
275 | if (tp->packets_out || !tcp_send_head(sk)) { | 275 | if (tp->packets_out || !tcp_send_head(sk)) { |
276 | icsk->icsk_probes_out = 0; | 276 | icsk->icsk_probes_out = 0; |
277 | return; | 277 | return; |
278 | } | 278 | } |
279 | 279 | ||
280 | /* *WARNING* RFC 1122 forbids this | 280 | /* RFC 1122 4.2.2.17 requires the sender to stay open indefinitely as |
281 | * | 281 | * long as the receiver continues to respond probes. We support this by |
282 | * It doesn't AFAIK, because we kill the retransmit timer -AK | 282 | * default and reset icsk_probes_out with incoming ACKs. But if the |
283 | * | 283 | * socket is orphaned or the user specifies TCP_USER_TIMEOUT, we |
284 | * FIXME: We ought not to do it, Solaris 2.5 actually has fixing | 284 | * kill the socket when the retry count and the time exceeds the |
285 | * this behaviour in Solaris down as a bug fix. [AC] | 285 | * corresponding system limit. We also implement similar policy when |
286 | * | 286 | * we use RTO to probe window in tcp_retransmit_timer(). |
287 | * Let me to explain. icsk_probes_out is zeroed by incoming ACKs | ||
288 | * even if they advertise zero window. Hence, connection is killed only | ||
289 | * if we received no ACKs for normal connection timeout. It is not killed | ||
290 | * only because window stays zero for some time, window may be zero | ||
291 | * until armageddon and even later. We are in full accordance | ||
292 | * with RFCs, only probe timer combines both retransmission timeout | ||
293 | * and probe timeout in one bottle. --ANK | ||
294 | */ | 287 | */ |
295 | max_probes = sysctl_tcp_retries2; | 288 | start_ts = tcp_skb_timestamp(tcp_send_head(sk)); |
289 | if (!start_ts) | ||
290 | skb_mstamp_get(&tcp_send_head(sk)->skb_mstamp); | ||
291 | else if (icsk->icsk_user_timeout && | ||
292 | (s32)(tcp_time_stamp - start_ts) > icsk->icsk_user_timeout) | ||
293 | goto abort; | ||
296 | 294 | ||
295 | max_probes = sysctl_tcp_retries2; | ||
297 | if (sock_flag(sk, SOCK_DEAD)) { | 296 | if (sock_flag(sk, SOCK_DEAD)) { |
298 | const int alive = ((icsk->icsk_rto << icsk->icsk_backoff) < TCP_RTO_MAX); | 297 | const int alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX; |
299 | 298 | ||
300 | max_probes = tcp_orphan_retries(sk, alive); | 299 | max_probes = tcp_orphan_retries(sk, alive); |
301 | 300 | if (!alive && icsk->icsk_backoff >= max_probes) | |
302 | if (tcp_out_of_resources(sk, alive || icsk->icsk_probes_out <= max_probes)) | 301 | goto abort; |
302 | if (tcp_out_of_resources(sk, true)) | ||
303 | return; | 303 | return; |
304 | } | 304 | } |
305 | 305 | ||
306 | if (icsk->icsk_probes_out > max_probes) { | 306 | if (icsk->icsk_probes_out > max_probes) { |
307 | tcp_write_err(sk); | 307 | abort: tcp_write_err(sk); |
308 | } else { | 308 | } else { |
309 | /* Only send another probe if we didn't close things up. */ | 309 | /* Only send another probe if we didn't close things up. */ |
310 | tcp_send_probe0(sk); | 310 | tcp_send_probe0(sk); |