Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_stacks/bbr.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 7,870 Lines • ▼ Show 20 Lines | if (tp->t_flags & TF_PREVVALID) { | ||||
if (tp->t_rxtshift == 1 && | if (tp->t_rxtshift == 1 && | ||||
(int)(ticks - tp->t_badrxtwin) < 0) | (int)(ticks - tp->t_badrxtwin) < 0) | ||||
bbr_cong_signal(tp, th, CC_RTO_ERR, NULL); | bbr_cong_signal(tp, th, CC_RTO_ERR, NULL); | ||||
} | } | ||||
SOCKBUF_LOCK(&so->so_snd); | SOCKBUF_LOCK(&so->so_snd); | ||||
acked_amount = min(acked, (int)sbavail(&so->so_snd)); | acked_amount = min(acked, (int)sbavail(&so->so_snd)); | ||||
tp->snd_wnd -= acked_amount; | tp->snd_wnd -= acked_amount; | ||||
mfree = sbcut_locked(&so->so_snd, acked_amount); | mfree = sbcut_locked(&so->so_snd, acked_amount); | ||||
SOCKBUF_UNLOCK(&so->so_snd); | /* NB: sowwakeup_locked() does an implicit unlock. */ | ||||
tp->t_flags |= TF_WAKESOW; | sowwakeup_locked(so); | ||||
m_freem(mfree); | m_freem(mfree); | ||||
if (SEQ_GT(th->th_ack, tp->snd_una)) { | if (SEQ_GT(th->th_ack, tp->snd_una)) { | ||||
bbr_collapse_rtt(tp, bbr, TCP_REXMTVAL(tp)); | bbr_collapse_rtt(tp, bbr, TCP_REXMTVAL(tp)); | ||||
} | } | ||||
tp->snd_una = th->th_ack; | tp->snd_una = th->th_ack; | ||||
bbr_ack_received(tp, bbr, th, acked, sack_changed, prev_acked, __LINE__, (bbr->r_ctl.rc_lost - lost)); | bbr_ack_received(tp, bbr, th, acked, sack_changed, prev_acked, __LINE__, (bbr->r_ctl.rc_lost - lost)); | ||||
if (IN_RECOVERY(tp->t_flags)) { | if (IN_RECOVERY(tp->t_flags)) { | ||||
if (SEQ_LT(th->th_ack, tp->snd_recover) && | if (SEQ_LT(th->th_ack, tp->snd_recover) && | ||||
▲ Show 20 Lines • Show All 459 Lines • ▼ Show 20 Lines | #endif | ||||
SOCKBUF_LOCK(&so->so_rcv); | SOCKBUF_LOCK(&so->so_rcv); | ||||
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) | if (so->so_rcv.sb_state & SBS_CANTRCVMORE) | ||||
m_freem(m); | m_freem(m); | ||||
else | else | ||||
#ifdef NETFLIX_SB_LIMITS | #ifdef NETFLIX_SB_LIMITS | ||||
appended = | appended = | ||||
#endif | #endif | ||||
sbappendstream_locked(&so->so_rcv, m, 0); | sbappendstream_locked(&so->so_rcv, m, 0); | ||||
SOCKBUF_UNLOCK(&so->so_rcv); | |||||
tp->t_flags |= TF_WAKESOR; | tp->t_flags |= TF_WAKESOR; | ||||
#ifdef NETFLIX_SB_LIMITS | #ifdef NETFLIX_SB_LIMITS | ||||
if (so->so_rcv.sb_shlim && appended != mcnt) | if (so->so_rcv.sb_shlim && appended != mcnt) | ||||
counter_fo_release(so->so_rcv.sb_shlim, | counter_fo_release(so->so_rcv.sb_shlim, | ||||
mcnt - appended); | mcnt - appended); | ||||
#endif | #endif | ||||
} else { | } else { | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
/* | /* | ||||
* If FIN is received ACK the FIN and let the user know that the | * If FIN is received ACK the FIN and let the user know that the | ||||
* connection is closing. | * connection is closing. | ||||
*/ | */ | ||||
if (thflags & TH_FIN) { | if (thflags & TH_FIN) { | ||||
if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { | if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { | ||||
socantrcvmore(so); | if (tp->t_flags & TF_WAKESOR) { | ||||
/* The socket upcall is handled by socantrcvmore. */ | /* The socket upcall is handled by socantrcvmore. */ | ||||
tp->t_flags &= ~TF_WAKESOR; | tp->t_flags &= ~TF_WAKESOR; | ||||
socantrcvmore_locked(so); | |||||
} else | |||||
socantrcvmore(so); | |||||
/* | /* | ||||
* If connection is half-synchronized (ie NEEDSYN | * If connection is half-synchronized (ie NEEDSYN | ||||
* flag on) then delay ACK, so it may be piggybacked | * flag on) then delay ACK, so it may be piggybacked | ||||
* when SYN is sent. Otherwise, since we received a | * when SYN is sent. Otherwise, since we received a | ||||
* FIN then no more input can be expected, send ACK | * FIN then no more input can be expected, send ACK | ||||
* now. | * now. | ||||
*/ | */ | ||||
if (tp->t_flags & TF_NEEDSYN) { | if (tp->t_flags & TF_NEEDSYN) { | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { | ||||
m_adj(m, drop_hdrlen); /* delayed header drop */ | m_adj(m, drop_hdrlen); /* delayed header drop */ | ||||
#ifdef NETFLIX_SB_LIMITS | #ifdef NETFLIX_SB_LIMITS | ||||
appended = | appended = | ||||
#endif | #endif | ||||
sbappendstream_locked(&so->so_rcv, m, 0); | sbappendstream_locked(&so->so_rcv, m, 0); | ||||
ctf_calc_rwin(so, tp); | ctf_calc_rwin(so, tp); | ||||
} | } | ||||
SOCKBUF_UNLOCK(&so->so_rcv); | |||||
tp->t_flags |= TF_WAKESOR; | tp->t_flags |= TF_WAKESOR; | ||||
#ifdef NETFLIX_SB_LIMITS | #ifdef NETFLIX_SB_LIMITS | ||||
if (so->so_rcv.sb_shlim && mcnt != appended) | if (so->so_rcv.sb_shlim && mcnt != appended) | ||||
counter_fo_release(so->so_rcv.sb_shlim, mcnt - appended); | counter_fo_release(so->so_rcv.sb_shlim, mcnt - appended); | ||||
#endif | #endif | ||||
if (DELAY_ACK(tp, bbr, nsegs)) { | if (DELAY_ACK(tp, bbr, nsegs)) { | ||||
bbr->bbr_segs_rcvd += max(1, nsegs); | bbr->bbr_segs_rcvd += max(1, nsegs); | ||||
tp->t_flags |= TF_DELACK; | tp->t_flags |= TF_DELACK; | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | #endif | ||||
*/ | */ | ||||
#ifdef TCPDEBUG | #ifdef TCPDEBUG | ||||
if (so->so_options & SO_DEBUG) | if (so->so_options & SO_DEBUG) | ||||
tcp_trace(TA_INPUT, ostate, tp, | tcp_trace(TA_INPUT, ostate, tp, | ||||
(void *)tcp_saveipgen, | (void *)tcp_saveipgen, | ||||
&tcp_savetcp, 0); | &tcp_savetcp, 0); | ||||
#endif | #endif | ||||
/* Wake up the socket if we have room to write more */ | /* Wake up the socket if we have room to write more */ | ||||
tp->t_flags |= TF_WAKESOW; | sowwakeup(so); | ||||
if (tp->snd_una == tp->snd_max) { | if (tp->snd_una == tp->snd_max) { | ||||
/* Nothing left outstanding */ | /* Nothing left outstanding */ | ||||
bbr_log_progress_event(bbr, tp, ticks, PROGRESS_CLEAR, __LINE__); | bbr_log_progress_event(bbr, tp, ticks, PROGRESS_CLEAR, __LINE__); | ||||
if (sbavail(&tp->t_inpcb->inp_socket->so_snd) == 0) | if (sbavail(&tp->t_inpcb->inp_socket->so_snd) == 0) | ||||
bbr->rc_tp->t_acktime = 0; | bbr->rc_tp->t_acktime = 0; | ||||
bbr_timer_cancel(bbr, __LINE__, bbr->r_ctl.rc_rcvtime); | bbr_timer_cancel(bbr, __LINE__, bbr->r_ctl.rc_rcvtime); | ||||
if (bbr->rc_in_persist == 0) { | if (bbr->rc_in_persist == 0) { | ||||
bbr->r_ctl.rc_went_idle_time = bbr->r_ctl.rc_rcvtime; | bbr->r_ctl.rc_went_idle_time = bbr->r_ctl.rc_rcvtime; | ||||
▲ Show 20 Lines • Show All 6,141 Lines • Show Last 20 Lines |