netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcp: Fix for stalling connections
@ 2009-12-07  0:28 Damian Lukowski
  2009-12-07  0:32 ` Damian Lukowski
  2009-12-07  6:15 ` Eric Dumazet
  0 siblings, 2 replies; 21+ messages in thread
From: Damian Lukowski @ 2009-12-07  0:28 UTC (permalink / raw)
  To: Netdev
  Cc: Ilpo Järvinen, Frederic Leroy, David Miller, Eric Dumazet,
	Herbert Xu, Greg KH

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.

Thanks to Ilpo Järvinen for code suggestions.

Signed-off-by: Damian Lukowski <damian@tvk.rwth-aachen.de>
---
 include/net/tcp.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 03a49c7..46f06e0 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1267,10 +1267,17 @@ static inline 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;
+	else
+		start_ts = tcp_sk(sk)->retrans_stamp;
+
 	linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN);
 
 	if (boundary <= linear_backoff_thresh)
@@ -1279,7 +1286,7 @@ static inline 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;
 }
 
 static inline struct sk_buff *tcp_send_head(struct sock *sk)
-- 
1.6.4.4


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2009-12-11 12:57 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).