Subject: kern/3618: [dM] keepalive time not run-time configurable
To: None <gnats-bugs@gnats.netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 05/14/1997 10:09:49
>Number:         3618
>Category:       kern
>Synopsis:       [dM] keepalive time not run-time configurable
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed May 14 07:20:01 1997
>Last-Modified:
>Originator:     der Mouse
>Organization:
	Dis-
>Release:        1.2_BETA
>Environment:
	Any (noticed on a "SUNW,Sun 4/75")
>Description:
	On a TCP connection with keepalives enabled, no keepalives are
	sent until two hours of idle time has elapsed.  This is the
	recommended minimum time for keepalives in RFC1122, but that
	RFC also says that the time "MUST be configurable".  Depending
	on your point of view, editing tcp_timer.h and rebuilding the
	kernel may or may not count as "configurable", but it certainly
	is suboptimal.

	This patch adds sysctl variables net.inet.tcp.keepidle and
	net.inet.tcp.keepintvl, and because the kernel variables are in
	PR_SLOWHZ units, also net.inet.tcp.slowhz (this last being
	read-only).  These times really ought to be configurable on a
	per-connection basis, but per-host was good enough for what I
	wanted and was significantly easier.
>How-To-Repeat:
	Try to get keepalives sent after less than two hours of idle
	time on a connection.
>Fix:
	I'm fairly sure I've missed some things here, notably additions
	to the relevant manpages.  Once I have those ready I'll add
	them to this PR (unless someone else does them first).  I think
	I have them, but not where I can easily get at them now.

	The line numbers in these patches may be a little off; I
	haven't brought them up to date with respect to -current yet.

--- OLD/sys/netinet/tcp_var.h	Thu Jan  1 00:00:00 1970
+++ NEW/sys/netinet/tcp_var.h	Thu Jan  1 00:00:00 1970
@@ -230,11 +231,17 @@
  */
 			/* enable/disable RFC1323 timestamps/scaling */
 #define	TCPCTL_RFC1323		1
-#define	TCPCTL_MAXID		2
+#define TCPCTL_KEEPIDLE		2
+#define TCPCTL_KEEPINTVL	3
+#define TCPCTL_SLOWHZ		4
+#define	TCPCTL_MAXID		5
 
 #define	TCPCTL_NAMES { \
 	{ 0, 0 }, \
 	{ "rfc1323",	CTLTYPE_INT }, \
+	{ "keepidle",	CTLTYPE_INT }, \
+	{ "keepintvl",	CTLTYPE_INT }, \
+	{ "slowhz",	CTLTYPE_INT }, \
 }
 
 #ifdef _KERNEL
--- OLD/sys/netinet/tcp_usrreq.c	Thu Jan  1 00:00:00 1970
+++ NEW/sys/netinet/tcp_usrreq.c	Thu Jan  1 00:00:00 1970
@@ -562,6 +562,17 @@
 		return (sysctl_int(oldp, oldlenp, newp, newlen,
 		    &tcp_do_rfc1323));
 
+	case TCPCTL_KEEPIDLE:
+		return (sysctl_int(oldp, oldlenp, newp, newlen,
+		    &tcp_keepidle));
+
+	case TCPCTL_KEEPINTVL:
+		return (sysctl_int(oldp, oldlenp, newp, newlen,
+		    &tcp_keepintvl));
+
+	case TCPCTL_SLOWHZ:
+		return (sysctl_rdint(oldp, oldlenp, newp, PR_SLOWHZ));
+
 	default:
 		return (ENOPROTOOPT);
 	}

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
>Audit-Trail:
>Unformatted: