diff options
author | David S. Miller <davem@davemloft.net> | 2010-10-04 14:56:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-04 14:56:38 -0400 |
commit | 21a180cda012e1f93e362dd4a9b0bfd3d8c92940 (patch) | |
tree | 0e0d10baa3fdcd8ffbc6881076ff1695808dad9d /net/ipv4/tcp_timer.c | |
parent | c7d4426a98a5f6654cd0b4b33d9dab2e77192c18 (diff) | |
parent | 51e97a12bef19b7e43199fc153cf9bd5f2140362 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts:
net/ipv4/Kconfig
net/ipv4/tcp_timer.c
Diffstat (limited to 'net/ipv4/tcp_timer.c')
-rw-r--r-- | net/ipv4/tcp_timer.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index baea4a129022..f3c8c6c019ae 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -135,13 +135,16 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) | |||
135 | 135 | ||
136 | /* This function calculates a "timeout" which is equivalent to the timeout of a | 136 | /* This function calculates a "timeout" which is equivalent to the timeout of a |
137 | * TCP connection after "boundary" unsuccessful, exponentially backed-off | 137 | * TCP connection after "boundary" unsuccessful, exponentially backed-off |
138 | * retransmissions with an initial RTO of TCP_RTO_MIN. | 138 | * retransmissions with an initial RTO of TCP_RTO_MIN or TCP_TIMEOUT_INIT if |
139 | * syn_set flag is set. | ||
139 | */ | 140 | */ |
140 | static bool retransmits_timed_out(struct sock *sk, | 141 | static bool retransmits_timed_out(struct sock *sk, |
141 | unsigned int boundary, | 142 | unsigned int boundary, |
142 | unsigned int timeout) | 143 | unsigned int timeout, |
144 | bool syn_set) | ||
143 | { | 145 | { |
144 | unsigned int linear_backoff_thresh, start_ts; | 146 | unsigned int linear_backoff_thresh, start_ts; |
147 | unsigned int rto_base = syn_set ? TCP_TIMEOUT_INIT : TCP_RTO_MIN; | ||
145 | 148 | ||
146 | if (!inet_csk(sk)->icsk_retransmits) | 149 | if (!inet_csk(sk)->icsk_retransmits) |
147 | return false; | 150 | return false; |
@@ -152,12 +155,12 @@ static bool retransmits_timed_out(struct sock *sk, | |||
152 | start_ts = tcp_sk(sk)->retrans_stamp; | 155 | start_ts = tcp_sk(sk)->retrans_stamp; |
153 | 156 | ||
154 | if (likely(timeout == 0)) { | 157 | if (likely(timeout == 0)) { |
155 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); | 158 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base); |
156 | 159 | ||
157 | if (boundary <= linear_backoff_thresh) | 160 | if (boundary <= linear_backoff_thresh) |
158 | timeout = ((2 << boundary) - 1) * TCP_RTO_MIN; | 161 | timeout = ((2 << boundary) - 1) * rto_base; |
159 | else | 162 | else |
160 | timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN + | 163 | timeout = ((2 << linear_backoff_thresh) - 1) * rto_base + |
161 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; | 164 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; |
162 | } | 165 | } |
163 | return (tcp_time_stamp - start_ts) >= timeout; | 166 | return (tcp_time_stamp - start_ts) >= timeout; |
@@ -168,14 +171,15 @@ static int tcp_write_timeout(struct sock *sk) | |||
168 | { | 171 | { |
169 | struct inet_connection_sock *icsk = inet_csk(sk); | 172 | struct inet_connection_sock *icsk = inet_csk(sk); |
170 | int retry_until; | 173 | int retry_until; |
171 | bool do_reset; | 174 | bool do_reset, syn_set = 0; |
172 | 175 | ||
173 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { | 176 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { |
174 | if (icsk->icsk_retransmits) | 177 | if (icsk->icsk_retransmits) |
175 | dst_negative_advice(sk); | 178 | dst_negative_advice(sk); |
176 | retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; | 179 | retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; |
180 | syn_set = 1; | ||
177 | } else { | 181 | } else { |
178 | if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0)) { | 182 | if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0, 0)) { |
179 | /* Black hole detection */ | 183 | /* Black hole detection */ |
180 | tcp_mtu_probing(icsk, sk); | 184 | tcp_mtu_probing(icsk, sk); |
181 | 185 | ||
@@ -188,7 +192,7 @@ static int tcp_write_timeout(struct sock *sk) | |||
188 | 192 | ||
189 | retry_until = tcp_orphan_retries(sk, alive); | 193 | retry_until = tcp_orphan_retries(sk, alive); |
190 | do_reset = alive || | 194 | do_reset = alive || |
191 | !retransmits_timed_out(sk, retry_until, 0); | 195 | !retransmits_timed_out(sk, retry_until, 0, 0); |
192 | 196 | ||
193 | if (tcp_out_of_resources(sk, do_reset)) | 197 | if (tcp_out_of_resources(sk, do_reset)) |
194 | return 1; | 198 | return 1; |
@@ -196,8 +200,7 @@ static int tcp_write_timeout(struct sock *sk) | |||
196 | } | 200 | } |
197 | 201 | ||
198 | if (retransmits_timed_out(sk, retry_until, | 202 | if (retransmits_timed_out(sk, retry_until, |
199 | (1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV) ? 0 : | 203 | syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) { |
200 | icsk->icsk_user_timeout)) { | ||
201 | /* Has it gone just too far? */ | 204 | /* Has it gone just too far? */ |
202 | tcp_write_err(sk); | 205 | tcp_write_err(sk); |
203 | return 1; | 206 | return 1; |
@@ -439,7 +442,7 @@ out_reset_timer: | |||
439 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); | 442 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); |
440 | } | 443 | } |
441 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); | 444 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); |
442 | if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1, 0)) | 445 | if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1, 0, 0)) |
443 | __sk_dst_reset(sk); | 446 | __sk_dst_reset(sk); |
444 | 447 | ||
445 | out:; | 448 | out:; |