From: tholo Date: Thu, 12 Sep 1996 06:19:56 +0000 (+0000) Subject: TCP Persist handling; from 4.4BSD Lite2 (via NetBSD PR 2335) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=db011c5bc0920cb435c571d01c766f4612755593;p=openbsd TCP Persist handling; from 4.4BSD Lite2 (via NetBSD PR 2335) --- diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 600f6bad8d5..d4192defcd5 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.3 1996/03/14 08:06:57 tholo Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.4 1996/09/12 06:19:56 tholo Exp $ */ /* $NetBSD: tcp_output.c,v 1.14 1996/02/13 23:43:53 christos Exp $ */ /* @@ -154,15 +154,18 @@ again: * but we haven't been called to retransmit, * len will be -1. Otherwise, window shrank * after we sent into it. If window shrank to 0, - * cancel pending retransmit and pull snd_nxt - * back to (closed) window. We will enter persist - * state below. If the window didn't close completely, - * just wait for an ACK. + * calcel pending retransmit, pull snd_nxt back + * to (closed) window, and set the persist timer + * if it isn't already running. If the window + * didn't close completely, just wait for an ACK. */ len = 0; if (win == 0) { tp->t_timer[TCPT_REXMT] = 0; + tp->t_rxtshift = 0; tp->snd_nxt = tp->snd_una; + if (tp->t_timer[TCPT_PERSIST] == 0) + tcp_setpersist(tp); } } if (len > tp->t_maxseg) { diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index dd075c0d120..14e8d42ca7b 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.5 1996/07/29 22:01:51 niklas Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.6 1996/09/12 06:19:57 tholo Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -63,6 +63,7 @@ int tcp_keepidle = TCPTV_KEEP_IDLE; int tcp_keepintvl = TCPTV_KEEPINTVL; +int tcp_maxpersistidle = TCPTV_KEEP_IDLE; /* max idle time in persist */ int tcp_maxidle; #endif /* TUBA_INCLUDE */ /* @@ -165,6 +166,8 @@ tcp_canceltimers(tp) int tcp_backoff[TCP_MAXRXTSHIFT + 1] = { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; +int tcp_totbackoff = 511; /* sum of tcp_backoff[] */ + /* * TCP timer processing. */ @@ -268,6 +271,20 @@ tcp_timers(tp, timer) */ case TCPT_PERSIST: tcpstat.tcps_persisttimeo++; + /* + * Hack: if the peer is dead/unreachable, we do not + * time out if the window is closed. After a full + * backoff, drop the connection if the idle time + * (no responses to probes) reaches the maximum + * backoff that we would use if retransmitting. + */ + if (tp->t_rxtshift == TCP_MAXRXTSHIFT && + (tp->t_idle >= tcp_maxpersistidle || + tp->t_idle >= TCP_REXMTVAL(tp) * tcp_totbackoff)) { + tcpstat.tcps_persistdrop++; + tp = tcp_drop(tp, ETIMEDOUT); + break; + } tcp_setpersist(tp); tp->t_force = 1; (void) tcp_output(tp); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index ecae9f2469d..dde7c1b1e77 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.3 1996/03/03 22:30:50 niklas Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.4 1996/09/12 06:19:57 tholo Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -181,6 +181,7 @@ struct tcpstat { u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ u_long tcps_rexmttimeo; /* retransmit timeouts */ u_long tcps_persisttimeo; /* persist timeouts */ + u_long tcps_persistdrop; /* connections dropped in persist */ u_long tcps_keeptimeo; /* keepalive timeouts */ u_long tcps_keepprobe; /* keepalive probes sent */ u_long tcps_keepdrops; /* connections dropped in keepalive */