netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: configurable tcp timewait timeout sysctl kernel knob ?
@ 2013-07-19 15:59 Vincent Li
  2013-07-19 17:42 ` Hannes Frederic Sowa
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Li @ 2013-07-19 15:59 UTC (permalink / raw)
  To: netdev

Hi,

there is sysctl tcp_fin_timeout to tune FIN_WAIT2 timeout, I couldn't
find a sysctl to tune TIME_WAIT timeout and it is hard coded to 60
seconds, we have a situation we need to either reduce the timewait
timeout value or recycle the timewait socket that is to use
tcp_tw_recycle and tcp_tw_reuse, is a sysctl to tune timewait value
good idea or bad idea that no one bothered to write one?

I have  a dirty hack patch to do that, but I think it may be  broken
to screw something I couldn't think of.

diff --git a/include/net/tcp.h b/include/net/tcp.h
index d198005..d1df673 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -245,6 +245,7 @@ extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
 extern int sysctl_tcp_fin_timeout;
+extern int sysctl_tcp_timewait_timeout;
 extern int sysctl_tcp_keepalive_time;
 extern int sysctl_tcp_keepalive_probes;
 extern int sysctl_tcp_keepalive_intvl;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index b2c123c..15a0056 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -412,6 +412,13 @@ static struct ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec_jiffies,
        },
+       {
+               .procname       = "tcp_timewait_timeout",
+               .data           = &sysctl_tcp_timewait_timeout,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_jiffies,
+       },
 #ifdef CONFIG_SYN_COOKIES
        {
                .procname       = "tcp_syncookies",
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 46ed9af..6df2a9c 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -282,6 +282,7 @@
 #include <net/ll_poll.h>

 int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
+int sysctl_tcp_timewait_timeout __read_mostly = TCP_TIMEWAIT_LEN;

 struct percpu_counter tcp_orphan_count;
 EXPORT_SYMBOL_GPL(tcp_orphan_count);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index ab1c086..9c2befc 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -332,6 +332,10 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)

                if (recycle_ok) {
                        tw->tw_timeout = rto;
+               } else if (sysctl_tcp_timewait_timeout) {
+                       tw->tw_timeout = sysctl_tcp_timewait_timeout;
+                       if (state == TCP_TIME_WAIT)
+                               timeo = sysctl_tcp_timewait_timeout;
                } else {
                        tw->tw_timeout = TCP_TIMEWAIT_LEN;
                        if (state == TCP_TIME_WAIT)

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

* Re: RFC: configurable tcp timewait timeout sysctl kernel knob ?
  2013-07-19 15:59 RFC: configurable tcp timewait timeout sysctl kernel knob ? Vincent Li
@ 2013-07-19 17:42 ` Hannes Frederic Sowa
  0 siblings, 0 replies; 2+ messages in thread
From: Hannes Frederic Sowa @ 2013-07-19 17:42 UTC (permalink / raw)
  To: Vincent Li; +Cc: netdev

On Fri, Jul 19, 2013 at 08:59:54AM -0700, Vincent Li wrote:
> there is sysctl tcp_fin_timeout to tune FIN_WAIT2 timeout, I couldn't
> find a sysctl to tune TIME_WAIT timeout and it is hard coded to 60
> seconds, we have a situation we need to either reduce the timewait
> timeout value or recycle the timewait socket that is to use
> tcp_tw_recycle and tcp_tw_reuse, is a sysctl to tune timewait value
> good idea or bad idea that no one bothered to write one?
> 
> I have  a dirty hack patch to do that, but I think it may be  broken
> to screw something I couldn't think of.

This topic pops up from time to time. Until now David Miller (rightfully)
rejected such a patch: <http://thread.gmane.org/gmane.linux.network/244411/>

Greetings,

  Hannes

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

end of thread, other threads:[~2013-07-19 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 15:59 RFC: configurable tcp timewait timeout sysctl kernel knob ? Vincent Li
2013-07-19 17:42 ` Hannes Frederic Sowa

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).