1 /* $NetBSD: tcp_timer.c,v 1.76 2006/10/09 16:27:07 rpaulo Exp $ */ 2 3 /* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the project nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 /*- 33 * Copyright (c) 1997, 1998, 2001, 2005 The NetBSD Foundation, Inc. 34 * All rights reserved. 35 * 36 * This code is derived from software contributed to The NetBSD Foundation 37 * by Jason R. Thorpe and Kevin M. Lahey of the Numerical Aerospace Simulation 38 * Facility, NASA Ames Research Center. 39 * This code is derived from software contributed to The NetBSD Foundation 40 * by Charles M. Hannum. 41 * 42 * Redistribution and use in source and binary forms, with or without 43 * modification, are permitted provided that the following conditions 44 * are met: 45 * 1. Redistributions of source code must retain the above copyright 46 * notice, this list of conditions and the following disclaimer. 47 * 2. Redistributions in binary form must reproduce the above copyright 48 * notice, this list of conditions and the following disclaimer in the 49 * documentation and/or other materials provided with the distribution. 50 * 3. All advertising materials mentioning features or use of this software 51 * must display the following acknowledgement: 52 * This product includes software developed by the NetBSD 53 * Foundation, Inc. and its contributors. 54 * 4. Neither the name of The NetBSD Foundation nor the names of its 55 * contributors may be used to endorse or promote products derived 56 * from this software without specific prior written permission. 57 * 58 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 59 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 60 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 61 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 62 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 65 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 66 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 68 * POSSIBILITY OF SUCH DAMAGE. 69 */ 70 71 /* 72 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 73 * The Regents of the University of California. All rights reserved. 74 * 75 * Redistribution and use in source and binary forms, with or without 76 * modification, are permitted provided that the following conditions 77 * are met: 78 * 1. Redistributions of source code must retain the above copyright 79 * notice, this list of conditions and the following disclaimer. 80 * 2. Redistributions in binary form must reproduce the above copyright 81 * notice, this list of conditions and the following disclaimer in the 82 * documentation and/or other materials provided with the distribution. 83 * 3. Neither the name of the University nor the names of its contributors 84 * may be used to endorse or promote products derived from this software 85 * without specific prior written permission. 86 * 87 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 88 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 89 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 90 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 91 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 92 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 93 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 94 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 95 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 96 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 97 * SUCH DAMAGE. 98 * 99 * @(#)tcp_timer.c 8.2 (Berkeley) 5/24/95 100 */ 101 102 #include <sys/cdefs.h> 103 __KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.76 2006/10/09 16:27:07 rpaulo Exp $"); 104 105 #include "opt_inet.h" 106 #include "opt_tcp_debug.h" 107 108 #include <sys/param.h> 109 #include <sys/systm.h> 110 #include <sys/malloc.h> 111 #include <sys/mbuf.h> 112 #include <sys/socket.h> 113 #include <sys/socketvar.h> 114 #include <sys/protosw.h> 115 #include <sys/errno.h> 116 #include <sys/kernel.h> 117 118 #include <net/if.h> 119 #include <net/route.h> 120 121 #include <netinet/in.h> 122 #include <netinet/in_systm.h> 123 #include <netinet/ip.h> 124 #include <netinet/in_pcb.h> 125 #include <netinet/ip_var.h> 126 #include <netinet/ip_icmp.h> 127 128 #ifdef INET6 129 #ifndef INET 130 #include <netinet/in.h> 131 #endif 132 #include <netinet/ip6.h> 133 #include <netinet6/in6_pcb.h> 134 #endif 135 136 #include <netinet/tcp.h> 137 #include <netinet/tcp_fsm.h> 138 #include <netinet/tcp_seq.h> 139 #include <netinet/tcp_timer.h> 140 #include <netinet/tcp_var.h> 141 #include <netinet/tcp_congctl.h> 142 #include <netinet/tcpip.h> 143 #ifdef TCP_DEBUG 144 #include <netinet/tcp_debug.h> 145 #endif 146 147 /* 148 * Various tunable timer parameters. These are initialized in tcp_init(), 149 * unless they are patched. 150 */ 151 int tcp_keepidle = 0; 152 int tcp_keepintvl = 0; 153 int tcp_keepcnt = 0; /* max idle probes */ 154 int tcp_maxpersistidle = 0; /* max idle time in persist */ 155 int tcp_maxidle; /* computed in tcp_slowtimo() */ 156 157 /* 158 * Time to delay the ACK. This is initialized in tcp_init(), unless 159 * its patched. 160 */ 161 int tcp_delack_ticks = 0; 162 163 void tcp_timer_rexmt(void *); 164 void tcp_timer_persist(void *); 165 void tcp_timer_keep(void *); 166 void tcp_timer_2msl(void *); 167 168 const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS] = { 169 tcp_timer_rexmt, 170 tcp_timer_persist, 171 tcp_timer_keep, 172 tcp_timer_2msl, 173 }; 174 175 /* 176 * Timer state initialization, called from tcp_init(). 177 */ 178 void 179 tcp_timer_init(void) 180 { 181 182 if (tcp_keepidle == 0) 183 tcp_keepidle = TCPTV_KEEP_IDLE; 184 185 if (tcp_keepintvl == 0) 186 tcp_keepintvl = TCPTV_KEEPINTVL; 187 188 if (tcp_keepcnt == 0) 189 tcp_keepcnt = TCPTV_KEEPCNT; 190 191 if (tcp_maxpersistidle == 0) 192 tcp_maxpersistidle = TCPTV_KEEP_IDLE; 193 194 if (tcp_delack_ticks == 0) 195 tcp_delack_ticks = TCP_DELACK_TICKS; 196 } 197 198 /* 199 * Return how many timers are currently being invoked. 200 */ 201 int 202 tcp_timers_invoking(struct tcpcb *tp) 203 { 204 int i; 205 int count = 0; 206 207 for (i = 0; i < TCPT_NTIMERS; i++) 208 if (callout_invoking(&tp->t_timer[i])) 209 count++; 210 if (callout_invoking(&tp->t_delack_ch)) 211 count++; 212 213 return count; 214 } 215 216 /* 217 * Callout to process delayed ACKs for a TCPCB. 218 */ 219 void 220 tcp_delack(void *arg) 221 { 222 struct tcpcb *tp = arg; 223 int s; 224 225 /* 226 * If tcp_output() wasn't able to transmit the ACK 227 * for whatever reason, it will restart the delayed 228 * ACK callout. 229 */ 230 231 s = splsoftnet(); 232 callout_ack(&tp->t_delack_ch); 233 if (tcp_isdead(tp)) { 234 splx(s); 235 return; 236 } 237 238 tp->t_flags |= TF_ACKNOW; 239 (void) tcp_output(tp); 240 splx(s); 241 } 242 243 /* 244 * Tcp protocol timeout routine called every 500 ms. 245 * Updates the timers in all active tcb's and 246 * causes finite state machine actions if timers expire. 247 */ 248 void 249 tcp_slowtimo(void) 250 { 251 int s; 252 253 s = splsoftnet(); 254 tcp_maxidle = tcp_keepcnt * tcp_keepintvl; 255 tcp_iss_seq += TCP_ISSINCR; /* increment iss */ 256 tcp_now++; /* for timestamps */ 257 splx(s); 258 } 259 260 /* 261 * Cancel all timers for TCP tp. 262 */ 263 void 264 tcp_canceltimers(struct tcpcb *tp) 265 { 266 int i; 267 268 for (i = 0; i < TCPT_NTIMERS; i++) 269 TCP_TIMER_DISARM(tp, i); 270 } 271 272 const int tcp_backoff[TCP_MAXRXTSHIFT + 1] = 273 { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; 274 275 const int tcp_totbackoff = 511; /* sum of tcp_backoff[] */ 276 277 /* 278 * TCP timer processing. 279 */ 280 281 void 282 tcp_timer_rexmt(void *arg) 283 { 284 struct tcpcb *tp = arg; 285 uint32_t rto; 286 int s; 287 #ifdef TCP_DEBUG 288 struct socket *so = NULL; 289 short ostate; 290 #endif 291 292 s = splsoftnet(); 293 callout_ack(&tp->t_timer[TCPT_REXMT]); 294 if (tcp_isdead(tp)) { 295 splx(s); 296 return; 297 } 298 299 if ((tp->t_flags & TF_PMTUD_PEND) && tp->t_inpcb && 300 SEQ_GEQ(tp->t_pmtud_th_seq, tp->snd_una) && 301 SEQ_LT(tp->t_pmtud_th_seq, (int)(tp->snd_una + tp->t_ourmss))) { 302 extern struct sockaddr_in icmpsrc; 303 struct icmp icmp; 304 305 tp->t_flags &= ~TF_PMTUD_PEND; 306 307 /* XXX create fake icmp message with relevant entries */ 308 icmp.icmp_nextmtu = tp->t_pmtud_nextmtu; 309 icmp.icmp_ip.ip_len = tp->t_pmtud_ip_len; 310 icmp.icmp_ip.ip_hl = tp->t_pmtud_ip_hl; 311 icmpsrc.sin_addr = tp->t_inpcb->inp_faddr; 312 icmp_mtudisc(&icmp, icmpsrc.sin_addr); 313 314 /* 315 * Notify all connections to the same peer about 316 * new mss and trigger retransmit. 317 */ 318 in_pcbnotifyall(&tcbtable, icmpsrc.sin_addr, EMSGSIZE, 319 tcp_mtudisc); 320 splx(s); 321 return; 322 } 323 #ifdef TCP_DEBUG 324 #ifdef INET 325 if (tp->t_inpcb) 326 so = tp->t_inpcb->inp_socket; 327 #endif 328 #ifdef INET6 329 if (tp->t_in6pcb) 330 so = tp->t_in6pcb->in6p_socket; 331 #endif 332 ostate = tp->t_state; 333 #endif /* TCP_DEBUG */ 334 335 /* 336 * Clear the SACK scoreboard, reset FACK estimate. 337 */ 338 tcp_free_sackholes(tp); 339 tp->snd_fack = tp->snd_una; 340 341 /* 342 * Retransmission timer went off. Message has not 343 * been acked within retransmit interval. Back off 344 * to a longer retransmit interval and retransmit one segment. 345 */ 346 347 if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) { 348 tp->t_rxtshift = TCP_MAXRXTSHIFT; 349 tcpstat.tcps_timeoutdrop++; 350 tp = tcp_drop(tp, tp->t_softerror ? 351 tp->t_softerror : ETIMEDOUT); 352 goto out; 353 } 354 tcpstat.tcps_rexmttimeo++; 355 rto = TCP_REXMTVAL(tp); 356 if (rto < tp->t_rttmin) 357 rto = tp->t_rttmin; 358 TCPT_RANGESET(tp->t_rxtcur, rto * tcp_backoff[tp->t_rxtshift], 359 tp->t_rttmin, TCPTV_REXMTMAX); 360 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur); 361 362 /* 363 * If we are losing and we are trying path MTU discovery, 364 * try turning it off. This will avoid black holes in 365 * the network which suppress or fail to send "packet 366 * too big" ICMP messages. We should ideally do 367 * lots more sophisticated searching to find the right 368 * value here... 369 */ 370 if (tp->t_mtudisc && tp->t_rxtshift > TCP_MAXRXTSHIFT / 6) { 371 tcpstat.tcps_pmtublackhole++; 372 373 #ifdef INET 374 /* try turning PMTUD off */ 375 if (tp->t_inpcb) 376 tp->t_mtudisc = 0; 377 #endif 378 #ifdef INET6 379 /* try using IPv6 minimum MTU */ 380 if (tp->t_in6pcb) 381 tp->t_mtudisc = 0; 382 #endif 383 384 /* XXX: more sophisticated Black hole recovery code? */ 385 } 386 387 /* 388 * If losing, let the lower level know and try for 389 * a better route. Also, if we backed off this far, 390 * our srtt estimate is probably bogus. Clobber it 391 * so we'll take the next rtt measurement as our srtt; 392 * move the current srtt into rttvar to keep the current 393 * retransmit times until then. 394 */ 395 if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) { 396 #ifdef INET 397 if (tp->t_inpcb) 398 in_losing(tp->t_inpcb); 399 #endif 400 #ifdef INET6 401 if (tp->t_in6pcb) 402 in6_losing(tp->t_in6pcb); 403 #endif 404 tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT); 405 tp->t_srtt = 0; 406 } 407 tp->snd_nxt = tp->snd_una; 408 tp->snd_high = tp->snd_max; 409 /* 410 * If timing a segment in this window, stop the timer. 411 */ 412 tp->t_rtttime = 0; 413 /* 414 * Remember if we are retransmitting a SYN, because if 415 * we do, set the initial congestion window must be set 416 * to 1 segment. 417 */ 418 if (tp->t_state == TCPS_SYN_SENT) 419 tp->t_flags |= TF_SYN_REXMT; 420 421 /* 422 * Adjust congestion control parameters. 423 */ 424 tp->t_congctl->slow_retransmit(tp); 425 426 (void) tcp_output(tp); 427 428 out: 429 #ifdef TCP_DEBUG 430 if (tp && so->so_options & SO_DEBUG) 431 tcp_trace(TA_USER, ostate, tp, NULL, 432 PRU_SLOWTIMO | (TCPT_REXMT << 8)); 433 #endif 434 splx(s); 435 } 436 437 void 438 tcp_timer_persist(void *arg) 439 { 440 struct tcpcb *tp = arg; 441 uint32_t rto; 442 int s; 443 #ifdef TCP_DEBUG 444 struct socket *so = NULL; 445 short ostate; 446 #endif 447 448 s = splsoftnet(); 449 callout_ack(&tp->t_timer[TCPT_PERSIST]); 450 if (tcp_isdead(tp)) { 451 splx(s); 452 return; 453 } 454 455 #ifdef TCP_DEBUG 456 #ifdef INET 457 if (tp->t_inpcb) 458 so = tp->t_inpcb->inp_socket; 459 #endif 460 #ifdef INET6 461 if (tp->t_in6pcb) 462 so = tp->t_in6pcb->in6p_socket; 463 #endif 464 465 ostate = tp->t_state; 466 #endif /* TCP_DEBUG */ 467 468 /* 469 * Persistance timer into zero window. 470 * Force a byte to be output, if possible. 471 */ 472 473 /* 474 * Hack: if the peer is dead/unreachable, we do not 475 * time out if the window is closed. After a full 476 * backoff, drop the connection if the idle time 477 * (no responses to probes) reaches the maximum 478 * backoff that we would use if retransmitting. 479 */ 480 rto = TCP_REXMTVAL(tp); 481 if (rto < tp->t_rttmin) 482 rto = tp->t_rttmin; 483 if (tp->t_rxtshift == TCP_MAXRXTSHIFT && 484 ((tcp_now - tp->t_rcvtime) >= tcp_maxpersistidle || 485 (tcp_now - tp->t_rcvtime) >= rto * tcp_totbackoff)) { 486 tcpstat.tcps_persistdrops++; 487 tp = tcp_drop(tp, ETIMEDOUT); 488 goto out; 489 } 490 tcpstat.tcps_persisttimeo++; 491 tcp_setpersist(tp); 492 tp->t_force = 1; 493 (void) tcp_output(tp); 494 tp->t_force = 0; 495 496 out: 497 #ifdef TCP_DEBUG 498 if (tp && so->so_options & SO_DEBUG) 499 tcp_trace(TA_USER, ostate, tp, NULL, 500 PRU_SLOWTIMO | (TCPT_PERSIST << 8)); 501 #endif 502 splx(s); 503 } 504 505 void 506 tcp_timer_keep(void *arg) 507 { 508 struct tcpcb *tp = arg; 509 struct socket *so = NULL; /* Quell compiler warning */ 510 int s; 511 #ifdef TCP_DEBUG 512 short ostate; 513 #endif 514 515 s = splsoftnet(); 516 callout_ack(&tp->t_timer[TCPT_KEEP]); 517 if (tcp_isdead(tp)) { 518 splx(s); 519 return; 520 } 521 522 #ifdef TCP_DEBUG 523 ostate = tp->t_state; 524 #endif /* TCP_DEBUG */ 525 526 /* 527 * Keep-alive timer went off; send something 528 * or drop connection if idle for too long. 529 */ 530 531 tcpstat.tcps_keeptimeo++; 532 if (TCPS_HAVEESTABLISHED(tp->t_state) == 0) 533 goto dropit; 534 #ifdef INET 535 if (tp->t_inpcb) 536 so = tp->t_inpcb->inp_socket; 537 #endif 538 #ifdef INET6 539 if (tp->t_in6pcb) 540 so = tp->t_in6pcb->in6p_socket; 541 #endif 542 KASSERT(so != NULL); 543 if (so->so_options & SO_KEEPALIVE && 544 tp->t_state <= TCPS_CLOSE_WAIT) { 545 if ((tcp_maxidle > 0) && 546 ((tcp_now - tp->t_rcvtime) >= 547 tcp_keepidle + tcp_maxidle)) 548 goto dropit; 549 /* 550 * Send a packet designed to force a response 551 * if the peer is up and reachable: 552 * either an ACK if the connection is still alive, 553 * or an RST if the peer has closed the connection 554 * due to timeout or reboot. 555 * Using sequence number tp->snd_una-1 556 * causes the transmitted zero-length segment 557 * to lie outside the receive window; 558 * by the protocol spec, this requires the 559 * correspondent TCP to respond. 560 */ 561 tcpstat.tcps_keepprobe++; 562 if (tcp_compat_42) { 563 /* 564 * The keepalive packet must have nonzero 565 * length to get a 4.2 host to respond. 566 */ 567 (void)tcp_respond(tp, tp->t_template, 568 (struct mbuf *)NULL, NULL, tp->rcv_nxt - 1, 569 tp->snd_una - 1, 0); 570 } else { 571 (void)tcp_respond(tp, tp->t_template, 572 (struct mbuf *)NULL, NULL, tp->rcv_nxt, 573 tp->snd_una - 1, 0); 574 } 575 TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepintvl); 576 } else 577 TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); 578 579 #ifdef TCP_DEBUG 580 if (tp && so->so_options & SO_DEBUG) 581 tcp_trace(TA_USER, ostate, tp, NULL, 582 PRU_SLOWTIMO | (TCPT_KEEP << 8)); 583 #endif 584 splx(s); 585 return; 586 587 dropit: 588 tcpstat.tcps_keepdrops++; 589 (void) tcp_drop(tp, ETIMEDOUT); 590 splx(s); 591 } 592 593 void 594 tcp_timer_2msl(void *arg) 595 { 596 struct tcpcb *tp = arg; 597 int s; 598 #ifdef TCP_DEBUG 599 struct socket *so = NULL; 600 short ostate; 601 #endif 602 603 s = splsoftnet(); 604 callout_ack(&tp->t_timer[TCPT_2MSL]); 605 if (tcp_isdead(tp)) { 606 splx(s); 607 return; 608 } 609 610 /* 611 * 2 MSL timeout went off, clear the SACK scoreboard, reset 612 * the FACK estimate. 613 */ 614 tcp_free_sackholes(tp); 615 tp->snd_fack = tp->snd_una; 616 617 #ifdef TCP_DEBUG 618 #ifdef INET 619 if (tp->t_inpcb) 620 so = tp->t_inpcb->inp_socket; 621 #endif 622 #ifdef INET6 623 if (tp->t_in6pcb) 624 so = tp->t_in6pcb->in6p_socket; 625 #endif 626 627 ostate = tp->t_state; 628 #endif /* TCP_DEBUG */ 629 630 /* 631 * 2 MSL timeout in shutdown went off. If we're closed but 632 * still waiting for peer to close and connection has been idle 633 * too long, or if 2MSL time is up from TIME_WAIT, delete connection 634 * control block. Otherwise, check again in a bit. 635 */ 636 if (tp->t_state != TCPS_TIME_WAIT && 637 ((tcp_maxidle == 0) || ((tcp_now - tp->t_rcvtime) <= tcp_maxidle))) 638 TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_keepintvl); 639 else 640 tp = tcp_close(tp); 641 642 #ifdef TCP_DEBUG 643 if (tp && so->so_options & SO_DEBUG) 644 tcp_trace(TA_USER, ostate, tp, NULL, 645 PRU_SLOWTIMO | (TCPT_2MSL << 8)); 646 #endif 647 splx(s); 648 } 649