Lines Matching refs:tp
278 #define ND6_HINT(tp) \ argument
280 if ((tp) && (tp)->t_inpcb && \
281 INP_ISIPV6((tp)->t_inpcb) && \
282 (tp)->t_inpcb->in6p_route.ro_rt) \
283 nd6_nud_hint((tp)->t_inpcb->in6p_route.ro_rt, NULL, 0); \
286 #define ND6_HINT(tp) argument
296 #define DELAY_ACK(tp) \ argument
297 (tcp_delack_enabled && !tcp_callout_pending(tp, tp->tt_delack) && \
298 !(tp->t_flags & TF_RXWIN0SENT))
300 #define acceptable_window_update(tp, th, tiwin) \ argument
301 (SEQ_LT(tp->snd_wl1, th->th_seq) || \
302 (tp->snd_wl1 == th->th_seq && \
303 (SEQ_LT(tp->snd_wl2, th->th_ack) || \
304 (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))
307 #define need_early_retransmit(tp, ownd) \ argument
309 (tcp_do_eifel_detect && (tp->t_flags & TF_RCVD_TSTMP)) && \
310 ownd < ((tp->t_rxtthresh + 1) * tp->t_maxseg) && \
311 tp->t_dupacks + 1 >= iceildiv(ownd, tp->t_maxseg) && \
312 (!TCP_DO_SACK(tp) || ownd <= tp->t_maxseg || \
313 tcp_sack_has_sacked(&tp->scb, ownd - tp->t_maxseg)))
322 tcp_paws_canreasslast(const struct tcpcb *tp, const struct tcphdr *th, int tlen) in tcp_paws_canreasslast() argument
326 last = TAILQ_LAST(&tp->t_segq, tsegqe_head); in tcp_paws_canreasslast()
360 tcp_ncr_update_rxtthresh(struct tcpcb *tp) in tcp_ncr_update_rxtthresh() argument
362 int old_rxtthresh = tp->t_rxtthresh; in tcp_ncr_update_rxtthresh()
363 uint32_t ownd = tp->snd_max - tp->snd_una; in tcp_ncr_update_rxtthresh()
365 tp->t_rxtthresh = min(tcp_ncr_rxtthresh_max, in tcp_ncr_update_rxtthresh()
366 max(tcprexmtthresh, ((ownd / tp->t_maxseg) >> 1))); in tcp_ncr_update_rxtthresh()
367 if (tp->t_rxtthresh != old_rxtthresh) { in tcp_ncr_update_rxtthresh()
368 tcp_sack_update_lostseq(&tp->scb, tp->snd_una, in tcp_ncr_update_rxtthresh()
369 tp->t_maxseg, tp->t_rxtthresh); in tcp_ncr_update_rxtthresh()
374 tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) in tcp_reass() argument
379 struct socket *so = tp->t_inpcb->inp_socket; in tcp_reass()
396 if (th->th_seq != tp->rcv_nxt && in tcp_reass()
402 tp->reportblk.rblk_start = tp->reportblk.rblk_end; in tcp_reass()
412 tp->reportblk.rblk_start = tp->reportblk.rblk_end; in tcp_reass()
418 tp->t_flags |= TF_QUEDFIN; in tcp_reass()
423 TAILQ_FOREACH(q, &tp->t_segq, tqe_q) { in tcp_reass()
440 tp->sack_flags |= in tcp_reass()
443 tp->encloseblk.rblk_start = p->tqe_th->th_seq; in tcp_reass()
449 tp->encloseblk.rblk_end = TCP_SACK_BLKEND( in tcp_reass()
469 tp->encloseblk.rblk_end = TCP_SACK_BLKEND( in tcp_reass()
472 tp->reportblk.rblk_end = th->th_seq; in tcp_reass()
490 if (!(tp->sack_flags & TSACK_F_DUPSEG)) { in tcp_reass()
492 tp->sack_flags |= (TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG); in tcp_reass()
493 tp->encloseblk = tp->reportblk; in tcp_reass()
495 tp->reportblk.rblk_start = q->tqe_th->th_seq; in tcp_reass()
497 if ((tp->sack_flags & TSACK_F_ENCLOSESEG) && in tcp_reass()
498 SEQ_GT(qend_sack, tp->encloseblk.rblk_end)) { in tcp_reass()
500 tp->encloseblk.rblk_end = qend_sack; in tcp_reass()
513 TAILQ_REMOVE(&tp->t_segq, q, tqe_q); in tcp_reass()
536 tp->encloseblk.rblk_end = tend_sack; in tcp_reass()
541 if (!(tp->sack_flags & TSACK_F_DUPSEG)) in tcp_reass()
542 tp->reportblk.rblk_end = tend_sack; in tcp_reass()
543 TAILQ_REMOVE(&tp->t_segq, q, tqe_q); in tcp_reass()
549 TAILQ_INSERT_HEAD(&tp->t_segq, te, tqe_q); in tcp_reass()
557 tp->encloseblk.rblk_start = p->tqe_th->th_seq; in tcp_reass()
562 if (!(tp->sack_flags & TSACK_F_DUPSEG)) in tcp_reass()
563 tp->reportblk.rblk_start = p->tqe_th->th_seq; in tcp_reass()
567 TAILQ_INSERT_AFTER(&tp->t_segq, p, te, tqe_q); in tcp_reass()
576 if (!TCPS_HAVEESTABLISHED(tp->t_state)) in tcp_reass()
578 q = TAILQ_FIRST(&tp->t_segq); in tcp_reass()
579 if (q == NULL || q->tqe_th->th_seq != tp->rcv_nxt) in tcp_reass()
581 tp->rcv_nxt += q->tqe_len; in tcp_reass()
582 if (!(tp->sack_flags & TSACK_F_DUPSEG)) { in tcp_reass()
584 tp->reportblk.rblk_start = tp->reportblk.rblk_end; in tcp_reass()
587 tp->sack_flags &= ~TSACK_F_ENCLOSESEG; in tcp_reass()
589 TAILQ_REMOVE(&tp->t_segq, q, tqe_q); in tcp_reass()
590 KASSERT(TAILQ_EMPTY(&tp->t_segq) || in tcp_reass()
591 TAILQ_FIRST(&tp->t_segq)->tqe_th->th_seq != tp->rcv_nxt, in tcp_reass()
602 ND6_HINT(tp); in tcp_reass()
649 struct tcpcb *tp = NULL; in tcp_input() local
930 tp = intotcpcb(inp); in tcp_input()
931 KASSERT(tp != NULL, ("tcp_input: tp is NULL")); in tcp_input()
932 if (tp->t_state <= TCPS_CLOSED) in tcp_input()
939 ostate = tp->t_state; in tcp_input()
1010 tp = intotcpcb(inp); in tcp_input()
1015 tp->snd_up = tp->snd_una; in tcp_input()
1016 tp->snd_max = tp->snd_nxt = tp->iss + 1; in tcp_input()
1017 tp->last_ack_sent = tp->rcv_nxt; in tcp_input()
1073 tp = NULL; in tcp_input()
1138 KASSERT(tp->t_state != TCPS_LISTEN, ("tcp_input: TCPS_LISTEN state")); in tcp_input()
1143 tiwin = th->th_win << tp->snd_scale; in tcp_input()
1163 if ((int)(ticks - tp->t_rcvtime) > hz) in tcp_input()
1164 tcp_timer_keep_activity(tp, thflags); in tcp_input()
1171 if (tp->t_state == TCPS_SYN_SENT && (thflags & TH_SYN)) { in tcp_input()
1172 if ((to.to_flags & TOF_SCALE) && (tp->t_flags & TF_REQ_SCALE)) { in tcp_input()
1173 tp->t_flags |= TF_RCVD_SCALE; in tcp_input()
1174 tp->snd_scale = to.to_requested_s_scale; in tcp_input()
1180 tp->snd_wnd = th->th_win; in tcp_input()
1183 tp->t_flags |= TF_RCVD_TSTMP; in tcp_input()
1184 tp->ts_recent = to.to_tsval; in tcp_input()
1185 tp->ts_recent_age = ticks; in tcp_input()
1189 tcp_rmx_init(tp, to.to_mss); in tcp_input()
1196 tp->t_flags |= TF_SACK_PERMITTED; in tcp_input()
1216 if (tp->t_state == TCPS_ESTABLISHED && in tcp_input()
1218 !(tp->t_flags & (TF_NEEDSYN | TF_NEEDFIN)) && in tcp_input()
1220 TSTMP_GEQ(to.to_tsval, tp->ts_recent)) && in tcp_input()
1221 th->th_seq == tp->rcv_nxt && in tcp_input()
1222 tp->snd_nxt == tp->snd_max) { in tcp_input()
1231 SEQ_LEQ(th->th_seq, tp->last_ack_sent)) { in tcp_input()
1232 tp->ts_recent_age = ticks; in tcp_input()
1233 tp->ts_recent = to.to_tsval; in tcp_input()
1237 if (SEQ_GT(th->th_ack, tp->snd_una) && in tcp_input()
1238 SEQ_LEQ(th->th_ack, tp->snd_max) && in tcp_input()
1239 tp->snd_cwnd >= tp->snd_wnd && in tcp_input()
1240 !IN_FASTRECOVERY(tp)) { in tcp_input()
1255 (tp->rxt_flags & TRXT_F_FIRSTACCACK)) { in tcp_input()
1257 if (to.to_tsecr < tp->t_rexmtTS) { in tcp_input()
1258 tcp_revert_congestion_state(tp); in tcp_input()
1260 if (tp->t_rxtshift != 1 || in tcp_input()
1261 ticks >= tp->t_badrxtwin) in tcp_input()
1264 } else if (tp->t_rxtshift == 1 && in tcp_input()
1265 ticks < tp->t_badrxtwin) { in tcp_input()
1266 tcp_revert_congestion_state(tp); in tcp_input()
1269 tp->rxt_flags &= ~(TRXT_F_FIRSTACCACK | in tcp_input()
1279 tcp_xmit_timer(tp, in tcp_input()
1282 } else if (tp->t_rtttime && in tcp_input()
1283 SEQ_GT(th->th_ack, tp->t_rtseq)) { in tcp_input()
1284 tcp_xmit_timer(tp, in tcp_input()
1285 ticks - tp->t_rtttime + 1, in tcp_input()
1288 tcp_xmit_bandwidth_limit(tp, th->th_ack); in tcp_input()
1289 acked = th->th_ack - tp->snd_una; in tcp_input()
1293 tp->snd_recover = th->th_ack - 1; in tcp_input()
1294 tp->snd_una = th->th_ack; in tcp_input()
1295 tp->t_dupacks = 0; in tcp_input()
1299 if (tiwin != tp->snd_wnd && in tcp_input()
1300 acceptable_window_update(tp, th, tiwin)) { in tcp_input()
1302 if (tp->snd_wl2 == th->th_ack && in tcp_input()
1303 tiwin > tp->snd_wnd) in tcp_input()
1305 tp->snd_wnd = tiwin; in tcp_input()
1306 tp->snd_wl1 = th->th_seq; in tcp_input()
1307 tp->snd_wl2 = th->th_ack; in tcp_input()
1308 if (tp->snd_wnd > tp->max_sndwnd) in tcp_input()
1309 tp->max_sndwnd = tp->snd_wnd; in tcp_input()
1312 ND6_HINT(tp); /* some progress has been done */ in tcp_input()
1322 if (tp->snd_una == tp->snd_max) { in tcp_input()
1323 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_input()
1324 } else if (!tcp_callout_active(tp, in tcp_input()
1325 tp->tt_persist)) { in tcp_input()
1326 tcp_callout_reset(tp, tp->tt_rexmt, in tcp_input()
1327 tp->t_rxtcur, tcp_timer_rexmt); in tcp_input()
1331 !tcp_output_pending(tp)) in tcp_input()
1332 tcp_output_fair(tp); in tcp_input()
1335 } else if (tiwin == tp->snd_wnd && in tcp_input()
1336 th->th_ack == tp->snd_una && in tcp_input()
1337 TAILQ_EMPTY(&tp->t_segq) && in tcp_input()
1346 tp->rcv_nxt += tlen; in tcp_input()
1349 ND6_HINT(tp); /* some progress has been done */ in tcp_input()
1386 if (to.to_tsecr > tp->rfbuf_ts && in tcp_input()
1387 to.to_tsecr - tp->rfbuf_ts < hz) { in tcp_input()
1388 if (tp->rfbuf_cnt > in tcp_input()
1398 tp->rfbuf_ts = 0; in tcp_input()
1399 tp->rfbuf_cnt = 0; in tcp_input()
1401 tp->rfbuf_cnt += tlen; /* add up */ in tcp_input()
1420 tp->t_flags |= TF_RXRESIZED; in tcp_input()
1426 (TCP_MAXWIN << tp->rcv_scale)) { in tcp_input()
1458 if (DELAY_ACK(tp)) { in tcp_input()
1459 tcp_callout_reset(tp, tp->tt_delack, in tcp_input()
1462 tp->t_flags |= TF_ACKNOW; in tcp_input()
1463 if (!(tp->t_flags & TF_ONOUTPUTQ)) { in tcp_input()
1464 tp->t_flags |= TF_ONOUTPUTQ; in tcp_input()
1465 tp->tt_cpu = mycpu->gd_cpuid; in tcp_input()
1467 &tcpcbackq[tp->tt_cpu].head, in tcp_input()
1468 tp, t_outputq); in tcp_input()
1471 tp->t_flags |= TF_ACKNOW; in tcp_input()
1472 tcp_output(tp); in tcp_input()
1487 tp->rcv_wnd = imax(recvwin, (int)(tp->rcv_adv - tp->rcv_nxt)); in tcp_input()
1490 tp->rfbuf_ts = 0; in tcp_input()
1491 tp->rfbuf_cnt = 0; in tcp_input()
1493 switch (tp->t_state) { in tcp_input()
1500 (SEQ_LEQ(th->th_ack, tp->snd_una) || in tcp_input()
1501 SEQ_GT(th->th_ack, tp->snd_max))) { in tcp_input()
1521 (SEQ_LEQ(th->th_ack, tp->iss) || in tcp_input()
1522 SEQ_GT(th->th_ack, tp->snd_max))) { in tcp_input()
1528 tp = tcp_drop(tp, ECONNREFUSED); in tcp_input()
1534 tp->irs = th->th_seq; in tcp_input()
1535 tcp_rcvseqinit(tp); in tcp_input()
1541 if ((tp->t_flags & (TF_RCVD_SCALE | TF_REQ_SCALE)) == in tcp_input()
1543 tp->rcv_scale = tp->request_r_scale; in tcp_input()
1544 tp->rcv_adv += tp->rcv_wnd; in tcp_input()
1545 tp->snd_una++; /* SYN is acked */ in tcp_input()
1546 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_input()
1551 if (DELAY_ACK(tp) && tlen != 0) { in tcp_input()
1552 tcp_callout_reset(tp, tp->tt_delack, in tcp_input()
1555 tp->t_flags |= TF_ACKNOW; in tcp_input()
1563 tp->t_starttime = ticks; in tcp_input()
1564 if (tp->t_flags & TF_NEEDFIN) { in tcp_input()
1565 TCP_STATE_CHANGE(tp, TCPS_FIN_WAIT_1); in tcp_input()
1566 tp->t_flags &= ~TF_NEEDFIN; in tcp_input()
1569 tcp_established(tp); in tcp_input()
1579 tp->t_flags |= TF_ACKNOW; in tcp_input()
1580 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_input()
1581 TCP_STATE_CHANGE(tp, TCPS_SYN_RECEIVED); in tcp_input()
1590 if (tlen > tp->rcv_wnd) { in tcp_input()
1591 todrop = tlen - tp->rcv_wnd; in tcp_input()
1593 tlen = tp->rcv_wnd; in tcp_input()
1598 tp->snd_wl1 = th->th_seq - 1; in tcp_input()
1599 tp->rcv_up = th->th_seq; in tcp_input()
1682 if (SEQ_GEQ(th->th_seq, tp->last_ack_sent) && in tcp_input()
1683 SEQ_LEQ(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) { in tcp_input()
1684 switch (tp->t_state) { in tcp_input()
1696 TCP_STATE_CHANGE(tp, TCPS_CLOSED); in tcp_input()
1698 tp = tcp_close(tp); in tcp_input()
1703 tp = tcp_close(tp); in tcp_input()
1719 tp->t_state == TCPS_TIME_WAIT && in tcp_input()
1720 th->th_seq != tp->irs) { in tcp_input()
1721 tp = tcp_close(tp); in tcp_input()
1729 if ((to.to_flags & TOF_TS) && tp->ts_recent != 0 && in tcp_input()
1730 TSTMP_LT(to.to_tsval, tp->ts_recent)) { in tcp_input()
1732 if ((int)(ticks - tp->ts_recent_age) > TCP_PAWS_IDLE) { in tcp_input()
1744 tp->ts_recent = 0; in tcp_input()
1746 tp->t_state == TCPS_ESTABLISHED && in tcp_input()
1748 !(tp->t_flags & (TF_NEEDSYN | TF_NEEDFIN)) && in tcp_input()
1749 th->th_ack == tp->snd_una && in tcp_input()
1750 tiwin == tp->snd_wnd && in tcp_input()
1751 TSTMP_GEQ(to.to_tsval + tcp_paws_tolerance, tp->ts_recent)&& in tcp_input()
1752 (th->th_seq == tp->rcv_nxt || in tcp_input()
1753 (SEQ_GT(th->th_seq, tp->rcv_nxt) && in tcp_input()
1754 tcp_paws_canreasslast(tp, th, tlen)))) { in tcp_input()
1795 if (tp->t_state == TCPS_SYN_RECEIVED && SEQ_LT(th->th_seq, tp->irs)) { in tcp_input()
1800 todrop = tp->rcv_nxt - th->th_seq; in tcp_input()
1802 if (TCP_DO_SACK(tp)) { in tcp_input()
1804 tp->reportblk.rblk_start = th->th_seq; in tcp_input()
1805 tp->reportblk.rblk_end = TCP_SACK_BLKEND( in tcp_input()
1807 if (SEQ_GT(tp->reportblk.rblk_end, tp->rcv_nxt)) in tcp_input()
1808 tp->reportblk.rblk_end = tp->rcv_nxt; in tcp_input()
1809 tp->sack_flags |= (TSACK_F_DUPSEG | TSACK_F_SACKLEFT); in tcp_input()
1810 tp->t_flags |= TF_ACKNOW; in tcp_input()
1837 tp->t_flags |= TF_ACKNOW; in tcp_input()
1861 tp->t_state > TCPS_CLOSE_WAIT && tlen) { in tcp_input()
1862 tp = tcp_close(tp); in tcp_input()
1872 todrop = (th->th_seq + tlen) - (tp->rcv_nxt + tp->rcv_wnd); in tcp_input()
1885 if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) { in tcp_input()
1886 tp->t_flags |= TF_ACKNOW; in tcp_input()
1915 if ((to.to_flags & TOF_TS) && SEQ_LEQ(th->th_seq, tp->last_ack_sent) && in tcp_input()
1916 SEQ_LEQ(tp->last_ack_sent, (th->th_seq + tlen in tcp_input()
1919 tp->ts_recent_age = ticks; in tcp_input()
1920 tp->ts_recent = to.to_tsval; in tcp_input()
1928 tp = tcp_drop(tp, ECONNRESET); in tcp_input()
1939 if (tp->t_state == TCPS_SYN_RECEIVED || in tcp_input()
1940 (tp->t_flags & TF_NEEDSYN)) in tcp_input()
1949 switch (tp->t_state) { in tcp_input()
1960 if ((tp->t_flags & (TF_RCVD_SCALE | TF_REQ_SCALE)) == in tcp_input()
1962 tp->rcv_scale = tp->request_r_scale; in tcp_input()
1968 tp->t_starttime = ticks; in tcp_input()
1969 if (tp->t_flags & TF_NEEDFIN) { in tcp_input()
1970 TCP_STATE_CHANGE(tp, TCPS_FIN_WAIT_1); in tcp_input()
1971 tp->t_flags &= ~TF_NEEDFIN; in tcp_input()
1973 tcp_established(tp); in tcp_input()
1980 tcp_reass(tp, NULL, NULL, NULL); in tcp_input()
1999 if (SEQ_LEQ(th->th_ack, tp->snd_una)) { in tcp_input()
2002 if (TCP_DO_SACK(tp)) in tcp_input()
2003 tcp_sack_update_scoreboard(tp, &to); in tcp_input()
2005 if (tlen != 0 || tiwin != tp->snd_wnd || in tcp_input()
2006 ((thflags & TH_FIN) && !(tp->t_flags & TF_SAWFIN))) in tcp_input()
2009 if (!tcp_callout_active(tp, tp->tt_rexmt) || in tcp_input()
2010 th->th_ack != tp->snd_una) { in tcp_input()
2013 tp->t_dupacks = 0; in tcp_input()
2025 !TCP_DO_SACK(tp) || in tcp_input()
2029 tp->t_dupacks = 0; in tcp_input()
2035 if ((thflags & TH_FIN) && !(tp->t_flags & TF_QUEDFIN)) { in tcp_input()
2047 if (tcp_recv_dupack(tp, th->th_ack, to.to_flags)) in tcp_input()
2053 KASSERT(SEQ_GT(th->th_ack, tp->snd_una), ("th_ack <= snd_una")); in tcp_input()
2054 tp->t_dupacks = 0; in tcp_input()
2055 if (SEQ_GT(th->th_ack, tp->snd_max)) { in tcp_input()
2060 tp->snd_cwnd = tp->t_maxseg; in tcp_input()
2061 tp->snd_wacked = 0; in tcp_input()
2070 if (tp->t_flags & TF_NEEDSYN) { in tcp_input()
2078 tp->t_flags &= ~TF_NEEDSYN; in tcp_input()
2079 tp->snd_una++; in tcp_input()
2081 if ((tp->t_flags & (TF_RCVD_SCALE | TF_REQ_SCALE)) == in tcp_input()
2083 tp->rcv_scale = tp->request_r_scale; in tcp_input()
2087 acked = th->th_ack - tp->snd_una; in tcp_input()
2093 (tp->rxt_flags & TRXT_F_FIRSTACCACK)) { in tcp_input()
2095 if (to.to_tsecr < tp->t_rexmtTS) { in tcp_input()
2097 tcp_revert_congestion_state(tp); in tcp_input()
2098 if (tp->t_rxtshift != 1 || in tcp_input()
2099 ticks >= tp->t_badrxtwin) in tcp_input()
2102 } else if (tp->t_rxtshift == 1 && ticks < tp->t_badrxtwin) { in tcp_input()
2111 tcp_revert_congestion_state(tp); in tcp_input()
2129 tcp_xmit_timer(tp, ticks - to.to_tsecr + 1, in tcp_input()
2131 else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq)) in tcp_input()
2132 tcp_xmit_timer(tp, ticks - tp->t_rtttime + 1, in tcp_input()
2134 tcp_xmit_bandwidth_limit(tp, th->th_ack); in tcp_input()
2144 tp->rxt_flags &= ~(TRXT_F_FIRSTACCACK | in tcp_input()
2148 tp->snd_wnd -= so->so_snd.ssb_cc; in tcp_input()
2153 tp->snd_wnd -= acked; in tcp_input()
2161 if (acceptable_window_update(tp, th, tiwin)) { in tcp_input()
2163 if (tlen == 0 && tp->snd_wl2 == th->th_ack && in tcp_input()
2164 tiwin > tp->snd_wnd) in tcp_input()
2166 tp->snd_wnd = tiwin; in tcp_input()
2167 tp->snd_wl1 = th->th_seq; in tcp_input()
2168 tp->snd_wl2 = th->th_ack; in tcp_input()
2169 if (tp->snd_wnd > tp->max_sndwnd) in tcp_input()
2170 tp->max_sndwnd = tp->snd_wnd; in tcp_input()
2174 tp->snd_una = th->th_ack; in tcp_input()
2175 if (TCP_DO_SACK(tp)) in tcp_input()
2176 tcp_sack_update_scoreboard(tp, &to); in tcp_input()
2177 if (IN_FASTRECOVERY(tp)) { in tcp_input()
2178 if (SEQ_GEQ(th->th_ack, tp->snd_recover)) { in tcp_input()
2179 EXIT_FASTRECOVERY(tp); in tcp_input()
2186 if (!TCP_DO_SACK(tp)) in tcp_input()
2187 tp->snd_cwnd = tp->snd_ssthresh; in tcp_input()
2196 if (SEQ_GT(th->th_ack + tp->snd_cwnd, in tcp_input()
2197 tp->snd_max + 2 * tp->t_maxseg)) in tcp_input()
2198 tp->snd_cwnd = in tcp_input()
2199 (tp->snd_max - tp->snd_una) + in tcp_input()
2200 2 * tp->t_maxseg; in tcp_input()
2202 tp->snd_wacked = 0; in tcp_input()
2204 if (TCP_DO_SACK(tp)) { in tcp_input()
2205 tp->snd_max_rexmt = tp->snd_max; in tcp_input()
2206 tcp_sack_rexmt(tp, in tcp_input()
2207 tp->snd_una == tp->rexmt_high); in tcp_input()
2209 tcp_newreno_partial_ack(tp, th, acked); in tcp_input()
2219 if (tp->snd_cwnd <= tp->snd_ssthresh) { in tcp_input()
2221 (SEQ_LT(tp->snd_nxt, tp->snd_max) ? in tcp_input()
2222 tp->t_maxseg : 2 * tp->t_maxseg); in tcp_input()
2225 tp->snd_cwnd += tcp_do_abc ? in tcp_input()
2226 min(acked, abc_sslimit) : tp->t_maxseg; in tcp_input()
2229 tp->snd_wacked += tcp_do_abc ? acked : in tcp_input()
2230 tp->t_maxseg; in tcp_input()
2231 if (tp->snd_wacked >= tp->snd_cwnd) { in tcp_input()
2232 tp->snd_wacked -= tp->snd_cwnd; in tcp_input()
2233 tp->snd_cwnd += tp->t_maxseg; in tcp_input()
2236 tp->snd_cwnd = min(tp->snd_cwnd, in tcp_input()
2237 TCP_MAXWIN << tp->snd_scale); in tcp_input()
2238 tp->snd_recover = th->th_ack - 1; in tcp_input()
2240 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) in tcp_input()
2241 tp->snd_nxt = tp->snd_una; in tcp_input()
2249 if (th->th_ack == tp->snd_max) { in tcp_input()
2250 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_input()
2252 } else if (!tcp_callout_active(tp, tp->tt_persist)) { in tcp_input()
2253 tcp_callout_reset(tp, tp->tt_rexmt, tp->t_rxtcur, in tcp_input()
2257 switch (tp->t_state) { in tcp_input()
2274 tcp_callout_reset(tp, tp->tt_2msl, in tcp_input()
2275 tp->t_maxidle, tcp_timer_2msl); in tcp_input()
2277 TCP_STATE_CHANGE(tp, TCPS_FIN_WAIT_2); in tcp_input()
2289 TCP_STATE_CHANGE(tp, TCPS_TIME_WAIT); in tcp_input()
2290 tcp_canceltimers(tp); in tcp_input()
2291 tcp_callout_reset(tp, tp->tt_2msl, in tcp_input()
2292 2 * tcp_rmx_msl(tp), in tcp_input()
2306 tp = tcp_close(tp); in tcp_input()
2317 tcp_callout_reset(tp, tp->tt_2msl, 2 * tcp_rmx_msl(tp), in tcp_input()
2329 acceptable_window_update(tp, th, tiwin)) { in tcp_input()
2331 if (tlen == 0 && tp->snd_wl2 == th->th_ack && in tcp_input()
2332 tiwin > tp->snd_wnd) in tcp_input()
2334 tp->snd_wnd = tiwin; in tcp_input()
2335 tp->snd_wl1 = th->th_seq; in tcp_input()
2336 tp->snd_wl2 = th->th_ack; in tcp_input()
2337 if (tp->snd_wnd > tp->max_sndwnd) in tcp_input()
2338 tp->max_sndwnd = tp->snd_wnd; in tcp_input()
2346 !TCPS_HAVERCVDFIN(tp->t_state)) { in tcp_input()
2372 if (SEQ_GT(th->th_seq + th->th_urp, tp->rcv_up)) { in tcp_input()
2373 tp->rcv_up = th->th_seq + th->th_urp; in tcp_input()
2375 (tp->rcv_up - tp->rcv_nxt) - 1; in tcp_input()
2379 tp->t_oobflags &= ~(TCPOOB_HAVEDATA | TCPOOB_HADDATA); in tcp_input()
2398 if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) in tcp_input()
2399 tp->rcv_up = tp->rcv_nxt; in tcp_input()
2411 if ((tlen || (thflags & TH_FIN)) && !TCPS_HAVERCVDFIN(tp->t_state)) { in tcp_input()
2413 tp->t_flags |= TF_SAWFIN; in tcp_input()
2427 if (th->th_seq == tp->rcv_nxt && in tcp_input()
2428 TAILQ_EMPTY(&tp->t_segq) && in tcp_input()
2429 TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_input()
2431 tp->t_flags |= TF_QUEDFIN; in tcp_input()
2432 if (DELAY_ACK(tp)) { in tcp_input()
2433 tcp_callout_reset(tp, tp->tt_delack, in tcp_input()
2436 tp->t_flags |= TF_ACKNOW; in tcp_input()
2438 tp->rcv_nxt += tlen; in tcp_input()
2442 ND6_HINT(tp); in tcp_input()
2452 if (!(tp->sack_flags & TSACK_F_DUPSEG)) { in tcp_input()
2454 tp->reportblk.rblk_start = th->th_seq; in tcp_input()
2455 tp->reportblk.rblk_end = TCP_SACK_BLKEND( in tcp_input()
2458 thflags = tcp_reass(tp, th, &tlen, m); in tcp_input()
2459 tp->t_flags |= TF_ACKNOW; in tcp_input()
2467 len = so->so_rcv.ssb_hiwat - (tp->rcv_adv - tp->rcv_nxt); in tcp_input()
2478 if (!TCPS_HAVERCVDFIN(tp->t_state)) { in tcp_input()
2487 if (DELAY_ACK(tp) && (tp->t_flags & TF_NEEDSYN)) { in tcp_input()
2488 tcp_callout_reset(tp, tp->tt_delack, in tcp_input()
2491 tp->t_flags |= TF_ACKNOW; in tcp_input()
2493 tp->rcv_nxt++; in tcp_input()
2496 switch (tp->t_state) { in tcp_input()
2502 tp->t_starttime = ticks; in tcp_input()
2505 TCP_STATE_CHANGE(tp, TCPS_CLOSE_WAIT); in tcp_input()
2513 TCP_STATE_CHANGE(tp, TCPS_CLOSING); in tcp_input()
2522 TCP_STATE_CHANGE(tp, TCPS_TIME_WAIT); in tcp_input()
2523 tcp_canceltimers(tp); in tcp_input()
2524 tcp_callout_reset(tp, tp->tt_2msl, 2 * tcp_rmx_msl(tp), in tcp_input()
2533 tcp_callout_reset(tp, tp->tt_2msl, 2 * tcp_rmx_msl(tp), in tcp_input()
2541 tcp_trace(TA_INPUT, ostate, tp, tcp_saveipgen, &tcp_savetcp, 0); in tcp_input()
2547 if (delayed_dupack && tcp_recv_dupack(tp, th_dupack, to_flags)) in tcp_input()
2553 if ((tp->t_flags & TF_ACKNOW) || in tcp_input()
2554 (needoutput && tcp_sack_report_needed(tp))) { in tcp_input()
2555 tcp_output_cancel(tp); in tcp_input()
2556 tcp_output_fair(tp); in tcp_input()
2557 } else if (needoutput && !tcp_output_pending(tp)) { in tcp_input()
2558 tcp_output_fair(tp); in tcp_input()
2560 tcp_sack_report_cleanup(tp); in tcp_input()
2579 if (tp->t_state == TCPS_SYN_RECEIVED && (thflags & TH_ACK) && in tcp_input()
2580 (SEQ_GT(tp->snd_una, th->th_ack) || in tcp_input()
2581 SEQ_GT(th->th_ack, tp->snd_max)) ) { in tcp_input()
2587 tcp_trace(TA_DROP, ostate, tp, tcp_saveipgen, &tcp_savetcp, 0); in tcp_input()
2590 tp->t_flags |= TF_ACKNOW; in tcp_input()
2591 tcp_output(tp); in tcp_input()
2592 tcp_sack_report_cleanup(tp); in tcp_input()
2625 if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) in tcp_input()
2626 tcp_trace(TA_DROP, ostate, tp, tcp_saveipgen, &tcp_savetcp, 0); in tcp_input()
2630 tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, th->th_ack, in tcp_input()
2636 tcp_respond(tp, mtod(m, void *), th, m, th->th_seq + tlen, in tcp_input()
2639 if (tp != NULL) in tcp_input()
2640 tcp_sack_report_cleanup(tp); in tcp_input()
2648 if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) in tcp_input()
2649 tcp_trace(TA_DROP, ostate, tp, tcp_saveipgen, &tcp_savetcp, 0); in tcp_input()
2652 if (tp != NULL) in tcp_input()
2653 tcp_sack_report_cleanup(tp); in tcp_input()
2783 struct tcpcb *tp = sototcpcb(so); in tcp_pulloutofband() local
2785 tp->t_iobc = *cp; in tcp_pulloutofband()
2786 tp->t_oobflags |= TCPOOB_HAVEDATA; in tcp_pulloutofband()
2806 tcp_xmit_timer(struct tcpcb *tp, int rtt, tcp_seq ack) in tcp_xmit_timer() argument
2811 tp->t_rttupdated++; in tcp_xmit_timer()
2812 if ((tp->rxt_flags & TRXT_F_REBASERTO) && in tcp_xmit_timer()
2813 SEQ_GT(ack, tp->snd_max_prev)) { in tcp_xmit_timer()
2816 tp->t_srtt_prev, tp->t_rttvar_prev, in tcp_xmit_timer()
2817 tp->t_srtt, tp->t_rttvar); in tcp_xmit_timer()
2822 tp->rxt_flags &= ~TRXT_F_REBASERTO; in tcp_xmit_timer()
2823 tp->t_srtt = max(tp->t_srtt_prev, (rtt << TCP_RTT_SHIFT)); in tcp_xmit_timer()
2824 tp->t_rttvar = max(tp->t_rttvar_prev, in tcp_xmit_timer()
2826 if (tp->t_rttbest > tp->t_srtt + tp->t_rttvar) in tcp_xmit_timer()
2827 tp->t_rttbest = tp->t_srtt + tp->t_rttvar; in tcp_xmit_timer()
2830 kprintf("new %d/%d ", tp->t_srtt, tp->t_rttvar); in tcp_xmit_timer()
2832 } else if (tp->t_srtt != 0) { in tcp_xmit_timer()
2843 - (tp->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)); in tcp_xmit_timer()
2845 if ((tp->t_srtt += delta) <= 0) in tcp_xmit_timer()
2846 tp->t_srtt = 1; in tcp_xmit_timer()
2860 delta -= tp->t_rttvar >> (TCP_RTTVAR_SHIFT - TCP_DELTA_SHIFT); in tcp_xmit_timer()
2861 if ((tp->t_rttvar += delta) <= 0) in tcp_xmit_timer()
2862 tp->t_rttvar = 1; in tcp_xmit_timer()
2863 if (tp->t_rttbest > tp->t_srtt + tp->t_rttvar) in tcp_xmit_timer()
2864 tp->t_rttbest = tp->t_srtt + tp->t_rttvar; in tcp_xmit_timer()
2871 tp->t_srtt = rtt << TCP_RTT_SHIFT; in tcp_xmit_timer()
2872 tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1); in tcp_xmit_timer()
2873 tp->t_rttbest = tp->t_srtt + tp->t_rttvar; in tcp_xmit_timer()
2875 tp->t_rtttime = 0; in tcp_xmit_timer()
2876 tp->t_rxtshift = 0; in tcp_xmit_timer()
2881 tp->t_rxtcur_prev, tp->t_rxtcur); in tcp_xmit_timer()
2896 TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp), in tcp_xmit_timer()
2897 max(tp->t_rttmin, rtt + 2), TCPTV_REXMTMAX); in tcp_xmit_timer()
2900 if (tp->t_rxtcur < tp->t_rxtcur_prev + tcp_eifel_rtoinc) { in tcp_xmit_timer()
2915 tp->t_rxtcur = tp->t_rxtcur_prev + tcp_eifel_rtoinc; in tcp_xmit_timer()
2918 kprintf("new %d\n", tp->t_rxtcur); in tcp_xmit_timer()
2929 tp->t_softerror = 0; in tcp_xmit_timer()
2955 tcp_rmx_mss(struct tcpcb *tp, struct rtentry *rt, int offer) in tcp_rmx_mss() argument
2960 struct inpcb *inp = tp->t_inpcb; in tcp_rmx_mss()
2973 tp->t_maxopd = tp->t_maxseg = in tcp_rmx_mss()
3037 tp->t_maxopd = mss; in tcp_rmx_mss()
3039 if ((tp->t_flags & (TF_REQ_TSTMP | TF_NOOPT)) == TF_REQ_TSTMP && in tcp_rmx_mss()
3040 ((tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP)) in tcp_rmx_mss()
3069 tp->t_maxseg = mss; in tcp_rmx_mss()
3091 tp->snd_cwnd = tcp_initial_window(tp); in tcp_rmx_mss()
3100 tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh); in tcp_rmx_mss()
3106 tcp_rmx_rtt(struct tcpcb *tp, struct rtentry *rt) in tcp_rmx_rtt() argument
3118 if (tp->t_srtt == 0 && (rtt = rt->rt_rmx.rmx_rtt)) { in tcp_rmx_rtt()
3124 tp->t_rttmin = rtt / (RTM_RTTUNIT / hz); in tcp_rmx_rtt()
3125 tp->t_srtt = rtt / (RTM_RTTUNIT / (hz * TCP_RTT_SCALE)); in tcp_rmx_rtt()
3126 tp->t_rttbest = tp->t_srtt + TCP_RTT_SCALE; in tcp_rmx_rtt()
3129 tp->t_rttvar = rt->rt_rmx.rmx_rttvar / in tcp_rmx_rtt()
3134 tp->t_rttvar = in tcp_rmx_rtt()
3135 tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE; in tcp_rmx_rtt()
3137 TCPT_RANGESET(tp->t_rxtcur, in tcp_rmx_rtt()
3138 ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1, in tcp_rmx_rtt()
3139 tp->t_rttmin, TCPTV_REXMTMAX); in tcp_rmx_rtt()
3144 tcp_rmx_init(struct tcpcb *tp, int offer) in tcp_rmx_init() argument
3146 struct inpcb *inp = tp->t_inpcb; in tcp_rmx_init()
3159 tcp_rmx_mss(tp, rt, offer); in tcp_rmx_init()
3160 tcp_rmx_rtt(tp, rt); in tcp_rmx_init()
3164 tp->t_flags &= ~TF_NCR; in tcp_rmx_init()
3172 tcp_mssopt(struct tcpcb *tp) in tcp_mssopt() argument
3176 boolean_t isipv6 = INP_ISIPV6(tp->t_inpcb); in tcp_mssopt()
3186 rt = tcp_rtlookup6(&tp->t_inpcb->inp_inc); in tcp_mssopt()
3188 rt = tcp_rtlookup(&tp->t_inpcb->inp_inc); in tcp_mssopt()
3209 tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th, int acked) in tcp_newreno_partial_ack() argument
3211 tcp_seq old_snd_nxt = tp->snd_nxt; in tcp_newreno_partial_ack()
3212 u_long ocwnd = tp->snd_cwnd; in tcp_newreno_partial_ack()
3214 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_newreno_partial_ack()
3215 tp->t_rtttime = 0; in tcp_newreno_partial_ack()
3216 tp->snd_nxt = th->th_ack; in tcp_newreno_partial_ack()
3218 tp->snd_cwnd = tp->t_maxseg; in tcp_newreno_partial_ack()
3219 tp->t_flags |= TF_ACKNOW; in tcp_newreno_partial_ack()
3220 tcp_output(tp); in tcp_newreno_partial_ack()
3221 if (SEQ_GT(old_snd_nxt, tp->snd_nxt)) in tcp_newreno_partial_ack()
3222 tp->snd_nxt = old_snd_nxt; in tcp_newreno_partial_ack()
3225 tp->snd_cwnd = ocwnd - acked + tp->t_maxseg; in tcp_newreno_partial_ack()
3227 tp->snd_cwnd = tp->t_maxseg; in tcp_newreno_partial_ack()
3236 tcp_sack_rexmt(struct tcpcb *tp, boolean_t force) in tcp_sack_rexmt() argument
3238 tcp_seq old_snd_nxt = tp->snd_nxt; in tcp_sack_rexmt()
3239 u_long ocwnd = tp->snd_cwnd; in tcp_sack_rexmt()
3246 uint32_t unsacked = tcp_sack_first_unsacked_len(tp); in tcp_sack_rexmt()
3252 maxrexmt = howmany(unsacked, tp->t_maxseg); in tcp_sack_rexmt()
3257 tp->t_rtttime = 0; in tcp_sack_rexmt()
3258 pipe = tcp_sack_compute_pipe(tp); in tcp_sack_rexmt()
3259 while (((tcp_seq_diff_t)(ocwnd - pipe) >= (tcp_seq_diff_t)tp->t_maxseg in tcp_sack_rexmt()
3267 old_rexmt_high = tp->rexmt_high; in tcp_sack_rexmt()
3268 if (!tcp_sack_nextseg(tp, &nextrexmt, &seglen, &rescue)) { in tcp_sack_rexmt()
3269 tp->rexmt_high = old_rexmt_high; in tcp_sack_rexmt()
3283 tp->rexmt_high = old_rexmt_high; in tcp_sack_rexmt()
3287 if (nextrexmt == tp->snd_max) in tcp_sack_rexmt()
3291 tp->snd_nxt = nextrexmt; in tcp_sack_rexmt()
3292 tp->snd_cwnd = nextrexmt - tp->snd_una + seglen; in tcp_sack_rexmt()
3293 old_snd_max = tp->snd_max; in tcp_sack_rexmt()
3294 if (nextrexmt == tp->snd_una) in tcp_sack_rexmt()
3295 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_sack_rexmt()
3296 tp->t_flags |= TF_XMITNOW; in tcp_sack_rexmt()
3297 error = tcp_output(tp); in tcp_sack_rexmt()
3299 tp->rexmt_high = old_rexmt_high; in tcp_sack_rexmt()
3302 sent = tp->snd_nxt - nextrexmt; in tcp_sack_rexmt()
3304 tp->rexmt_high = old_rexmt_high; in tcp_sack_rexmt()
3313 tp->rexmt_rescue = tp->snd_nxt; in tcp_sack_rexmt()
3314 tp->sack_flags |= TSACK_F_SACKRESCUED; in tcp_sack_rexmt()
3318 SEQ_LT(tp->rexmt_high, tp->snd_nxt)) { in tcp_sack_rexmt()
3319 tp->rexmt_high = seq_min(tp->snd_nxt, old_snd_max); in tcp_sack_rexmt()
3321 (tp->sack_flags & TSACK_F_SACKRESCUED) && in tcp_sack_rexmt()
3322 SEQ_LT(tp->rexmt_rescue, tp->rexmt_high)) { in tcp_sack_rexmt()
3324 tp->rexmt_rescue = tp->rexmt_high; in tcp_sack_rexmt()
3328 if (SEQ_GT(old_snd_nxt, tp->snd_nxt)) in tcp_sack_rexmt()
3329 tp->snd_nxt = old_snd_nxt; in tcp_sack_rexmt()
3330 tp->snd_cwnd = ocwnd; in tcp_sack_rexmt()
3337 tcp_sack_limitedxmit(struct tcpcb *tp) in tcp_sack_limitedxmit() argument
3339 tcp_seq oldsndnxt = tp->snd_nxt; in tcp_sack_limitedxmit()
3340 tcp_seq oldsndmax = tp->snd_max; in tcp_sack_limitedxmit()
3341 u_long ocwnd = tp->snd_cwnd; in tcp_sack_limitedxmit()
3347 tp->rexmt_high = tp->snd_una - 1; in tcp_sack_limitedxmit()
3348 pipe = tcp_sack_compute_pipe(tp); in tcp_sack_limitedxmit()
3350 if (cwnd_left < (tcp_seq_diff_t)tp->t_maxseg) in tcp_sack_limitedxmit()
3354 cwnd_left = ulmin(cwnd_left, tp->t_maxseg * TCP_SACK_MAXBURST); in tcp_sack_limitedxmit()
3356 next = tp->snd_nxt = tp->snd_max; in tcp_sack_limitedxmit()
3357 tp->snd_cwnd = tp->snd_nxt - tp->snd_una + in tcp_sack_limitedxmit()
3358 rounddown(cwnd_left, tp->t_maxseg); in tcp_sack_limitedxmit()
3360 tp->t_flags |= TF_XMITNOW; in tcp_sack_limitedxmit()
3361 tcp_output(tp); in tcp_sack_limitedxmit()
3363 sent = tp->snd_nxt - next; in tcp_sack_limitedxmit()
3365 tcpstat.tcps_sndlimited += howmany(sent, tp->t_maxseg); in tcp_sack_limitedxmit()
3370 KASSERT(SEQ_GEQ(oldsndnxt, tp->snd_una), in tcp_sack_limitedxmit()
3372 tp->snd_nxt = oldsndnxt; in tcp_sack_limitedxmit()
3374 tp->snd_cwnd = ocwnd; in tcp_sack_limitedxmit()
3376 if (ret && TCP_DO_NCR(tp)) in tcp_sack_limitedxmit()
3377 tcp_ncr_update_rxtthresh(tp); in tcp_sack_limitedxmit()
3396 tcp_timer_keep_activity(struct tcpcb *tp, int thflags) in tcp_timer_keep_activity() argument
3398 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_timer_keep_activity()
3400 tp->t_flags |= TF_KEEPALIVE; in tcp_timer_keep_activity()
3401 tcp_callout_reset(tp, tp->tt_keep, hz / 2, in tcp_timer_keep_activity()
3404 tp->t_rcvtime = ticks; in tcp_timer_keep_activity()
3405 tp->t_flags &= ~TF_KEEPALIVE; in tcp_timer_keep_activity()
3406 tcp_callout_reset(tp, tp->tt_keep, in tcp_timer_keep_activity()
3407 tp->t_keepidle, in tcp_timer_keep_activity()
3414 tcp_rmx_msl(const struct tcpcb *tp) in tcp_rmx_msl() argument
3417 struct inpcb *inp = tp->t_inpcb; in tcp_rmx_msl()
3440 tcp_established(struct tcpcb *tp) in tcp_established() argument
3442 TCP_STATE_CHANGE(tp, TCPS_ESTABLISHED); in tcp_established()
3443 tcp_callout_reset(tp, tp->tt_keep, tp->t_keepidle, tcp_timer_keep); in tcp_established()
3445 if (tp->t_rxtsyn > 0) { in tcp_established()
3453 if (tp->t_rxtcur < TCPTV_RTOBASE3) in tcp_established()
3454 tp->t_rxtcur = TCPTV_RTOBASE3; in tcp_established()
3462 tcp_recv_dupack(struct tcpcb *tp, tcp_seq th_ack, u_int to_flags) in tcp_recv_dupack() argument
3477 if (IN_FASTRECOVERY(tp)) { in tcp_recv_dupack()
3478 if (TCP_DO_SACK(tp)) { in tcp_recv_dupack()
3481 if (tp->snd_una == tp->rexmt_high && in tcp_recv_dupack()
3492 tcp_sack_rexmt(tp, force); in tcp_recv_dupack()
3501 tp->snd_cwnd += tp->t_maxseg; in tcp_recv_dupack()
3502 tcp_output(tp); in tcp_recv_dupack()
3505 } else if (SEQ_LT(th_ack, tp->snd_recover)) { in tcp_recv_dupack()
3506 tp->t_dupacks = 0; in tcp_recv_dupack()
3508 } else if (tcp_ignore_redun_dsack && TCP_DO_SACK(tp) && in tcp_recv_dupack()
3527 } else if (tp->t_dupacks == 0 && TCP_DO_NCR(tp)) { in tcp_recv_dupack()
3528 tcp_ncr_update_rxtthresh(tp); in tcp_recv_dupack()
3531 if (++tp->t_dupacks == tp->t_rxtthresh) { in tcp_recv_dupack()
3536 if (tcp_do_eifel_detect && (tp->t_flags & TF_RCVD_TSTMP)) { in tcp_recv_dupack()
3537 tcp_save_congestion_state(tp); in tcp_recv_dupack()
3538 tp->rxt_flags |= TRXT_F_FASTREXMT; in tcp_recv_dupack()
3546 win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; in tcp_recv_dupack()
3549 tp->snd_ssthresh = win * tp->t_maxseg; in tcp_recv_dupack()
3550 ENTER_FASTRECOVERY(tp); in tcp_recv_dupack()
3551 tp->snd_recover = tp->snd_max; in tcp_recv_dupack()
3552 tcp_callout_stop(tp, tp->tt_rexmt); in tcp_recv_dupack()
3553 tp->t_rtttime = 0; in tcp_recv_dupack()
3554 old_snd_nxt = tp->snd_nxt; in tcp_recv_dupack()
3555 tp->snd_nxt = th_ack; in tcp_recv_dupack()
3556 if (TCP_DO_SACK(tp)) { in tcp_recv_dupack()
3559 rxtlen = tcp_sack_first_unsacked_len(tp); in tcp_recv_dupack()
3560 if (rxtlen > tp->t_maxseg) in tcp_recv_dupack()
3561 rxtlen = tp->t_maxseg; in tcp_recv_dupack()
3562 tp->snd_cwnd = rxtlen; in tcp_recv_dupack()
3564 tp->snd_cwnd = tp->t_maxseg; in tcp_recv_dupack()
3566 tcp_output(tp); in tcp_recv_dupack()
3568 tp->snd_cwnd = tp->snd_ssthresh; in tcp_recv_dupack()
3569 tp->rexmt_high = tp->snd_nxt; in tcp_recv_dupack()
3570 tp->sack_flags &= ~TSACK_F_SACKRESCUED; in tcp_recv_dupack()
3571 if (SEQ_GT(old_snd_nxt, tp->snd_nxt)) in tcp_recv_dupack()
3572 tp->snd_nxt = old_snd_nxt; in tcp_recv_dupack()
3573 KASSERT(tp->snd_limited <= 2, ("tp->snd_limited too big")); in tcp_recv_dupack()
3574 if (TCP_DO_SACK(tp)) { in tcp_recv_dupack()
3576 tcp_sack_rexmt(tp, FALSE); in tcp_recv_dupack()
3578 tp->snd_cwnd += tp->t_maxseg * in tcp_recv_dupack()
3579 (tp->t_dupacks - tp->snd_limited); in tcp_recv_dupack()
3581 } else if ((tcp_do_rfc6675 && TCP_DO_SACK(tp)) || TCP_DO_NCR(tp)) { in tcp_recv_dupack()
3592 tcp_sack_islost(&tp->scb, tp->snd_una)) in tcp_recv_dupack()
3595 if (tcp_do_limitedtransmit || TCP_DO_NCR(tp)) { in tcp_recv_dupack()
3596 if (!tcp_sack_limitedxmit(tp)) { in tcp_recv_dupack()
3598 uint32_t ownd = tp->snd_max - tp->snd_una; in tcp_recv_dupack()
3600 if (need_early_retransmit(tp, ownd)) { in tcp_recv_dupack()
3602 tp->rxt_flags |= TRXT_F_EARLYREXMT; in tcp_recv_dupack()
3605 tcp_sack_islost(&tp->scb, tp->snd_una)) { in tcp_recv_dupack()
3612 u_long oldcwnd = tp->snd_cwnd; in tcp_recv_dupack()
3613 tcp_seq oldsndmax = tp->snd_max; in tcp_recv_dupack()
3614 tcp_seq oldsndnxt = tp->snd_nxt; in tcp_recv_dupack()
3616 uint32_t ownd = tp->snd_max - tp->snd_una; in tcp_recv_dupack()
3619 KASSERT(tp->t_dupacks == 1 || tp->t_dupacks == 2, in tcp_recv_dupack()
3621 if (tp->t_dupacks == 1) in tcp_recv_dupack()
3622 tp->snd_limited = 0; in tcp_recv_dupack()
3623 tp->snd_nxt = tp->snd_max; in tcp_recv_dupack()
3624 tp->snd_cwnd = ownd + in tcp_recv_dupack()
3625 (tp->t_dupacks - tp->snd_limited) * tp->t_maxseg; in tcp_recv_dupack()
3626 tp->t_flags |= TF_XMITNOW; in tcp_recv_dupack()
3627 tcp_output(tp); in tcp_recv_dupack()
3630 KASSERT(SEQ_GEQ(oldsndnxt, tp->snd_una), in tcp_recv_dupack()
3632 tp->snd_nxt = oldsndnxt; in tcp_recv_dupack()
3634 tp->snd_cwnd = oldcwnd; in tcp_recv_dupack()
3635 sent = tp->snd_max - oldsndmax; in tcp_recv_dupack()
3636 if (sent > tp->t_maxseg) { in tcp_recv_dupack()
3637 KASSERT((tp->t_dupacks == 2 && tp->snd_limited == 0) || in tcp_recv_dupack()
3638 (sent == tp->t_maxseg + 1 && in tcp_recv_dupack()
3639 (tp->t_flags & TF_SENTFIN)), in tcp_recv_dupack()
3641 KASSERT(sent <= tp->t_maxseg * 2, in tcp_recv_dupack()
3643 tp->snd_limited = 2; in tcp_recv_dupack()
3646 ++tp->snd_limited; in tcp_recv_dupack()
3648 } else if (need_early_retransmit(tp, ownd)) { in tcp_recv_dupack()
3650 tp->rxt_flags |= TRXT_F_EARLYREXMT; in tcp_recv_dupack()