Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_stacks/rack.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 9,851 Lines • ▼ Show 20 Lines | if ((sbused(&so->so_snd) == 0) && | ||||
* sent the fin). | * sent the fin). | ||||
*/ | */ | ||||
ourfinisacked = 1; | ourfinisacked = 1; | ||||
} | } | ||||
tp->snd_una = th->th_ack; | tp->snd_una = th->th_ack; | ||||
if (acked_amount && sbavail(&so->so_snd)) | if (acked_amount && sbavail(&so->so_snd)) | ||||
rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); | rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); | ||||
rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); | rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); | ||||
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(tp->snd_una, tp->snd_recover)) | if (SEQ_GT(tp->snd_una, tp->snd_recover)) | ||||
tp->snd_recover = tp->snd_una; | tp->snd_recover = tp->snd_una; | ||||
if (SEQ_LT(tp->snd_nxt, tp->snd_una)) { | if (SEQ_LT(tp->snd_nxt, tp->snd_una)) { | ||||
tp->snd_nxt = tp->snd_una; | tp->snd_nxt = tp->snd_una; | ||||
} | } | ||||
if (under_pacing && | if (under_pacing && | ||||
▲ Show 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | #endif | ||||
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); | ||||
rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); | rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); | ||||
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 All 40 Lines | if ((tp->t_flags & TF_SACK_PERMIT) && | ||||
tcp_update_dsack_list(tp, save_start, | tcp_update_dsack_list(tp, save_start, | ||||
save_start + save_tlen); | save_start + save_tlen); | ||||
} else if (tlen > 0) { | } else if (tlen > 0) { | ||||
RACK_OPTS_INC(tcp_sack_path_4); | RACK_OPTS_INC(tcp_sack_path_4); | ||||
tcp_update_dsack_list(tp, save_start, | tcp_update_dsack_list(tp, save_start, | ||||
save_start + tlen); | save_start + tlen); | ||||
} | } | ||||
} | } | ||||
tcp_handle_wakeup(tp, so); | |||||
} else { | } else { | ||||
m_freem(m); | m_freem(m); | ||||
thflags &= ~TH_FIN; | thflags &= ~TH_FIN; | ||||
} | } | ||||
/* | /* | ||||
* 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); | |||||
/* The socket upcall is handled by socantrcvmore. */ | /* The socket upcall is handled by socantrcvmore. */ | ||||
tp->t_flags &= ~TF_WAKESOR; | 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 176 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); | ||||
} | } | ||||
rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); | rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); | ||||
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 | ||||
rack_handle_delayed_ack(tp, rack, tlen, 0); | rack_handle_delayed_ack(tp, rack, tlen, 0); | ||||
if (tp->snd_una == tp->snd_max) | if (tp->snd_una == tp->snd_max) | ||||
sack_filter_clear(&rack->r_ctl.rack_sf, tp->snd_una); | sack_filter_clear(&rack->r_ctl.rack_sf, tp->snd_una); | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | if (acked) { | ||||
rack_ack_received(tp, rack, th->th_ack, nsegs, CC_ACK, 0); | rack_ack_received(tp, rack, th->th_ack, nsegs, CC_ACK, 0); | ||||
SOCKBUF_LOCK(&so->so_snd); | SOCKBUF_LOCK(&so->so_snd); | ||||
mfree = sbcut_locked(&so->so_snd, acked); | mfree = sbcut_locked(&so->so_snd, acked); | ||||
tp->snd_una = th->th_ack; | tp->snd_una = th->th_ack; | ||||
/* Note we want to hold the sb lock through the sendmap adjust */ | /* Note we want to hold the sb lock through the sendmap adjust */ | ||||
rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); | rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); | ||||
/* Wake up the socket if we have room to write more */ | /* Wake up the socket if we have room to write more */ | ||||
rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); | rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); | ||||
SOCKBUF_UNLOCK(&so->so_snd); | sowwakeup(so); | ||||
tp->t_flags |= TF_WAKESOW; | |||||
m_freem(mfree); | m_freem(mfree); | ||||
tp->t_rxtshift = 0; | tp->t_rxtshift = 0; | ||||
RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), | RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), | ||||
rack_rto_min, rack_rto_max); | rack_rto_min, rack_rto_max); | ||||
rack->rc_tlp_in_progress = 0; | rack->rc_tlp_in_progress = 0; | ||||
rack->r_ctl.rc_tlp_cnt_out = 0; | rack->r_ctl.rc_tlp_cnt_out = 0; | ||||
/* | /* | ||||
* If it is the RXT timer we want to | * If it is the RXT timer we want to | ||||
▲ Show 20 Lines • Show All 421 Lines • ▼ Show 20 Lines | rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, | ||||
* simultaneous SYN, which is handled later. | * simultaneous SYN, which is handled later. | ||||
*/ | */ | ||||
if (SEQ_GT(th->th_ack, tp->snd_una) && !(tp->t_flags & TF_NEEDSYN)) | if (SEQ_GT(th->th_ack, tp->snd_una) && !(tp->t_flags & TF_NEEDSYN)) | ||||
tp->snd_una++; | tp->snd_una++; | ||||
/* | /* | ||||
* If segment contains data or ACK, will call tcp_reass() later; if | * If segment contains data or ACK, will call tcp_reass() later; if | ||||
* not, do so now to pass queued data to user. | * not, do so now to pass queued data to user. | ||||
*/ | */ | ||||
if (tlen == 0 && (thflags & TH_FIN) == 0) | if (tlen == 0 && (thflags & TH_FIN) == 0) { | ||||
(void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, | (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, | ||||
(struct mbuf *)0); | (struct mbuf *)0); | ||||
tcp_handle_wakeup(tp, so); | |||||
} | |||||
tp->snd_wl1 = th->th_seq - 1; | tp->snd_wl1 = th->th_seq - 1; | ||||
/* For syn-recv we need to possibly update the rtt */ | /* For syn-recv we need to possibly update the rtt */ | ||||
if ((to->to_flags & TOF_TS) != 0 && to->to_tsecr) { | if ((to->to_flags & TOF_TS) != 0 && to->to_tsecr) { | ||||
uint32_t t, mcts; | uint32_t t, mcts; | ||||
mcts = tcp_ts_getticks(); | mcts = tcp_ts_getticks(); | ||||
t = (mcts - to->to_tsecr) * HPTS_USEC_IN_MSEC; | t = (mcts - to->to_tsecr) * HPTS_USEC_IN_MSEC; | ||||
if (!tp->t_rttlow || tp->t_rttlow > t) | if (!tp->t_rttlow || tp->t_rttlow > t) | ||||
▲ Show 20 Lines • Show All 2,066 Lines • ▼ Show 20 Lines | if (acked_amount > 0) { | ||||
rack_ack_received(tp, rack, high_seq, nsegs, CC_ACK, recovery); | rack_ack_received(tp, rack, high_seq, nsegs, CC_ACK, recovery); | ||||
SOCKBUF_LOCK(&so->so_snd); | SOCKBUF_LOCK(&so->so_snd); | ||||
mfree = sbcut_locked(&so->so_snd, acked); | mfree = sbcut_locked(&so->so_snd, acked); | ||||
tp->snd_una = high_seq; | tp->snd_una = high_seq; | ||||
/* Note we want to hold the sb lock through the sendmap adjust */ | /* Note we want to hold the sb lock through the sendmap adjust */ | ||||
rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); | rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); | ||||
/* Wake up the socket if we have room to write more */ | /* Wake up the socket if we have room to write more */ | ||||
rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); | rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); | ||||
SOCKBUF_UNLOCK(&so->so_snd); | sowwakeup(so); | ||||
tp->t_flags |= TF_WAKESOW; | |||||
m_freem(mfree); | m_freem(mfree); | ||||
} | } | ||||
/* update progress */ | /* update progress */ | ||||
tp->t_acktime = ticks; | tp->t_acktime = ticks; | ||||
rack_log_progress_event(rack, tp, tp->t_acktime, | rack_log_progress_event(rack, tp, tp->t_acktime, | ||||
PROGRESS_UPDATE, __LINE__); | PROGRESS_UPDATE, __LINE__); | ||||
/* Clear out shifts and such */ | /* Clear out shifts and such */ | ||||
tp->t_rxtshift = 0; | tp->t_rxtshift = 0; | ||||
▲ Show 20 Lines • Show All 6,802 Lines • Show Last 20 Lines |