Lines Matching refs:tp
279 hhook_run_tcp_est_in(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to) in hhook_run_tcp_est_in() argument
284 hhook_data.tp = tp; in hhook_run_tcp_est_in()
289 tp->osd); in hhook_run_tcp_est_in()
298 cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, in cc_ack_received() argument
301 INP_WLOCK_ASSERT(tp->t_inpcb); in cc_ack_received()
303 tp->ccv->nsegs = nsegs; in cc_ack_received()
304 tp->ccv->bytes_this_ack = BYTES_THIS_ACK(tp, th); in cc_ack_received()
305 if (tp->snd_cwnd <= tp->snd_wnd) in cc_ack_received()
306 tp->ccv->flags |= CCF_CWND_LIMITED; in cc_ack_received()
308 tp->ccv->flags &= ~CCF_CWND_LIMITED; in cc_ack_received()
311 if (tp->snd_cwnd > tp->snd_ssthresh) { in cc_ack_received()
312 tp->t_bytes_acked += min(tp->ccv->bytes_this_ack, in cc_ack_received()
313 nsegs * V_tcp_abc_l_var * tcp_maxseg(tp)); in cc_ack_received()
314 if (tp->t_bytes_acked >= tp->snd_cwnd) { in cc_ack_received()
315 tp->t_bytes_acked -= tp->snd_cwnd; in cc_ack_received()
316 tp->ccv->flags |= CCF_ABC_SENTAWND; in cc_ack_received()
319 tp->ccv->flags &= ~CCF_ABC_SENTAWND; in cc_ack_received()
320 tp->t_bytes_acked = 0; in cc_ack_received()
324 if (CC_ALGO(tp)->ack_received != NULL) { in cc_ack_received()
326 tp->ccv->curack = th->th_ack; in cc_ack_received()
327 CC_ALGO(tp)->ack_received(tp->ccv, type); in cc_ack_received()
332 cc_conn_init(struct tcpcb *tp) in cc_conn_init() argument
335 struct inpcb *inp = tp->t_inpcb; in cc_conn_init()
339 INP_WLOCK_ASSERT(tp->t_inpcb); in cc_conn_init()
342 maxseg = tcp_maxseg(tp); in cc_conn_init()
344 if (tp->t_srtt == 0 && (rtt = metrics.rmx_rtt)) { in cc_conn_init()
345 tp->t_srtt = rtt; in cc_conn_init()
346 tp->t_rttbest = tp->t_srtt + TCP_RTT_SCALE; in cc_conn_init()
349 tp->t_rttvar = metrics.rmx_rttvar; in cc_conn_init()
353 tp->t_rttvar = in cc_conn_init()
354 tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE; in cc_conn_init()
356 TCPT_RANGESET(tp->t_rxtcur, in cc_conn_init()
357 ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1, in cc_conn_init()
358 tp->t_rttmin, TCPTV_REXMTMAX); in cc_conn_init()
367 tp->snd_ssthresh = max(2 * maxseg, metrics.rmx_ssthresh); in cc_conn_init()
383 if (tp->snd_cwnd == 1) in cc_conn_init()
384 tp->snd_cwnd = maxseg; /* SYN(-ACK) lost */ in cc_conn_init()
386 tp->snd_cwnd = min(V_tcp_initcwnd_segments * maxseg, in cc_conn_init()
389 tp->snd_cwnd = min(4 * maxseg, max(2 * maxseg, 4380)); in cc_conn_init()
393 tp->snd_cwnd = 2 * maxseg; in cc_conn_init()
395 tp->snd_cwnd = 3 * maxseg; in cc_conn_init()
397 tp->snd_cwnd = 4 * maxseg; in cc_conn_init()
400 if (CC_ALGO(tp)->conn_init != NULL) in cc_conn_init()
401 CC_ALGO(tp)->conn_init(tp->ccv); in cc_conn_init()
405 cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) in cc_cong_signal() argument
409 INP_WLOCK_ASSERT(tp->t_inpcb); in cc_cong_signal()
413 if (!IN_FASTRECOVERY(tp->t_flags)) { in cc_cong_signal()
414 tp->snd_recover = tp->snd_max; in cc_cong_signal()
415 if (tp->t_flags & TF_ECN_PERMIT) in cc_cong_signal()
416 tp->t_flags |= TF_ECN_SND_CWR; in cc_cong_signal()
420 if (!IN_CONGRECOVERY(tp->t_flags)) { in cc_cong_signal()
422 tp->snd_recover = tp->snd_max; in cc_cong_signal()
423 if (tp->t_flags & TF_ECN_PERMIT) in cc_cong_signal()
424 tp->t_flags |= TF_ECN_SND_CWR; in cc_cong_signal()
428 maxseg = tcp_maxseg(tp); in cc_cong_signal()
429 tp->t_dupacks = 0; in cc_cong_signal()
430 tp->t_bytes_acked = 0; in cc_cong_signal()
431 EXIT_RECOVERY(tp->t_flags); in cc_cong_signal()
432 tp->snd_ssthresh = max(2, min(tp->snd_wnd, tp->snd_cwnd) / 2 / in cc_cong_signal()
434 tp->snd_cwnd = maxseg; in cc_cong_signal()
439 tp->snd_cwnd = tp->snd_cwnd_prev; in cc_cong_signal()
440 tp->snd_ssthresh = tp->snd_ssthresh_prev; in cc_cong_signal()
441 tp->snd_recover = tp->snd_recover_prev; in cc_cong_signal()
442 if (tp->t_flags & TF_WASFRECOVERY) in cc_cong_signal()
443 ENTER_FASTRECOVERY(tp->t_flags); in cc_cong_signal()
444 if (tp->t_flags & TF_WASCRECOVERY) in cc_cong_signal()
445 ENTER_CONGRECOVERY(tp->t_flags); in cc_cong_signal()
446 tp->snd_nxt = tp->snd_max; in cc_cong_signal()
447 tp->t_flags &= ~TF_PREVVALID; in cc_cong_signal()
448 tp->t_badrxtwin = 0; in cc_cong_signal()
452 if (CC_ALGO(tp)->cong_signal != NULL) { in cc_cong_signal()
454 tp->ccv->curack = th->th_ack; in cc_cong_signal()
455 CC_ALGO(tp)->cong_signal(tp->ccv, type); in cc_cong_signal()
460 cc_post_recovery(struct tcpcb *tp, struct tcphdr *th) in cc_post_recovery() argument
462 INP_WLOCK_ASSERT(tp->t_inpcb); in cc_post_recovery()
466 if (CC_ALGO(tp)->post_recovery != NULL) { in cc_post_recovery()
467 tp->ccv->curack = th->th_ack; in cc_post_recovery()
468 CC_ALGO(tp)->post_recovery(tp->ccv); in cc_post_recovery()
471 tp->t_bytes_acked = 0; in cc_post_recovery()
483 #define DELAY_ACK(tp, tlen) \ argument
484 ((!tcp_timer_active(tp, TT_DELACK) && \
485 (tp->t_flags & TF_RXWIN0SENT) == 0) && \
486 (tlen <= tp->t_maxseg) && \
487 (V_tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN)))
490 cc_ecnpkt_handler(struct tcpcb *tp, struct tcphdr *th, uint8_t iptos) in cc_ecnpkt_handler() argument
492 INP_WLOCK_ASSERT(tp->t_inpcb); in cc_ecnpkt_handler()
494 if (CC_ALGO(tp)->ecnpkt_handler != NULL) { in cc_ecnpkt_handler()
497 tp->ccv->flags |= CCF_IPHDR_CE; in cc_ecnpkt_handler()
500 tp->ccv->flags &= ~CCF_IPHDR_CE; in cc_ecnpkt_handler()
503 tp->ccv->flags &= ~CCF_IPHDR_CE; in cc_ecnpkt_handler()
508 tp->ccv->flags |= CCF_TCPHDR_CWR; in cc_ecnpkt_handler()
510 tp->ccv->flags &= ~CCF_TCPHDR_CWR; in cc_ecnpkt_handler()
512 if (tp->t_flags & TF_DELACK) in cc_ecnpkt_handler()
513 tp->ccv->flags |= CCF_DELACK; in cc_ecnpkt_handler()
515 tp->ccv->flags &= ~CCF_DELACK; in cc_ecnpkt_handler()
517 CC_ALGO(tp)->ecnpkt_handler(tp->ccv); in cc_ecnpkt_handler()
519 if (tp->ccv->flags & CCF_ACKNOW) in cc_ecnpkt_handler()
520 tcp_timer_activate(tp, TT_DELACK, tcp_delacktime); in cc_ecnpkt_handler()
572 struct tcpcb *tp = NULL; in tcp_input() local
989 tp = intotcpcb(inp); in tcp_input()
990 if (tp == NULL || tp->t_state == TCPS_CLOSED) { in tcp_input()
996 if (tp->t_flags & TF_TOE) { in tcp_input()
997 tcp_offload_input(tp, m); in tcp_input()
1014 if (!((tp->t_state == TCPS_ESTABLISHED && (thflags & TH_SYN) == 0) || in tcp_input()
1015 (tp->t_state == TCPS_LISTEN && (thflags & TH_SYN) && in tcp_input()
1016 !IS_FASTOPEN(tp->t_flags)))) { in tcp_input()
1033 ostate = tp->t_state; in tcp_input()
1048 KASSERT(tp->t_state == TCPS_LISTEN || !(so->so_options & SO_ACCEPTCONN), in tcp_input()
1049 ("%s: so accepting but tp %p not listening", __func__, tp)); in tcp_input()
1050 if (tp->t_state == TCPS_LISTEN && (so->so_options & SO_ACCEPTCONN)) { in tcp_input()
1145 tp = intotcpcb(inp); in tcp_input()
1146 KASSERT(tp->t_state == TCPS_SYN_RECEIVED, in tcp_input()
1153 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input()
1154 tp->t_fb->tfb_tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, in tcp_input()
1348 tcp_trace(TA_INPUT, ostate, tp, in tcp_input()
1351 TCP_PROBE3(debug__input, tp, th, m); in tcp_input()
1366 } else if (tp->t_state == TCPS_LISTEN) { in tcp_input()
1377 if (tp->t_flags & TF_SIGNATURE) { in tcp_input()
1388 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input()
1395 tp->t_fb->tfb_tcp_do_segment(m, th, so, tp, drop_hdrlen, tlen, iptos); in tcp_input()
1401 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input()
1416 tcp_dropwithreset(m, th, tp, tlen, rstreason); in tcp_input()
1425 TCP_PROBE5(receive, NULL, tp, m, tp, th); in tcp_input()
1488 struct tcpcb *tp, int tlen) in tcp_autorcvbuf() argument
1493 tp->t_srtt != 0 && tp->rfbuf_ts != 0 && in tcp_autorcvbuf()
1494 TCP_TS_TO_TICKS(tcp_ts_getticks() - tp->rfbuf_ts) > in tcp_autorcvbuf()
1495 (tp->t_srtt >> TCP_RTT_SHIFT)) { in tcp_autorcvbuf()
1496 if (tp->rfbuf_cnt > (so->so_rcv.sb_hiwat / 8 * 7) && in tcp_autorcvbuf()
1501 TCP_PROBE6(receive__autoresize, NULL, tp, m, tp, th, newsize); in tcp_autorcvbuf()
1504 tp->rfbuf_ts = 0; in tcp_autorcvbuf()
1505 tp->rfbuf_cnt = 0; in tcp_autorcvbuf()
1507 tp->rfbuf_cnt += tlen; /* add up */ in tcp_autorcvbuf()
1514 struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos) in tcp_do_segment() argument
1536 inc = &tp->t_inpcb->inp_inc; in tcp_do_segment()
1537 tp->sackhint.last_sack_ack = 0; in tcp_do_segment()
1547 tp->t_state != TCPS_ESTABLISHED) { in tcp_do_segment()
1550 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_do_segment()
1551 KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN", in tcp_do_segment()
1553 KASSERT(tp->t_state != TCPS_TIME_WAIT, ("%s: TCPS_TIME_WAIT", in tcp_do_segment()
1558 tcp_pcap_add(th, m, &(tp->t_inpkts)); in tcp_do_segment()
1560 TCP_LOG_EVENT(tp, th, &so->so_rcv, &so->so_snd, TCP_LOG_IN, 0, in tcp_do_segment()
1577 if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) && in tcp_do_segment()
1578 (SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { in tcp_do_segment()
1589 tp->t_rcvtime = ticks; in tcp_do_segment()
1595 tiwin = th->th_win << tp->snd_scale; in tcp_do_segment()
1600 if (tp->t_flags & TF_ECN_PERMIT) { in tcp_do_segment()
1602 tp->t_flags &= ~TF_ECN_SND_ECE; in tcp_do_segment()
1605 tp->t_flags |= TF_ECN_SND_ECE; in tcp_do_segment()
1617 cc_ecnpkt_handler(tp, th, iptos); in tcp_do_segment()
1621 cc_cong_signal(tp, th, CC_ECN); in tcp_do_segment()
1633 if ((tp->t_flags & TF_SIGNATURE) != 0 && in tcp_do_segment()
1646 to.to_tsecr -= tp->ts_offset; in tcp_do_segment()
1649 else if (tp->t_flags & TF_PREVVALID && in tcp_do_segment()
1650 tp->t_badrxtwin != 0 && SEQ_LT(to.to_tsecr, tp->t_badrxtwin)) in tcp_do_segment()
1651 cc_cong_signal(tp, th, CC_RTO_ERR); in tcp_do_segment()
1660 if (tp->t_state == TCPS_SYN_SENT && (thflags & TH_SYN)) { in tcp_do_segment()
1662 (tp->t_flags & TF_REQ_SCALE)) { in tcp_do_segment()
1663 tp->t_flags |= TF_RCVD_SCALE; in tcp_do_segment()
1664 tp->snd_scale = to.to_wscale; in tcp_do_segment()
1670 tp->snd_wnd = th->th_win; in tcp_do_segment()
1672 tp->t_flags |= TF_RCVD_TSTMP; in tcp_do_segment()
1673 tp->ts_recent = to.to_tsval; in tcp_do_segment()
1674 tp->ts_recent_age = tcp_ts_getticks(); in tcp_do_segment()
1677 tcp_mss(tp, to.to_mss); in tcp_do_segment()
1678 if ((tp->t_flags & TF_SACK_PERMIT) && in tcp_do_segment()
1680 tp->t_flags &= ~TF_SACK_PERMIT; in tcp_do_segment()
1681 if (IS_FASTOPEN(tp->t_flags)) { in tcp_do_segment()
1688 if ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) in tcp_do_segment()
1692 tcp_fastopen_update_cache(tp, mss, in tcp_do_segment()
1695 tcp_fastopen_disable_path(tp); in tcp_do_segment()
1703 if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS)) { in tcp_do_segment()
1710 if (!(tp->t_flags & TF_RCVD_TSTMP) && (to.to_flags & TOF_TS)) { in tcp_do_segment()
1735 if (tp->t_state == TCPS_ESTABLISHED && in tcp_do_segment()
1736 th->th_seq == tp->rcv_nxt && in tcp_do_segment()
1738 tp->snd_nxt == tp->snd_max && in tcp_do_segment()
1739 tiwin && tiwin == tp->snd_wnd && in tcp_do_segment()
1740 ((tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN)) == 0) && in tcp_do_segment()
1741 SEGQ_EMPTY(tp) && in tcp_do_segment()
1743 TSTMP_GEQ(to.to_tsval, tp->ts_recent)) ) { in tcp_do_segment()
1752 SEQ_LEQ(th->th_seq, tp->last_ack_sent)) { in tcp_do_segment()
1753 tp->ts_recent_age = tcp_ts_getticks(); in tcp_do_segment()
1754 tp->ts_recent = to.to_tsval; in tcp_do_segment()
1758 if (SEQ_GT(th->th_ack, tp->snd_una) && in tcp_do_segment()
1759 SEQ_LEQ(th->th_ack, tp->snd_max) && in tcp_do_segment()
1760 !IN_RECOVERY(tp->t_flags) && in tcp_do_segment()
1762 TAILQ_EMPTY(&tp->snd_holes)) { in tcp_do_segment()
1772 tp->t_rxtshift == 1 && in tcp_do_segment()
1773 tp->t_flags & TF_PREVVALID && in tcp_do_segment()
1774 (int)(ticks - tp->t_badrxtwin) < 0) { in tcp_do_segment()
1775 cc_cong_signal(tp, th, CC_RTO_ERR); in tcp_do_segment()
1791 if (!tp->t_rttlow || tp->t_rttlow > t) in tcp_do_segment()
1792 tp->t_rttlow = t; in tcp_do_segment()
1793 tcp_xmit_timer(tp, in tcp_do_segment()
1795 } else if (tp->t_rtttime && in tcp_do_segment()
1796 SEQ_GT(th->th_ack, tp->t_rtseq)) { in tcp_do_segment()
1797 if (!tp->t_rttlow || in tcp_do_segment()
1798 tp->t_rttlow > ticks - tp->t_rtttime) in tcp_do_segment()
1799 tp->t_rttlow = ticks - tp->t_rtttime; in tcp_do_segment()
1800 tcp_xmit_timer(tp, in tcp_do_segment()
1801 ticks - tp->t_rtttime); in tcp_do_segment()
1803 acked = BYTES_THIS_ACK(tp, th); in tcp_do_segment()
1807 hhook_run_tcp_est_in(tp, th, &to); in tcp_do_segment()
1813 if (SEQ_GT(tp->snd_una, tp->snd_recover) && in tcp_do_segment()
1814 SEQ_LEQ(th->th_ack, tp->snd_recover)) in tcp_do_segment()
1815 tp->snd_recover = th->th_ack - 1; in tcp_do_segment()
1823 cc_ack_received(tp, th, nsegs, CC_ACK); in tcp_do_segment()
1825 tp->snd_una = th->th_ack; in tcp_do_segment()
1830 tp->snd_wl2 = th->th_ack; in tcp_do_segment()
1831 tp->t_dupacks = 0; in tcp_do_segment()
1845 tcp_trace(TA_INPUT, ostate, tp, in tcp_do_segment()
1849 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
1850 if (tp->snd_una == tp->snd_max) in tcp_do_segment()
1851 tcp_timer_activate(tp, TT_REXMT, 0); in tcp_do_segment()
1852 else if (!tcp_timer_active(tp, TT_PERSIST)) in tcp_do_segment()
1853 tcp_timer_activate(tp, TT_REXMT, in tcp_do_segment()
1854 tp->t_rxtcur); in tcp_do_segment()
1857 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
1860 } else if (th->th_ack == tp->snd_una && in tcp_do_segment()
1870 if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks) in tcp_do_segment()
1871 tcp_clean_sackreport(tp); in tcp_do_segment()
1873 tp->rcv_nxt += tlen; in tcp_do_segment()
1878 tp->snd_wl1 = th->th_seq; in tcp_do_segment()
1883 tp->rcv_up = tp->rcv_nxt; in tcp_do_segment()
1888 tcp_trace(TA_INPUT, ostate, tp, in tcp_do_segment()
1891 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
1893 newsize = tcp_autorcvbuf(m, th, so, tp, tlen); in tcp_do_segment()
1913 if (DELAY_ACK(tp, tlen)) { in tcp_do_segment()
1914 tp->t_flags |= TF_DELACK; in tcp_do_segment()
1916 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
1917 tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
1932 tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt)); in tcp_do_segment()
1934 switch (tp->t_state) { in tcp_do_segment()
1942 (SEQ_LEQ(th->th_ack, tp->snd_una) || in tcp_do_segment()
1943 SEQ_GT(th->th_ack, tp->snd_max))) { in tcp_do_segment()
1947 if (IS_FASTOPEN(tp->t_flags)) { in tcp_do_segment()
1960 if ((tcp_timer_active(tp, TT_DELACK) || in tcp_do_segment()
1961 tcp_timer_active(tp, TT_REXMT))) in tcp_do_segment()
1986 TCP_PROBE5(connect__refused, NULL, tp, in tcp_do_segment()
1987 m, tp, th); in tcp_do_segment()
1988 tp = tcp_drop(tp, ECONNREFUSED); in tcp_do_segment()
1995 tp->irs = th->th_seq; in tcp_do_segment()
1996 tcp_rcvseqinit(tp); in tcp_do_segment()
2006 if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) == in tcp_do_segment()
2008 tp->rcv_scale = tp->request_r_scale; in tcp_do_segment()
2010 tp->rcv_adv += min(tp->rcv_wnd, in tcp_do_segment()
2011 TCP_MAXWIN << tp->rcv_scale); in tcp_do_segment()
2012 tp->snd_una++; /* SYN is acked */ in tcp_do_segment()
2017 if (IS_FASTOPEN(tp->t_flags) && in tcp_do_segment()
2018 (tp->snd_una != tp->snd_max)) { in tcp_do_segment()
2019 tp->snd_nxt = th->th_ack; in tcp_do_segment()
2026 if (DELAY_ACK(tp, tlen) && tlen != 0 && !tfo_partial_ack) in tcp_do_segment()
2027 tcp_timer_activate(tp, TT_DELACK, in tcp_do_segment()
2030 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
2034 tp->t_flags |= TF_ECN_PERMIT; in tcp_do_segment()
2044 tp->t_starttime = ticks; in tcp_do_segment()
2045 if (tp->t_flags & TF_NEEDFIN) { in tcp_do_segment()
2046 tcp_state_change(tp, TCPS_FIN_WAIT_1); in tcp_do_segment()
2047 tp->t_flags &= ~TF_NEEDFIN; in tcp_do_segment()
2050 tcp_state_change(tp, TCPS_ESTABLISHED); in tcp_do_segment()
2051 TCP_PROBE5(connect__established, NULL, tp, in tcp_do_segment()
2052 m, tp, th); in tcp_do_segment()
2053 cc_conn_init(tp); in tcp_do_segment()
2054 tcp_timer_activate(tp, TT_KEEP, in tcp_do_segment()
2055 TP_KEEPIDLE(tp)); in tcp_do_segment()
2066 tp->t_flags |= (TF_ACKNOW | TF_NEEDSYN); in tcp_do_segment()
2067 tcp_timer_activate(tp, TT_REXMT, 0); in tcp_do_segment()
2068 tcp_state_change(tp, TCPS_SYN_RECEIVED); in tcp_do_segment()
2072 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_do_segment()
2080 if (tlen > tp->rcv_wnd) { in tcp_do_segment()
2081 todrop = tlen - tp->rcv_wnd; in tcp_do_segment()
2083 tlen = tp->rcv_wnd; in tcp_do_segment()
2088 tp->snd_wl1 = th->th_seq - 1; in tcp_do_segment()
2089 tp->rcv_up = th->th_seq; in tcp_do_segment()
2140 if ((SEQ_GEQ(th->th_seq, tp->last_ack_sent) && in tcp_do_segment()
2141 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) || in tcp_do_segment()
2142 (tp->rcv_wnd == 0 && tp->last_ack_sent == th->th_seq)) { in tcp_do_segment()
2145 KASSERT(tp->t_state != TCPS_SYN_SENT, in tcp_do_segment()
2147 __func__, th, tp)); in tcp_do_segment()
2150 tp->last_ack_sent == th->th_seq) { in tcp_do_segment()
2153 switch (tp->t_state) { in tcp_do_segment()
2167 tp = tcp_close(tp); in tcp_do_segment()
2172 tcp_respond(tp, mtod(m, void *), th, m, in tcp_do_segment()
2173 tp->rcv_nxt, tp->snd_nxt, TH_ACK); in tcp_do_segment()
2174 tp->last_ack_sent = tp->rcv_nxt; in tcp_do_segment()
2185 if ((thflags & TH_SYN) && tp->t_state != TCPS_SYN_SENT && in tcp_do_segment()
2186 tp->t_state != TCPS_SYN_RECEIVED) { in tcp_do_segment()
2191 SEQ_GEQ(th->th_seq, tp->last_ack_sent) && in tcp_do_segment()
2192 SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) { in tcp_do_segment()
2193 tp = tcp_drop(tp, ECONNRESET); in tcp_do_segment()
2197 tcp_respond(tp, mtod(m, void *), th, m, tp->rcv_nxt, in tcp_do_segment()
2198 tp->snd_nxt, TH_ACK); in tcp_do_segment()
2199 tp->last_ack_sent = tp->rcv_nxt; in tcp_do_segment()
2209 if ((to.to_flags & TOF_TS) != 0 && tp->ts_recent && in tcp_do_segment()
2210 TSTMP_LT(to.to_tsval, tp->ts_recent)) { in tcp_do_segment()
2213 if (tcp_ts_getticks() - tp->ts_recent_age > TCP_PAWS_IDLE) { in tcp_do_segment()
2225 tp->ts_recent = 0; in tcp_do_segment()
2243 if (tp->t_state == TCPS_SYN_RECEIVED && SEQ_LT(th->th_seq, tp->irs)) { in tcp_do_segment()
2248 todrop = tp->rcv_nxt - th->th_seq; in tcp_do_segment()
2275 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
2286 if (tp->t_flags & TF_SACK_PERMIT) { in tcp_do_segment()
2287 tcp_update_sack_list(tp, th->th_seq, in tcp_do_segment()
2293 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
2311 tp->t_state > TCPS_CLOSE_WAIT && tlen) { in tcp_do_segment()
2318 s, __func__, tcpstates[tp->t_state], tlen); in tcp_do_segment()
2321 tp = tcp_close(tp); in tcp_do_segment()
2331 todrop = (th->th_seq + tlen) - (tp->rcv_nxt + tp->rcv_wnd); in tcp_do_segment()
2343 if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) { in tcp_do_segment()
2344 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
2374 SEQ_LEQ(th->th_seq, tp->last_ack_sent) && in tcp_do_segment()
2375 SEQ_LEQ(tp->last_ack_sent, th->th_seq + tlen + in tcp_do_segment()
2377 tp->ts_recent_age = tcp_ts_getticks(); in tcp_do_segment()
2378 tp->ts_recent = to.to_tsval; in tcp_do_segment()
2387 if (tp->t_state == TCPS_SYN_RECEIVED || in tcp_do_segment()
2388 (tp->t_flags & TF_NEEDSYN)) { in tcp_do_segment()
2389 if (tp->t_state == TCPS_SYN_RECEIVED && in tcp_do_segment()
2390 IS_FASTOPEN(tp->t_flags)) { in tcp_do_segment()
2391 tp->snd_wnd = tiwin; in tcp_do_segment()
2392 cc_conn_init(tp); in tcp_do_segment()
2395 } else if (tp->t_flags & TF_ACKNOW) in tcp_do_segment()
2404 switch (tp->t_state) { in tcp_do_segment()
2416 if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) == in tcp_do_segment()
2418 tp->rcv_scale = tp->request_r_scale; in tcp_do_segment()
2420 tp->snd_wnd = tiwin; in tcp_do_segment()
2426 tp->t_starttime = ticks; in tcp_do_segment()
2427 if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { in tcp_do_segment()
2428 tcp_fastopen_decrement_counter(tp->t_tfo_pending); in tcp_do_segment()
2429 tp->t_tfo_pending = NULL; in tcp_do_segment()
2435 tp->snd_una++; in tcp_do_segment()
2437 if (tp->t_flags & TF_NEEDFIN) { in tcp_do_segment()
2438 tcp_state_change(tp, TCPS_FIN_WAIT_1); in tcp_do_segment()
2439 tp->t_flags &= ~TF_NEEDFIN; in tcp_do_segment()
2441 tcp_state_change(tp, TCPS_ESTABLISHED); in tcp_do_segment()
2442 TCP_PROBE5(accept__established, NULL, tp, in tcp_do_segment()
2443 m, tp, th); in tcp_do_segment()
2451 if (!IS_FASTOPEN(tp->t_flags)) in tcp_do_segment()
2452 cc_conn_init(tp); in tcp_do_segment()
2453 tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); in tcp_do_segment()
2460 (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, in tcp_do_segment()
2462 tp->snd_wl1 = th->th_seq - 1; in tcp_do_segment()
2479 if (SEQ_GT(th->th_ack, tp->snd_max)) { in tcp_do_segment()
2483 if ((tp->t_flags & TF_SACK_PERMIT) && in tcp_do_segment()
2485 !TAILQ_EMPTY(&tp->snd_holes))) in tcp_do_segment()
2486 sack_changed = tcp_sack_doack(tp, &to, th->th_ack); in tcp_do_segment()
2492 tp->sackhint.sacked_bytes = 0; in tcp_do_segment()
2496 hhook_run_tcp_est_in(tp, th, &to); in tcp_do_segment()
2499 if (SEQ_LEQ(th->th_ack, tp->snd_una)) { in tcp_do_segment()
2502 maxseg = tcp_maxseg(tp); in tcp_do_segment()
2504 (tiwin == tp->snd_wnd || in tcp_do_segment()
2505 (tp->t_flags & TF_SACK_PERMIT))) { in tcp_do_segment()
2514 (TCPS_HAVERCVDFIN(tp->t_state) == 0)) { in tcp_do_segment()
2515 tp->t_dupacks = 0; in tcp_do_segment()
2556 if (th->th_ack != tp->snd_una || in tcp_do_segment()
2557 ((tp->t_flags & TF_SACK_PERMIT) && in tcp_do_segment()
2560 else if (!tcp_timer_active(tp, TT_REXMT)) in tcp_do_segment()
2561 tp->t_dupacks = 0; in tcp_do_segment()
2562 else if (++tp->t_dupacks > tcprexmtthresh || in tcp_do_segment()
2563 IN_FASTRECOVERY(tp->t_flags)) { in tcp_do_segment()
2564 cc_ack_received(tp, th, nsegs, in tcp_do_segment()
2566 if ((tp->t_flags & TF_SACK_PERMIT) && in tcp_do_segment()
2567 IN_FASTRECOVERY(tp->t_flags)) { in tcp_do_segment()
2577 awnd = tcp_compute_pipe(tp); in tcp_do_segment()
2579 awnd = (tp->snd_nxt - tp->snd_fack) + in tcp_do_segment()
2580 tp->sackhint.sack_bytes_rexmit; in tcp_do_segment()
2582 if (awnd < tp->snd_ssthresh) { in tcp_do_segment()
2583 tp->snd_cwnd += maxseg; in tcp_do_segment()
2584 if (tp->snd_cwnd > tp->snd_ssthresh) in tcp_do_segment()
2585 tp->snd_cwnd = tp->snd_ssthresh; in tcp_do_segment()
2588 tp->snd_cwnd += maxseg; in tcp_do_segment()
2589 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
2591 } else if (tp->t_dupacks == tcprexmtthresh) { in tcp_do_segment()
2592 tcp_seq onxt = tp->snd_nxt; in tcp_do_segment()
2601 if (tp->t_flags & TF_SACK_PERMIT) { in tcp_do_segment()
2602 if (IN_FASTRECOVERY(tp->t_flags)) { in tcp_do_segment()
2603 tp->t_dupacks = 0; in tcp_do_segment()
2608 tp->snd_recover)) { in tcp_do_segment()
2609 tp->t_dupacks = 0; in tcp_do_segment()
2614 cc_cong_signal(tp, th, CC_NDUPACK); in tcp_do_segment()
2615 cc_ack_received(tp, th, nsegs, in tcp_do_segment()
2617 tcp_timer_activate(tp, TT_REXMT, 0); in tcp_do_segment()
2618 tp->t_rtttime = 0; in tcp_do_segment()
2619 if (tp->t_flags & TF_SACK_PERMIT) { in tcp_do_segment()
2622 tp->sack_newdata = tp->snd_nxt; in tcp_do_segment()
2623 tp->snd_cwnd = maxseg; in tcp_do_segment()
2624 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
2627 tp->snd_nxt = th->th_ack; in tcp_do_segment()
2628 tp->snd_cwnd = maxseg; in tcp_do_segment()
2629 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
2630 KASSERT(tp->snd_limited <= 2, in tcp_do_segment()
2633 tp->snd_cwnd = tp->snd_ssthresh + in tcp_do_segment()
2635 (tp->t_dupacks - tp->snd_limited); in tcp_do_segment()
2636 if (SEQ_GT(onxt, tp->snd_nxt)) in tcp_do_segment()
2637 tp->snd_nxt = onxt; in tcp_do_segment()
2650 cc_ack_received(tp, th, nsegs, in tcp_do_segment()
2652 uint32_t oldcwnd = tp->snd_cwnd; in tcp_do_segment()
2653 tcp_seq oldsndmax = tp->snd_max; in tcp_do_segment()
2657 KASSERT(tp->t_dupacks == 1 || in tcp_do_segment()
2658 tp->t_dupacks == 2, in tcp_do_segment()
2661 if (tp->t_dupacks == 1) in tcp_do_segment()
2662 tp->snd_limited = 0; in tcp_do_segment()
2663 tp->snd_cwnd = in tcp_do_segment()
2664 (tp->snd_nxt - tp->snd_una) + in tcp_do_segment()
2665 (tp->t_dupacks - tp->snd_limited) * in tcp_do_segment()
2674 (tp->snd_nxt - tp->snd_una); in tcp_do_segment()
2677 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
2678 sent = tp->snd_max - oldsndmax; in tcp_do_segment()
2680 KASSERT((tp->t_dupacks == 2 && in tcp_do_segment()
2681 tp->snd_limited == 0) || in tcp_do_segment()
2683 tp->t_flags & TF_SENTFIN), in tcp_do_segment()
2686 tp->snd_limited = 2; in tcp_do_segment()
2688 ++tp->snd_limited; in tcp_do_segment()
2689 tp->snd_cwnd = oldcwnd; in tcp_do_segment()
2699 tp->t_dupacks = 0; in tcp_do_segment()
2704 if ((tp->t_flags & TF_SACK_PERMIT) && sack_changed) in tcp_do_segment()
2705 tp->t_dupacks++; in tcp_do_segment()
2708 KASSERT(SEQ_GT(th->th_ack, tp->snd_una), in tcp_do_segment()
2715 if (IN_FASTRECOVERY(tp->t_flags)) { in tcp_do_segment()
2716 if (SEQ_LT(th->th_ack, tp->snd_recover)) { in tcp_do_segment()
2717 if (tp->t_flags & TF_SACK_PERMIT) in tcp_do_segment()
2718 tcp_sack_partialack(tp, th); in tcp_do_segment()
2720 tcp_newreno_partial_ack(tp, th); in tcp_do_segment()
2722 cc_post_recovery(tp, th); in tcp_do_segment()
2728 if (tp->t_flags & TF_NEEDSYN) { in tcp_do_segment()
2736 tp->t_flags &= ~TF_NEEDSYN; in tcp_do_segment()
2737 tp->snd_una++; in tcp_do_segment()
2739 if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) == in tcp_do_segment()
2741 tp->rcv_scale = tp->request_r_scale; in tcp_do_segment()
2747 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_do_segment()
2749 acked = BYTES_THIS_ACK(tp, th); in tcp_do_segment()
2752 tp->snd_una, th->th_ack, tp, m)); in tcp_do_segment()
2763 if (tp->t_rxtshift == 1 && in tcp_do_segment()
2764 tp->t_flags & TF_PREVVALID && in tcp_do_segment()
2765 tp->t_badrxtwin && in tcp_do_segment()
2766 SEQ_LT(to.to_tsecr, tp->t_badrxtwin)) in tcp_do_segment()
2767 cc_cong_signal(tp, th, CC_RTO_ERR); in tcp_do_segment()
2787 if (!tp->t_rttlow || tp->t_rttlow > t) in tcp_do_segment()
2788 tp->t_rttlow = t; in tcp_do_segment()
2789 tcp_xmit_timer(tp, TCP_TS_TO_TICKS(t) + 1); in tcp_do_segment()
2790 } else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq)) { in tcp_do_segment()
2791 if (!tp->t_rttlow || tp->t_rttlow > ticks - tp->t_rtttime) in tcp_do_segment()
2792 tp->t_rttlow = ticks - tp->t_rtttime; in tcp_do_segment()
2793 tcp_xmit_timer(tp, ticks - tp->t_rtttime); in tcp_do_segment()
2802 if (th->th_ack == tp->snd_max) { in tcp_do_segment()
2803 tcp_timer_activate(tp, TT_REXMT, 0); in tcp_do_segment()
2805 } else if (!tcp_timer_active(tp, TT_PERSIST)) in tcp_do_segment()
2806 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur); in tcp_do_segment()
2820 cc_ack_received(tp, th, nsegs, CC_ACK); in tcp_do_segment()
2824 if (tp->snd_wnd >= sbavail(&so->so_snd)) in tcp_do_segment()
2825 tp->snd_wnd -= sbavail(&so->so_snd); in tcp_do_segment()
2827 tp->snd_wnd = 0; in tcp_do_segment()
2833 if (tp->snd_wnd >= (uint32_t) acked) in tcp_do_segment()
2834 tp->snd_wnd -= acked; in tcp_do_segment()
2836 tp->snd_wnd = 0; in tcp_do_segment()
2843 if (!IN_RECOVERY(tp->t_flags) && in tcp_do_segment()
2844 SEQ_GT(tp->snd_una, tp->snd_recover) && in tcp_do_segment()
2845 SEQ_LEQ(th->th_ack, tp->snd_recover)) in tcp_do_segment()
2846 tp->snd_recover = th->th_ack - 1; in tcp_do_segment()
2848 if (IN_RECOVERY(tp->t_flags) && in tcp_do_segment()
2849 SEQ_GEQ(th->th_ack, tp->snd_recover)) { in tcp_do_segment()
2850 EXIT_RECOVERY(tp->t_flags); in tcp_do_segment()
2852 tp->snd_una = th->th_ack; in tcp_do_segment()
2853 if (tp->t_flags & TF_SACK_PERMIT) { in tcp_do_segment()
2854 if (SEQ_GT(tp->snd_una, tp->snd_recover)) in tcp_do_segment()
2855 tp->snd_recover = tp->snd_una; in tcp_do_segment()
2857 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) in tcp_do_segment()
2858 tp->snd_nxt = tp->snd_una; in tcp_do_segment()
2860 switch (tp->t_state) { in tcp_do_segment()
2882 tcp_timer_activate(tp, TT_2MSL, in tcp_do_segment()
2885 TP_MAXIDLE(tp))); in tcp_do_segment()
2887 tcp_state_change(tp, TCPS_FIN_WAIT_2); in tcp_do_segment()
2900 tcp_twstart(tp); in tcp_do_segment()
2915 tp = tcp_close(tp); in tcp_do_segment()
2923 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_do_segment()
2930 (SEQ_LT(tp->snd_wl1, th->th_seq) || in tcp_do_segment()
2931 (tp->snd_wl1 == th->th_seq && (SEQ_LT(tp->snd_wl2, th->th_ack) || in tcp_do_segment()
2932 (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))) { in tcp_do_segment()
2935 tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd) in tcp_do_segment()
2937 tp->snd_wnd = tiwin; in tcp_do_segment()
2938 tp->snd_wl1 = th->th_seq; in tcp_do_segment()
2939 tp->snd_wl2 = th->th_ack; in tcp_do_segment()
2940 if (tp->snd_wnd > tp->max_sndwnd) in tcp_do_segment()
2941 tp->max_sndwnd = tp->snd_wnd; in tcp_do_segment()
2949 TCPS_HAVERCVDFIN(tp->t_state) == 0) { in tcp_do_segment()
2977 if (SEQ_GT(th->th_seq+th->th_urp, tp->rcv_up)) { in tcp_do_segment()
2978 tp->rcv_up = th->th_seq + th->th_urp; in tcp_do_segment()
2980 (tp->rcv_up - tp->rcv_nxt) - 1; in tcp_do_segment()
2984 tp->t_oobflags &= ~(TCPOOB_HAVEDATA | TCPOOB_HADDATA); in tcp_do_segment()
3004 if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) in tcp_do_segment()
3005 tp->rcv_up = tp->rcv_nxt; in tcp_do_segment()
3008 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_do_segment()
3018 tfo_syn = ((tp->t_state == TCPS_SYN_RECEIVED) && in tcp_do_segment()
3019 IS_FASTOPEN(tp->t_flags)); in tcp_do_segment()
3021 TCPS_HAVERCVDFIN(tp->t_state) == 0) { in tcp_do_segment()
3023 tcp_seq save_rnxt = tp->rcv_nxt; in tcp_do_segment()
3038 if (th->th_seq == tp->rcv_nxt && in tcp_do_segment()
3039 SEGQ_EMPTY(tp) && in tcp_do_segment()
3040 (TCPS_HAVEESTABLISHED(tp->t_state) || in tcp_do_segment()
3042 if (DELAY_ACK(tp, tlen) || tfo_syn) in tcp_do_segment()
3043 tp->t_flags |= TF_DELACK; in tcp_do_segment()
3045 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
3046 tp->rcv_nxt += tlen; in tcp_do_segment()
3065 thflags = tcp_reass(tp, th, &temp, &tlen, m); in tcp_do_segment()
3066 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
3068 if ((tp->t_flags & TF_SACK_PERMIT) && (save_tlen > 0)) { in tcp_do_segment()
3074 tcp_update_sack_list(tp, save_start, in tcp_do_segment()
3076 } else if ((tlen > 0) && SEQ_GT(tp->rcv_nxt, save_rnxt)) { in tcp_do_segment()
3077 if ((tp->rcv_numsacks >= 1) && in tcp_do_segment()
3078 (tp->sackblks[0].end == save_start)) { in tcp_do_segment()
3083 tcp_update_sack_list(tp, in tcp_do_segment()
3084 tp->sackblks[0].start, in tcp_do_segment()
3085 tp->sackblks[0].end); in tcp_do_segment()
3087 tcp_update_dsack_list(tp, save_start, in tcp_do_segment()
3092 tcp_update_dsack_list(tp, save_start, in tcp_do_segment()
3095 tcp_update_dsack_list(tp, save_start, in tcp_do_segment()
3106 if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt)) in tcp_do_segment()
3107 len = so->so_rcv.sb_hiwat - (tp->rcv_adv - tp->rcv_nxt); in tcp_do_segment()
3121 if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { in tcp_do_segment()
3130 if (tp->t_flags & TF_NEEDSYN) in tcp_do_segment()
3131 tp->t_flags |= TF_DELACK; in tcp_do_segment()
3133 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
3134 tp->rcv_nxt++; in tcp_do_segment()
3136 switch (tp->t_state) { in tcp_do_segment()
3143 tp->t_starttime = ticks; in tcp_do_segment()
3146 tcp_state_change(tp, TCPS_CLOSE_WAIT); in tcp_do_segment()
3154 tcp_state_change(tp, TCPS_CLOSING); in tcp_do_segment()
3165 tcp_twstart(tp); in tcp_do_segment()
3171 tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen, in tcp_do_segment()
3174 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
3179 if (needoutput || (tp->t_flags & TF_ACKNOW)) in tcp_do_segment()
3180 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
3183 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_do_segment()
3185 if (tp->t_flags & TF_DELACK) { in tcp_do_segment()
3186 tp->t_flags &= ~TF_DELACK; in tcp_do_segment()
3187 tcp_timer_activate(tp, TT_DELACK, tcp_delacktime); in tcp_do_segment()
3189 INP_WUNLOCK(tp->t_inpcb); in tcp_do_segment()
3208 if (tp->t_state == TCPS_SYN_RECEIVED && (thflags & TH_ACK) && in tcp_do_segment()
3209 (SEQ_GT(tp->snd_una, th->th_ack) || in tcp_do_segment()
3210 SEQ_GT(th->th_ack, tp->snd_max)) ) { in tcp_do_segment()
3216 tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen, in tcp_do_segment()
3219 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
3220 tp->t_flags |= TF_ACKNOW; in tcp_do_segment()
3221 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_do_segment()
3222 INP_WUNLOCK(tp->t_inpcb); in tcp_do_segment()
3227 if (tp != NULL) { in tcp_do_segment()
3228 tcp_dropwithreset(m, th, tp, tlen, rstreason); in tcp_do_segment()
3229 INP_WUNLOCK(tp->t_inpcb); in tcp_do_segment()
3239 if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) in tcp_do_segment()
3240 tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen, in tcp_do_segment()
3243 TCP_PROBE3(debug__input, tp, th, m); in tcp_do_segment()
3244 if (tp != NULL) in tcp_do_segment()
3245 INP_WUNLOCK(tp->t_inpcb); in tcp_do_segment()
3255 tcp_dropwithreset(struct mbuf *m, struct tcphdr *th, struct tcpcb *tp, in tcp_dropwithreset() argument
3265 if (tp != NULL) { in tcp_dropwithreset()
3266 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_dropwithreset()
3301 tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, in tcp_dropwithreset()
3308 tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen, in tcp_dropwithreset()
3436 struct tcpcb *tp = sototcpcb(so); in tcp_pulloutofband() local
3438 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_pulloutofband()
3440 tp->t_iobc = *cp; in tcp_pulloutofband()
3441 tp->t_oobflags |= TCPOOB_HAVEDATA; in tcp_pulloutofband()
3461 tcp_xmit_timer(struct tcpcb *tp, int rtt) in tcp_xmit_timer() argument
3465 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_xmit_timer()
3468 tp->t_rttupdated++; in tcp_xmit_timer()
3469 if ((tp->t_srtt != 0) && (tp->t_rxtshift <= TCP_RTT_INVALIDATE)) { in tcp_xmit_timer()
3478 - (tp->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)); in tcp_xmit_timer()
3480 if ((tp->t_srtt += delta) <= 0) in tcp_xmit_timer()
3481 tp->t_srtt = 1; in tcp_xmit_timer()
3495 delta -= tp->t_rttvar >> (TCP_RTTVAR_SHIFT - TCP_DELTA_SHIFT); in tcp_xmit_timer()
3496 if ((tp->t_rttvar += delta) <= 0) in tcp_xmit_timer()
3497 tp->t_rttvar = 1; in tcp_xmit_timer()
3498 if (tp->t_rttbest > tp->t_srtt + tp->t_rttvar) in tcp_xmit_timer()
3499 tp->t_rttbest = tp->t_srtt + tp->t_rttvar; in tcp_xmit_timer()
3506 tp->t_srtt = rtt << TCP_RTT_SHIFT; in tcp_xmit_timer()
3507 tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1); in tcp_xmit_timer()
3508 tp->t_rttbest = tp->t_srtt + tp->t_rttvar; in tcp_xmit_timer()
3510 tp->t_rtttime = 0; in tcp_xmit_timer()
3511 tp->t_rxtshift = 0; in tcp_xmit_timer()
3524 TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp), in tcp_xmit_timer()
3525 max(tp->t_rttmin, rtt + 2), TCPTV_REXMTMAX); in tcp_xmit_timer()
3534 tp->t_softerror = 0; in tcp_xmit_timer()
3559 tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, in tcp_mss_update() argument
3564 struct inpcb *inp = tp->t_inpcb; in tcp_mss_update()
3575 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_mss_update()
3586 tp->t_maxseg = V_tcp_v6mssdflt; in tcp_mss_update()
3595 tp->t_maxseg = V_tcp_mssdflt; in tcp_mss_update()
3621 offer = tp->t_maxseg; in tcp_mss_update()
3702 tp->t_maxseg = mss; in tcp_mss_update()
3706 tcp_mss(struct tcpcb *tp, int offer) in tcp_mss() argument
3715 KASSERT(tp != NULL, ("%s: tp == NULL", __func__)); in tcp_mss()
3718 tcp_mss_update(tp, offer, -1, &metrics, &cap); in tcp_mss()
3720 mss = tp->t_maxseg; in tcp_mss()
3721 inp = tp->t_inpcb; in tcp_mss()
3754 tp->t_maxseg = max(mss, 64); in tcp_mss()
3772 tp->t_flags |= TF_TSO; in tcp_mss()
3773 tp->t_tsomax = cap.tsomax; in tcp_mss()
3774 tp->t_tsomaxsegcount = cap.tsomaxsegcount; in tcp_mss()
3775 tp->t_tsomaxsegsize = cap.tsomaxsegsize; in tcp_mss()
3829 tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th) in tcp_newreno_partial_ack() argument
3831 tcp_seq onxt = tp->snd_nxt; in tcp_newreno_partial_ack()
3832 uint32_t ocwnd = tp->snd_cwnd; in tcp_newreno_partial_ack()
3833 u_int maxseg = tcp_maxseg(tp); in tcp_newreno_partial_ack()
3835 INP_WLOCK_ASSERT(tp->t_inpcb); in tcp_newreno_partial_ack()
3837 tcp_timer_activate(tp, TT_REXMT, 0); in tcp_newreno_partial_ack()
3838 tp->t_rtttime = 0; in tcp_newreno_partial_ack()
3839 tp->snd_nxt = th->th_ack; in tcp_newreno_partial_ack()
3844 tp->snd_cwnd = maxseg + BYTES_THIS_ACK(tp, th); in tcp_newreno_partial_ack()
3845 tp->t_flags |= TF_ACKNOW; in tcp_newreno_partial_ack()
3846 (void) tp->t_fb->tfb_tcp_output(tp); in tcp_newreno_partial_ack()
3847 tp->snd_cwnd = ocwnd; in tcp_newreno_partial_ack()
3848 if (SEQ_GT(onxt, tp->snd_nxt)) in tcp_newreno_partial_ack()
3849 tp->snd_nxt = onxt; in tcp_newreno_partial_ack()
3854 if (tp->snd_cwnd > BYTES_THIS_ACK(tp, th)) in tcp_newreno_partial_ack()
3855 tp->snd_cwnd -= BYTES_THIS_ACK(tp, th); in tcp_newreno_partial_ack()
3857 tp->snd_cwnd = 0; in tcp_newreno_partial_ack()
3858 tp->snd_cwnd += maxseg; in tcp_newreno_partial_ack()
3862 tcp_compute_pipe(struct tcpcb *tp) in tcp_compute_pipe() argument
3864 return (tp->snd_max - tp->snd_una + in tcp_compute_pipe()
3865 tp->sackhint.sack_bytes_rexmit - in tcp_compute_pipe()
3866 tp->sackhint.sacked_bytes); in tcp_compute_pipe()