Lines Matching refs:tp

124 static void inline	hhook_run_tcp_est_out(struct tcpcb *tp,
127 static void inline cc_after_idle(struct tcpcb *tp);
133 hhook_run_tcp_est_out(struct tcpcb *tp, struct tcphdr *th,
139 hhook_data.tp = tp;
146 tp->osd);
154 cc_after_idle(struct tcpcb *tp)
156 INP_WLOCK_ASSERT(tp->t_inpcb);
158 if (CC_ALGO(tp)->after_idle != NULL)
159 CC_ALGO(tp)->after_idle(tp->ccv);
166 tcp_output(struct tcpcb *tp)
168 struct socket *so = tp->t_inpcb->inp_socket;
192 isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
195 INP_WLOCK_ASSERT(tp->t_inpcb);
198 if (tp->t_flags & TF_TOE)
199 return (tcp_offload_output(tp));
208 idle = (tp->t_flags & TF_LASTIDLE) || (tp->snd_max == tp->snd_una);
209 if (idle && ticks - tp->t_rcvtime >= tp->t_rxtcur)
210 cc_after_idle(tp);
211 tp->t_flags &= ~TF_LASTIDLE;
213 if (tp->t_flags & TF_MORETOCOME) {
214 tp->t_flags |= TF_LASTIDLE;
224 if ((tp->t_flags & TF_SACK_PERMIT) &&
225 SEQ_LT(tp->snd_nxt, tp->snd_max))
226 tcp_sack_adjust(tp);
230 off = tp->snd_nxt - tp->snd_una;
231 sendwin = min(tp->snd_wnd, tp->snd_cwnd);
233 flags = tcp_outflags[tp->t_state];
248 if ((tp->t_flags & TF_SACK_PERMIT) && IN_FASTRECOVERY(tp->t_flags) &&
249 (p = tcp_sack_output(tp, &sack_bytes_rxmt))) {
252 cwin = min(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt;
256 if (SEQ_GT(p->end, tp->snd_recover)) {
262 if (SEQ_GEQ(p->rxmit, tp->snd_recover)) {
274 tp->snd_recover - p->rxmit));
277 off = p->rxmit - tp->snd_una;
285 min(len, tp->t_maxseg));
293 if (tp->t_flags & TF_NEEDFIN)
295 if (tp->t_flags & TF_NEEDSYN)
305 if (tp->t_flags & TF_FORCEDATA) {
327 tcp_timer_activate(tp, TT_PERSIST, 0);
328 tp->t_rxtshift = 0;
358 len = ((long)ulmin(so->so_snd.sb_cc, tp->snd_wnd)
369 cwin = tp->snd_cwnd -
370 (tp->snd_nxt - tp->sack_newdata) -
384 if ((flags & TH_SYN) && SEQ_GT(tp->snd_nxt, tp->snd_una)) {
385 if (tp->t_state != TCPS_SYN_RECEIVED)
395 if ((flags & TH_SYN) && (tp->t_flags & TF_NOOPT)) {
418 if ((sendwin == 0) && (TCPS_HAVEESTABLISHED(tp->t_state)) &&
420 tcp_timer_activate(tp, TT_REXMT, 0);
421 tp->t_rxtshift = 0;
422 tp->snd_nxt = tp->snd_una;
423 if (!tcp_timer_active(tp, TT_PERSIST))
424 tcp_setpersist(tp);
467 if ((tp->snd_wnd / 4 * 5) >= so->so_snd.sb_hiwat &&
470 sendwin >= (so->so_snd.sb_cc - (tp->snd_nxt - tp->snd_una))) {
494 ipsec_optlen = ipsec_hdrsiz_tcp(tp);
496 if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg &&
497 ((tp->t_flags & TF_SIGNATURE) == 0) &&
498 tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
502 tp->t_inpcb->inp_options == NULL &&
503 tp->t_inpcb->in6p_options == NULL)
507 if (SEQ_LT(p->rxmit + len, tp->snd_una + so->so_snd.sb_cc))
510 if (SEQ_LT(tp->snd_nxt + len, tp->snd_una + so->so_snd.sb_cc))
529 if (len >= tp->t_maxseg)
538 if (!(tp->t_flags & TF_MORETOCOME) && /* normal case */
539 (idle || (tp->t_flags & TF_NODELAY)) &&
541 (tp->t_flags & TF_NOPUSH) == 0) {
544 if (tp->t_flags & TF_FORCEDATA) /* typ. timeout case */
546 if (len >= tp->max_sndwnd / 2 && tp->max_sndwnd > 0)
548 if (SEQ_LT(tp->snd_nxt, tp->snd_max)) /* retransmit case */
583 if (recwin > 0 && !(tp->t_flags & TF_NEEDSYN) &&
584 !(tp->t_flags & TF_DELACK) &&
585 !TCPS_HAVERCVDFIN(tp->t_state)) {
589 * TCP_MAXWIN << tp->rcv_scale.
594 adv = min(recwin, (long)TCP_MAXWIN << tp->rcv_scale);
595 if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt)) {
596 oldwin = (tp->rcv_adv - tp->rcv_nxt);
605 if (oldwin >> tp->rcv_scale == (adv + oldwin) >> tp->rcv_scale)
608 if (adv >= (long)(2 * tp->t_maxseg) &&
611 so->so_rcv.sb_hiwat <= 8 * tp->t_maxseg))
620 if (tp->t_flags & TF_ACKNOW)
623 ((flags & TH_SYN) && (tp->t_flags & TF_NEEDSYN) == 0))
625 if (SEQ_GT(tp->snd_up, tp->snd_una))
632 ((tp->t_flags & TF_SENTFIN) == 0 || tp->snd_nxt == tp->snd_una))
639 if ((tp->t_flags & TF_SACK_PERMIT) &&
640 SEQ_GT(tp->snd_max, tp->snd_una) &&
641 !tcp_timer_active(tp, TT_REXMT) &&
642 !tcp_timer_active(tp, TT_PERSIST)) {
643 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
654 * tcp_timer_active(tp, TT_PERSIST)
656 * (tp->t_flags & TF_FORCEDATA)
658 * tcp_timer_active(tp, TT_REXMT)
668 if (so->so_snd.sb_cc && !tcp_timer_active(tp, TT_REXMT) &&
669 !tcp_timer_active(tp, TT_PERSIST)) {
670 tp->t_rxtshift = 0;
671 tcp_setpersist(tp);
706 if ((tp->t_flags & TF_NOOPT) == 0) {
709 tp->snd_nxt = tp->iss;
710 to.to_mss = tcp_mssopt(&tp->t_inpcb->inp_inc);
714 if ((flags & TH_SYN) && (tp->t_flags & TF_REQ_SCALE)) {
715 to.to_wscale = tp->request_r_scale;
719 if ((tp->t_flags & TF_RCVD_TSTMP) ||
720 ((flags & TH_SYN) && (tp->t_flags & TF_REQ_TSTMP))) {
721 to.to_tsval = tcp_ts_getticks() + tp->ts_offset;
722 to.to_tsecr = tp->ts_recent;
725 if (tp->rfbuf_ts == 0 &&
727 tp->rfbuf_ts = tcp_ts_getticks();
730 if (tp->t_flags & TF_SACK_PERMIT) {
733 else if (TCPS_HAVEESTABLISHED(tp->t_state) &&
734 (tp->t_flags & TF_SACK_PERMIT) &&
735 tp->rcv_numsacks > 0) {
737 to.to_nsacks = tp->rcv_numsacks;
738 to.to_sacks = (u_char *)tp->sackblks;
743 if (tp->t_flags & TF_SIGNATURE)
753 ipoptlen = ip6_optlen(tp->t_inpcb);
756 if (tp->t_inpcb->inp_options)
757 ipoptlen = tp->t_inpcb->inp_options->m_len -
771 if (len + optlen + ipoptlen > tp->t_maxopd) {
784 if (len > tp->t_tsomax - hdrlen) {
785 len = tp->t_tsomax - hdrlen;
795 len -= len % (tp->t_maxopd - optlen);
806 if (tp->t_flags & TF_NEEDFIN)
810 len = tp->t_maxopd - optlen - ipoptlen;
843 if ((tp->t_flags & TF_FORCEDATA) && len == 1)
845 else if (SEQ_LT(tp->snd_nxt, tp->snd_max) || sack_rxmit) {
846 tp->t_sndrexmitpack++;
904 if (tp->t_flags & TF_ACKNOW)
908 else if (SEQ_GT(tp->snd_up, tp->snd_una))
930 mac_inpcb_create_mbuf(tp->t_inpcb, m);
936 tcpip_fillheaders(tp->t_inpcb, ip6, th);
943 tcpip_fillheaders(tp->t_inpcb, ip, th);
951 if (flags & TH_FIN && tp->t_flags & TF_SENTFIN &&
952 tp->snd_nxt == tp->snd_max)
953 tp->snd_nxt--;
960 if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn) {
961 if (tp->t_rxtshift >= 1) {
962 if (tp->t_rxtshift <= V_tcp_ecn_maxretries)
968 if (tp->t_state == TCPS_ESTABLISHED &&
969 (tp->t_flags & TF_ECN_PERMIT)) {
975 if (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max) &&
976 !((tp->t_flags & TF_FORCEDATA) && len == 1)) {
989 if (tp->t_flags & TF_ECN_SND_CWR) {
991 tp->t_flags &= ~TF_ECN_SND_CWR;
993 if (tp->t_flags & TF_ECN_SND_ECE)
1012 tcp_timer_active(tp, TT_PERSIST))
1013 th->th_seq = htonl(tp->snd_nxt);
1015 th->th_seq = htonl(tp->snd_max);
1019 tp->sackhint.sack_bytes_rexmit += len;
1021 th->th_ack = htonl(tp->rcv_nxt);
1032 recwin < (long)tp->t_maxseg)
1034 if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) &&
1035 recwin < (long)(tp->rcv_adv - tp->rcv_nxt))
1036 recwin = (long)(tp->rcv_adv - tp->rcv_nxt);
1037 if (recwin > (long)TCP_MAXWIN << tp->rcv_scale)
1038 recwin = (long)TCP_MAXWIN << tp->rcv_scale;
1049 th->th_win = htons((u_short)(recwin >> tp->rcv_scale));
1060 tp->t_sndzerowin++;
1061 tp->t_flags |= TF_RXWIN0SENT;
1063 tp->t_flags &= ~TF_RXWIN0SENT;
1064 if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
1065 th->th_urp = htons((u_short)(tp->snd_up - tp->snd_nxt));
1074 tp->snd_up = tp->snd_una; /* drag it along */
1122 KASSERT(len > tp->t_maxopd - optlen,
1125 m->m_pkthdr.tso_segsz = tp->t_maxopd - optlen;
1142 if ((tp->t_flags & TF_FORCEDATA) == 0 ||
1143 !tcp_timer_active(tp, TT_PERSIST)) {
1144 tcp_seq startseq = tp->snd_nxt;
1151 tp->snd_nxt++;
1153 tp->snd_nxt++;
1154 tp->t_flags |= TF_SENTFIN;
1159 tp->snd_nxt += len;
1160 if (SEQ_GT(tp->snd_nxt, tp->snd_max)) {
1161 tp->snd_max = tp->snd_nxt;
1166 if (tp->t_rtttime == 0) {
1167 tp->t_rtttime = ticks;
1168 tp->t_rtseq = startseq;
1182 if (!tcp_timer_active(tp, TT_REXMT) &&
1183 ((sack_rxmit && tp->snd_nxt != tp->snd_max) ||
1184 (tp->snd_nxt != tp->snd_una))) {
1185 if (tcp_timer_active(tp, TT_PERSIST)) {
1186 tcp_timer_activate(tp, TT_PERSIST, 0);
1187 tp->t_rxtshift = 0;
1189 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
1201 tp->t_flags |= TF_SENTFIN;
1203 if (SEQ_GT(tp->snd_nxt + xlen, tp->snd_max))
1204 tp->snd_max = tp->snd_nxt + len;
1208 hhook_run_tcp_est_out(tp, th, &to, len, tso);
1223 tcp_trace(TA_OUTPUT, tp->t_state, tp, mtod(m, void *), th, 0);
1252 ip6->ip6_hlim = in6_selecthlim(tp->t_inpcb, NULL);
1255 error = ip6_output(m, tp->t_inpcb->in6p_outputopts, &ro,
1257 NULL, NULL, tp->t_inpcb);
1274 if (tp->t_inpcb->inp_vflag & INP_IPV6PROTO)
1275 ip->ip_ttl = in6_selecthlim(tp->t_inpcb, NULL);
1285 if (V_path_mtu_discovery && tp->t_maxopd > V_tcp_minmss)
1288 error = ip_output(m, tp->t_inpcb->inp_options, &ro,
1290 tp->t_inpcb);
1312 if (((tp->t_flags & TF_FORCEDATA) == 0 ||
1313 !tcp_timer_active(tp, TT_PERSIST)) &&
1318 tp->sackhint.sack_bytes_rexmit -= len;
1319 KASSERT(tp->sackhint.sack_bytes_rexmit >= 0,
1322 tp->snd_nxt -= len;
1328 tp->t_softerror = error;
1331 if (!tcp_timer_active(tp, TT_REXMT) &&
1332 !tcp_timer_active(tp, TT_PERSIST))
1333 tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
1334 tp->snd_cwnd = tp->t_maxseg;
1347 tp->t_flags &= ~TF_TSO;
1349 tcp_mss_update(tp, -1, mtu, NULL, NULL);
1357 if (TCPS_HAVERCVDSYN(tp->t_state)) {
1358 tp->t_softerror = error;
1374 if (recwin >= 0 && SEQ_GT(tp->rcv_nxt + recwin, tp->rcv_adv))
1375 tp->rcv_adv = tp->rcv_nxt + recwin;
1376 tp->last_ack_sent = tp->rcv_nxt;
1377 tp->t_flags &= ~(TF_ACKNOW | TF_DELACK);
1378 if (tcp_timer_active(tp, TT_DELACK))
1379 tcp_timer_activate(tp, TT_DELACK, 0);
1396 tcp_setpersist(struct tcpcb *tp)
1398 int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
1401 tp->t_flags &= ~TF_PREVVALID;
1402 if (tcp_timer_active(tp, TT_REXMT))
1407 TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift],
1409 tcp_timer_activate(tp, TT_PERSIST, tt);
1410 if (tp->t_rxtshift < TCP_MAXRXTSHIFT)
1411 tp->t_rxtshift++;