Lines Matching refs:tp

298 static inline int tcp_stretch_ack_enable(struct tcpcb *tp);
301 static inline void update_iaj_state(struct tcpcb *tp, uint32_t tlen, int reset_size);
302 void compute_iaj(struct tcpcb *tp);
309 static void tcp_sbrcv_grow(struct tcpcb *tp, struct sockbuf *sb,
312 void tcp_sbrcv_trim(struct tcpcb *tp, struct sockbuf *sb);
314 static inline void tcp_sbrcv_tstmp_check(struct tcpcb *tp);
315 static inline void tcp_sbrcv_reserve(struct tcpcb *tp, struct sockbuf *sb,
322 #define ND6_HINT(tp) \
324 if ((tp) && (tp)->t_inpcb && \
325 ((tp)->t_inpcb->inp_vflag & INP_IPV6) != 0 && \
326 (tp)->t_inpcb->in6p_route.ro_rt) \
327 nd6_nud_hint((tp)->t_inpcb->in6p_route.ro_rt, NULL, 0); \
330 #define ND6_HINT(tp)
357 #define DELAY_ACK(tp, th) (CC_ALGO(tp)->delay_ack != NULL && CC_ALGO(tp)->delay_ack(tp, th))
360 static void tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th);
362 static void update_base_rtt(struct tcpcb *tp, uint32_t rtt);
363 uint32_t get_base_rtt(struct tcpcb *tp);
367 static void tcp_bwmeas_check(struct tcpcb *tp);
371 reset_acc_iaj(struct tcpcb *tp)
373 tp->acc_iaj = 0;
374 tp->iaj_rwintop = 0;
375 CLEAR_IAJ_STATE(tp);
379 update_iaj_state(struct tcpcb *tp, uint32_t size, int rst_size)
382 tp->iaj_size = 0;
383 if (tp->iaj_size == 0 || size >= tp->iaj_size) {
384 tp->iaj_size = size;
385 tp->iaj_rcv_ts = tcp_now;
386 tp->iaj_small_pkt = 0;
421 compute_iaj(struct tcpcb *tp)
429 uint32_t cur_iaj = tcp_now - tp->iaj_rcv_ts;
433 cur_iaj_dev = (cur_iaj - tp->avg_iaj);
439 allowed_iaj = tp->avg_iaj + tp->std_dev_iaj;
448 if (tp->iaj_pktcnt > IAJ_IGNORE_PKTCNT) {
450 if (tp->acc_iaj >= 2)
451 acc_iaj = tp->acc_iaj - 2;
455 acc_iaj = tp->acc_iaj + (cur_iaj - allowed_iaj);
460 tp->acc_iaj = acc_iaj;
467 tp->avg_iaj = (((tp->avg_iaj << 4) - tp->avg_iaj) + cur_iaj) >> 4;
472 temp = tp->std_dev_iaj * tp->std_dev_iaj;
475 tp->std_dev_iaj = isqrt(mean);
477 DTRACE_TCP3(iaj, struct tcpcb *, tp, uint32_t, cur_iaj, uint32_t, allowed_iaj);
487 tcp_bwmeas_check(struct tcpcb *tp)
491 bw_meas_bytes = tp->snd_una - tp->t_bwmeas->bw_start;
492 if ((tp->t_flagsext & TF_BWMEAS_INPROGRESS) != 0 &&
493 bw_meas_bytes >= (int32_t)(tp->t_bwmeas->bw_size)) {
495 elapsed_time = tcp_now - tp->t_bwmeas->bw_ts;
499 if (tp->t_bwmeas->bw_sndbw > 0) {
500 tp->t_bwmeas->bw_sndbw =
501 (((tp->t_bwmeas->bw_sndbw << 3) - tp->t_bwmeas->bw_sndbw) + bw) >> 3;
503 tp->t_bwmeas->bw_sndbw = bw;
507 tp->t_flagsext &= ~(TF_BWMEAS_INPROGRESS);
512 tcp_reass(tp, th, tlenp, m)
513 register struct tcpcb *tp;
522 struct socket *so = tp->t_inpcb->inp_socket;
537 if ((tp->t_flags & TF_STRETCHACK) != 0)
538 tcp_reset_stretch_ack(tp);
545 tp->t_flagsext |= TF_RCVUNACK_WAITSS;
546 tp->rcv_waitforss = 0;
550 if (tp->acc_iaj > 0)
551 reset_acc_iaj(tp);
561 if (th->th_seq != tp->rcv_nxt &&
582 LIST_FOREACH(q, &tp->t_segq, tqe_q) {
602 nstat_route_rx(tp->t_inpcb->inp_route.ro_rt, 1, *tlenp, NSTAT_RX_FLAG_DUPLICATE);
603 locked_add_64(&tp->t_inpcb->inp_stat->rxpackets, 1);
604 locked_add_64(&tp->t_inpcb->inp_stat->rxbytes, *tlenp);
605 tp->t_stat.rxduplicatebytes += *tlenp;
626 nstat_route_rx(tp->t_inpcb->inp_route.ro_rt, 1, *tlenp, NSTAT_RX_FLAG_OUT_OF_ORDER);
627 locked_add_64(&tp->t_inpcb->inp_stat->rxpackets, 1);
628 locked_add_64(&tp->t_inpcb->inp_stat->rxbytes, *tlenp);
629 tp->t_stat.rxoutoforderbytes += *tlenp;
661 LIST_INSERT_HEAD(&tp->t_segq, te, tqe_q);
671 if (!TCPS_HAVEESTABLISHED(tp->t_state))
673 q = LIST_FIRST(&tp->t_segq);
674 if (!q || q->tqe_th->th_seq != tp->rcv_nxt) {
676 if (tp->t_flagsext & TF_LRO_OFFLOADED) {
677 tcp_lro_remove_state(tp->t_inpcb->inp_laddr,
678 tp->t_inpcb->inp_faddr,
680 tp->t_flagsext &= ~TF_LRO_OFFLOADED;
685 tp->rcv_nxt += q->tqe_len;
695 if (tp->t_flagsext & TF_LRO_OFFLOADED) {
696 tcp_update_lro_seq(tp->rcv_nxt,
697 tp->t_inpcb->inp_laddr,
698 tp->t_inpcb->inp_faddr, th->th_dport, th->th_sport);
704 } while (q && q->tqe_th->th_seq == tp->rcv_nxt);
705 ND6_HINT(tp);
708 if ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) {
711 ((tp->t_inpcb->inp_fport << 16) | tp->t_inpcb->inp_lport),
712 (((tp->t_inpcb->in6p_laddr.s6_addr16[0] & 0xffff) << 16) |
713 (tp->t_inpcb->in6p_faddr.s6_addr16[0] & 0xffff)),
720 ((tp->t_inpcb->inp_fport << 16) | tp->t_inpcb->inp_lport),
721 (((tp->t_inpcb->inp_laddr.s_addr & 0xffff) << 16) |
722 (tp->t_inpcb->inp_faddr.s_addr & 0xffff)),
736 struct tcpcb *tp)
743 if (CC_ALGO(tp)->pre_fr != NULL)
744 CC_ALGO(tp)->pre_fr(tp);
745 ENTER_FASTRECOVERY(tp);
746 tp->snd_recover = tp->snd_max;
747 tp->t_timer[TCPT_REXMT] = 0;
748 tp->t_rtttime = 0;
749 tp->ecn_flags |= TE_SENDCWR;
750 tp->snd_cwnd = tp->snd_ssthresh +
751 tp->t_maxseg * tcprexmtthresh;
831 tcp_sbrcv_reserve(struct tcpcb *tp,
843 newsize = min(newsize, TCP_MAXWIN << tp->rcv_scale);
856 TCP_MAXWIN << tp->rcv_scale);
866 tcp_sbrcv_grow(struct tcpcb *tp, struct sockbuf *sbrcv,
878 tp->rfbuf_ts + TCPTV_RCVBUFIDLE)) {
885 if ((tp->t_flags & (TF_REQ_TSTMP | TF_RCVD_TSTMP)) !=
894 tp->rfbuf_ts + TCPTV_RCVNOTS_QUANTUM)) {
895 if (tp->rfbuf_cnt >= TCP_RCVNOTS_BYTELEVEL) {
896 tcp_sbrcv_reserve(tp, sbrcv,
901 tp->rfbuf_cnt += pktlen;
917 if (TSTMP_GEQ(to->to_tsecr, tp->rfbuf_ts)) {
918 if ((tp->rfbuf_cnt > (sbrcv->sb_hiwat -
921 (tp->rfbuf_cnt >> tcp_rbuf_win_shift))) {
934 rcvbuf_inc = tp->t_maxseg << tcp_autorcvbuf_inc_shift;
935 tcp_sbrcv_reserve(tp, sbrcv,
937 (tp->rfbuf_cnt * 2));
941 tp->rfbuf_cnt += pktlen;
947 tp->rfbuf_ts = 0;
948 tp->rfbuf_cnt = 0;
958 tcp_sbrcv_trim(struct tcpcb *tp, struct sockbuf *sbrcv) {
968 u_int32_t advwin = tp->rcv_adv - tp->rcv_nxt;
981 leave = tp->t_maxseg << tcp_autorcvbuf_inc_shift;
1024 tcp_sbrcv_tstmp_check(struct tcpcb *tp) {
1025 struct socket *so = tp->t_inpcb->inp_socket;
1029 if ((tp->t_flags & (TF_REQ_TSTMP | TF_RCVD_TSTMP)) !=
1032 tcp_sbrcv_reserve(tp, sbrcv, newsize, 0);
1056 tcp_stretch_ack_enable(struct tcpcb *tp) {
1057 if (tp->rcv_by_unackwin >= (maxseg_unacked * tp->t_maxseg) &&
1058 TSTMP_GT(tp->rcv_unackwin + tcp_maxrcvidle, tcp_now) &&
1059 (((tp->t_flagsext & TF_RCVUNACK_WAITSS) == 0) ||
1060 (tp->rcv_waitforss >= tcp_rcvsspktcnt))) {
1073 tcp_reset_stretch_ack(struct tcpcb *tp)
1075 tp->t_flags &= ~(TF_STRETCHACK);
1076 tp->rcv_by_unackwin = 0;
1077 tp->rcv_unackwin = tcp_now + tcp_rcvunackwin;
1093 register struct tcpcb *tp = 0;
1631 tp = intotcpcb(inp);
1632 if (tp == 0) {
1640 if (tp->t_state == TCPS_CLOSED)
1645 tiwin = th->th_win << tp->snd_scale;
1655 if (tp->t_state == TCPS_LISTEN && (so->so_options & SO_ACCEPTCONN) == 0)
1661 ostate = tp->t_state;
1673 register struct tcpcb *tp0 = tp;
1706 tp = NULL;
1792 tp = NULL;
1843 /* Point "inp" and "tp" in tandem to new socket */
1845 tp = intotcpcb(inp);
1956 struct tcpcb *, tp, int32_t, TCPS_LISTEN);
1957 tp->t_state = TCPS_LISTEN;
1958 tp->t_flags |= tp0->t_flags & (TF_NOPUSH|TF_NOOPT|TF_NODELAY);
1959 tp->t_flagsext |= (tp0->t_flagsext & TF_RXTFINDROP);
1960 tp->t_keepinit = tp0->t_keepinit;
1961 tp->t_inpcb->inp_ip_ttl = tp0->t_inpcb->inp_ip_ttl;
1963 tp->t_notsent_lowat = tp0->t_notsent_lowat;
1968 tcp_set_max_rwinscale(tp, so);
2002 if (tp->t_state == TCPS_ESTABLISHED && tlen > 0) {
2003 if (TSTMP_GT(tp->rcv_reset, tcp_now)) {
2004 tp->rcv_pps++;
2005 tp->rcv_byps += tlen + off;
2006 if (tp->rcv_byps > tp->rcv_maxbyps)
2007 tp->rcv_maxbyps = tp->rcv_byps;
2012 if (tcp_minmss && tcp_minmssoverload && tp->rcv_pps > tcp_minmssoverload) {
2013 if ((tp->rcv_byps / tp->rcv_pps) < tcp_minmss) {
2026 tp->rcv_byps / tp->rcv_pps);
2027 tp = tcp_drop(tp, ECONNRESET);
2033 tp->rcv_reset = tcp_now + TCP_RETRANSHZ;
2034 tp->rcv_pps = 1;
2035 tp->rcv_byps = tlen + off;
2043 if ((tp->t_flagsext & TF_RCVUNACK_WAITSS) != 0) {
2044 TCP_INC_VAR(tp->rcv_waitforss, nlropkts);
2046 if (tcp_stretch_ack_enable(tp)) {
2047 tp->t_flags |= TF_STRETCHACK;
2048 tp->t_flagsext &= ~(TF_RCVUNACK_WAITSS);
2049 tp->rcv_waitforss = 0;
2051 tp->t_flags &= ~(TF_STRETCHACK);
2053 if (TSTMP_GT(tp->rcv_unackwin, tcp_now)) {
2054 tp->rcv_by_unackwin += (tlen + off);
2056 tp->rcv_unackwin = tcp_now + tcp_rcvunackwin;
2057 tp->rcv_by_unackwin = tlen + off;
2065 tp->t_lropktlen += tlen;
2077 if (ip_ecn == IPTOS_ECN_CE && tp->t_state == TCPS_ESTABLISHED &&
2078 ((tp->ecn_flags & (TE_ECN_ON)) == (TE_ECN_ON)) && tlen > 0 &&
2079 SEQ_GEQ(th->th_seq, tp->last_ack_sent) &&
2080 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) {
2081 tp->ecn_flags |= TE_SENDECE;
2089 tp->ecn_flags &= ~TE_SENDECE;
2096 if (tp->t_state == TCPS_ESTABLISHED && (tp->t_flags & TF_STRETCHACK) != 0 &&
2098 tcp_reset_stretch_ack(tp);
2107 if (sw_lro && (tp->t_flagsext & TF_LRO_OFFLOADED) &&
2108 ((tcp_now - tp->t_rcvtime) >= (TCP_IDLETIMEOUT(tp)))) {
2116 tp->t_rcvtime = tcp_now;
2117 if (TCPS_HAVEESTABLISHED(tp->t_state))
2118 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp, TCP_KEEPIDLE(tp));
2124 if (tp->t_state != TCPS_LISTEN && optp)
2125 tcp_dooptions(tp, optp, optlen, th, &to, ifscope);
2127 if (tp->t_state == TCPS_SYN_SENT && (thflags & TH_SYN)) {
2129 tp->t_flags |= TF_RCVD_SCALE;
2130 tp->requested_s_scale = to.to_requested_s_scale;
2131 tp->snd_wnd = th->th_win << tp->snd_scale;
2132 tiwin = tp->snd_wnd;
2135 tp->t_flags |= TF_RCVD_TSTMP;
2136 tp->ts_recent = to.to_tsval;
2137 tp->ts_recent_age = tcp_now;
2140 tcp_mss(tp, to.to_mss, ifscope);
2141 if (tp->sack_enable) {
2143 tp->sack_enable = 0;
2145 tp->t_flags |= TF_SACK_PERMIT;
2159 if (tp->t_state == TCPS_ESTABLISHED &&
2161 ((tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN)) == 0) &&
2163 TSTMP_GEQ(to.to_tsval, tp->ts_recent)) &&
2164 th->th_seq == tp->rcv_nxt &&
2165 LIST_EMPTY(&tp->t_segq)) {
2167 if (tp->iaj_pktcnt <= IAJ_IGNORE_PKTCNT) {
2168 TCP_INC_VAR(tp->iaj_pktcnt, nlropkts);
2174 if ( tp->iaj_size == 0 || seg_size > tp->iaj_size ||
2175 (seg_size == tp->iaj_size && tp->iaj_rcv_ts == 0)) {
2180 update_iaj_state(tp, seg_size, 0);
2182 if (seg_size == tp->iaj_size) {
2186 compute_iaj(tp);
2188 if (seg_size < tp->iaj_size) {
2196 tp->iaj_small_pkt++;
2197 if (tp->iaj_small_pkt > RESET_IAJ_SIZE_THRESH) {
2198 update_iaj_state(tp, seg_size, 1);
2200 CLEAR_IAJ_STATE(tp);
2203 update_iaj_state(tp, seg_size, 0);
2207 CLEAR_IAJ_STATE(tp);
2228 if (tp->t_state == TCPS_ESTABLISHED &&
2230 ((tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN)) == 0) &&
2232 TSTMP_GEQ(to.to_tsval, tp->ts_recent)) &&
2233 th->th_seq == tp->rcv_nxt &&
2234 tiwin && tiwin == tp->snd_wnd &&
2235 tp->snd_nxt == tp->snd_max) {
2244 SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
2245 tp->ts_recent_age = tcp_now;
2246 tp->ts_recent = to.to_tsval;
2252 tp->t_flags |= TF_ACKNOW;
2255 if (SEQ_GT(th->th_ack, tp->snd_una) &&
2256 SEQ_LEQ(th->th_ack, tp->snd_max) &&
2257 tp->snd_cwnd >= tp->snd_ssthresh &&
2258 (!IN_FASTRECOVERY(tp) &&
2259 ((!tp->sack_enable && tp->t_dupacks < tcprexmtthresh) ||
2260 (tp->sack_enable && to.to_nsacks == 0 &&
2261 TAILQ_EMPTY(&tp->snd_holes))))) {
2269 if (tp->t_rxtshift == 1 &&
2270 TSTMP_LT(tcp_now, tp->t_badrxtwin)) {
2272 tp->snd_cwnd = tp->snd_cwnd_prev;
2273 tp->snd_ssthresh =
2274 tp->snd_ssthresh_prev;
2275 tp->snd_recover = tp->snd_recover_prev;
2276 if (tp->t_flags & TF_WASFRECOVERY)
2277 ENTER_FASTRECOVERY(tp);
2278 tp->snd_nxt = tp->snd_max;
2279 tp->t_badrxtwin = 0;
2280 tp->t_rxtshift = 0;
2281 tp->rxt_start = 0;
2282 tcp_bad_rexmt_fix_sndbuf(tp);
2283 DTRACE_TCP5(cc, void, NULL, struct inpcb *, tp->t_inpcb,
2284 struct tcpcb *, tp, struct tcphdr *, th,
2297 tcp_xmit_timer(tp,
2299 } else if (tp->t_rtttime &&
2300 SEQ_GT(th->th_ack, tp->t_rtseq)) {
2301 tcp_xmit_timer(tp, tcp_now - tp->t_rtttime);
2303 acked = th->th_ack - tp->snd_una;
2311 if (CC_ALGO(tp)->inseq_ack_rcvd != NULL)
2312 CC_ALGO(tp)->inseq_ack_rcvd(tp, th);
2315 struct tcpcb *, tp, struct tcphdr *, th,
2321 if (SEQ_GT(tp->snd_una, tp->snd_recover) &&
2322 SEQ_LEQ(th->th_ack, tp->snd_recover))
2323 tp->snd_recover = th->th_ack - 1;
2324 tp->snd_una = th->th_ack;
2330 tp->snd_wl2 = th->th_ack;
2331 tp->t_dupacks = 0;
2333 ND6_HINT(tp); /* some progress has been done */
2344 if (tp->snd_una == tp->snd_max)
2345 tp->t_timer[TCPT_REXMT] = 0;
2346 else if (tp->t_timer[TCPT_PERSIST] == 0)
2347 tp->t_timer[TCPT_REXMT] = OFFSET_FROM_START(tp, tp->t_rxtcur);
2349 if ((tp->t_flagsext & TF_MEASURESNDBW) != 0 &&
2350 tp->t_bwmeas != NULL)
2351 tcp_bwmeas_check(tp);
2353 if ((so->so_snd.sb_cc) || (tp->t_flags & TF_ACKNOW)) {
2354 (void) tcp_output(tp);
2357 tcp_check_timer_state(tp);
2362 } else if (th->th_ack == tp->snd_una &&
2363 LIST_EMPTY(&tp->t_segq) &&
2364 tlen <= tcp_sbspace(tp)) {
2376 tcp_lro_remove_state(tp->t_inpcb->inp_laddr,
2377 tp->t_inpcb->inp_faddr,
2378 tp->t_inpcb->inp_lport,
2379 tp->t_inpcb->inp_fport);
2380 tp->t_flagsext &= ~TF_LRO_OFFLOADED;
2381 tp->t_idleat = tp->rcv_nxt;
2386 ((th->th_seq - tp->irs) >
2387 (tp->t_maxseg << lro_start)) &&
2388 ((tp->t_idleat == 0) || ((th->th_seq -
2389 tp->t_idleat) > (tp->t_maxseg << lro_start)))) {
2390 tp->t_flagsext |= TF_LRO_OFFLOADED;
2392 tp->t_idleat = 0;
2396 if (tp->sack_enable && tp->rcv_numsacks)
2397 tcp_clean_sackreport(tp);
2399 tp->rcv_nxt += tlen;
2404 tp->snd_wl1 = th->th_seq;
2409 tp->rcv_up = tp->rcv_nxt;
2421 ND6_HINT(tp); /* some progress has been done */
2423 tcp_sbrcv_grow(tp, &so->so_rcv, &to, tlen);
2445 TCP_INC_VAR(tp->t_unacksegs, nlropkts);
2446 if (DELAY_ACK(tp, th)) {
2447 if ((tp->t_flags & TF_DELACK) == 0) {
2448 tp->t_flags |= TF_DELACK;
2449 tp->t_timer[TCPT_DELACK] = OFFSET_FROM_START(tp, tcp_delack);
2452 tp->t_flags |= TF_ACKNOW;
2453 tcp_output(tp);
2455 tcp_check_timer_state(tp);
2472 win = tcp_sbspace(tp);
2477 if (tp->t_flags & TF_SLOWLINK && slowlink_wsize > 0)
2480 tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt));
2483 switch (tp->t_state) {
2486 * Initialize tp->rcv_nxt, and tp->irs, select an initial
2487 * tp->iss, and send a segment:
2489 * Also initialize tp->snd_nxt to tp->iss+1 and tp->snd_una to tp->iss.
2546 tcp_dooptions(tp, optp, optlen, th, &to, ifscope);
2548 if (tp->sack_enable) {
2550 tp->sack_enable = 0;
2552 tp->t_flags |= TF_SACK_PERMIT;
2556 tp->iss = iss;
2558 tp->iss = tcp_new_isn(tp);
2560 tp->irs = th->th_seq;
2561 tcp_sendseqinit(tp);
2562 tcp_rcvseqinit(tp);
2563 tp->snd_recover = tp->snd_una;
2569 tp->snd_wnd = tiwin; /* initial send-window */
2570 tp->t_flags |= TF_ACKNOW;
2571 tp->t_unacksegs = 0;
2573 struct tcpcb *, tp, int32_t, TCPS_SYN_RECEIVED);
2574 tp->t_state = TCPS_SYN_RECEIVED;
2575 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp,
2576 tp->t_keepinit ? tp->t_keepinit : tcp_keepinit);
2587 tp->ecn_flags |= (TE_SETUPRECEIVED | TE_SENDIPECT);
2594 tp->t_flags &= ~TF_REQ_SCALE;
2606 (SEQ_LEQ(th->th_ack, tp->snd_una) ||
2607 SEQ_GT(th->th_ack, tp->snd_max))) {
2623 * initialize tp->rcv_nxt and tp->irs
2624 * if seg contains ack then advance tp->snd_una
2631 (SEQ_LEQ(th->th_ack, tp->iss) ||
2632 SEQ_GT(th->th_ack, tp->snd_max))) {
2645 tp = tcp_drop(tp, ECONNREFUSED);
2652 tp->snd_wnd = th->th_win; /* initial send window */
2654 tp->irs = th->th_seq;
2655 tcp_rcvseqinit(tp);
2661 tp->ecn_flags |= TE_SETUPRECEIVED;
2665 tp->ecn_flags &= ~TE_SENDIPECT;
2674 if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
2676 tp->snd_scale = tp->requested_s_scale;
2677 tp->rcv_scale = tp->request_r_scale;
2679 tp->rcv_adv += min(tp->rcv_wnd, TCP_MAXWIN << tp->rcv_scale);
2680 tp->snd_una++; /* SYN is acked */
2685 TCP_INC_VAR(tp->t_unacksegs, nlropkts);
2686 if (DELAY_ACK(tp, th) && tlen != 0 ) {
2687 if ((tp->t_flags & TF_DELACK) == 0) {
2688 tp->t_flags |= TF_DELACK;
2689 tp->t_timer[TCPT_DELACK] = OFFSET_FROM_START(tp, tcp_delack);
2693 tp->t_flags |= TF_ACKNOW;
2701 tp->t_starttime = tcp_now;
2702 tcp_sbrcv_tstmp_check(tp);
2703 if (tp->t_flags & TF_NEEDFIN) {
2705 struct tcpcb *, tp, int32_t, TCPS_FIN_WAIT_1);
2706 tp->t_state = TCPS_FIN_WAIT_1;
2707 tp->t_flags &= ~TF_NEEDFIN;
2711 struct tcpcb *, tp, int32_t, TCPS_ESTABLISHED);
2712 tp->t_state = TCPS_ESTABLISHED;
2713 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp, TCP_KEEPIDLE(tp));
2715 nstat_route_connect_success(tp->t_inpcb->inp_route.ro_rt);
2727 tp->t_flags |= TF_ACKNOW;
2728 tp->t_timer[TCPT_REXMT] = 0;
2730 struct tcpcb *, tp, int32_t, TCPS_SYN_RECEIVED);
2731 tp->t_state = TCPS_SYN_RECEIVED;
2742 if (tlen > tp->rcv_wnd) {
2743 todrop = tlen - tp->rcv_wnd;
2745 tlen = tp->rcv_wnd;
2750 tp->snd_wl1 = th->th_seq - 1;
2751 tp->rcv_up = th->th_seq;
2853 if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) &&
2854 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) ||
2855 (tp->rcv_wnd == 0 &&
2856 ((tp->last_ack_sent == th->th_seq) || ((tp->last_ack_sent -1) == th->th_seq)))) {
2857 switch (tp->t_state) {
2866 if (tp->last_ack_sent != th->th_seq) {
2880 struct tcpcb *, tp, int32_t, TCPS_CLOSED);
2886 tp->t_state = TCPS_CLOSED;
2888 tp = tcp_close(tp);
2893 tp = tcp_close(tp);
2907 if ((to.to_flags & TOF_TS) != 0 && tp->ts_recent &&
2908 TSTMP_LT(to.to_tsval, tp->ts_recent)) {
2911 if ((int)(tcp_now - tp->ts_recent_age) > TCP_PAWS_IDLE) {
2923 tp->ts_recent = 0;
2929 nstat_route_rx(tp->t_inpcb->inp_route.ro_rt, 1, tlen, NSTAT_RX_FLAG_DUPLICATE);
2932 tp->t_stat.rxduplicatebytes += tlen;
2947 if (tp->t_state == TCPS_SYN_RECEIVED && SEQ_LT(th->th_seq, tp->irs)) {
2956 todrop = tp->rcv_nxt - th->th_seq;
2983 tp->t_flags |= TF_ACKNOW;
2997 nstat_route_rx(tp->t_inpcb->inp_route.ro_rt, 1, todrop, NSTAT_RX_FLAG_DUPLICATE);
3000 tp->t_stat.rxduplicatebytes += todrop;
3018 tp->t_state > TCPS_CLOSE_WAIT && tlen) {
3019 tp = tcp_close(tp);
3033 todrop = (th->th_seq+tlen) - (tp->rcv_nxt+tp->rcv_wnd);
3045 tp->t_state == TCPS_TIME_WAIT &&
3046 SEQ_GT(th->th_seq, tp->rcv_nxt)) {
3047 iss = tcp_new_isn(tp);
3048 tp = tcp_close(tp);
3059 if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) {
3060 tp->t_flags |= TF_ACKNOW;
3090 SEQ_LEQ(th->th_seq, tp->last_ack_sent) &&
3091 SEQ_LEQ(tp->last_ack_sent, th->th_seq + tlen +
3093 tp->ts_recent_age = tcp_now;
3094 tp->ts_recent = to.to_tsval;
3102 tp = tcp_drop(tp, ECONNRESET);
3118 if (tp->t_state == TCPS_SYN_RECEIVED ||
3119 (tp->t_flags & TF_NEEDSYN))
3121 else if (tp->t_flags & TF_ACKNOW)
3130 switch (tp->t_state) {
3142 if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
3144 tp->snd_scale = tp->requested_s_scale;
3145 tp->rcv_scale = tp->request_r_scale;
3146 tp->snd_wnd = th->th_win << tp->snd_scale;
3147 tiwin = tp->snd_wnd;
3154 tp->t_starttime = tcp_now;
3155 tcp_sbrcv_tstmp_check(tp);
3156 if (tp->t_flags & TF_NEEDFIN) {
3158 struct tcpcb *, tp, int32_t, TCPS_FIN_WAIT_1);
3159 tp->t_state = TCPS_FIN_WAIT_1;
3160 tp->t_flags &= ~TF_NEEDFIN;
3163 struct tcpcb *, tp, int32_t, TCPS_ESTABLISHED);
3164 tp->t_state = TCPS_ESTABLISHED;
3165 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp, TCP_KEEPIDLE(tp));
3167 nstat_route_connect_success(tp->t_inpcb->inp_route.ro_rt);
3174 (void) tcp_reass(tp, (struct tcphdr *)0, &tlen,
3176 tp->snd_wl1 = th->th_seq - 1;
3185 * tp->snd_una < th->th_ack <= tp->snd_max
3186 * then advance tp->snd_una to th->th_ack and drop
3197 if (SEQ_GT(th->th_ack, tp->snd_max)) {
3201 if (tp->sack_enable &&
3202 (to.to_nsacks > 0 || !TAILQ_EMPTY(&tp->snd_holes)))
3203 tcp_sack_doack(tp, &to, th->th_ack);
3204 if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
3205 if (tlen == 0 && tiwin == tp->snd_wnd) {
3231 if (tp->t_timer[TCPT_REXMT] == 0 ||
3232 th->th_ack != tp->snd_una)
3233 tp->t_dupacks = 0;
3234 else if (++tp->t_dupacks > tcprexmtthresh ||
3235 IN_FASTRECOVERY(tp)) {
3236 if (tp->sack_enable && IN_FASTRECOVERY(tp)) {
3245 awnd = (tp->snd_nxt - tp->snd_fack) +
3246 tp->sackhint.sack_bytes_rexmit;
3247 if (awnd < tp->snd_ssthresh) {
3248 tp->snd_cwnd += tp->t_maxseg;
3249 if (tp->snd_cwnd > tp->snd_ssthresh)
3250 tp->snd_cwnd = tp->snd_ssthresh;
3253 tp->snd_cwnd += tp->t_maxseg;
3256 struct tcpcb *, tp, struct tcphdr *, th,
3259 (void) tcp_output(tp);
3261 } else if (tp->t_dupacks == tcprexmtthresh) {
3262 tcp_seq onxt = tp->snd_nxt;
3271 if (tp->sack_enable) {
3272 if (IN_FASTRECOVERY(tp)) {
3273 tp->t_dupacks = 0;
3278 tp->snd_recover)) {
3279 tp->t_dupacks = 0;
3289 if (CC_ALGO(tp)->pre_fr != NULL)
3290 CC_ALGO(tp)->pre_fr(tp);
3291 ENTER_FASTRECOVERY(tp);
3292 tp->snd_recover = tp->snd_max;
3293 tp->t_timer[TCPT_REXMT] = 0;
3294 tp->t_rtttime = 0;
3295 if ((tp->ecn_flags & TE_ECN_ON) == TE_ECN_ON) {
3296 tp->ecn_flags |= TE_SENDCWR;
3298 if (tp->sack_enable) {
3300 tp->sack_newdata = tp->snd_nxt;
3301 tp->snd_cwnd = tp->t_maxseg;
3304 struct tcpcb *, tp, struct tcphdr *, th,
3307 (void) tcp_output(tp);
3310 tp->snd_nxt = th->th_ack;
3311 tp->snd_cwnd = tp->t_maxseg;
3312 (void) tcp_output(tp);
3313 tp->snd_cwnd = tp->snd_ssthresh +
3314 tp->t_maxseg * tp->t_dupacks;
3315 if (SEQ_GT(onxt, tp->snd_nxt))
3316 tp->snd_nxt = onxt;
3318 struct tcpcb *, tp, struct tcphdr *, th,
3323 tp->t_dupacks = 0;
3330 if (IN_FASTRECOVERY(tp)) {
3331 if (SEQ_LT(th->th_ack, tp->snd_recover)) {
3332 if (tp->sack_enable)
3333 tcp_sack_partialack(tp, th);
3335 tcp_newreno_partial_ack(tp, th);
3338 struct tcpcb *, tp, struct tcphdr *, th,
3341 EXIT_FASTRECOVERY(tp);
3342 if (CC_ALGO(tp)->post_fr != NULL)
3343 CC_ALGO(tp)->post_fr(tp, th);
3344 tp->t_dupacks = 0;
3347 struct tcpcb *, tp, struct tcphdr *, th,
3355 tp->t_dupacks = 0;
3363 if (tp->t_flags & TF_NEEDSYN) {
3371 tp->t_flags &= ~TF_NEEDSYN;
3372 tp->snd_una++;
3374 if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
3376 tp->snd_scale = tp->requested_s_scale;
3377 tp->rcv_scale = tp->request_r_scale;
3382 acked = th->th_ack - tp->snd_una;
3393 if (tp->t_rxtshift == 1 &&
3394 TSTMP_LT(tcp_now, tp->t_badrxtwin)) {
3396 tp->snd_cwnd = tp->snd_cwnd_prev;
3397 tp->snd_ssthresh = tp->snd_ssthresh_prev;
3398 tp->snd_recover = tp->snd_recover_prev;
3399 if (tp->t_flags & TF_WASFRECOVERY)
3400 ENTER_FASTRECOVERY(tp);
3401 tp->snd_nxt = tp->snd_max;
3402 tp->t_badrxtwin = 0; /* XXX probably not required */
3403 tp->t_rxtshift = 0;
3404 tp->rxt_start = 0;
3405 tcp_bad_rexmt_fix_sndbuf(tp);
3408 struct tcpcb *, tp, struct tcphdr *, th,
3429 tcp_xmit_timer(tp, tcp_now - to.to_tsecr);
3430 } else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq)) {
3431 tcp_xmit_timer(tp, tcp_now - tp->t_rtttime);
3440 if (th->th_ack == tp->snd_max) {
3441 tp->t_timer[TCPT_REXMT] = 0;
3443 } else if (tp->t_timer[TCPT_PERSIST] == 0)
3444 tp->t_timer[TCPT_REXMT] = OFFSET_FROM_START(tp, tp->t_rxtcur);
3454 ((tp->ecn_flags & TE_ECN_ON) == TE_ECN_ON)) {
3458 if (!tp->sack_enable && !IN_FASTRECOVERY(tp) &&
3459 SEQ_GEQ(th->th_ack, tp->snd_recover)) {
3460 tcp_reduce_congestion_window(tp);
3462 struct tcpcb *, tp, struct tcphdr *, th,
3475 if (!IN_FASTRECOVERY(tp)) {
3476 if (CC_ALGO(tp)->ack_rcvd != NULL)
3477 CC_ALGO(tp)->ack_rcvd(tp, th);
3480 struct tcpcb *, tp, struct tcphdr *, th,
3484 tp->snd_wnd -= so->so_snd.sb_cc;
3490 tp->snd_wnd -= acked;
3494 if ( !IN_FASTRECOVERY(tp) &&
3495 SEQ_GT(tp->snd_una, tp->snd_recover) &&
3496 SEQ_LEQ(th->th_ack, tp->snd_recover))
3497 tp->snd_recover = th->th_ack - 1;
3499 if (IN_FASTRECOVERY(tp) &&
3500 SEQ_GEQ(th->th_ack, tp->snd_recover))
3501 EXIT_FASTRECOVERY(tp);
3503 tp->snd_una = th->th_ack;
3504 if (tp->sack_enable) {
3505 if (SEQ_GT(tp->snd_una, tp->snd_recover))
3506 tp->snd_recover = tp->snd_una;
3508 if (SEQ_LT(tp->snd_nxt, tp->snd_una))
3509 tp->snd_nxt = tp->snd_una;
3510 if ((tp->t_flagsext & TF_MEASURESNDBW) != 0 &&
3511 tp->t_bwmeas != NULL)
3512 tcp_bwmeas_check(tp);
3520 switch (tp->t_state) {
3537 add_to_time_wait(tp, tcp_maxidle);
3542 struct tcpcb *, tp, int32_t, TCPS_FIN_WAIT_2);
3543 tp->t_state = TCPS_FIN_WAIT_2;
3546 tp->t_flags |= TF_ACKNOW;
3558 struct tcpcb *, tp, int32_t, TCPS_TIME_WAIT);
3559 tp->t_state = TCPS_TIME_WAIT;
3560 tcp_canceltimers(tp);
3562 if (tp->cc_recv != 0 &&
3563 ((int)(tcp_now - tp->t_starttime)) < tcp_msl)
3564 add_to_time_wait(tp, tp->t_rxtcur * TCPTV_TWTRUNC);
3566 add_to_time_wait(tp, 2 * tcp_msl);
3570 tp->t_flags |= TF_ACKNOW;
3581 tp = tcp_close(tp);
3592 add_to_time_wait(tp, 2 * tcp_msl);
3603 (SEQ_LT(tp->snd_wl1, th->th_seq) ||
3604 (tp->snd_wl1 == th->th_seq && (SEQ_LT(tp->snd_wl2, th->th_ack) ||
3605 (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))) {
3608 tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd)
3610 tp->snd_wnd = tiwin;
3611 tp->snd_wl1 = th->th_seq;
3612 tp->snd_wl2 = th->th_ack;
3613 if (tp->snd_wnd > tp->max_sndwnd)
3614 tp->max_sndwnd = tp->snd_wnd;
3622 TCPS_HAVERCVDFIN(tp->t_state) == 0) {
3648 if (SEQ_GT(th->th_seq+th->th_urp, tp->rcv_up)) {
3649 tp->rcv_up = th->th_seq + th->th_urp;
3651 (tp->rcv_up - tp->rcv_nxt) - 1;
3657 tp->t_oobflags &= ~(TCPOOB_HAVEDATA | TCPOOB_HADDATA);
3678 if (SEQ_GT(tp->rcv_nxt, tp->rcv_up))
3679 tp->rcv_up = tp->rcv_nxt;
3704 * This process logically involves adjusting tp->rcv_wnd as data
3710 TCPS_HAVERCVDFIN(tp->t_state) == 0) {
3716 * with control block tp. Set thflags to whether reassembly now
3726 if (th->th_seq == tp->rcv_nxt &&
3727 LIST_EMPTY(&tp->t_segq) &&
3728 TCPS_HAVEESTABLISHED(tp->t_state)) {
3729 TCP_INC_VAR(tp->t_unacksegs, nlropkts);
3730 if (DELAY_ACK(tp, th) &&
3731 ((tp->t_flags & TF_ACKNOW) == 0) ) {
3732 if ((tp->t_flags & TF_DELACK) == 0) {
3733 tp->t_flags |= TF_DELACK;
3734 tp->t_timer[TCPT_DELACK] = OFFSET_FROM_START(tp, tcp_delack);
3738 tp->t_flags |= TF_ACKNOW;
3740 tp->rcv_nxt += tlen;
3752 ND6_HINT(tp);
3754 tcp_sbrcv_grow(tp, &so->so_rcv, &to, tlen);
3759 thflags = tcp_reass(tp, th, &tlen, m);
3760 tp->t_flags |= TF_ACKNOW;
3763 if (tlen > 0 && tp->sack_enable)
3764 tcp_update_sack_list(tp, save_start, save_end);
3766 if (tp->t_flags & TF_DELACK)
3793 if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
3803 TCP_INC_VAR(tp->t_unacksegs, nlropkts);
3804 if (DELAY_ACK(tp, th) && (tp->t_flags & TF_NEEDSYN)) {
3805 if ((tp->t_flags & TF_DELACK) == 0) {
3806 tp->t_flags |= TF_DELACK;
3807 tp->t_timer[TCPT_DELACK] = OFFSET_FROM_START(tp, tcp_delack);
3811 tp->t_flags |= TF_ACKNOW;
3813 tp->rcv_nxt++;
3815 switch (tp->t_state) {
3822 tp->t_starttime = tcp_now;
3825 struct tcpcb *, tp, int32_t, TCPS_CLOSE_WAIT);
3826 tp->t_state = TCPS_CLOSE_WAIT;
3835 struct tcpcb *, tp, int32_t, TCPS_CLOSING);
3836 tp->t_state = TCPS_CLOSING;
3846 struct tcpcb *, tp, int32_t, TCPS_TIME_WAIT);
3847 tp->t_state = TCPS_TIME_WAIT;
3848 tcp_canceltimers(tp);
3850 if (tp->cc_recv != 0 &&
3851 ((int)(tcp_now - tp->t_starttime)) < tcp_msl) {
3852 add_to_time_wait(tp, tp->t_rxtcur * TCPTV_TWTRUNC);
3854 tp->t_flags |= TF_ACKNOW;
3855 tp->t_unacksegs = 0;
3858 add_to_time_wait(tp, 2 * tcp_msl);
3866 add_to_time_wait(tp, 2 * tcp_msl);
3872 tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
3879 if (needoutput || (tp->t_flags & TF_ACKNOW)) {
3880 (void) tcp_output(tp);
3883 tcp_check_timer_state(tp);
3906 if (tp->t_state == TCPS_SYN_RECEIVED && (thflags & TH_ACK) &&
3907 (SEQ_GT(tp->snd_una, th->th_ack) ||
3908 SEQ_GT(th->th_ack, tp->snd_max)) ) {
3918 tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
3922 tp->t_flags |= TF_ACKNOW;
3923 (void) tcp_output(tp);
3962 if (tp == 0 || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
3963 tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
3968 tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, th->th_ack,
3974 tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen,
3994 if (tp == 0 || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
3995 tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
4012 tcp_dooptions(tp, cp, cnt, th, to, input_ifscope)
4016 struct tcpcb *tp;
4062 tp->t_flags |= TF_RCVD_SCALE;
4063 tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
4089 tp->t_flags |= TF_RCVD_TSTMP;
4090 tp->ts_recent = to->to_tsval;
4091 tp->ts_recent_age = tcp_now;
4112 tcp_mss(tp, mss, input_ifscope); /* sets t_maxseg */
4133 struct tcpcb *tp = sototcpcb(so);
4135 tp->t_iobc = *cp;
4136 tp->t_oobflags |= TCPOOB_HAVEDATA;
4152 get_base_rtt(struct tcpcb *tp)
4156 if (tp->rtt_hist[i] != 0 &&
4157 (base_rtt == 0 || tp->rtt_hist[i] < base_rtt))
4158 base_rtt = tp->rtt_hist[i];
4167 update_base_rtt(struct tcpcb *tp, uint32_t rtt)
4169 if (++tp->rtt_count >= rtt_samples_per_slot) {
4172 tp->rtt_hist[i] = tp->rtt_hist[i-1];
4174 tp->rtt_hist[0] = rtt;
4175 tp->rtt_count = 0;
4177 tp->rtt_hist[0] = min(tp->rtt_hist[0], rtt);
4186 tcp_xmit_timer(tp, rtt)
4187 register struct tcpcb *tp;
4193 tp->t_rttupdated++;
4196 tp->t_rttcur = rtt;
4197 update_base_rtt(tp, rtt);
4200 if (tp->t_srtt != 0) {
4214 - (tp->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT));
4216 if ((tp->t_srtt += delta) <= 0)
4217 tp->t_srtt = 1;
4231 delta -= tp->t_rttvar >> (TCP_RTTVAR_SHIFT - TCP_DELTA_SHIFT);
4232 if ((tp->t_rttvar += delta) <= 0)
4233 tp->t_rttvar = 1;
4234 if (tp->t_rttbest == 0 ||
4235 tp->t_rttbest > (tp->t_srtt + tp->t_rttvar))
4236 tp->t_rttbest = tp->t_srtt + tp->t_rttvar;
4243 tp->t_srtt = rtt << TCP_RTT_SHIFT;
4244 tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1);
4246 nstat_route_rtt(tp->t_inpcb->inp_route.ro_rt, tp->t_srtt, tp->t_rttvar);
4247 tp->t_rtttime = 0;
4248 tp->t_rxtshift = 0;
4249 tp->rxt_start = 0;
4262 TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp),
4263 max(tp->t_rttmin, rtt + 2), TCPTV_REXMTMAX,
4264 TCP_ADD_REXMTSLOP(tp));
4273 tp->t_softerror = 0;
4341 tcp_mss(tp, offer, input_ifscope)
4342 struct tcpcb *tp;
4361 inp = tp->t_inpcb;
4378 tp->t_flags |= TF_LOCAL;
4389 tp->t_flags |= TF_LOCAL;
4392 isnetlocal = (tp->t_flags & TF_LOCAL);
4395 tp->t_maxopd = tp->t_maxseg =
4411 tp->t_flags |= TF_SLOWLINK;
4453 if (tp->t_srtt == 0 && (rtt = rt->rt_rmx.rmx_rtt) != 0) {
4454 tcp_getrt_rtt(tp, rt);
4456 tp->t_rttmin = isnetlocal ? tcp_TCPTV_MIN : TCPTV_REXMTMIN;
4485 tp->t_maxopd = mss;
4491 if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
4493 (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP))
4495 tp->t_maxseg = mss;
4523 tp->t_maxseg = mss;
4546 tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh);
4549 tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
4557 if (CC_ALGO(tp)->cwnd_init != NULL)
4558 CC_ALGO(tp)->cwnd_init(tp);
4560 DTRACE_TCP5(cc, void, NULL, struct inpcb *, tp->t_inpcb, struct tcpcb *, tp,
4571 tcp_mssopt(tp)
4572 struct tcpcb *tp;
4582 isipv6 = ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) ? 1 : 0;
4591 rt = tcp_rtlookup6(tp->t_inpcb, IFSCOPE_NONE);
4594 rt = tcp_rtlookup(tp->t_inpcb, IFSCOPE_NONE);
4610 tp->t_flags |= TF_SLOWLINK;
4625 * next unacknowledged segment. Do not clear tp->t_dupacks.
4630 tcp_newreno_partial_ack(tp, th)
4631 struct tcpcb *tp;
4634 tcp_seq onxt = tp->snd_nxt;
4635 u_int32_t ocwnd = tp->snd_cwnd;
4636 tp->t_timer[TCPT_REXMT] = 0;
4637 tp->t_rtttime = 0;
4638 tp->snd_nxt = th->th_ack;
4641 * (tp->snd_una has not yet been updated when this function
4644 tp->snd_cwnd = tp->t_maxseg + (th->th_ack - tp->snd_una);
4645 tp->t_flags |= TF_ACKNOW;
4646 (void) tcp_output(tp);
4647 tp->snd_cwnd = ocwnd;
4648 if (SEQ_GT(onxt, tp->snd_nxt))
4649 tp->snd_nxt = onxt;
4651 * Partial window deflation. Relies on fact that tp->snd_una
4654 if (tp->snd_cwnd > th->th_ack - tp->snd_una)
4655 tp->snd_cwnd -= th->th_ack - tp->snd_una;
4657 tp->snd_cwnd = 0;
4658 tp->snd_cwnd += tp->t_maxseg;
4681 struct tcpcb *tp;
4759 tp = sototcpcb(so);
4763 tcp_close(tp);
4764 tp->t_unacksegs = 0;
4830 struct tcpcb *tp = intotcpcb(inp);
4832 if (tp->tcp_cc_index != cc_index) {
4834 old_cc_index = tp->tcp_cc_index;
4836 if (CC_ALGO(tp)->cleanup != NULL)
4837 CC_ALGO(tp)->cleanup(tp);
4838 tp->tcp_cc_index = cc_index;
4843 if (tp->snd_nxt > tp->iss) {
4845 if (CC_ALGO(tp)->switch_to != NULL)
4846 CC_ALGO(tp)->switch_to(tp, old_cc_index);
4848 if (CC_ALGO(tp)->init != NULL)
4849 CC_ALGO(tp)->init(tp);
4852 struct tcpcb *, tp, struct tcphdr *, NULL,
4874 struct tcpcb *tp = inp->inp_ppcb;
4879 if (CC_ALGO(tp)->pre_fr != NULL)
4880 CC_ALGO(tp)->pre_fr(tp);
4882 tp->snd_cwnd = tp->snd_ssthresh;
4888 tp->t_bytes_acked = 0;
4895 tp->t_rxtshift = 0;
4902 tcp_output(tp);