Make tcp msl (max segment life) tunable via sysctl net.inet.tcp.msl.

Okayed by tls@.
This commit is contained in:
darran 2009-09-09 22:41:28 +00:00
parent 76a0c0e7d2
commit ddd44491c6
3 changed files with 21 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_input.c,v 1.298 2009/07/18 23:09:53 minskim Exp $ */
/* $NetBSD: tcp_input.c,v 1.299 2009/09/09 22:41:28 darran Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -145,7 +145,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.298 2009/07/18 23:09:53 minskim Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.299 2009/09/09 22:41:28 darran Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -242,6 +242,7 @@ int tcp_log_refused;
int tcp_do_autorcvbuf = 0;
int tcp_autorcvbuf_inc = 16 * 1024;
int tcp_autorcvbuf_max = 256 * 1024;
int tcp_msl = (TCPTV_MSL / PR_SLOWHZ);
static int tcp_rst_ppslim_count = 0;
static struct timeval tcp_rst_ppslim_last;
@ -2499,7 +2500,8 @@ after_listen:
if (ourfinisacked) {
tp->t_state = TCPS_TIME_WAIT;
tcp_canceltimers(tp);
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
TCP_TIMER_ARM(tp, TCPT_2MSL,
2 * PR_SLOWHZ * tcp_msl);
soisdisconnected(so);
}
break;
@ -2523,7 +2525,7 @@ after_listen:
* it and restart the finack timer.
*/
case TCPS_TIME_WAIT:
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * PR_SLOWHZ * tcp_msl);
goto dropafterack;
}
}
@ -2707,7 +2709,7 @@ dodata: /* XXX */
case TCPS_FIN_WAIT_2:
tp->t_state = TCPS_TIME_WAIT;
tcp_canceltimers(tp);
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * PR_SLOWHZ * tcp_msl);
soisdisconnected(so);
break;
@ -2715,7 +2717,7 @@ dodata: /* XXX */
* In TIME_WAIT state restart the 2 MSL time_wait timer.
*/
case TCPS_TIME_WAIT:
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * PR_SLOWHZ * tcp_msl);
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_usrreq.c,v 1.155 2009/06/07 16:20:29 rmind Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.156 2009/09/09 22:41:28 darran 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.155 2009/06/07 16:20:29 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.156 2009/09/09 22:41:28 darran Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -1687,6 +1687,12 @@ sysctl_net_inet_tcp_setup2(struct sysctllog **clog, int pf, const char *pfname,
SYSCTL_DESCR("Lower limit for TCP maximum segment size"),
NULL, 0, &tcp_minmss, 0,
CTL_NET, pf, IPPROTO_TCP, CTL_CREATE, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "msl",
SYSCTL_DESCR("Maximum Segment Life"),
NULL, 0, &tcp_msl, 0,
CTL_NET, pf, IPPROTO_TCP, TCPCTL_MSL, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "syn_cache_limit",

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_var.h,v 1.160 2009/05/27 17:41:03 pooka Exp $ */
/* $NetBSD: tcp_var.h,v 1.161 2009/09/09 22:41:28 darran Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -686,7 +686,8 @@ struct syn_cache_head {
#define TCPCTL_DEBUG 31 /* TCP debug sockets */
#define TCPCTL_DEBX 32 /* # of tcp debug sockets */
#define TCPCTL_DROP 33 /* drop tcp connection */
#define TCPCTL_MAXID 34
#define TCPCTL_MSL 34 /* Max Segment Life */
#define TCPCTL_MAXID 35
#define TCPCTL_NAMES { \
{ 0, 0 }, \
@ -723,6 +724,7 @@ struct syn_cache_head {
{ "debug", CTLTYPE_STRUCT }, \
{ "debx", CTLTYPE_INT }, \
{ "drop", CTLTYPE_STRUCT }, \
{ "msl", CTLTYPE_INT }, \
}
#ifdef _KERNEL
@ -734,6 +736,7 @@ extern int tcp_do_win_scale; /* RFC1323 window scaling enabled/disabled? */
extern int tcp_do_timestamps; /* RFC1323 timestamps enabled/disabled? */
extern int tcp_mssdflt; /* default seg size */
extern int tcp_minmss; /* minimal seg size */
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_mss_ifmtu; /* take MSS from interface, not in_maxmtu */