Module Name:    src
Committed By:   christos
Date:           Wed Apr 10 00:16:04 UTC 2013

Modified Files:
        src/sys/netinet: tcp_subr.c tcp_usrreq.c tcp_var.h

Log Message:
Limit the tcp initial window setting to 10, leaving it by default to 4
and simplifying the code in process. Per draft-ietf-initcwnd-08.txt.


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.165 -r1.166 src/sys/netinet/tcp_usrreq.c
cvs rdiff -u -r1.169 -r1.170 src/sys/netinet/tcp_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.248 src/sys/netinet/tcp_subr.c:1.249
--- src/sys/netinet/tcp_subr.c:1.248	Fri Sep  7 22:58:13 2012
+++ src/sys/netinet/tcp_subr.c	Tue Apr  9 20:16:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.248 2012/09/08 02:58:13 msaitoh Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.249 2013/04/10 00:16:03 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.248 2012/09/08 02:58:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.249 2013/04/10 00:16:03 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -173,11 +173,28 @@ int	tcp_do_timestamps = 1;	/* RFC1323 ti
 int	tcp_ack_on_push = 0;	/* set to enable immediate ACK-on-PUSH */
 int	tcp_do_ecn = 0;		/* Explicit Congestion Notification */
 #ifndef TCP_INIT_WIN
-#define	TCP_INIT_WIN	0	/* initial slow start window */
+#define	TCP_INIT_WIN	4	/* initial slow start window */
 #endif
 #ifndef TCP_INIT_WIN_LOCAL
 #define	TCP_INIT_WIN_LOCAL 4	/* initial slow start window for local nets */
 #endif
+/*
+ * Up to 5 we scale linearly, to reach 3 * 1460; then (iw) * 1460.
+ * This is to simulate current behavior for iw == 4
+ */
+int tcp_init_win_max[] = {
+	 1 * 1460,
+	 1 * 1460,
+	 2 * 1460,
+	 2 * 1460,
+	 3 * 1460,
+	 5 * 1460,
+	 6 * 1460,
+	 7 * 1460,
+	 8 * 1460,
+	 9 * 1460,
+	10 * 1460
+};
 int	tcp_init_win = TCP_INIT_WIN;
 int	tcp_init_win_local = TCP_INIT_WIN_LOCAL;
 int	tcp_mss_ifmtu = 0;

Index: src/sys/netinet/tcp_usrreq.c
diff -u src/sys/netinet/tcp_usrreq.c:1.165 src/sys/netinet/tcp_usrreq.c:1.166
--- src/sys/netinet/tcp_usrreq.c:1.165	Sat Jun  2 17:36:47 2012
+++ src/sys/netinet/tcp_usrreq.c	Tue Apr  9 20:16:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_usrreq.c,v 1.165 2012/06/02 21:36:47 dsl Exp $	*/
+/*	$NetBSD: tcp_usrreq.c,v 1.166 2013/04/10 00:16:03 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.165 2012/06/02 21:36:47 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.166 2013/04/10 00:16:03 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -1600,6 +1600,27 @@ sysctl_tcp_congctl(SYSCTLFN_ARGS)
 }
 
 static int
+sysctl_tcp_init_win(SYSCTLFN_ARGS)
+{
+	int error;
+	u_int iw;
+	struct sysctlnode node;
+
+	iw = *(u_int *)rnode->sysctl_data;
+	node = *rnode;
+	node.sysctl_data = &iw;
+	node.sysctl_size = sizeof(iw);
+	error = sysctl_lookup(SYSCTLFN_CALL(&node));
+	if (error || newp == NULL)
+		return error;
+
+	if (iw >= __arraycount(tcp_init_win_max))
+		return EINVAL;
+	*(u_int *)rnode->sysctl_data = iw;
+	return 0;
+}
+
+static int
 sysctl_tcp_keep(SYSCTLFN_ARGS)
 {  
 	int error;
@@ -1732,7 +1753,7 @@ sysctl_net_inet_tcp_setup2(struct sysctl
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 		       CTLTYPE_INT, "init_win",
 		       SYSCTL_DESCR("Initial TCP congestion window"),
-		       NULL, 0, &tcp_init_win, 0,
+		       sysctl_tcp_init_win, 0, &tcp_init_win, 0,
 		       CTL_NET, pf, IPPROTO_TCP, TCPCTL_INIT_WIN, CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
@@ -1861,7 +1882,7 @@ sysctl_net_inet_tcp_setup2(struct sysctl
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 		       CTLTYPE_INT, "init_win_local",
 		       SYSCTL_DESCR("Initial TCP window size (in segments)"),
-		       NULL, 0, &tcp_init_win_local, 0,
+		       sysctl_tcp_init_win, 0, &tcp_init_win_local, 0,
 		       CTL_NET, pf, IPPROTO_TCP, TCPCTL_INIT_WIN_LOCAL,
 		       CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,

Index: src/sys/netinet/tcp_var.h
diff -u src/sys/netinet/tcp_var.h:1.169 src/sys/netinet/tcp_var.h:1.170
--- src/sys/netinet/tcp_var.h:1.169	Thu Feb  2 14:43:08 2012
+++ src/sys/netinet/tcp_var.h	Tue Apr  9 20:16:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_var.h,v 1.169 2012/02/02 19:43:08 tls Exp $	*/
+/*	$NetBSD: tcp_var.h,v 1.170 2013/04/10 00:16:04 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -613,8 +613,7 @@ struct syn_cache_head {
  * Compute the initial window for slow start.
  */
 #define	TCP_INITIAL_WINDOW(iw, segsz) \
-	(((iw) == 0) ? (min(4 * (segsz), max(2 * (segsz), 4380))) : \
-	 ((segsz) * (iw)))
+	min((iw) * (segsz), max(2 * (segsz), tcp_init_win_max[(iw)]))
 
 /*
  * TCP statistics.
@@ -797,6 +796,7 @@ extern	int tcp_minmss;		/* minimal seg s
 extern  int tcp_msl;		/* max segment life */
 extern	int tcp_init_win;	/* initial window */
 extern	int tcp_init_win_local;	/* initial window for local nets */
+extern	int tcp_init_win_max[11];/* max sizes for values of tcp_init_win_* */
 extern	int tcp_mss_ifmtu;	/* take MSS from interface, not in_maxmtu */
 extern	int tcp_compat_42;	/* work around ancient broken TCP peers */
 extern	int tcp_cwm;		/* enable Congestion Window Monitoring */

Reply via email to