MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_timer_2msl

Function tcp_timer_2msl

freebsd/netinet/tcp_timer.c:308–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void
309tcp_timer_2msl(void *xtp)
310{
311 struct tcpcb *tp = xtp;
312 struct inpcb *inp;
313 struct epoch_tracker et;
314 CURVNET_SET(tp->t_vnet);
315#ifdef TCPDEBUG
316 int ostate;
317
318 ostate = tp->t_state;
319#endif
320 inp = tp->t_inpcb;
321 KASSERT(inp != NULL, ("%s: tp %p tp->t_inpcb == NULL", __func__, tp));
322 INP_WLOCK(inp);
323 tcp_free_sackholes(tp);
324 if (callout_pending(&tp->t_timers->tt_2msl) ||
325 !callout_active(&tp->t_timers->tt_2msl)) {
326 INP_WUNLOCK(tp->t_inpcb);
327 CURVNET_RESTORE();
328 return;
329 }
330 callout_deactivate(&tp->t_timers->tt_2msl);
331 if ((inp->inp_flags & INP_DROPPED) != 0) {
332 INP_WUNLOCK(inp);
333 CURVNET_RESTORE();
334 return;
335 }
336 KASSERT((tp->t_timers->tt_flags & TT_STOPPED) == 0,
337 ("%s: tp %p tcpcb can't be stopped here", __func__, tp));
338 /*
339 * 2 MSL timeout in shutdown went off. If we're closed but
340 * still waiting for peer to close and connection has been idle
341 * too long delete connection control block. Otherwise, check
342 * again in a bit.
343 *
344 * If in TIME_WAIT state just ignore as this timeout is handled in
345 * tcp_tw_2msl_scan().
346 *
347 * If fastrecycle of FIN_WAIT_2, in FIN_WAIT_2 and receiver has closed,
348 * there's no point in hanging onto FIN_WAIT_2 socket. Just close it.
349 * Ignore fact that there were recent incoming segments.
350 */
351 if ((inp->inp_flags & INP_TIMEWAIT) != 0) {
352 INP_WUNLOCK(inp);
353 CURVNET_RESTORE();
354 return;
355 }
356 if (tcp_fast_finwait2_recycle && tp->t_state == TCPS_FIN_WAIT_2 &&
357 tp->t_inpcb && tp->t_inpcb->inp_socket &&
358 (tp->t_inpcb->inp_socket->so_rcv.sb_state & SBS_CANTRCVMORE)) {
359 TCPSTAT_INC(tcps_finwait2_drops);
360 if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
361 tcp_inpinfo_lock_del(inp, tp);
362 goto out;
363 }
364 NET_EPOCH_ENTER(et);
365 tp = tcp_close(tp);

Callers

nothing calls this directly

Calls 4

tcp_free_sackholesFunction · 0.85
tcp_inpinfo_lock_delFunction · 0.85
tcp_closeFunction · 0.85
tcp_traceFunction · 0.85

Tested by

no test coverage detected