1df8bae1dSRodney W. Grimes /* 2e79adb8eSGarrett Wollman * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 33e79adb8eSGarrett Wollman * @(#)tcp_timer.c 8.2 (Berkeley) 5/24/95 340312fbe9SPoul-Henning Kamp * $Id: tcp_timer.c,v 1.11 1995/11/09 20:23:07 phk Exp $ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37df8bae1dSRodney W. Grimes #ifndef TUBA_INCLUDE 38df8bae1dSRodney W. Grimes #include <sys/param.h> 39df8bae1dSRodney W. Grimes #include <sys/systm.h> 4098163b98SPoul-Henning Kamp #include <sys/kernel.h> 4198163b98SPoul-Henning Kamp #include <sys/sysctl.h> 42df8bae1dSRodney W. Grimes #include <sys/malloc.h> 43df8bae1dSRodney W. Grimes #include <sys/mbuf.h> 44df8bae1dSRodney W. Grimes #include <sys/socket.h> 45df8bae1dSRodney W. Grimes #include <sys/socketvar.h> 46df8bae1dSRodney W. Grimes #include <sys/protosw.h> 47df8bae1dSRodney W. Grimes #include <sys/errno.h> 4815bd2b43SDavid Greenman #include <sys/queue.h> 49df8bae1dSRodney W. Grimes 50e79adb8eSGarrett Wollman #include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */ 51e79adb8eSGarrett Wollman 52df8bae1dSRodney W. Grimes #include <net/if.h> 53df8bae1dSRodney W. Grimes #include <net/route.h> 54df8bae1dSRodney W. Grimes 55df8bae1dSRodney W. Grimes #include <netinet/in.h> 56df8bae1dSRodney W. Grimes #include <netinet/in_systm.h> 57df8bae1dSRodney W. Grimes #include <netinet/ip.h> 58df8bae1dSRodney W. Grimes #include <netinet/in_pcb.h> 59df8bae1dSRodney W. Grimes #include <netinet/ip_var.h> 60df8bae1dSRodney W. Grimes #include <netinet/tcp.h> 61df8bae1dSRodney W. Grimes #include <netinet/tcp_fsm.h> 62df8bae1dSRodney W. Grimes #include <netinet/tcp_seq.h> 63df8bae1dSRodney W. Grimes #include <netinet/tcp_timer.h> 64df8bae1dSRodney W. Grimes #include <netinet/tcp_var.h> 65df8bae1dSRodney W. Grimes #include <netinet/tcpip.h> 66df8bae1dSRodney W. Grimes 67df8bae1dSRodney W. Grimes int tcp_keepidle = TCPTV_KEEP_IDLE; 6898163b98SPoul-Henning Kamp SYSCTL_INT(_net_inet_tcp, TCPCTL_KEEPIDLE, keepidle, 6998163b98SPoul-Henning Kamp CTLFLAG_RW, &tcp_keepidle , 0, ""); 7098163b98SPoul-Henning Kamp 710312fbe9SPoul-Henning Kamp static int tcp_keepintvl = TCPTV_KEEPINTVL; 7298163b98SPoul-Henning Kamp SYSCTL_INT(_net_inet_tcp, TCPCTL_KEEPINTVL, keepintvl, 7398163b98SPoul-Henning Kamp CTLFLAG_RW, &tcp_keepintvl , 0, ""); 7498163b98SPoul-Henning Kamp 750312fbe9SPoul-Henning Kamp static int tcp_keepcnt = TCPTV_KEEPCNT; 760312fbe9SPoul-Henning Kamp /* max idle probes */ 770312fbe9SPoul-Henning Kamp static int tcp_maxpersistidle = TCPTV_KEEP_IDLE; 780312fbe9SPoul-Henning Kamp /* max idle time in persist */ 79df8bae1dSRodney W. Grimes int tcp_maxidle; 80e79adb8eSGarrett Wollman #else /* TUBA_INCLUDE */ 81e79adb8eSGarrett Wollman 820312fbe9SPoul-Henning Kamp static int tcp_maxpersistidle; 83df8bae1dSRodney W. Grimes #endif /* TUBA_INCLUDE */ 84e79adb8eSGarrett Wollman 85df8bae1dSRodney W. Grimes /* 86df8bae1dSRodney W. Grimes * Fast timeout routine for processing delayed acks 87df8bae1dSRodney W. Grimes */ 88df8bae1dSRodney W. Grimes void 89df8bae1dSRodney W. Grimes tcp_fasttimo() 90df8bae1dSRodney W. Grimes { 91df8bae1dSRodney W. Grimes register struct inpcb *inp; 92df8bae1dSRodney W. Grimes register struct tcpcb *tp; 9315bd2b43SDavid Greenman int s; 94df8bae1dSRodney W. Grimes 9515bd2b43SDavid Greenman s = splnet(); 9615bd2b43SDavid Greenman 9715bd2b43SDavid Greenman for (inp = tcb.lh_first; inp != NULL; inp = inp->inp_list.le_next) { 98df8bae1dSRodney W. Grimes if ((tp = (struct tcpcb *)inp->inp_ppcb) && 99df8bae1dSRodney W. Grimes (tp->t_flags & TF_DELACK)) { 100df8bae1dSRodney W. Grimes tp->t_flags &= ~TF_DELACK; 101df8bae1dSRodney W. Grimes tp->t_flags |= TF_ACKNOW; 102df8bae1dSRodney W. Grimes tcpstat.tcps_delack++; 103df8bae1dSRodney W. Grimes (void) tcp_output(tp); 104df8bae1dSRodney W. Grimes } 10515bd2b43SDavid Greenman } 106df8bae1dSRodney W. Grimes splx(s); 107df8bae1dSRodney W. Grimes } 108df8bae1dSRodney W. Grimes 109df8bae1dSRodney W. Grimes /* 110df8bae1dSRodney W. Grimes * Tcp protocol timeout routine called every 500 ms. 111df8bae1dSRodney W. Grimes * Updates the timers in all active tcb's and 112df8bae1dSRodney W. Grimes * causes finite state machine actions if timers expire. 113df8bae1dSRodney W. Grimes */ 114df8bae1dSRodney W. Grimes void 115df8bae1dSRodney W. Grimes tcp_slowtimo() 116df8bae1dSRodney W. Grimes { 117df8bae1dSRodney W. Grimes register struct inpcb *ip, *ipnxt; 118df8bae1dSRodney W. Grimes register struct tcpcb *tp; 119df8bae1dSRodney W. Grimes register int i; 12015bd2b43SDavid Greenman int s; 12115bd2b43SDavid Greenman 12215bd2b43SDavid Greenman s = splnet(); 123df8bae1dSRodney W. Grimes 124e79adb8eSGarrett Wollman tcp_maxidle = tcp_keepcnt * tcp_keepintvl; 12515bd2b43SDavid Greenman 12615bd2b43SDavid Greenman ip = tcb.lh_first; 12715bd2b43SDavid Greenman if (ip == NULL) { 128df8bae1dSRodney W. Grimes splx(s); 129df8bae1dSRodney W. Grimes return; 130df8bae1dSRodney W. Grimes } 13115bd2b43SDavid Greenman /* 13215bd2b43SDavid Greenman * Search through tcb's and update active timers. 13315bd2b43SDavid Greenman */ 13415bd2b43SDavid Greenman for (; ip != NULL; ip = ipnxt) { 13515bd2b43SDavid Greenman ipnxt = ip->inp_list.le_next; 136df8bae1dSRodney W. Grimes tp = intotcpcb(ip); 137e79adb8eSGarrett Wollman if (tp == 0 || tp->t_state == TCPS_LISTEN) 138df8bae1dSRodney W. Grimes continue; 139df8bae1dSRodney W. Grimes for (i = 0; i < TCPT_NTIMERS; i++) { 140df8bae1dSRodney W. Grimes if (tp->t_timer[i] && --tp->t_timer[i] == 0) { 14123062062SDavid Greenman if (tcp_usrreq(tp->t_inpcb->inp_socket, 142df8bae1dSRodney W. Grimes PRU_SLOWTIMO, (struct mbuf *)0, 14323062062SDavid Greenman (struct mbuf *)i, (struct mbuf *)0) == NULL) 144df8bae1dSRodney W. Grimes goto tpgone; 145df8bae1dSRodney W. Grimes } 146df8bae1dSRodney W. Grimes } 147df8bae1dSRodney W. Grimes tp->t_idle++; 148a0292f23SGarrett Wollman tp->t_duration++; 149df8bae1dSRodney W. Grimes if (tp->t_rtt) 150df8bae1dSRodney W. Grimes tp->t_rtt++; 151df8bae1dSRodney W. Grimes tpgone: 152df8bae1dSRodney W. Grimes ; 153df8bae1dSRodney W. Grimes } 154df8bae1dSRodney W. Grimes tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 155df8bae1dSRodney W. Grimes #ifdef TCP_COMPAT_42 156df8bae1dSRodney W. Grimes if ((int)tcp_iss < 0) 157e79adb8eSGarrett Wollman tcp_iss = TCP_ISSINCR; /* XXX */ 158df8bae1dSRodney W. Grimes #endif 159df8bae1dSRodney W. Grimes tcp_now++; /* for timestamps */ 160df8bae1dSRodney W. Grimes splx(s); 161df8bae1dSRodney W. Grimes } 162df8bae1dSRodney W. Grimes #ifndef TUBA_INCLUDE 163df8bae1dSRodney W. Grimes 164df8bae1dSRodney W. Grimes /* 165df8bae1dSRodney W. Grimes * Cancel all timers for TCP tp. 166df8bae1dSRodney W. Grimes */ 167df8bae1dSRodney W. Grimes void 168df8bae1dSRodney W. Grimes tcp_canceltimers(tp) 169df8bae1dSRodney W. Grimes struct tcpcb *tp; 170df8bae1dSRodney W. Grimes { 171df8bae1dSRodney W. Grimes register int i; 172df8bae1dSRodney W. Grimes 173df8bae1dSRodney W. Grimes for (i = 0; i < TCPT_NTIMERS; i++) 174df8bae1dSRodney W. Grimes tp->t_timer[i] = 0; 175df8bae1dSRodney W. Grimes } 176df8bae1dSRodney W. Grimes 177df8bae1dSRodney W. Grimes int tcp_backoff[TCP_MAXRXTSHIFT + 1] = 178df8bae1dSRodney W. Grimes { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; 179df8bae1dSRodney W. Grimes 1800312fbe9SPoul-Henning Kamp static int tcp_totbackoff = 511; /* sum of tcp_backoff[] */ 181e79adb8eSGarrett Wollman 182df8bae1dSRodney W. Grimes /* 183df8bae1dSRodney W. Grimes * TCP timer processing. 184df8bae1dSRodney W. Grimes */ 185df8bae1dSRodney W. Grimes struct tcpcb * 186df8bae1dSRodney W. Grimes tcp_timers(tp, timer) 187df8bae1dSRodney W. Grimes register struct tcpcb *tp; 188df8bae1dSRodney W. Grimes int timer; 189df8bae1dSRodney W. Grimes { 190df8bae1dSRodney W. Grimes register int rexmt; 191df8bae1dSRodney W. Grimes 192df8bae1dSRodney W. Grimes switch (timer) { 193df8bae1dSRodney W. Grimes 194df8bae1dSRodney W. Grimes /* 195df8bae1dSRodney W. Grimes * 2 MSL timeout in shutdown went off. If we're closed but 196df8bae1dSRodney W. Grimes * still waiting for peer to close and connection has been idle 197df8bae1dSRodney W. Grimes * too long, or if 2MSL time is up from TIME_WAIT, delete connection 198df8bae1dSRodney W. Grimes * control block. Otherwise, check again in a bit. 199df8bae1dSRodney W. Grimes */ 200df8bae1dSRodney W. Grimes case TCPT_2MSL: 201df8bae1dSRodney W. Grimes if (tp->t_state != TCPS_TIME_WAIT && 202df8bae1dSRodney W. Grimes tp->t_idle <= tcp_maxidle) 203df8bae1dSRodney W. Grimes tp->t_timer[TCPT_2MSL] = tcp_keepintvl; 204df8bae1dSRodney W. Grimes else 205df8bae1dSRodney W. Grimes tp = tcp_close(tp); 206df8bae1dSRodney W. Grimes break; 207df8bae1dSRodney W. Grimes 208df8bae1dSRodney W. Grimes /* 209df8bae1dSRodney W. Grimes * Retransmission timer went off. Message has not 210df8bae1dSRodney W. Grimes * been acked within retransmit interval. Back off 211df8bae1dSRodney W. Grimes * to a longer retransmit interval and retransmit one segment. 212df8bae1dSRodney W. Grimes */ 213df8bae1dSRodney W. Grimes case TCPT_REXMT: 214df8bae1dSRodney W. Grimes if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) { 215df8bae1dSRodney W. Grimes tp->t_rxtshift = TCP_MAXRXTSHIFT; 216df8bae1dSRodney W. Grimes tcpstat.tcps_timeoutdrop++; 217df8bae1dSRodney W. Grimes tp = tcp_drop(tp, tp->t_softerror ? 218df8bae1dSRodney W. Grimes tp->t_softerror : ETIMEDOUT); 219df8bae1dSRodney W. Grimes break; 220df8bae1dSRodney W. Grimes } 221df8bae1dSRodney W. Grimes tcpstat.tcps_rexmttimeo++; 222df8bae1dSRodney W. Grimes rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; 223df8bae1dSRodney W. Grimes TCPT_RANGESET(tp->t_rxtcur, rexmt, 224df8bae1dSRodney W. Grimes tp->t_rttmin, TCPTV_REXMTMAX); 225df8bae1dSRodney W. Grimes tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; 226df8bae1dSRodney W. Grimes /* 227df8bae1dSRodney W. Grimes * If losing, let the lower level know and try for 228df8bae1dSRodney W. Grimes * a better route. Also, if we backed off this far, 229df8bae1dSRodney W. Grimes * our srtt estimate is probably bogus. Clobber it 230df8bae1dSRodney W. Grimes * so we'll take the next rtt measurement as our srtt; 231df8bae1dSRodney W. Grimes * move the current srtt into rttvar to keep the current 232df8bae1dSRodney W. Grimes * retransmit times until then. 233df8bae1dSRodney W. Grimes */ 234df8bae1dSRodney W. Grimes if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) { 235df8bae1dSRodney W. Grimes in_losing(tp->t_inpcb); 236df8bae1dSRodney W. Grimes tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT); 237df8bae1dSRodney W. Grimes tp->t_srtt = 0; 238df8bae1dSRodney W. Grimes } 239df8bae1dSRodney W. Grimes tp->snd_nxt = tp->snd_una; 240a0292f23SGarrett Wollman /* 241df8bae1dSRodney W. Grimes * If timing a segment in this window, stop the timer. 242df8bae1dSRodney W. Grimes */ 243df8bae1dSRodney W. Grimes tp->t_rtt = 0; 244df8bae1dSRodney W. Grimes /* 245df8bae1dSRodney W. Grimes * Close the congestion window down to one segment 246df8bae1dSRodney W. Grimes * (we'll open it by one segment for each ack we get). 247df8bae1dSRodney W. Grimes * Since we probably have a window's worth of unacked 248df8bae1dSRodney W. Grimes * data accumulated, this "slow start" keeps us from 249df8bae1dSRodney W. Grimes * dumping all that data as back-to-back packets (which 250df8bae1dSRodney W. Grimes * might overwhelm an intermediate gateway). 251df8bae1dSRodney W. Grimes * 252df8bae1dSRodney W. Grimes * There are two phases to the opening: Initially we 253df8bae1dSRodney W. Grimes * open by one mss on each ack. This makes the window 254df8bae1dSRodney W. Grimes * size increase exponentially with time. If the 255df8bae1dSRodney W. Grimes * window is larger than the path can handle, this 256df8bae1dSRodney W. Grimes * exponential growth results in dropped packet(s) 257df8bae1dSRodney W. Grimes * almost immediately. To get more time between 258df8bae1dSRodney W. Grimes * drops but still "push" the network to take advantage 259df8bae1dSRodney W. Grimes * of improving conditions, we switch from exponential 260df8bae1dSRodney W. Grimes * to linear window opening at some threshhold size. 261df8bae1dSRodney W. Grimes * For a threshhold, we use half the current window 262df8bae1dSRodney W. Grimes * size, truncated to a multiple of the mss. 263df8bae1dSRodney W. Grimes * 264df8bae1dSRodney W. Grimes * (the minimum cwnd that will give us exponential 265df8bae1dSRodney W. Grimes * growth is 2 mss. We don't allow the threshhold 266df8bae1dSRodney W. Grimes * to go below this.) 267df8bae1dSRodney W. Grimes */ 268df8bae1dSRodney W. Grimes { 269df8bae1dSRodney W. Grimes u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; 270df8bae1dSRodney W. Grimes if (win < 2) 271df8bae1dSRodney W. Grimes win = 2; 272df8bae1dSRodney W. Grimes tp->snd_cwnd = tp->t_maxseg; 273df8bae1dSRodney W. Grimes tp->snd_ssthresh = win * tp->t_maxseg; 274df8bae1dSRodney W. Grimes tp->t_dupacks = 0; 275df8bae1dSRodney W. Grimes } 276df8bae1dSRodney W. Grimes (void) tcp_output(tp); 277df8bae1dSRodney W. Grimes break; 278df8bae1dSRodney W. Grimes 279df8bae1dSRodney W. Grimes /* 280df8bae1dSRodney W. Grimes * Persistance timer into zero window. 281df8bae1dSRodney W. Grimes * Force a byte to be output, if possible. 282df8bae1dSRodney W. Grimes */ 283df8bae1dSRodney W. Grimes case TCPT_PERSIST: 284df8bae1dSRodney W. Grimes tcpstat.tcps_persisttimeo++; 285cc0964fbSDavid Greenman /* 286cc0964fbSDavid Greenman * Hack: if the peer is dead/unreachable, we do not 287cc0964fbSDavid Greenman * time out if the window is closed. After a full 288cc0964fbSDavid Greenman * backoff, drop the connection if the idle time 289cc0964fbSDavid Greenman * (no responses to probes) reaches the maximum 290cc0964fbSDavid Greenman * backoff that we would use if retransmitting. 291cc0964fbSDavid Greenman */ 292cc0964fbSDavid Greenman if (tp->t_rxtshift == TCP_MAXRXTSHIFT && 293cc0964fbSDavid Greenman (tp->t_idle >= tcp_maxpersistidle || 294cc0964fbSDavid Greenman tp->t_idle >= TCP_REXMTVAL(tp) * tcp_totbackoff)) { 295cc0964fbSDavid Greenman tcpstat.tcps_persistdrop++; 296cc0964fbSDavid Greenman tp = tcp_drop(tp, ETIMEDOUT); 297cc0964fbSDavid Greenman break; 298cc0964fbSDavid Greenman } 299df8bae1dSRodney W. Grimes tcp_setpersist(tp); 300df8bae1dSRodney W. Grimes tp->t_force = 1; 301df8bae1dSRodney W. Grimes (void) tcp_output(tp); 302df8bae1dSRodney W. Grimes tp->t_force = 0; 303df8bae1dSRodney W. Grimes break; 304df8bae1dSRodney W. Grimes 305df8bae1dSRodney W. Grimes /* 306df8bae1dSRodney W. Grimes * Keep-alive timer went off; send something 307df8bae1dSRodney W. Grimes * or drop connection if idle for too long. 308df8bae1dSRodney W. Grimes */ 309df8bae1dSRodney W. Grimes case TCPT_KEEP: 310df8bae1dSRodney W. Grimes tcpstat.tcps_keeptimeo++; 311df8bae1dSRodney W. Grimes if (tp->t_state < TCPS_ESTABLISHED) 312df8bae1dSRodney W. Grimes goto dropit; 313df8bae1dSRodney W. Grimes if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE && 314df8bae1dSRodney W. Grimes tp->t_state <= TCPS_CLOSE_WAIT) { 315df8bae1dSRodney W. Grimes if (tp->t_idle >= tcp_keepidle + tcp_maxidle) 316df8bae1dSRodney W. Grimes goto dropit; 317df8bae1dSRodney W. Grimes /* 318df8bae1dSRodney W. Grimes * Send a packet designed to force a response 319df8bae1dSRodney W. Grimes * if the peer is up and reachable: 320df8bae1dSRodney W. Grimes * either an ACK if the connection is still alive, 321df8bae1dSRodney W. Grimes * or an RST if the peer has closed the connection 322df8bae1dSRodney W. Grimes * due to timeout or reboot. 323df8bae1dSRodney W. Grimes * Using sequence number tp->snd_una-1 324df8bae1dSRodney W. Grimes * causes the transmitted zero-length segment 325df8bae1dSRodney W. Grimes * to lie outside the receive window; 326df8bae1dSRodney W. Grimes * by the protocol spec, this requires the 327df8bae1dSRodney W. Grimes * correspondent TCP to respond. 328df8bae1dSRodney W. Grimes */ 329df8bae1dSRodney W. Grimes tcpstat.tcps_keepprobe++; 330df8bae1dSRodney W. Grimes #ifdef TCP_COMPAT_42 331df8bae1dSRodney W. Grimes /* 332df8bae1dSRodney W. Grimes * The keepalive packet must have nonzero length 333df8bae1dSRodney W. Grimes * to get a 4.2 host to respond. 334df8bae1dSRodney W. Grimes */ 335df8bae1dSRodney W. Grimes tcp_respond(tp, tp->t_template, (struct mbuf *)NULL, 336df8bae1dSRodney W. Grimes tp->rcv_nxt - 1, tp->snd_una - 1, 0); 337df8bae1dSRodney W. Grimes #else 338df8bae1dSRodney W. Grimes tcp_respond(tp, tp->t_template, (struct mbuf *)NULL, 339df8bae1dSRodney W. Grimes tp->rcv_nxt, tp->snd_una - 1, 0); 340df8bae1dSRodney W. Grimes #endif 341df8bae1dSRodney W. Grimes tp->t_timer[TCPT_KEEP] = tcp_keepintvl; 342df8bae1dSRodney W. Grimes } else 343df8bae1dSRodney W. Grimes tp->t_timer[TCPT_KEEP] = tcp_keepidle; 344df8bae1dSRodney W. Grimes break; 345df8bae1dSRodney W. Grimes dropit: 346df8bae1dSRodney W. Grimes tcpstat.tcps_keepdrops++; 347df8bae1dSRodney W. Grimes tp = tcp_drop(tp, ETIMEDOUT); 348df8bae1dSRodney W. Grimes break; 349df8bae1dSRodney W. Grimes } 350df8bae1dSRodney W. Grimes return (tp); 351df8bae1dSRodney W. Grimes } 352df8bae1dSRodney W. Grimes #endif /* TUBA_INCLUDE */ 353