summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_timer.c
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2011-07-06 23:44:21 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2011-07-06 23:44:21 +0000
commit68494a1c586f98ca697a91771fddff329f1dcf14 (patch)
treeadd29116d30508f173c5db57724b3e51943d22f7 /sys/netinet/tcp_timer.c
parenteec1e28e98046e35507e4a84c524322c3bce684c (diff)
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@
Diffstat (limited to 'sys/netinet/tcp_timer.c')
-rw-r--r--sys/netinet/tcp_timer.c6
1 files changed, 4 insertions, 2 deletions
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 <netinet/ip_icmp.h>
#include <netinet/tcp_seq.h>
+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))