All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damian Lukowski <damian@tvk.rwth-aachen.de>
To: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	Netdev <netdev@vger.kernel.org>,
	Frederic Leroy <fredo@starox.org>,
	David Miller <davem@davemloft.net>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Greg KH <gregkh@suse.de>
Subject: Re: [PATCHv2 2/2] tcp: Stalling connections: Fix timeout calculation routine
Date: Mon, 07 Dec 2009 13:27:42 +0100	[thread overview]
Message-ID: <op.u4kh8gosp498uc@nexus> (raw)
In-Reply-To: <alpine.DEB.2.00.0912071405200.7024@wel-95.cs.helsinki.fi>

Am 07.12.2009, 13:08 Uhr, schrieb Ilpo Järvinen  
<ilpo.jarvinen@helsinki.fi>:

> On Mon, 7 Dec 2009, Damian Lukowski wrote:
>
>> This patch fixes a problem in the TCP connection timeout calculation.
>> Currently, timeout decisions are made on the basis of the current
>> tcp_time_stamp and retrans_stamp, which is usually set at the first
>> retransmission.
>> However, if the retransmission fails in tcp_retransmit_skb(),
>> retrans_stamp is not updated and remains zero. This leads to wrong
>> decisions in retransmits_timed_out() if tcp_time_stamp is larger than
>> the specified timeout, which is very likely.
>> In this case, the TCP connection dies after the first attempted
>> (and unsuccessful) retransmission.
>>
>> With this patch, tcp_skb_cb->when is used instead, when retrans_stamp
>> is not available.
>>
>> This bug has been introduced together with retransmits_timed_out()
>> in 2.6.32, as the number of retransmissions has been used for timeout
>> decisions before.
>>
>> Thanks to Ilpo Järvinen for code suggestions and Frederic Leroy for
>> testing.
>>
>> Signed-off-by: Damian Lukowski <damian@tvk.rwth-aachen.de>
>> ---
>>  net/ipv4/tcp_timer.c |    9 ++++++++-
>>  1 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
>> index 5c5f739..a9d2891 100644
>> --- a/net/ipv4/tcp_timer.c
>> +++ b/net/ipv4/tcp_timer.c
>> @@ -140,10 +140,17 @@ static bool retransmits_timed_out(const 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(
>> +					(struct sock *)sk))->when;
>
> Grr, a cast....

I'm a little bit confused now (not the first time :)).
Without the cast, there are a lot of compiler warnings.
Also, I remember that I have specified const in the function signature
on purpose because of other warnings.
But now, it seems to work without const and no cast ...

>
>> +	else
>> +		start_ts = tcp_sk(sk)->retrans_stamp;
>> +
>>  	linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
>>
>>  	if (boundary <= linear_backoff_thresh)
>> @@ -152,7 +159,7 @@ static 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;
>>  }
>>
>>  /* A write timeout has occurred. Process the after effects. */
>>
>
> Also, in here it's more useful to provide the fix as the first patch  
> (1/2)
> since it's going to stable and those people don't want the move patch
> there.

Ok, I will patch the other way round, without the cast.

Damian

  reply	other threads:[~2009-12-07 12:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07  0:28 [PATCH] tcp: Fix for stalling connections Damian Lukowski
2009-12-07  0:32 ` Damian Lukowski
2009-12-07  6:15 ` Eric Dumazet
2009-12-07 11:17   ` Damian Lukowski
2009-12-07 11:22     ` David Miller
2009-12-07 11:41     ` [PATCHv2 0/2] tcp: Stalling connections Damian Lukowski
2009-12-07 11:41     ` [PATCHv2 1/2] tcp: Stalling connections: Move timeout calculation routine Damian Lukowski
2009-12-07 12:01       ` Frederic Leroy
2009-12-07 16:11         ` Damian Lukowski
2009-12-07 11:41     ` [PATCHv2 2/2] tcp: Stalling connections: Fix " Damian Lukowski
2009-12-07 12:08       ` Ilpo Järvinen
2009-12-07 12:27         ` Damian Lukowski [this message]
2009-12-07 12:32           ` Ilpo Järvinen
2009-12-07 16:06     ` [PATCHv3 0/2] tcp: Stalling connections Damian Lukowski
2009-12-07 16:06     ` [PATCHv3 1/2] tcp: Stalling connections: Fix timeout calculation routine Damian Lukowski
2009-12-07 18:50       ` Ilpo Järvinen
2009-12-07 19:09         ` Frederic Leroy
2009-12-10 13:24           ` TCP not retransmitting Ilpo Järvinen
2009-12-11 12:57             ` Frederic Leroy
2009-12-09  4:53         ` [PATCHv3 1/2] tcp: Stalling connections: Fix timeout calculation routine David Miller
2009-12-07 16:06     ` [PATCHv3 2/2] tcp: Stalling connections: Move " Damian Lukowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.u4kh8gosp498uc@nexus \
    --to=damian@tvk.rwth-aachen.de \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=fredo@starox.org \
    --cc=gregkh@suse.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.