Lines Matching refs:tp

135 #define TCP_XMIT_TIMER_ASSERT(tp, len, th_flags)			\
137 tcp_timer_active((tp), TT_REXMT) || \
138 tcp_timer_active((tp), TT_PERSIST), \
141 static void inline hhook_run_tcp_est_out(struct tcpcb *tp,
144 static void inline cc_after_idle(struct tcpcb *tp);
150 hhook_run_tcp_est_out(struct tcpcb *tp, struct tcphdr *th,
156 hhook_data.tp = tp;
163 tp->osd);
171 cc_after_idle(struct tcpcb *tp)
173 INP_WLOCK_ASSERT(tp->t_inpcb);
175 if (CC_ALGO(tp)->after_idle != NULL)
176 CC_ALGO(tp)->after_idle(tp->ccv);
183 tcp_output(struct tcpcb *tp)
185 struct socket *so = tp->t_inpcb->inp_socket;
209 isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
212 INP_WLOCK_ASSERT(tp->t_inpcb);
215 if (tp->t_flags & TF_TOE)
216 return (tcp_offload_output(tp));
224 if ((tp->t_flags & TF_FASTOPEN) &&
225 (tp->t_state == TCPS_SYN_RECEIVED) &&
226 SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN|ACK sent */
227 (tp->snd_nxt != tp->snd_una)) /* not a retransmit */
236 idle = (tp->t_flags & TF_LASTIDLE) || (tp->snd_max == tp->snd_una);
237 if (idle && ticks - tp->t_rcvtime >= tp->t_rxtcur)
238 cc_after_idle(tp);
239 tp->t_flags &= ~TF_LASTIDLE;
241 if (tp->t_flags & TF_MORETOCOME) {
242 tp->t_flags |= TF_LASTIDLE;
252 if ((tp->t_flags & TF_SACK_PERMIT) &&
253 SEQ_LT(tp->snd_nxt, tp->snd_max))
254 tcp_sack_adjust(tp);
258 off = tp->snd_nxt - tp->snd_una;
259 sendwin = min(tp->snd_wnd, tp->snd_cwnd);
261 flags = tcp_outflags[tp->t_state];
276 if ((tp->t_flags & TF_SACK_PERMIT) && IN_FASTRECOVERY(tp->t_flags) &&
277 (p = tcp_sack_output(tp, &sack_bytes_rxmt))) {
280 cwin = min(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt;
284 if (SEQ_GT(p->end, tp->snd_recover)) {
290 if (SEQ_GEQ(p->rxmit, tp->snd_recover)) {
302 tp->snd_recover - p->rxmit));
305 off = p->rxmit - tp->snd_una;
313 min(len, tp->t_maxseg));
321 if (tp->t_flags & TF_NEEDFIN)
323 if (tp->t_flags & TF_NEEDSYN)
333 if (tp->t_flags & TF_FORCEDATA) {
355 tcp_timer_activate(tp, TT_PERSIST, 0);
356 tp->t_rxtshift = 0;
387 len = ((long)ulmin(sbavail(&so->so_snd), tp->snd_wnd) -
398 cwin = tp->snd_cwnd -
399 (tp->snd_nxt - tp->sack_newdata) -
413 if ((flags & TH_SYN) && SEQ_GT(tp->snd_nxt, tp->snd_una)) {
414 if (tp->t_state != TCPS_SYN_RECEIVED)
421 if ((tp->t_flags & TF_FASTOPEN) &&
422 (tp->t_state == TCPS_SYN_RECEIVED))
433 if ((flags & TH_SYN) && (tp->t_flags & TF_NOOPT)) {
444 if ((tp->t_flags & TF_FASTOPEN) &&
445 (((tp->t_state == TCPS_SYN_RECEIVED) && (tp->t_rxtshift > 0)) ||
467 if ((sendwin == 0) && (TCPS_HAVEESTABLISHED(tp->t_state)) &&
469 tcp_timer_activate(tp, TT_REXMT, 0);
470 tp->t_rxtshift = 0;
471 tp->snd_nxt = tp->snd_una;
472 if (!tcp_timer_active(tp, TT_PERSIST))
473 tcp_setpersist(tp);
518 if ((tp->snd_wnd / 4 * 5) >= so->so_snd.sb_hiwat &&
522 (tp->snd_nxt - tp->snd_una))) {
553 ipsec_optlen = IPSEC_HDRSIZE(ipv6, tp->t_inpcb);
560 ipsec_optlen = IPSEC_HDRSIZE(ipv4, tp->t_inpcb);
565 ipoptlen = ip6_optlen(tp->t_inpcb);
568 if (tp->t_inpcb->inp_options)
569 ipoptlen = tp->t_inpcb->inp_options->m_len -
577 if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg &&
578 ((tp->t_flags & TF_SIGNATURE) == 0) &&
579 tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
584 if (SEQ_LT(p->rxmit + len, tp->snd_una + sbused(&so->so_snd)))
587 if (SEQ_LT(tp->snd_nxt + len, tp->snd_una +
607 if (len >= tp->t_maxseg)
616 if (!(tp->t_flags & TF_MORETOCOME) && /* normal case */
617 (idle || (tp->t_flags & TF_NODELAY)) &&
619 (tp->t_flags & TF_NOPUSH) == 0) {
622 if (tp->t_flags & TF_FORCEDATA) /* typ. timeout case */
624 if (len >= tp->max_sndwnd / 2 && tp->max_sndwnd > 0)
626 if (SEQ_LT(tp->snd_nxt, tp->snd_max)) /* retransmit case */
661 if (recwin > 0 && !(tp->t_flags & TF_NEEDSYN) &&
662 !(tp->t_flags & TF_DELACK) &&
663 !TCPS_HAVERCVDFIN(tp->t_state)) {
667 * TCP_MAXWIN << tp->rcv_scale.
672 adv = min(recwin, (long)TCP_MAXWIN << tp->rcv_scale);
673 if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt)) {
674 oldwin = (tp->rcv_adv - tp->rcv_nxt);
684 if (oldwin >> tp->rcv_scale >= (adv + oldwin) >> tp->rcv_scale)
687 if (adv >= (long)(2 * tp->t_maxseg) &&
690 so->so_rcv.sb_hiwat <= 8 * tp->t_maxseg))
701 if (tp->t_flags & TF_ACKNOW)
704 ((flags & TH_SYN) && (tp->t_flags & TF_NEEDSYN) == 0))
706 if (SEQ_GT(tp->snd_up, tp->snd_una))
713 ((tp->t_flags & TF_SENTFIN) == 0 || tp->snd_nxt == tp->snd_una))
720 if ((tp->t_flags & TF_SACK_PERMIT) &&
721 SEQ_GT(tp->snd_max, tp->snd_una) &&
722 !tcp_timer_active(tp, TT_REXMT) &&
723 !tcp_timer_active(tp, TT_PERSIST)) {
724 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
735 * tcp_timer_active(tp, TT_PERSIST)
737 * (tp->t_flags & TF_FORCEDATA)
739 * tcp_timer_active(tp, TT_REXMT)
749 if (sbavail(&so->so_snd) && !tcp_timer_active(tp, TT_REXMT) &&
750 !tcp_timer_active(tp, TT_PERSIST)) {
751 tp->t_rxtshift = 0;
752 tcp_setpersist(tp);
765 if (len >= tp->t_maxseg)
766 tp->t_flags2 |= TF2_PLPMTU_MAXSEGSNT;
768 tp->t_flags2 &= ~TF2_PLPMTU_MAXSEGSNT;
793 if ((tp->t_flags & TF_NOOPT) == 0) {
796 tp->snd_nxt = tp->iss;
797 to.to_mss = tcp_mssopt(&tp->t_inpcb->inp_inc);
807 if ((tp->t_flags & TF_FASTOPEN) &&
808 (tp->t_state == TCPS_SYN_RECEIVED) &&
809 (tp->t_rxtshift == 0)) {
811 to.to_tfo_cookie = (u_char *)&tp->t_tfo_cookie;
817 if ((flags & TH_SYN) && (tp->t_flags & TF_REQ_SCALE)) {
818 to.to_wscale = tp->request_r_scale;
822 if ((tp->t_flags & TF_RCVD_TSTMP) ||
823 ((flags & TH_SYN) && (tp->t_flags & TF_REQ_TSTMP))) {
824 to.to_tsval = tcp_ts_getticks() + tp->ts_offset;
825 to.to_tsecr = tp->ts_recent;
830 if (tp->rfbuf_ts == 0 &&
832 tp->rfbuf_ts = tcp_ts_getticks();
835 if (tp->t_flags & TF_SACK_PERMIT) {
838 else if (TCPS_HAVEESTABLISHED(tp->t_state) &&
839 (tp->t_flags & TF_SACK_PERMIT) &&
840 tp->rcv_numsacks > 0) {
842 to.to_nsacks = tp->rcv_numsacks;
843 to.to_sacks = (u_char *)tp->sackblks;
852 if (tp->t_flags & TF_SIGNATURE)
866 if (len + optlen + ipoptlen > tp->t_maxseg) {
878 if_hw_tsomax = tp->t_tsomax;
879 if_hw_tsomaxsegcount = tp->t_tsomaxsegcount;
880 if_hw_tsomaxsegsize = tp->t_tsomaxsegsize;
969 max_len = (tp->t_maxseg - optlen);
995 if (tp->t_flags & TF_NEEDFIN)
999 len = tp->t_maxseg - optlen - ipoptlen;
1032 if ((tp->t_flags & TF_FORCEDATA) && len == 1)
1034 else if (SEQ_LT(tp->snd_nxt, tp->snd_max) || sack_rxmit) {
1035 tp->t_sndrexmitpack++;
1091 if (tp->t_flags & TF_ACKNOW)
1095 else if (SEQ_GT(tp->snd_up, tp->snd_una))
1118 mac_inpcb_create_mbuf(tp->t_inpcb, m);
1124 tcpip_fillheaders(tp->t_inpcb, ip6, th);
1131 tcpip_fillheaders(tp->t_inpcb, ip, th);
1139 if (flags & TH_FIN && tp->t_flags & TF_SENTFIN &&
1140 tp->snd_nxt == tp->snd_max)
1141 tp->snd_nxt--;
1148 if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn == 1) {
1149 if (tp->t_rxtshift >= 1) {
1150 if (tp->t_rxtshift <= V_tcp_ecn_maxretries)
1156 if (TCPS_HAVEESTABLISHED(tp->t_state) &&
1157 (tp->t_flags & TF_ECN_PERMIT)) {
1163 if (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max) &&
1164 !((tp->t_flags & TF_FORCEDATA) && len == 1 &&
1165 SEQ_LT(tp->snd_una, tp->snd_max))) {
1177 if (tp->t_flags & TF_ECN_SND_CWR) {
1179 tp->t_flags &= ~TF_ECN_SND_CWR;
1182 if (tp->t_flags & TF_ECN_SND_ECE)
1201 tcp_timer_active(tp, TT_PERSIST))
1202 th->th_seq = htonl(tp->snd_nxt);
1204 th->th_seq = htonl(tp->snd_max);
1208 tp->sackhint.sack_bytes_rexmit += len;
1210 th->th_ack = htonl(tp->rcv_nxt);
1221 recwin < (long)tp->t_maxseg)
1223 if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) &&
1224 recwin < (long)(tp->rcv_adv - tp->rcv_nxt))
1225 recwin = (long)(tp->rcv_adv - tp->rcv_nxt);
1226 if (recwin > (long)TCP_MAXWIN << tp->rcv_scale)
1227 recwin = (long)TCP_MAXWIN << tp->rcv_scale;
1238 th->th_win = htons((u_short)(recwin >> tp->rcv_scale));
1249 tp->t_sndzerowin++;
1250 tp->t_flags |= TF_RXWIN0SENT;
1252 tp->t_flags &= ~TF_RXWIN0SENT;
1253 if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
1254 th->th_urp = htons((u_short)(tp->snd_up - tp->snd_nxt));
1263 tp->snd_up = tp->snd_una; /* drag it along */
1322 KASSERT(len > tp->t_maxseg - optlen,
1325 m->m_pkthdr.tso_segsz = tp->t_maxseg - optlen;
1339 hhook_run_tcp_est_out(tp, th, &to, len, tso);
1354 tcp_trace(TA_OUTPUT, tp->t_state, tp, mtod(m, void *), th, 0);
1361 TCP_PROBE3(debug__output, tp, th, m);
1381 ip6->ip6_hlim = in6_selecthlim(tp->t_inpcb, NULL);
1390 if (V_path_mtu_discovery && tp->t_maxseg > V_tcp_minmss)
1391 tp->t_flags2 |= TF2_PLPMTU_PMTUD;
1393 tp->t_flags2 &= ~TF2_PLPMTU_PMTUD;
1395 if (tp->t_state == TCPS_SYN_SENT)
1396 TCP_PROBE5(connect__request, NULL, tp, ip6, tp, th);
1398 TCP_PROBE5(send, NULL, tp, ip6, tp, th);
1402 tcp_pcap_add(th, m, &(tp->t_outpkts));
1406 error = ip6_output(m, tp->t_inpcb->in6p_outputopts,
1407 &tp->t_inpcb->inp_route6,
1409 NULL, NULL, tp->t_inpcb);
1411 if (error == EMSGSIZE && tp->t_inpcb->inp_route6.ro_rt != NULL)
1412 mtu = tp->t_inpcb->inp_route6.ro_rt->rt_mtu;
1422 if (tp->t_inpcb->inp_vflag & INP_IPV6PROTO)
1423 ip->ip_ttl = in6_selecthlim(tp->t_inpcb, NULL);
1433 if (V_path_mtu_discovery && tp->t_maxseg > V_tcp_minmss) {
1435 tp->t_flags2 |= TF2_PLPMTU_PMTUD;
1437 tp->t_flags2 &= ~TF2_PLPMTU_PMTUD;
1440 if (tp->t_state == TCPS_SYN_SENT)
1441 TCP_PROBE5(connect__request, NULL, tp, ip, tp, th);
1443 TCP_PROBE5(send, NULL, tp, ip, tp, th);
1447 tcp_pcap_add(th, m, &(tp->t_outpkts));
1450 error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
1452 tp->t_inpcb);
1454 if (error == EMSGSIZE && tp->t_inpcb->inp_route.ro_rt != NULL)
1455 mtu = tp->t_inpcb->inp_route.ro_rt->rt_mtu;
1464 if ((tp->t_flags & TF_FORCEDATA) == 0 ||
1465 !tcp_timer_active(tp, TT_PERSIST)) {
1466 tcp_seq startseq = tp->snd_nxt;
1473 tp->snd_nxt++;
1475 tp->snd_nxt++;
1476 tp->t_flags |= TF_SENTFIN;
1481 tp->snd_nxt += len;
1482 if (SEQ_GT(tp->snd_nxt, tp->snd_max)) {
1483 tp->snd_max = tp->snd_nxt;
1488 if (tp->t_rtttime == 0) {
1489 tp->t_rtttime = ticks;
1490 tp->t_rtseq = startseq;
1504 if (!tcp_timer_active(tp, TT_REXMT) &&
1505 ((sack_rxmit && tp->snd_nxt != tp->snd_max) ||
1506 (tp->snd_nxt != tp->snd_una))) {
1507 if (tcp_timer_active(tp, TT_PERSIST)) {
1508 tcp_timer_activate(tp, TT_PERSIST, 0);
1509 tp->t_rxtshift = 0;
1511 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
1513 !tcp_timer_active(tp, TT_REXMT) &&
1514 !tcp_timer_active(tp, TT_PERSIST)) {
1534 tp->t_rxtshift = 0;
1535 tcp_setpersist(tp);
1547 tp->t_flags |= TF_SENTFIN;
1549 if (SEQ_GT(tp->snd_nxt + xlen, tp->snd_max))
1550 tp->snd_max = tp->snd_nxt + xlen;
1553 (TCPS_HAVEESTABLISHED(tp->t_state) &&
1554 (tp->t_flags & TF_SACK_PERMIT) &&
1555 tp->rcv_numsacks > 0)) {
1557 tcp_clean_dsack_blocks(tp);
1574 if (((tp->t_flags & TF_FORCEDATA) == 0 ||
1575 !tcp_timer_active(tp, TT_PERSIST)) &&
1580 tp->sackhint.sack_bytes_rexmit -= len;
1581 KASSERT(tp->sackhint.sack_bytes_rexmit >= 0,
1584 tp->snd_nxt -= len;
1590 tp->t_softerror = error;
1593 TCP_XMIT_TIMER_ASSERT(tp, len, flags);
1594 tp->snd_cwnd = tp->t_maxseg;
1607 tp->t_flags &= ~TF_TSO;
1609 tcp_mss_update(tp, -1, mtu, NULL, NULL);
1617 if (TCPS_HAVERCVDSYN(tp->t_state)) {
1618 tp->t_softerror = error;
1634 if (recwin >= 0 && SEQ_GT(tp->rcv_nxt + recwin, tp->rcv_adv))
1635 tp->rcv_adv = tp->rcv_nxt + recwin;
1636 tp->last_ack_sent = tp->rcv_nxt;
1637 tp->t_flags &= ~(TF_ACKNOW | TF_DELACK);
1638 if (tcp_timer_active(tp, TT_DELACK))
1639 tcp_timer_activate(tp, TT_DELACK, 0);
1656 tcp_setpersist(struct tcpcb *tp)
1658 int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
1661 tp->t_flags &= ~TF_PREVVALID;
1662 if (tcp_timer_active(tp, TT_REXMT))
1667 TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift],
1669 tcp_timer_activate(tp, TT_PERSIST, tt);
1670 if (tp->t_rxtshift < TCP_MAXRXTSHIFT)
1671 tp->t_rxtshift++;