From 68494a1c586f98ca697a91771fddff329f1dcf14 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Wed, 6 Jul 2011 23:44:21 +0000 Subject: Add sysctl net.inet.tcp.always_keepalive, when this is set the system behaves as if SO_KEEPALIVE was set on all TCP sockets, forcing keepalives to be sent every net.inet.tcp.keepidle half-seconds. In conjunction with a keepidle value greatly reduced from the default, this can be useful for keeping sessions open if you are stuck on a network with short NAT or firewall timeouts. Feedback from various people, ok henning@ claudio@ --- sys/netinet/tcp_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys/netinet/tcp_timer.c') diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index a1dd72aae79..7f2511d751a 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.45 2010/07/03 04:44:51 guenther Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.46 2011/07/06 23:44:20 sthen Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -55,6 +55,7 @@ #include #include +int tcp_always_keepalive; int tcp_keepidle; int tcp_keepintvl; int tcp_maxpersistidle; /* max idle time in persist */ @@ -435,7 +436,8 @@ tcp_timer_keep(void *arg) tcpstat.tcps_keeptimeo++; if (TCPS_HAVEESTABLISHED(tp->t_state) == 0) goto dropit; - if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE && + if ((tcp_always_keepalive || + tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) && tp->t_state <= TCPS_CLOSING) { if ((tcp_maxidle > 0) && ((tcp_now - tp->t_rcvtime) >= tcp_keepidle + tcp_maxidle)) -- cgit v1.2.3