diff options
Diffstat (limited to 'net/ipv4/tcp_timer.c')
| -rw-r--r-- | net/ipv4/tcp_timer.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index b144a26359bc..8353a538cd4c 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
| @@ -137,17 +137,18 @@ static int tcp_write_timeout(struct sock *sk) | |||
| 137 | { | 137 | { |
| 138 | struct inet_connection_sock *icsk = inet_csk(sk); | 138 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 139 | int retry_until; | 139 | int retry_until; |
| 140 | bool do_reset; | ||
| 140 | 141 | ||
| 141 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { | 142 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { |
| 142 | if (icsk->icsk_retransmits) | 143 | if (icsk->icsk_retransmits) |
| 143 | dst_negative_advice(&sk->sk_dst_cache); | 144 | dst_negative_advice(&sk->sk_dst_cache, sk); |
| 144 | retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; | 145 | retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; |
| 145 | } else { | 146 | } else { |
| 146 | if (icsk->icsk_retransmits >= sysctl_tcp_retries1) { | 147 | if (retransmits_timed_out(sk, sysctl_tcp_retries1)) { |
| 147 | /* Black hole detection */ | 148 | /* Black hole detection */ |
| 148 | tcp_mtu_probing(icsk, sk); | 149 | tcp_mtu_probing(icsk, sk); |
| 149 | 150 | ||
| 150 | dst_negative_advice(&sk->sk_dst_cache); | 151 | dst_negative_advice(&sk->sk_dst_cache, sk); |
| 151 | } | 152 | } |
| 152 | 153 | ||
| 153 | retry_until = sysctl_tcp_retries2; | 154 | retry_until = sysctl_tcp_retries2; |
| @@ -155,13 +156,15 @@ static int tcp_write_timeout(struct sock *sk) | |||
| 155 | const int alive = (icsk->icsk_rto < TCP_RTO_MAX); | 156 | const int alive = (icsk->icsk_rto < TCP_RTO_MAX); |
| 156 | 157 | ||
| 157 | retry_until = tcp_orphan_retries(sk, alive); | 158 | retry_until = tcp_orphan_retries(sk, alive); |
| 159 | do_reset = alive || | ||
| 160 | !retransmits_timed_out(sk, retry_until); | ||
| 158 | 161 | ||
| 159 | if (tcp_out_of_resources(sk, alive || icsk->icsk_retransmits < retry_until)) | 162 | if (tcp_out_of_resources(sk, do_reset)) |
| 160 | return 1; | 163 | return 1; |
| 161 | } | 164 | } |
| 162 | } | 165 | } |
| 163 | 166 | ||
| 164 | if (icsk->icsk_retransmits >= retry_until) { | 167 | if (retransmits_timed_out(sk, retry_until)) { |
| 165 | /* Has it gone just too far? */ | 168 | /* Has it gone just too far? */ |
| 166 | tcp_write_err(sk); | 169 | tcp_write_err(sk); |
| 167 | return 1; | 170 | return 1; |
| @@ -279,7 +282,7 @@ static void tcp_probe_timer(struct sock *sk) | |||
| 279 | * The TCP retransmit timer. | 282 | * The TCP retransmit timer. |
| 280 | */ | 283 | */ |
| 281 | 284 | ||
| 282 | static void tcp_retransmit_timer(struct sock *sk) | 285 | void tcp_retransmit_timer(struct sock *sk) |
| 283 | { | 286 | { |
| 284 | struct tcp_sock *tp = tcp_sk(sk); | 287 | struct tcp_sock *tp = tcp_sk(sk); |
| 285 | struct inet_connection_sock *icsk = inet_csk(sk); | 288 | struct inet_connection_sock *icsk = inet_csk(sk); |
| @@ -300,15 +303,15 @@ static void tcp_retransmit_timer(struct sock *sk) | |||
| 300 | struct inet_sock *inet = inet_sk(sk); | 303 | struct inet_sock *inet = inet_sk(sk); |
| 301 | if (sk->sk_family == AF_INET) { | 304 | if (sk->sk_family == AF_INET) { |
| 302 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", | 305 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", |
| 303 | &inet->daddr, ntohs(inet->dport), | 306 | &inet->inet_daddr, ntohs(inet->inet_dport), |
| 304 | inet->num, tp->snd_una, tp->snd_nxt); | 307 | inet->inet_num, tp->snd_una, tp->snd_nxt); |
| 305 | } | 308 | } |
| 306 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 309 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 307 | else if (sk->sk_family == AF_INET6) { | 310 | else if (sk->sk_family == AF_INET6) { |
| 308 | struct ipv6_pinfo *np = inet6_sk(sk); | 311 | struct ipv6_pinfo *np = inet6_sk(sk); |
| 309 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", | 312 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", |
| 310 | &np->daddr, ntohs(inet->dport), | 313 | &np->daddr, ntohs(inet->inet_dport), |
| 311 | inet->num, tp->snd_una, tp->snd_nxt); | 314 | inet->inet_num, tp->snd_una, tp->snd_nxt); |
| 312 | } | 315 | } |
| 313 | #endif | 316 | #endif |
| 314 | #endif | 317 | #endif |
| @@ -385,7 +388,7 @@ static void tcp_retransmit_timer(struct sock *sk) | |||
| 385 | out_reset_timer: | 388 | out_reset_timer: |
| 386 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); | 389 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); |
| 387 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); | 390 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); |
| 388 | if (icsk->icsk_retransmits > sysctl_tcp_retries1) | 391 | if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1)) |
| 389 | __sk_dst_reset(sk); | 392 | __sk_dst_reset(sk); |
| 390 | 393 | ||
| 391 | out:; | 394 | out:; |
| @@ -499,8 +502,7 @@ static void tcp_keepalive_timer (unsigned long data) | |||
| 499 | elapsed = tcp_time_stamp - tp->rcv_tstamp; | 502 | elapsed = tcp_time_stamp - tp->rcv_tstamp; |
| 500 | 503 | ||
| 501 | if (elapsed >= keepalive_time_when(tp)) { | 504 | if (elapsed >= keepalive_time_when(tp)) { |
| 502 | if ((!tp->keepalive_probes && icsk->icsk_probes_out >= sysctl_tcp_keepalive_probes) || | 505 | if (icsk->icsk_probes_out >= keepalive_probes(tp)) { |
| 503 | (tp->keepalive_probes && icsk->icsk_probes_out >= tp->keepalive_probes)) { | ||
| 504 | tcp_send_active_reset(sk, GFP_ATOMIC); | 506 | tcp_send_active_reset(sk, GFP_ATOMIC); |
| 505 | tcp_write_err(sk); | 507 | tcp_write_err(sk); |
| 506 | goto out; | 508 | goto out; |
