Commit 4d22f7d3 authored by Damian Lukowski's avatar Damian Lukowski Committed by David S. Miller

net-2.6: SYN retransmits: Add new parameter to retransmits_timed_out()

Fixes kernel Bugzilla Bug 18952

This patch adds a syn_set parameter to the retransmits_timed_out()
routine and updates its callers. If not set, TCP_RTO_MIN is taken
as the calculation basis as before. If set, TCP_TIMEOUT_INIT is
used instead, so that sysctl_syn_retries represents the actual
amount of SYN retransmissions in case no SYNACKs are received when
establishing a new connection.
Signed-off-by: default avatarDamian Lukowski <damian@tvk.rwth-aachen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 01db403c
...@@ -135,13 +135,16 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) ...@@ -135,13 +135,16 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
/* This function calculates a "timeout" which is equivalent to the timeout of a /* This function calculates a "timeout" which is equivalent to the timeout of a
* TCP connection after "boundary" unsuccessful, exponentially backed-off * TCP connection after "boundary" unsuccessful, exponentially backed-off
* retransmissions with an initial RTO of TCP_RTO_MIN. * retransmissions with an initial RTO of TCP_RTO_MIN or TCP_TIMEOUT_INIT if
* syn_set flag is set.
*/ */
static bool retransmits_timed_out(struct sock *sk, static bool retransmits_timed_out(struct sock *sk,
unsigned int boundary) unsigned int boundary,
bool syn_set)
{ {
unsigned int timeout, linear_backoff_thresh; unsigned int timeout, linear_backoff_thresh;
unsigned int start_ts; unsigned int start_ts;
unsigned int rto_base = syn_set ? TCP_TIMEOUT_INIT : TCP_RTO_MIN;
if (!inet_csk(sk)->icsk_retransmits) if (!inet_csk(sk)->icsk_retransmits)
return false; return false;
...@@ -151,12 +154,12 @@ static bool retransmits_timed_out(struct sock *sk, ...@@ -151,12 +154,12 @@ static bool retransmits_timed_out(struct sock *sk,
else else
start_ts = tcp_sk(sk)->retrans_stamp; start_ts = tcp_sk(sk)->retrans_stamp;
linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base);
if (boundary <= linear_backoff_thresh) if (boundary <= linear_backoff_thresh)
timeout = ((2 << boundary) - 1) * TCP_RTO_MIN; timeout = ((2 << boundary) - 1) * rto_base;
else else
timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN + timeout = ((2 << linear_backoff_thresh) - 1) * rto_base +
(boundary - linear_backoff_thresh) * TCP_RTO_MAX; (boundary - linear_backoff_thresh) * TCP_RTO_MAX;
return (tcp_time_stamp - start_ts) >= timeout; return (tcp_time_stamp - start_ts) >= timeout;
...@@ -167,14 +170,15 @@ static int tcp_write_timeout(struct sock *sk) ...@@ -167,14 +170,15 @@ static int tcp_write_timeout(struct sock *sk)
{ {
struct inet_connection_sock *icsk = inet_csk(sk); struct inet_connection_sock *icsk = inet_csk(sk);
int retry_until; int retry_until;
bool do_reset; bool do_reset, syn_set = 0;
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
if (icsk->icsk_retransmits) if (icsk->icsk_retransmits)
dst_negative_advice(sk); dst_negative_advice(sk);
retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries;
syn_set = 1;
} else { } else {
if (retransmits_timed_out(sk, sysctl_tcp_retries1)) { if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0)) {
/* Black hole detection */ /* Black hole detection */
tcp_mtu_probing(icsk, sk); tcp_mtu_probing(icsk, sk);
...@@ -187,14 +191,14 @@ static int tcp_write_timeout(struct sock *sk) ...@@ -187,14 +191,14 @@ static int tcp_write_timeout(struct sock *sk)
retry_until = tcp_orphan_retries(sk, alive); retry_until = tcp_orphan_retries(sk, alive);
do_reset = alive || do_reset = alive ||
!retransmits_timed_out(sk, retry_until); !retransmits_timed_out(sk, retry_until, 0);
if (tcp_out_of_resources(sk, do_reset)) if (tcp_out_of_resources(sk, do_reset))
return 1; return 1;
} }
} }
if (retransmits_timed_out(sk, retry_until)) { if (retransmits_timed_out(sk, retry_until, syn_set)) {
/* Has it gone just too far? */ /* Has it gone just too far? */
tcp_write_err(sk); tcp_write_err(sk);
return 1; return 1;
...@@ -436,7 +440,7 @@ void tcp_retransmit_timer(struct sock *sk) ...@@ -436,7 +440,7 @@ void tcp_retransmit_timer(struct sock *sk)
icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
} }
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX);
if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1)) if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1, 0))
__sk_dst_reset(sk); __sk_dst_reset(sk);
out:; out:;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment