Deleted Added
full compact
tcp_timer.c (96972) tcp_timer.c (97658)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tcp_timer.c 8.2 (Berkeley) 5/24/95
1/*
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tcp_timer.c 8.2 (Berkeley) 5/24/95
34 * $FreeBSD: head/sys/netinet/tcp_timer.c 96972 2002-05-20 05:41:09Z tanimura $
34 * $FreeBSD: head/sys/netinet/tcp_timer.c 97658 2002-05-31 11:52:35Z tanimura $
35 */
36
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_tcpdebug.h"
40
41#include <sys/param.h>
35 */
36
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_tcpdebug.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/kernel.h>
43#include <sys/lock.h>
44#include <sys/mbuf.h>
44#include <sys/mbuf.h>
45#include <sys/mutex.h>
46#include <sys/protosw.h>
45#include <sys/sysctl.h>
47#include <sys/socket.h>
48#include <sys/socketvar.h>
46#include <sys/socket.h>
47#include <sys/socketvar.h>
49#include <sys/sysctl.h>
50#include <sys/systm.h>
48#include <sys/protosw.h>
51
52#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
53
54#include <net/route.h>
55
56#include <netinet/in.h>
57#include <netinet/in_systm.h>
58#include <netinet/in_pcb.h>

--- 149 unchanged lines hidden (view full) ---

208 if (tp->t_state != TCPS_TIME_WAIT &&
209 (ticks - tp->t_rcvtime) <= tcp_maxidle)
210 callout_reset(tp->tt_2msl, tcp_keepintvl,
211 tcp_timer_2msl, tp);
212 else
213 tp = tcp_close(tp);
214
215#ifdef TCPDEBUG
49
50#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
51
52#include <net/route.h>
53
54#include <netinet/in.h>
55#include <netinet/in_systm.h>
56#include <netinet/in_pcb.h>

--- 149 unchanged lines hidden (view full) ---

206 if (tp->t_state != TCPS_TIME_WAIT &&
207 (ticks - tp->t_rcvtime) <= tcp_maxidle)
208 callout_reset(tp->tt_2msl, tcp_keepintvl,
209 tcp_timer_2msl, tp);
210 else
211 tp = tcp_close(tp);
212
213#ifdef TCPDEBUG
216 if (tp != 0) {
217 SOCK_LOCK(tp->t_inpcb->inp_socket);
218 if ((tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) {
219 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
220 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
221 PRU_SLOWTIMO);
222 } else
223 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
224 }
214 if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
215 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
216 PRU_SLOWTIMO);
225#endif
226 splx(s);
227}
228
229void
230tcp_timer_keep(xtp)
231 void *xtp;
232{

--- 13 unchanged lines hidden (view full) ---

246 callout_deactivate(tp->tt_keep);
247 /*
248 * Keep-alive timer went off; send something
249 * or drop connection if idle for too long.
250 */
251 tcpstat.tcps_keeptimeo++;
252 if (tp->t_state < TCPS_ESTABLISHED)
253 goto dropit;
217#endif
218 splx(s);
219}
220
221void
222tcp_timer_keep(xtp)
223 void *xtp;
224{

--- 13 unchanged lines hidden (view full) ---

238 callout_deactivate(tp->tt_keep);
239 /*
240 * Keep-alive timer went off; send something
241 * or drop connection if idle for too long.
242 */
243 tcpstat.tcps_keeptimeo++;
244 if (tp->t_state < TCPS_ESTABLISHED)
245 goto dropit;
254 SOCK_LOCK(tp->t_inpcb->inp_socket);
255 if ((always_keepalive ||
256 tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) &&
257 tp->t_state <= TCPS_CLOSING) {
246 if ((always_keepalive ||
247 tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) &&
248 tp->t_state <= TCPS_CLOSING) {
258 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
259 if ((ticks - tp->t_rcvtime) >= tcp_keepidle + tcp_maxidle)
260 goto dropit;
261 /*
262 * Send a packet designed to force a response
263 * if the peer is up and reachable:
264 * either an ACK if the connection is still alive,
265 * or an RST if the peer has closed the connection
266 * due to timeout or reboot.

--- 7 unchanged lines hidden (view full) ---

274 t_template = tcp_maketemplate(tp);
275 if (t_template) {
276 tcp_respond(tp, t_template->tt_ipgen,
277 &t_template->tt_t, (struct mbuf *)NULL,
278 tp->rcv_nxt, tp->snd_una - 1, 0);
279 (void) m_free(dtom(t_template));
280 }
281 callout_reset(tp->tt_keep, tcp_keepintvl, tcp_timer_keep, tp);
249 if ((ticks - tp->t_rcvtime) >= tcp_keepidle + tcp_maxidle)
250 goto dropit;
251 /*
252 * Send a packet designed to force a response
253 * if the peer is up and reachable:
254 * either an ACK if the connection is still alive,
255 * or an RST if the peer has closed the connection
256 * due to timeout or reboot.

--- 7 unchanged lines hidden (view full) ---

264 t_template = tcp_maketemplate(tp);
265 if (t_template) {
266 tcp_respond(tp, t_template->tt_ipgen,
267 &t_template->tt_t, (struct mbuf *)NULL,
268 tp->rcv_nxt, tp->snd_una - 1, 0);
269 (void) m_free(dtom(t_template));
270 }
271 callout_reset(tp->tt_keep, tcp_keepintvl, tcp_timer_keep, tp);
282 } else {
283 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
272 } else
284 callout_reset(tp->tt_keep, tcp_keepidle, tcp_timer_keep, tp);
273 callout_reset(tp->tt_keep, tcp_keepidle, tcp_timer_keep, tp);
285 }
286
287#ifdef TCPDEBUG
274
275#ifdef TCPDEBUG
288 SOCK_LOCK(tp->t_inpcb->inp_socket);
289 if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG) {
290 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
276 if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
291 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
292 PRU_SLOWTIMO);
277 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
278 PRU_SLOWTIMO);
293 } else
294 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
295#endif
296 splx(s);
297 return;
298
299dropit:
300 tcpstat.tcps_keepdrops++;
301 tp = tcp_drop(tp, ETIMEDOUT);
302
303#ifdef TCPDEBUG
279#endif
280 splx(s);
281 return;
282
283dropit:
284 tcpstat.tcps_keepdrops++;
285 tp = tcp_drop(tp, ETIMEDOUT);
286
287#ifdef TCPDEBUG
304 if (tp != 0) {
305 SOCK_LOCK(tp->t_inpcb->inp_socket);
306 if ((tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) {
307 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
308 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
309 PRU_SLOWTIMO);
310 } else
311 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
312 }
288 if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
289 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
290 PRU_SLOWTIMO);
313#endif
314 splx(s);
315}
316
317void
318tcp_timer_persist(xtp)
319 void *xtp;
320{

--- 31 unchanged lines hidden (view full) ---

352 }
353 tcp_setpersist(tp);
354 tp->t_force = 1;
355 (void) tcp_output(tp);
356 tp->t_force = 0;
357
358out:
359#ifdef TCPDEBUG
291#endif
292 splx(s);
293}
294
295void
296tcp_timer_persist(xtp)
297 void *xtp;
298{

--- 31 unchanged lines hidden (view full) ---

330 }
331 tcp_setpersist(tp);
332 tp->t_force = 1;
333 (void) tcp_output(tp);
334 tp->t_force = 0;
335
336out:
337#ifdef TCPDEBUG
360 if (tp != 0) {
361 SOCK_LOCK(tp->t_inpcb->inp_socket);
362 if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG) {
363 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
364 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
365 PRU_SLOWTIMO);
366 } else
367 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
368 }
338 if (tp && tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
339 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
340 PRU_SLOWTIMO);
369#endif
370 splx(s);
371}
372
373void
374tcp_timer_rexmt(xtp)
375 void *xtp;
376{

--- 116 unchanged lines hidden (view full) ---

493 tp->snd_cwnd = tp->t_maxseg;
494 tp->snd_ssthresh = win * tp->t_maxseg;
495 tp->t_dupacks = 0;
496 }
497 (void) tcp_output(tp);
498
499out:
500#ifdef TCPDEBUG
341#endif
342 splx(s);
343}
344
345void
346tcp_timer_rexmt(xtp)
347 void *xtp;
348{

--- 116 unchanged lines hidden (view full) ---

465 tp->snd_cwnd = tp->t_maxseg;
466 tp->snd_ssthresh = win * tp->t_maxseg;
467 tp->t_dupacks = 0;
468 }
469 (void) tcp_output(tp);
470
471out:
472#ifdef TCPDEBUG
501 if (tp != 0) {
502 SOCK_LOCK(tp->t_inpcb->inp_socket);
503 if ((tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) {
504 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
505 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
506 PRU_SLOWTIMO);
507 } else
508 SOCK_UNLOCK(tp->t_inpcb->inp_socket);
509 }
473 if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
474 tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
475 PRU_SLOWTIMO);
510#endif
511 splx(s);
512}
476#endif
477 splx(s);
478}