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

Function tcp_default_fb_init

freebsd/netinet/tcp_subr.c:699–753  ·  view source on GitHub ↗

* tfb_tcp_fb_init() function for the default stack. * * This handles making sure we have appropriate timers set if you are * transitioning a socket that has some amount of setup done. * * The init() fuction from the default can *never* return non-zero i.e. * it is required to always succeed since it is the stack of last resort! */

Source from the content-addressed store, hash-verified

697 * it is required to always succeed since it is the stack of last resort!
698 */
699static int
700tcp_default_fb_init(struct tcpcb *tp)
701{
702
703 struct socket *so;
704
705 INP_WLOCK_ASSERT(tp->t_inpcb);
706
707 KASSERT(tp->t_state >= 0 && tp->t_state < TCPS_TIME_WAIT,
708 ("%s: connection %p in unexpected state %d", __func__, tp,
709 tp->t_state));
710
711 /*
712 * Nothing to do for ESTABLISHED or LISTEN states. And, we don't
713 * know what to do for unexpected states (which includes TIME_WAIT).
714 */
715 if (tp->t_state <= TCPS_LISTEN || tp->t_state >= TCPS_TIME_WAIT)
716 return (0);
717
718 /*
719 * Make sure some kind of transmission timer is set if there is
720 * outstanding data.
721 */
722 so = tp->t_inpcb->inp_socket;
723 if ((!TCPS_HAVEESTABLISHED(tp->t_state) || sbavail(&so->so_snd) ||
724 tp->snd_una != tp->snd_max) && !(tcp_timer_active(tp, TT_REXMT) ||
725 tcp_timer_active(tp, TT_PERSIST))) {
726 /*
727 * If the session has established and it looks like it should
728 * be in the persist state, set the persist timer. Otherwise,
729 * set the retransmit timer.
730 */
731 if (TCPS_HAVEESTABLISHED(tp->t_state) && tp->snd_wnd == 0 &&
732 (int32_t)(tp->snd_nxt - tp->snd_una) <
733 (int32_t)sbavail(&so->so_snd))
734 tcp_setpersist(tp);
735 else
736 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
737 }
738
739 /* All non-embryonic sessions get a keepalive timer. */
740 if (!tcp_timer_active(tp, TT_KEEP))
741 tcp_timer_activate(tp, TT_KEEP,
742 TCPS_HAVEESTABLISHED(tp->t_state) ? TP_KEEPIDLE(tp) :
743 TP_KEEPINIT(tp));
744
745 /*
746 * Make sure critical variables are initialized
747 * if transitioning while in Recovery.
748 */
749 if IN_FASTRECOVERY(tp->t_flags) {
750 if (tp->sackhint.recover_fs == 0)
751 tp->sackhint.recover_fs = max(1,
752 tp->snd_nxt - tp->snd_una);
753 }
754
755 return (0);
756}

Callers

nothing calls this directly

Calls 5

tcp_timer_activeFunction · 0.85
tcp_setpersistFunction · 0.85
tcp_timer_activateFunction · 0.85
maxFunction · 0.85
sbavailFunction · 0.50

Tested by

no test coverage detected