Add a sysctl (net.inet.tcp.always_keepalive: 0) that when set will force
keepalive on all tcp sessions. Setsockopt(2) cannot override this setting. Maybe another one is needed that just changes the default for SO_KEEPALIVE ? Requested by: Joe Greco <jgreco@brasil.moneng.mei.com>
This commit is contained in:
parent
816a3d836e
commit
34be9bf3ce
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15039
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tcp_timer.c 8.2 (Berkeley) 5/24/95
|
||||
* $Id: tcp_timer.c,v 1.13 1996/01/04 21:34:21 olah Exp $
|
||||
* $Id: tcp_timer.c,v 1.14 1996/03/11 15:13:35 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef TUBA_INCLUDE
|
||||
@ -72,6 +72,10 @@ static int tcp_keepintvl = TCPTV_KEEPINTVL;
|
||||
SYSCTL_INT(_net_inet_tcp, TCPCTL_KEEPINTVL, keepintvl,
|
||||
CTLFLAG_RW, &tcp_keepintvl , 0, "");
|
||||
|
||||
static int always_keepalive = 0;
|
||||
SYSCTL_INT(_net_inet_tcp, OID_AUTO, always_keepalive,
|
||||
CTLFLAG_RW, &always_keepalive , 0, "");
|
||||
|
||||
static int tcp_keepcnt = TCPTV_KEEPCNT;
|
||||
/* max idle probes */
|
||||
static int tcp_maxpersistidle = TCPTV_KEEP_IDLE;
|
||||
@ -314,7 +318,8 @@ tcp_timers(tp, timer)
|
||||
tcpstat.tcps_keeptimeo++;
|
||||
if (tp->t_state < TCPS_ESTABLISHED)
|
||||
goto dropit;
|
||||
if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE &&
|
||||
if ((always_keepalive ||
|
||||
tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) &&
|
||||
tp->t_state <= TCPS_CLOSE_WAIT) {
|
||||
if (tp->t_idle >= tcp_keepidle + tcp_maxidle)
|
||||
goto dropit;
|
||||
|
Loading…
Reference in New Issue
Block a user