Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Apr 1996 11:17:03 -0600 (CST)
From:      Joe Greco <jgreco@brasil.moneng.mei.com>
To:        phk@critter.tfs.com (Poul-Henning Kamp)
Cc:        hackers@freebsd.org
Subject:   Re: SO_KEEPALIVE - New feature patch enclosed.
Message-ID:  <199604031717.LAA00364@brasil.moneng.mei.com>
In-Reply-To: <1208.828464800@critter.tfs.com> from "Poul-Henning Kamp" at Apr 2, 96 05:06:40 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > > > Question, stupid, nonetheless a question:
> > > > 
> > > > Does anybody see any advantage to allowing for a way to set a systemwide
> > > > SO_KEEPALIVE default of ON?
> > > 
> > > make a sysctl variable for this.  It's really easy.
> > 
> > Yeah, well, that's nice :-)  I wanted to know if there would be any general
> > interest.  I'm not a kernel hacker so it would take a bit of expenditure of
> > effort on my part to figure all that out, yadda yadda yadda, and if it was
> > something that would not make it into -current, I would opt for a quick and
> > dirty hack.
> > 
> > Can anyone suggest an appropriate name for such a variable?
> 
> 	sysctl.inet.tcp.keepalive 
> taking a boolean argument.

actually I made it take an integer argument..  

It seems to work for me.  I warn you now, though, I'm no kernel hacker.

... Joe

-------------------------------------------------------------------------------
Joe Greco - Systems Administrator			      jgreco@ns.sol.net
Solaria Public Access UNIX - Milwaukee, WI			   414/546-7968



*** /usr/src/sys/netinet/tcp_var.h.fcs	Sat Jul 29 18:16:53 1995
--- /usr/src/sys/netinet/tcp_var.h	Tue Apr  2 22:41:01 1996
***************
*** 300,306 ****
  #define	TCPCTL_KEEPINTVL	7	/* interval to send keepalives */
  #define	TCPCTL_SENDSPACE	8	/* send buffer space */
  #define	TCPCTL_RECVSPACE	9	/* receive buffer space */
! #define TCPCTL_MAXID		10
  
  #define TCPCTL_NAMES { \
  	{ 0, 0 }, \
--- 300,307 ----
  #define	TCPCTL_KEEPINTVL	7	/* interval to send keepalives */
  #define	TCPCTL_SENDSPACE	8	/* send buffer space */
  #define	TCPCTL_RECVSPACE	9	/* receive buffer space */
! #define	TCPCTL_DO_KEEPALIVE	10	/* do keepalive's by default */
! #define TCPCTL_MAXID		11
  
  #define TCPCTL_NAMES { \
  	{ 0, 0 }, \
***************
*** 313,318 ****
--- 314,320 ----
  	{ "keepintvl", CTLTYPE_INT }, \
  	{ "sendspace", CTLTYPE_INT }, \
  	{ "recvspace", CTLTYPE_INT }, \
+ 	{ "keepalive", CTLTYPE_INT }, \
  }
  
  #ifdef KERNEL
***************
*** 325,330 ****
--- 327,333 ----
  extern	u_long tcp_now;		/* for RFC 1323 timestamps */
  extern	int tcp_rttdflt;	/* XXX */
  extern  u_short tcp_lastport;	/* last assigned port */
+ extern	int tcp_do_keepalive;	/* XXX */
  
  int	 tcp_attach __P((struct socket *));
  void	 tcp_canceltimers __P((struct tcpcb *));
*** /usr/src/sys/netinet/tcp_usrreq.c.fcs	Fri Nov  3 01:53:59 1995
--- /usr/src/sys/netinet/tcp_usrreq.c	Wed Apr  3 07:59:21 1996
***************
*** 576,581 ****
--- 576,588 ----
  u_long	tcp_recvspace = 1024*16;
  
  /*
+  * tcp_do_keepalive specifies that all tcp sockets should be created with
+  * the SO_KEEPALIVE flag set, for environments where connections frequently
+  * go into limbo and hang forever.  Settable via sysctl..
+  */
+ int	tcp_do_keepalive = 0;
+ 
+ /*
   * Attach TCP protocol to socket, allocating
   * internet protocol control block, tcp control block,
   * bufer space, and entering LISTEN state if to accept connections.
***************
*** 607,612 ****
--- 614,622 ----
  		return (ENOBUFS);
  	}
  	tp->t_state = TCPS_CLOSED;
+ 
+ 	if (tcp_do_keepalive)
+ 		so->so_options |= SO_KEEPALIVE;	/* wrong place for this? */
  	return (0);
  }
  
***************
*** 726,731 ****
--- 736,744 ----
  	case TCPCTL_RECVSPACE:
  		return (sysctl_int(oldp, oldlenp, newp, newlen,
  				   (int *)&tcp_recvspace)); /* XXX */
+ 	case TCPCTL_DO_KEEPALIVE:
+ 		return (sysctl_int(oldp, oldlenp, newp, newlen,
+ 		    &tcp_do_keepalive));
  	default:
  		return (ENOPROTOOPT);
  	}




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604031717.LAA00364>