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 3498163b98SPoul-Henning Kamp * $Id: tcp_timer.c,v 1.10 1995/11/03 22:19:50 olah 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 71df8bae1dSRodney W. Grimes 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 75e79adb8eSGarrett Wollman int tcp_keepcnt = TCPTV_KEEPCNT; /* max idle probes */ 76e79adb8eSGarrett Wollman int tcp_maxpersistidle = TCPTV_KEEP_IDLE; /* max idle time in persist */ 77df8bae1dSRodney W. Grimes int tcp_maxidle; 78e79adb8eSGarrett Wollman #else /* TUBA_INCLUDE */ 79e79adb8eSGarrett Wollman 80e79adb8eSGarrett Wollman extern int tcp_maxpersistidle; 81df8bae1dSRodney W. Grimes #endif /* TUBA_INCLUDE */ 82e79adb8eSGarrett Wollman 83df8bae1dSRodney W. Grimes /* 84df8bae1dSRodney W. Grimes * Fast timeout routine for processing delayed acks 85df8bae1dSRodney W. Grimes */ 86df8bae1dSRodney W. Grimes void 87df8bae1dSRodney W. Grimes tcp_fasttimo() 88df8bae1dSRodney W. Grimes { 89df8bae1dSRodney W. Grimes register struct inpcb *inp; 90df8bae1dSRodney W. Grimes register struct tcpcb *tp; 9115bd2b43SDavid Greenman int s; 92df8bae1dSRodney W. Grimes 9315bd2b43SDavid Greenman s = splnet(); 9415bd2b43SDavid Greenman 9515bd2b43SDavid Greenman for (inp = tcb.lh_first; inp != NULL; inp = inp->inp_list.le_next) { 96df8bae1dSRodney W. Grimes if ((tp = (struct tcpcb *)inp->inp_ppcb) && 97df8bae1dSRodney W. Grimes (tp->t_flags & TF_DELACK)) { 98df8bae1dSRodney W. Grimes tp->t_flags &= ~TF_DELACK; 99df8bae1dSRodney W. Grimes tp->t_flags |= TF_ACKNOW; 100df8bae1dSRodney W. Grimes tcpstat.tcps_delack++; 101df8bae1dSRodney W. Grimes (void) tcp_output(tp); 102df8bae1dSRodney W. Grimes } 10315bd2b43SDavid Greenman } 104df8bae1dSRodney W. Grimes splx(s); 105df8bae1dSRodney W. Grimes } 106df8bae1dSRodney W. Grimes 107df8bae1dSRodney W. Grimes /* 108df8bae1dSRodney W. Grimes * Tcp protocol timeout routine called every 500 ms. 109df8bae1dSRodney W. Grimes * Updates the timers in all active tcb's and 110df8bae1dSRodney W. Grimes * causes finite state machine actions if timers expire. 111df8bae1dSRodney W. Grimes */ 112df8bae1dSRodney W. Grimes void 113df8bae1dSRodney W. Grimes tcp_slowtimo() 114df8bae1dSRodney W. Grimes { 115df8bae1dSRodney W. Grimes register struct inpcb *ip, *ipnxt; 116df8bae1dSRodney W. Grimes register struct tcpcb *tp; 117df8bae1dSRodney W. Grimes register int i; 11815bd2b43SDavid Greenman int s; 11915bd2b43SDavid Greenman 12015bd2b43SDavid Greenman s = splnet(); 121df8bae1dSRodney W. Grimes 122e79adb8eSGarrett Wollman tcp_maxidle = tcp_keepcnt * tcp_keepintvl; 12315bd2b43SDavid Greenman 12415bd2b43SDavid Greenman ip = tcb.lh_first; 12515bd2b43SDavid Greenman if (ip == NULL) { 126df8bae1dSRodney W. Grimes splx(s); 127df8bae1dSRodney W. Grimes return; 128df8bae1dSRodney W. Grimes } 12915bd2b43SDavid Greenman /* 13015bd2b43SDavid Greenman * Search through tcb's and update active timers. 13115bd2b43SDavid Greenman */ 13215bd2b43SDavid Greenman for (; ip != NULL; ip = ipnxt) { 13315bd2b43SDavid Greenman ipnxt = ip->inp_list.le_next; 134df8bae1dSRodney W. Grimes tp = intotcpcb(ip); 135e79adb8eSGarrett Wollman if (tp == 0 || tp->t_state == TCPS_LISTEN) 136df8bae1dSRodney W. Grimes continue; 137df8bae1dSRodney W. Grimes for (i = 0; i < TCPT_NTIMERS; i++) { 138df8bae1dSRodney W. Grimes if (tp->t_timer[i] && --tp->t_timer[i] == 0) { 13923062062SDavid Greenman if (tcp_usrreq(tp->t_inpcb->inp_socket, 140df8bae1dSRodney W. Grimes PRU_SLOWTIMO, (struct mbuf *)0, 14123062062SDavid Greenman (struct mbuf *)i, (struct mbuf *)0) == NULL) 142df8bae1dSRodney W. Grimes goto tpgone; 143df8bae1dSRodney W. Grimes } 144df8bae1dSRodney W. Grimes } 145df8bae1dSRodney W. Grimes tp->t_idle++; 146a0292f23SGarrett Wollman tp->t_duration++; 147df8bae1dSRodney W. Grimes if (tp->t_rtt) 148df8bae1dSRodney W. Grimes tp->t_rtt++; 149df8bae1dSRodney W. Grimes tpgone: 150df8bae1dSRodney W. Grimes ; 151df8bae1dSRodney W. Grimes } 152df8bae1dSRodney W. Grimes tcp_iss += TCP_ISSINCR/PR_SLOWHZ; /* increment iss */ 153df8bae1dSRodney W. Grimes #ifdef TCP_COMPAT_42 154df8bae1dSRodney W. Grimes if ((int)tcp_iss < 0) 155e79adb8eSGarrett Wollman tcp_iss = TCP_ISSINCR; /* XXX */ 156df8bae1dSRodney W. Grimes #endif 157df8bae1dSRodney W. Grimes tcp_now++; /* for timestamps */ 158df8bae1dSRodney W. Grimes splx(s); 159df8bae1dSRodney W. Grimes } 160df8bae1dSRodney W. Grimes #ifndef TUBA_INCLUDE 161df8bae1dSRodney W. Grimes 162df8bae1dSRodney W. Grimes /* 163df8bae1dSRodney W. Grimes * Cancel all timers for TCP tp. 164df8bae1dSRodney W. Grimes */ 165df8bae1dSRodney W. Grimes void 166df8bae1dSRodney W. Grimes tcp_canceltimers(tp) 167df8bae1dSRodney W. Grimes struct tcpcb *tp; 168df8bae1dSRodney W. Grimes { 169df8bae1dSRodney W. Grimes register int i; 170df8bae1dSRodney W. Grimes 171df8bae1dSRodney W. Grimes for (i = 0; i < TCPT_NTIMERS; i++) 172df8bae1dSRodney W. Grimes tp->t_timer[i] = 0; 173df8bae1dSRodney W. Grimes } 174df8bae1dSRodney W. Grimes 175df8bae1dSRodney W. Grimes int tcp_backoff[TCP_MAXRXTSHIFT + 1] = 176df8bae1dSRodney W. Grimes { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; 177df8bae1dSRodney W. Grimes 178e79adb8eSGarrett Wollman int tcp_totbackoff = 511; /* sum of tcp_backoff[] */ 179e79adb8eSGarrett Wollman 180df8bae1dSRodney W. Grimes /* 181df8bae1dSRodney W. Grimes * TCP timer processing. 182df8bae1dSRodney W. Grimes */ 183df8bae1dSRodney W. Grimes struct tcpcb * 184df8bae1dSRodney W. Grimes tcp_timers(tp, timer) 185df8bae1dSRodney W. Grimes register struct tcpcb *tp; 186df8bae1dSRodney W. Grimes int timer; 187df8bae1dSRodney W. Grimes { 188df8bae1dSRodney W. Grimes register int rexmt; 189df8bae1dSRodney W. Grimes 190df8bae1dSRodney W. Grimes switch (timer) { 191df8bae1dSRodney W. Grimes 192df8bae1dSRodney W. Grimes /* 193df8bae1dSRodney W. Grimes * 2 MSL timeout in shutdown went off. If we're closed but 194df8bae1dSRodney W. Grimes * still waiting for peer to close and connection has been idle 195df8bae1dSRodney W. Grimes * too long, or if 2MSL time is up from TIME_WAIT, delete connection 196df8bae1dSRodney W. Grimes * control block. Otherwise, check again in a bit. 197df8bae1dSRodney W. Grimes */ 198df8bae1dSRodney W. Grimes case TCPT_2MSL: 199df8bae1dSRodney W. Grimes if (tp->t_state != TCPS_TIME_WAIT && 200df8bae1dSRodney W. Grimes tp->t_idle <= tcp_maxidle) 201df8bae1dSRodney W. Grimes tp->t_timer[TCPT_2MSL] = tcp_keepintvl; 202df8bae1dSRodney W. Grimes else 203df8bae1dSRodney W. Grimes tp = tcp_close(tp); 204df8bae1dSRodney W. Grimes break; 205df8bae1dSRodney W. Grimes 206df8bae1dSRodney W. Grimes /* 207df8bae1dSRodney W. Grimes * Retransmission timer went off. Message has not 208df8bae1dSRodney W. Grimes * been acked within retransmit interval. Back off 209df8bae1dSRodney W. Grimes * to a longer retransmit interval and retransmit one segment. 210df8bae1dSRodney W. Grimes */ 211df8bae1dSRodney W. Grimes case TCPT_REXMT: 212df8bae1dSRodney W. Grimes if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) { 213df8bae1dSRodney W. Grimes tp->t_rxtshift = TCP_MAXRXTSHIFT; 214df8bae1dSRodney W. Grimes tcpstat.tcps_timeoutdrop++; 215df8bae1dSRodney W. Grimes tp = tcp_drop(tp, tp->t_softerror ? 216df8bae1dSRodney W. Grimes tp->t_softerror : ETIMEDOUT); 217df8bae1dSRodney W. Grimes break; 218df8bae1dSRodney W. Grimes } 219df8bae1dSRodney W. Grimes tcpstat.tcps_rexmttimeo++; 220df8bae1dSRodney W. Grimes rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; 221df8bae1dSRodney W. Grimes TCPT_RANGESET(tp->t_rxtcur, rexmt, 222df8bae1dSRodney W. Grimes tp->t_rttmin, TCPTV_REXMTMAX); 223df8bae1dSRodney W. Grimes tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; 224df8bae1dSRodney W. Grimes /* 225df8bae1dSRodney W. Grimes * If losing, let the lower level know and try for 226df8bae1dSRodney W. Grimes * a better route. Also, if we backed off this far, 227df8bae1dSRodney W. Grimes * our srtt estimate is probably bogus. Clobber it 228df8bae1dSRodney W. Grimes * so we'll take the next rtt measurement as our srtt; 229df8bae1dSRodney W. Grimes * move the current srtt into rttvar to keep the current 230df8bae1dSRodney W. Grimes * retransmit times until then. 231df8bae1dSRodney W. Grimes */ 232df8bae1dSRodney W. Grimes if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) { 233df8bae1dSRodney W. Grimes in_losing(tp->t_inpcb); 234df8bae1dSRodney W. Grimes tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT); 235df8bae1dSRodney W. Grimes tp->t_srtt = 0; 236df8bae1dSRodney W. Grimes } 237df8bae1dSRodney W. Grimes tp->snd_nxt = tp->snd_una; 238a0292f23SGarrett Wollman /* 239df8bae1dSRodney W. Grimes * If timing a segment in this window, stop the timer. 240df8bae1dSRodney W. Grimes */ 241df8bae1dSRodney W. Grimes tp->t_rtt = 0; 242df8bae1dSRodney W. Grimes /* 243df8bae1dSRodney W. Grimes * Close the congestion window down to one segment 244df8bae1dSRodney W. Grimes * (we'll open it by one segment for each ack we get). 245df8bae1dSRodney W. Grimes * Since we probably have a window's worth of unacked 246df8bae1dSRodney W. Grimes * data accumulated, this "slow start" keeps us from 247df8bae1dSRodney W. Grimes * dumping all that data as back-to-back packets (which 248df8bae1dSRodney W. Grimes * might overwhelm an intermediate gateway). 249df8bae1dSRodney W. Grimes * 250df8bae1dSRodney W. Grimes * There are two phases to the opening: Initially we 251df8bae1dSRodney W. Grimes * open by one mss on each ack. This makes the window 252df8bae1dSRodney W. Grimes * size increase exponentially with time. If the 253df8bae1dSRodney W. Grimes * window is larger than the path can handle, this 254df8bae1dSRodney W. Grimes * exponential growth results in dropped packet(s) 255df8bae1dSRodney W. Grimes * almost immediately. To get more time between 256df8bae1dSRodney W. Grimes * drops but still "push" the network to take advantage 257df8bae1dSRodney W. Grimes * of improving conditions, we switch from exponential 258df8bae1dSRodney W. Grimes * to linear window opening at some threshhold size. 259df8bae1dSRodney W. Grimes * For a threshhold, we use half the current window 260df8bae1dSRodney W. Grimes * size, truncated to a multiple of the mss. 261df8bae1dSRodney W. Grimes * 262df8bae1dSRodney W. Grimes * (the minimum cwnd that will give us exponential 263df8bae1dSRodney W. Grimes * growth is 2 mss. We don't allow the threshhold 264df8bae1dSRodney W. Grimes * to go below this.) 265df8bae1dSRodney W. Grimes */ 266df8bae1dSRodney W. Grimes { 267df8bae1dSRodney W. Grimes u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; 268df8bae1dSRodney W. Grimes if (win < 2) 269df8bae1dSRodney W. Grimes win = 2; 270df8bae1dSRodney W. Grimes tp->snd_cwnd = tp->t_maxseg; 271df8bae1dSRodney W. Grimes tp->snd_ssthresh = win * tp->t_maxseg; 272df8bae1dSRodney W. Grimes tp->t_dupacks = 0; 273df8bae1dSRodney W. Grimes } 274df8bae1dSRodney W. Grimes (void) tcp_output(tp); 275df8bae1dSRodney W. Grimes break; 276df8bae1dSRodney W. Grimes 277df8bae1dSRodney W. Grimes /* 278df8bae1dSRodney W. Grimes * Persistance timer into zero window. 279df8bae1dSRodney W. Grimes * Force a byte to be output, if possible. 280df8bae1dSRodney W. Grimes */ 281df8bae1dSRodney W. Grimes case TCPT_PERSIST: 282df8bae1dSRodney W. Grimes tcpstat.tcps_persisttimeo++; 283cc0964fbSDavid Greenman /* 284cc0964fbSDavid Greenman * Hack: if the peer is dead/unreachable, we do not 285cc0964fbSDavid Greenman * time out if the window is closed. After a full 286cc0964fbSDavid Greenman * backoff, drop the connection if the idle time 287cc0964fbSDavid Greenman * (no responses to probes) reaches the maximum 288cc0964fbSDavid Greenman * backoff that we would use if retransmitting. 289cc0964fbSDavid Greenman */ 290cc0964fbSDavid Greenman if (tp->t_rxtshift == TCP_MAXRXTSHIFT && 291cc0964fbSDavid Greenman (tp->t_idle >= tcp_maxpersistidle || 292cc0964fbSDavid Greenman tp->t_idle >= TCP_REXMTVAL(tp) * tcp_totbackoff)) { 293cc0964fbSDavid Greenman tcpstat.tcps_persistdrop++; 294cc0964fbSDavid Greenman tp = tcp_drop(tp, ETIMEDOUT); 295cc0964fbSDavid Greenman break; 296cc0964fbSDavid Greenman } 297df8bae1dSRodney W. Grimes tcp_setpersist(tp); 298df8bae1dSRodney W. Grimes tp->t_force = 1; 299df8bae1dSRodney W. Grimes (void) tcp_output(tp); 300df8bae1dSRodney W. Grimes tp->t_force = 0; 301df8bae1dSRodney W. Grimes break; 302df8bae1dSRodney W. Grimes 303df8bae1dSRodney W. Grimes /* 304df8bae1dSRodney W. Grimes * Keep-alive timer went off; send something 305df8bae1dSRodney W. Grimes * or drop connection if idle for too long. 306df8bae1dSRodney W. Grimes */ 307df8bae1dSRodney W. Grimes case TCPT_KEEP: 308df8bae1dSRodney W. Grimes tcpstat.tcps_keeptimeo++; 309df8bae1dSRodney W. Grimes if (tp->t_state < TCPS_ESTABLISHED) 310df8bae1dSRodney W. Grimes goto dropit; 311df8bae1dSRodney W. Grimes if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE && 312df8bae1dSRodney W. Grimes tp->t_state <= TCPS_CLOSE_WAIT) { 313df8bae1dSRodney W. Grimes if (tp->t_idle >= tcp_keepidle + tcp_maxidle) 314df8bae1dSRodney W. Grimes goto dropit; 315df8bae1dSRodney W. Grimes /* 316df8bae1dSRodney W. Grimes * Send a packet designed to force a response 317df8bae1dSRodney W. Grimes * if the peer is up and reachable: 318df8bae1dSRodney W. Grimes * either an ACK if the connection is still alive, 319df8bae1dSRodney W. Grimes * or an RST if the peer has closed the connection 320df8bae1dSRodney W. Grimes * due to timeout or reboot. 321df8bae1dSRodney W. Grimes * Using sequence number tp->snd_una-1 322df8bae1dSRodney W. Grimes * causes the transmitted zero-length segment 323df8bae1dSRodney W. Grimes * to lie outside the receive window; 324df8bae1dSRodney W. Grimes * by the protocol spec, this requires the 325df8bae1dSRodney W. Grimes * correspondent TCP to respond. 326df8bae1dSRodney W. Grimes */ 327df8bae1dSRodney W. Grimes tcpstat.tcps_keepprobe++; 328df8bae1dSRodney W. Grimes #ifdef TCP_COMPAT_42 329df8bae1dSRodney W. Grimes /* 330df8bae1dSRodney W. Grimes * The keepalive packet must have nonzero length 331df8bae1dSRodney W. Grimes * to get a 4.2 host to respond. 332df8bae1dSRodney W. Grimes */ 333df8bae1dSRodney W. Grimes tcp_respond(tp, tp->t_template, (struct mbuf *)NULL, 334df8bae1dSRodney W. Grimes tp->rcv_nxt - 1, tp->snd_una - 1, 0); 335df8bae1dSRodney W. Grimes #else 336df8bae1dSRodney W. Grimes tcp_respond(tp, tp->t_template, (struct mbuf *)NULL, 337df8bae1dSRodney W. Grimes tp->rcv_nxt, tp->snd_una - 1, 0); 338df8bae1dSRodney W. Grimes #endif 339df8bae1dSRodney W. Grimes tp->t_timer[TCPT_KEEP] = tcp_keepintvl; 340df8bae1dSRodney W. Grimes } else 341df8bae1dSRodney W. Grimes tp->t_timer[TCPT_KEEP] = tcp_keepidle; 342df8bae1dSRodney W. Grimes break; 343df8bae1dSRodney W. Grimes dropit: 344df8bae1dSRodney W. Grimes tcpstat.tcps_keepdrops++; 345df8bae1dSRodney W. Grimes tp = tcp_drop(tp, ETIMEDOUT); 346df8bae1dSRodney W. Grimes break; 347df8bae1dSRodney W. Grimes } 348df8bae1dSRodney W. Grimes return (tp); 349df8bae1dSRodney W. Grimes } 350df8bae1dSRodney W. Grimes #endif /* TUBA_INCLUDE */ 351