1 /* $NetBSD: tcp_timer.c,v 1.71.2.1 2008/11/18 22:57:09 snj 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.71.2.1 2008/11/18 22:57:09 snj 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
127 #ifdef INET6
128 #ifndef INET
129 #include <netinet/in.h>
130 #endif
131 #include <netinet/ip6.h>
132 #include <netinet6/in6_pcb.h>
133 #endif
134
135 #include <netinet/tcp.h>
136 #include <netinet/tcp_fsm.h>
137 #include <netinet/tcp_seq.h>
138 #include <netinet/tcp_timer.h>
139 #include <netinet/tcp_var.h>
140 #include <netinet/tcpip.h>
141 #ifdef TCP_DEBUG
142 #include <netinet/tcp_debug.h>
143 #endif
144
145 /*
146 * Various tunable timer parameters. These are initialized in tcp_init(),
147 * unless they are patched.
148 */
149 int tcp_keepidle = 0;
150 int tcp_keepintvl = 0;
151 int tcp_keepcnt = 0; /* max idle probes */
152 int tcp_maxpersistidle = 0; /* max idle time in persist */
153 int tcp_maxidle; /* computed in tcp_slowtimo() */
154
155 /*
156 * Time to delay the ACK. This is initialized in tcp_init(), unless
157 * its patched.
158 */
159 int tcp_delack_ticks = 0;
160
161 void tcp_timer_rexmt(void *);
162 void tcp_timer_persist(void *);
163 void tcp_timer_keep(void *);
164 void tcp_timer_2msl(void *);
165
166 const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS] = {
167 tcp_timer_rexmt,
168 tcp_timer_persist,
169 tcp_timer_keep,
170 tcp_timer_2msl,
171 };
172
173 /*
174 * Timer state initialization, called from tcp_init().
175 */
176 void
177 tcp_timer_init(void)
178 {
179
180 if (tcp_keepidle == 0)
181 tcp_keepidle = TCPTV_KEEP_IDLE;
182
183 if (tcp_keepintvl == 0)
184 tcp_keepintvl = TCPTV_KEEPINTVL;
185
186 if (tcp_keepcnt == 0)
187 tcp_keepcnt = TCPTV_KEEPCNT;
188
189 if (tcp_maxpersistidle == 0)
190 tcp_maxpersistidle = TCPTV_KEEP_IDLE;
191
192 if (tcp_delack_ticks == 0)
193 tcp_delack_ticks = TCP_DELACK_TICKS;
194 }
195
196 /*
197 * Return how many timers are currently being invoked.
198 */
199 int
200 tcp_timers_invoking(struct tcpcb *tp)
201 {
202 int i;
203 int count = 0;
204
205 for (i = 0; i < TCPT_NTIMERS; i++)
206 if (callout_invoking(&tp->t_timer[i]))
207 count++;
208 if (callout_invoking(&tp->t_delack_ch))
209 count++;
210
211 return count;
212 }
213
214 /*
215 * Callout to process delayed ACKs for a TCPCB.
216 */
217 void
218 tcp_delack(void *arg)
219 {
220 struct tcpcb *tp = arg;
221 int s;
222
223 /*
224 * If tcp_output() wasn't able to transmit the ACK
225 * for whatever reason, it will restart the delayed
226 * ACK callout.
227 */
228
229 s = splsoftnet();
230 callout_ack(&tp->t_delack_ch);
231 if (tcp_isdead(tp)) {
232 splx(s);
233 return;
234 }
235 if (!callout_expired(&tp->t_delack_ch)) {
236 splx(s);
237 return;
238 }
239
240 tp->t_flags |= TF_ACKNOW;
241 (void) tcp_output(tp);
242 splx(s);
243 }
244
245 /*
246 * Tcp protocol timeout routine called every 500 ms.
247 * Updates the timers in all active tcb's and
248 * causes finite state machine actions if timers expire.
249 */
250 void
251 tcp_slowtimo(void)
252 {
253 int s;
254
255 s = splsoftnet();
256 tcp_maxidle = tcp_keepcnt * tcp_keepintvl;
257 tcp_iss_seq += TCP_ISSINCR; /* increment iss */
258 tcp_now++; /* for timestamps */
259 splx(s);
260 }
261
262 /*
263 * Cancel all timers for TCP tp.
264 */
265 void
266 tcp_canceltimers(struct tcpcb *tp)
267 {
268 int i;
269
270 for (i = 0; i < TCPT_NTIMERS; i++)
271 TCP_TIMER_DISARM(tp, i);
272 }
273
274 const int tcp_backoff[TCP_MAXRXTSHIFT + 1] =
275 { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
276
277 const int tcp_totbackoff = 511; /* sum of tcp_backoff[] */
278
279 /*
280 * TCP timer processing.
281 */
282
283 void
284 tcp_timer_rexmt(void *arg)
285 {
286 struct tcpcb *tp = arg;
287 uint32_t rto;
288 int s;
289 #ifdef TCP_DEBUG
290 struct socket *so = NULL;
291 short ostate;
292 #endif
293
294 s = splsoftnet();
295 callout_ack(&tp->t_timer[TCPT_REXMT]);
296 if (tcp_isdead(tp)) {
297 splx(s);
298 return;
299 }
300 if (!callout_expired(&tp->t_timer[TCPT_REXMT])) {
301 splx(s);
302 return;
303 }
304
305 #ifdef TCP_DEBUG
306 #ifdef INET
307 if (tp->t_inpcb)
308 so = tp->t_inpcb->inp_socket;
309 #endif
310 #ifdef INET6
311 if (tp->t_in6pcb)
312 so = tp->t_in6pcb->in6p_socket;
313 #endif
314 ostate = tp->t_state;
315 #endif /* TCP_DEBUG */
316
317 /*
318 * Clear the SACK scoreboard, reset FACK estimate.
319 */
320 tcp_free_sackholes(tp);
321 tp->snd_fack = tp->snd_una;
322
323 /*
324 * Retransmission timer went off. Message has not
325 * been acked within retransmit interval. Back off
326 * to a longer retransmit interval and retransmit one segment.
327 */
328
329 if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) {
330 tp->t_rxtshift = TCP_MAXRXTSHIFT;
331 tcpstat.tcps_timeoutdrop++;
332 tp = tcp_drop(tp, tp->t_softerror ?
333 tp->t_softerror : ETIMEDOUT);
334 goto out;
335 }
336 tcpstat.tcps_rexmttimeo++;
337 rto = TCP_REXMTVAL(tp);
338 if (rto < tp->t_rttmin)
339 rto = tp->t_rttmin;
340 TCPT_RANGESET(tp->t_rxtcur, rto * tcp_backoff[tp->t_rxtshift],
341 tp->t_rttmin, TCPTV_REXMTMAX);
342 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur);
343
344 /*
345 * If we are losing and we are trying path MTU discovery,
346 * try turning it off. This will avoid black holes in
347 * the network which suppress or fail to send "packet
348 * too big" ICMP messages. We should ideally do
349 * lots more sophisticated searching to find the right
350 * value here...
351 */
352 if (tp->t_mtudisc && tp->t_rxtshift > TCP_MAXRXTSHIFT / 6) {
353 tcpstat.tcps_pmtublackhole++;
354
355 #ifdef INET
356 /* try turning PMTUD off */
357 if (tp->t_inpcb)
358 tp->t_mtudisc = 0;
359 #endif
360 #ifdef INET6
361 /* try using IPv6 minimum MTU */
362 if (tp->t_in6pcb)
363 tp->t_mtudisc = 0;
364 #endif
365
366 /* XXX: more sophisticated Black hole recovery code? */
367 }
368
369 /*
370 * If losing, let the lower level know and try for
371 * a better route. Also, if we backed off this far,
372 * our srtt estimate is probably bogus. Clobber it
373 * so we'll take the next rtt measurement as our srtt;
374 * move the current srtt into rttvar to keep the current
375 * retransmit times until then.
376 */
377 if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
378 #ifdef INET
379 if (tp->t_inpcb)
380 in_losing(tp->t_inpcb);
381 #endif
382 #ifdef INET6
383 if (tp->t_in6pcb)
384 in6_losing(tp->t_in6pcb);
385 #endif
386 tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT);
387 tp->t_srtt = 0;
388 }
389 tp->snd_nxt = tp->snd_una;
390 tp->snd_high = tp->snd_max;
391 /*
392 * If timing a segment in this window, stop the timer.
393 */
394 tp->t_rtttime = 0;
395 /*
396 * Remember if we are retransmitting a SYN, because if
397 * we do, set the initial congestion window must be set
398 * to 1 segment.
399 */
400 if (tp->t_state == TCPS_SYN_SENT)
401 tp->t_flags |= TF_SYN_REXMT;
402 /*
403 * Close the congestion window down to one segment
404 * (we'll open it by one segment for each ack we get).
405 * Since we probably have a window's worth of unacked
406 * data accumulated, this "slow start" keeps us from
407 * dumping all that data as back-to-back packets (which
408 * might overwhelm an intermediate gateway).
409 *
410 * There are two phases to the opening: Initially we
411 * open by one mss on each ack. This makes the window
412 * size increase exponentially with time. If the
413 * window is larger than the path can handle, this
414 * exponential growth results in dropped packet(s)
415 * almost immediately. To get more time between
416 * drops but still "push" the network to take advantage
417 * of improving conditions, we switch from exponential
418 * to linear window opening at some threshhold size.
419 * For a threshhold, we use half the current window
420 * size, truncated to a multiple of the mss.
421 *
422 * (the minimum cwnd that will give us exponential
423 * growth is 2 mss. We don't allow the threshhold
424 * to go below this.)
425 */
426 {
427 u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_segsz;
428 if (win < 2)
429 win = 2;
430 /* Loss Window MUST be one segment. */
431 tp->snd_cwnd = tp->t_segsz;
432 tp->snd_ssthresh = win * tp->t_segsz;
433 tp->t_partialacks = -1;
434 tp->t_dupacks = 0;
435 }
436 (void) tcp_output(tp);
437
438 out:
439 #ifdef TCP_DEBUG
440 if (tp && so->so_options & SO_DEBUG)
441 tcp_trace(TA_USER, ostate, tp, NULL,
442 PRU_SLOWTIMO | (TCPT_REXMT << 8));
443 #endif
444 splx(s);
445 }
446
447 void
448 tcp_timer_persist(void *arg)
449 {
450 struct tcpcb *tp = arg;
451 uint32_t rto;
452 int s;
453 #ifdef TCP_DEBUG
454 struct socket *so = NULL;
455 short ostate;
456 #endif
457
458 s = splsoftnet();
459 callout_ack(&tp->t_timer[TCPT_PERSIST]);
460 if (tcp_isdead(tp)) {
461 splx(s);
462 return;
463 }
464 if (!callout_expired(&tp->t_timer[TCPT_PERSIST])) {
465 splx(s);
466 return;
467 }
468
469 #ifdef TCP_DEBUG
470 #ifdef INET
471 if (tp->t_inpcb)
472 so = tp->t_inpcb->inp_socket;
473 #endif
474 #ifdef INET6
475 if (tp->t_in6pcb)
476 so = tp->t_in6pcb->in6p_socket;
477 #endif
478
479 ostate = tp->t_state;
480 #endif /* TCP_DEBUG */
481
482 /*
483 * Persistance timer into zero window.
484 * Force a byte to be output, if possible.
485 */
486
487 /*
488 * Hack: if the peer is dead/unreachable, we do not
489 * time out if the window is closed. After a full
490 * backoff, drop the connection if the idle time
491 * (no responses to probes) reaches the maximum
492 * backoff that we would use if retransmitting.
493 */
494 rto = TCP_REXMTVAL(tp);
495 if (rto < tp->t_rttmin)
496 rto = tp->t_rttmin;
497 if (tp->t_rxtshift == TCP_MAXRXTSHIFT &&
498 ((tcp_now - tp->t_rcvtime) >= tcp_maxpersistidle ||
499 (tcp_now - tp->t_rcvtime) >= rto * tcp_totbackoff)) {
500 tcpstat.tcps_persistdrops++;
501 tp = tcp_drop(tp, ETIMEDOUT);
502 goto out;
503 }
504 tcpstat.tcps_persisttimeo++;
505 tcp_setpersist(tp);
506 tp->t_force = 1;
507 (void) tcp_output(tp);
508 tp->t_force = 0;
509
510 out:
511 #ifdef TCP_DEBUG
512 if (tp && so->so_options & SO_DEBUG)
513 tcp_trace(TA_USER, ostate, tp, NULL,
514 PRU_SLOWTIMO | (TCPT_PERSIST << 8));
515 #endif
516 splx(s);
517 }
518
519 void
520 tcp_timer_keep(void *arg)
521 {
522 struct tcpcb *tp = arg;
523 struct socket *so = NULL; /* Quell compiler warning */
524 int s;
525 #ifdef TCP_DEBUG
526 short ostate;
527 #endif
528
529 s = splsoftnet();
530 callout_ack(&tp->t_timer[TCPT_KEEP]);
531 if (tcp_isdead(tp)) {
532 splx(s);
533 return;
534 }
535 if (!callout_expired(&tp->t_timer[TCPT_KEEP])) {
536 splx(s);
537 return;
538 }
539
540 #ifdef TCP_DEBUG
541 ostate = tp->t_state;
542 #endif /* TCP_DEBUG */
543
544 /*
545 * Keep-alive timer went off; send something
546 * or drop connection if idle for too long.
547 */
548
549 tcpstat.tcps_keeptimeo++;
550 if (TCPS_HAVEESTABLISHED(tp->t_state) == 0)
551 goto dropit;
552 #ifdef INET
553 if (tp->t_inpcb)
554 so = tp->t_inpcb->inp_socket;
555 #endif
556 #ifdef INET6
557 if (tp->t_in6pcb)
558 so = tp->t_in6pcb->in6p_socket;
559 #endif
560 if (so->so_options & SO_KEEPALIVE &&
561 tp->t_state <= TCPS_CLOSE_WAIT) {
562 if ((tcp_maxidle > 0) &&
563 ((tcp_now - tp->t_rcvtime) >=
564 tcp_keepidle + tcp_maxidle))
565 goto dropit;
566 /*
567 * Send a packet designed to force a response
568 * if the peer is up and reachable:
569 * either an ACK if the connection is still alive,
570 * or an RST if the peer has closed the connection
571 * due to timeout or reboot.
572 * Using sequence number tp->snd_una-1
573 * causes the transmitted zero-length segment
574 * to lie outside the receive window;
575 * by the protocol spec, this requires the
576 * correspondent TCP to respond.
577 */
578 tcpstat.tcps_keepprobe++;
579 if (tcp_compat_42) {
580 /*
581 * The keepalive packet must have nonzero
582 * length to get a 4.2 host to respond.
583 */
584 (void)tcp_respond(tp, tp->t_template,
585 (struct mbuf *)NULL, NULL, tp->rcv_nxt - 1,
586 tp->snd_una - 1, 0);
587 } else {
588 (void)tcp_respond(tp, tp->t_template,
589 (struct mbuf *)NULL, NULL, tp->rcv_nxt,
590 tp->snd_una - 1, 0);
591 }
592 TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepintvl);
593 } else
594 TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle);
595
596 #ifdef TCP_DEBUG
597 if (tp && so->so_options & SO_DEBUG)
598 tcp_trace(TA_USER, ostate, tp, NULL,
599 PRU_SLOWTIMO | (TCPT_KEEP << 8));
600 #endif
601 splx(s);
602 return;
603
604 dropit:
605 tcpstat.tcps_keepdrops++;
606 (void) tcp_drop(tp, ETIMEDOUT);
607 splx(s);
608 }
609
610 void
611 tcp_timer_2msl(void *arg)
612 {
613 struct tcpcb *tp = arg;
614 int s;
615 #ifdef TCP_DEBUG
616 struct socket *so = NULL;
617 short ostate;
618 #endif
619
620 s = splsoftnet();
621 callout_ack(&tp->t_timer[TCPT_2MSL]);
622 if (tcp_isdead(tp)) {
623 splx(s);
624 return;
625 }
626 if (!callout_expired(&tp->t_timer[TCPT_2MSL])) {
627 splx(s);
628 return;
629 }
630
631 /*
632 * 2 MSL timeout went off, clear the SACK scoreboard, reset
633 * the FACK estimate.
634 */
635 tcp_free_sackholes(tp);
636 tp->snd_fack = tp->snd_una;
637
638 #ifdef TCP_DEBUG
639 #ifdef INET
640 if (tp->t_inpcb)
641 so = tp->t_inpcb->inp_socket;
642 #endif
643 #ifdef INET6
644 if (tp->t_in6pcb)
645 so = tp->t_in6pcb->in6p_socket;
646 #endif
647
648 ostate = tp->t_state;
649 #endif /* TCP_DEBUG */
650
651 /*
652 * 2 MSL timeout in shutdown went off. If we're closed but
653 * still waiting for peer to close and connection has been idle
654 * too long, or if 2MSL time is up from TIME_WAIT, delete connection
655 * control block. Otherwise, check again in a bit.
656 */
657 if (tp->t_state != TCPS_TIME_WAIT &&
658 ((tcp_maxidle == 0) || ((tcp_now - tp->t_rcvtime) <= tcp_maxidle)))
659 TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_keepintvl);
660 else
661 tp = tcp_close(tp);
662
663 #ifdef TCP_DEBUG
664 if (tp && so->so_options & SO_DEBUG)
665 tcp_trace(TA_USER, ostate, tp, NULL,
666 PRU_SLOWTIMO | (TCPT_2MSL << 8));
667 #endif
668 splx(s);
669 }
Cache object: c05365713ae27a23ea31ddff47626f9b
|