Lines Matching refs:tp
226 tcp_segsize(struct tcpcb *tp, int *txsegsizep, int *rxsegsizep,
229 struct inpcb *inp = tp->t_inpcb;
240 switch (tp->t_family) {
262 if (tp->t_mtudisc && rt->rt_rmx.rmx_mtu != 0) {
279 else if (inp->inp_af == AF_INET && tp->t_mtudisc)
289 if (tp->t_mtudisc || in_localaddr(d))
296 size = tp->t_mtudisc ? ifp->if_mtu : IPV6_MMTU;
307 optlen = tcp_optlen(tp);
310 * XXX tp->t_ourmss should have the right size, but without this code
318 optlen += ipsec4_hdrsiz_tcp(tp);
324 if (inp->inp_af == AF_INET6 && tp->t_family == AF_INET) {
328 optlen += ipsec4_hdrsiz_tcp(tp);
335 optlen += ipsec6_hdrsiz_tcp(tp);
358 *txsegsizep = uimin(tp->t_peermss - optlen, size);
359 *rxsegsizep = uimin(tp->t_ourmss - optlen, size);
378 if (*txsegsizep != tp->t_segsz) {
388 if (*txsegsizep < tp->t_segsz) {
389 tp->snd_cwnd = uimax((tp->snd_cwnd / tp->t_segsz)
391 tp->snd_ssthresh = uimax((tp->snd_ssthresh / tp->t_segsz)
394 tp->t_segsz = *txsegsizep;
401 tcp_build_datapkt(struct tcpcb *tp, struct socket *so, int off,
408 if (tp->t_force && len == 1)
410 else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
411 tp->t_sndrexmitpack++;
450 if (off == 0 || tp->t_lastm == NULL ||
451 (tp->t_lastoff + tp->t_lastlen) != off) {
457 tp->t_lastm = so->so_snd.sb_mb;
458 tp->t_inoff = off;
461 tp->t_inoff += tp->t_lastlen;
465 while (tp->t_inoff > 0) {
466 if (tp->t_lastm == NULL)
467 panic("tp->t_lastm == NULL");
468 if (tp->t_inoff < tp->t_lastm->m_len)
470 tp->t_inoff -= tp->t_lastm->m_len;
471 tp->t_lastm = tp->t_lastm->m_next;
474 tp->t_lastoff = off;
475 tp->t_lastlen = len;
476 m0 = tp->t_lastm;
477 off = tp->t_inoff;
505 tcp_output(struct tcpcb *tp)
539 so = tp->t_inpcb->inp_socket;
540 ro = &tp->t_inpcb->inp_route;
542 switch (af = tp->t_family) {
545 if (tp->t_inpcb)
552 if (tcp_segsize(tp, &txsegsize, &rxsegsize, &alwaysfrag))
555 idle = (tp->snd_max == tp->snd_una);
565 has_tso4 = tp->t_inpcb->inp_af == AF_INET &&
567 (!ipsec_used || ipsec_pcb_skip_ipsec(tp->t_inpcb->inp_sp,
570 (rt = rtcache_validate(&tp->t_inpcb->inp_route)) != NULL &&
573 rtcache_unref(rt, &tp->t_inpcb->inp_route);
578 has_tso6 = tp->t_inpcb->inp_af == AF_INET6 &&
580 (!ipsec_used || ipsec_pcb_skip_ipsec(tp->t_inpcb->inp_sp,
583 (rt = rtcache_validate(&tp->t_inpcb->inp_route)) != NULL &&
586 rtcache_unref(rt, &tp->t_inpcb->inp_route);
610 tp->snd_cwnd = uimin(tp->snd_cwnd,
612 (tp->snd_nxt - tp->snd_una));
614 if (idle && (tcp_now - tp->t_rcvtime) >= tp->t_rxtcur) {
621 if (tp->t_inpcb->inp_af == AF_INET &&
622 in_localaddr(in4p_faddr(tp->t_inpcb)))
625 else if (tp->t_inpcb->inp_af == AF_INET6 &&
626 in6_localaddr(&in6p_faddr(tp->t_inpcb)))
629 tp->snd_cwnd = uimin(tp->snd_cwnd,
638 if ((tp->t_flags & (TF_ECN_SND_CWR|TF_ECN_SND_ECE)) != 0) {
642 TCP_REASS_LOCK(tp);
643 sack_numblks = tcp_sack_numblks(tp);
652 if ((tp->rcv_sack_flags & TCPSACK_HAVED) != 0) {
670 if (TCP_SACK_ENABLED(tp) && SEQ_LT(tp->snd_nxt, tp->snd_max))
671 tcp_sack_adjust(tp);
673 off = tp->snd_nxt - tp->snd_una;
674 win = uimin(tp->snd_wnd, tp->snd_cwnd);
676 flags = tcp_outflags[tp->t_state];
694 if (!TCP_SACK_ENABLED(tp))
696 if (tp->t_partialacks < 0)
698 p = tcp_sack_output(tp, &sack_bytes_rxmt);
702 cwin = uimin(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt;
706 if (SEQ_GT(p->end, tp->snd_recover)) {
712 if (SEQ_GEQ(p->rxmit, tp->snd_recover)) {
723 len = ((long)ulmin(cwin, tp->snd_recover - p->rxmit));
726 off = p->rxmit - tp->snd_una;
730 KASSERT(p->rxmit + len == tp->snd_max);
745 if (tp->t_force) {
767 TCP_TIMER_DISARM(tp, TCPT_PERSIST);
768 tp->t_rxtshift = 0;
773 if (TCP_SACK_ENABLED(tp) && tp->t_partialacks >= 0) {
781 if (tp->snd_wnd < so->so_snd.sb_cc) {
782 len = tp->snd_wnd - off;
798 cwin = tp->snd_cwnd -
799 (tp->snd_nxt - tp->sack_newdata) -
839 TCP_TIMER_DISARM(tp, TCPT_REXMT);
840 tp->t_rxtshift = 0;
841 tp->snd_nxt = tp->snd_una;
842 if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0)
843 tcp_setpersist(tp);
878 if ((tp->snd_wnd / 4 * 5) >= so->so_snd.sb_hiwat &&
881 win >= (so->so_snd.sb_cc - (tp->snd_nxt - tp->snd_una))) {
910 if (SEQ_LT(p->rxmit + len, tp->snd_una + so->so_snd.sb_cc))
930 ((idle || tp->t_flags & TF_NODELAY) &&
933 if (tp->t_force)
935 if (len >= tp->max_sndwnd / 2)
937 if (SEQ_LT(tp->snd_nxt, tp->snd_max))
955 * TCP_MAXWIN << tp->rcv_scale.
957 long recwin = uimin(win, (long)TCP_MAXWIN << tp->rcv_scale);
964 if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt))
965 oldwin = tp->rcv_adv - tp->rcv_nxt;
974 if (recwin >> tp->rcv_scale <= oldwin >> tp->rcv_scale)
988 if (tp->t_flags & TF_ACKNOW)
992 if (SEQ_GT(tp->snd_up, tp->snd_una))
999 if (TCP_SACK_ENABLED(tp) && SEQ_GT(tp->snd_max, tp->snd_una) &&
1000 !TCP_TIMER_ISARMED(tp, TCPT_REXMT) &&
1001 !TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) {
1002 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur);
1014 * tp->t_timer[TCPT_PERSIST]
1016 * tp->t_force
1018 * tp->t_timer[TCPT_REXMT]
1028 if (so->so_snd.sb_cc && TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0 &&
1029 TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) {
1030 tp->t_rxtshift = 0;
1031 tcp_setpersist(tp);
1038 TCP_REASS_UNLOCK(tp);
1069 synrt = inpcb_rtentry(tp->t_inpcb);
1070 tp->snd_nxt = tp->iss;
1071 tp->t_ourmss = tcp_mss_to_advertise(synrt != NULL ?
1073 inpcb_rtentry_unref(synrt, tp->t_inpcb);
1074 if ((tp->t_flags & TF_NOOPT) == 0 && OPT_FITS(TCPOLEN_MAXSEG)) {
1077 *optp++ = (tp->t_ourmss >> 8) & 0xff;
1078 *optp++ = tp->t_ourmss & 0xff;
1081 if ((tp->t_flags & TF_REQ_SCALE) &&
1083 (tp->t_flags & TF_RCVD_SCALE)) &&
1089 tp->request_r_scale);
1106 if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
1109 (tp->t_flags & TF_RCVD_TSTMP))) {
1121 *lp++ = htonl(TCP_TIMESTAMP(tp));
1122 *lp = htonl(tp->ts_recent);
1127 if (tp->rfbuf_ts == 0 &&
1129 tp->rfbuf_ts = TCP_TIMESTAMP(tp);
1137 if (tp->t_flags & TF_SIGNATURE) {
1169 if ((tp->rcv_sack_flags & TCPSACK_HAVED) != 0) {
1171 *lp++ = htonl(tp->rcv_dsack_block.left);
1172 *lp++ = htonl(tp->rcv_dsack_block.right);
1173 tp->rcv_sack_flags &= ~TCPSACK_HAVED;
1175 for (tiqe = TAILQ_FIRST(&tp->timeq);
1195 reset: TCP_REASS_UNLOCK(tp);
1215 TCP_REASS_UNLOCK(tp);
1234 error = tcp_build_datapkt(tp, so, off, len, hdrlen, &m);
1247 if (tp->t_flags & TF_ACKNOW)
1251 else if (SEQ_GT(tp->snd_up, tp->snd_una))
1297 if (tp->t_template == NULL)
1299 if (tp->t_template->m_len < iphdrlen)
1300 panic("%s: %d < %d", __func__, tp->t_template->m_len, iphdrlen);
1301 bcopy(mtod(tp->t_template, void *), mtod(m, void *), iphdrlen);
1309 if (tp->t_state == TCPS_SYN_SENT && tcp_do_ecn) {
1310 if (tp->t_flags & TF_SYN_REXMT) {
1311 if (tp->t_ecn_retries--)
1315 tp->t_ecn_retries = tcp_ecn_maxretries;
1319 if (TCP_ECN_ALLOWED(tp)) {
1325 if (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max) &&
1326 !(tp->t_force && len == 1)) {
1334 if (tp->t_flags & TF_ECN_SND_CWR) {
1336 tp->t_flags &= ~TF_ECN_SND_CWR;
1338 if (tp->t_flags & TF_ECN_SND_ECE) {
1356 if (TCP_SACK_ENABLED(tp) && sack_rxmit) {
1361 TCP_TIMER_ISARMED(tp, TCPT_PERSIST))
1362 th->th_seq = htonl(tp->snd_nxt);
1364 th->th_seq = htonl(tp->snd_max);
1366 th->th_ack = htonl(tp->rcv_nxt);
1378 if (win > (long)TCP_MAXWIN << tp->rcv_scale)
1379 win = (long)TCP_MAXWIN << tp->rcv_scale;
1380 if (win < (long)(int32_t)(tp->rcv_adv - tp->rcv_nxt))
1381 win = (long)(int32_t)(tp->rcv_adv - tp->rcv_nxt);
1382 th->th_win = htons((u_int16_t) (win>>tp->rcv_scale));
1384 tp->t_sndzerowin++;
1386 if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
1387 u_int32_t urp = tp->snd_up - tp->snd_nxt;
1399 tp->snd_up = tp->snd_una; /* drag it along */
1402 if (sigoff && (tp->t_flags & TF_SIGNATURE)) {
1464 if (tp->t_force == 0 || TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) {
1465 tcp_seq startseq = tp->snd_nxt;
1473 tp->snd_nxt++;
1476 tp->snd_nxt += len;
1477 if (SEQ_GT(tp->snd_nxt, tp->snd_max)) {
1478 tp->snd_max = tp->snd_nxt;
1483 if (tp->t_rtttime == 0) {
1484 tp->t_rtttime = tcp_now;
1485 tp->t_rtseq = startseq;
1499 if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0) {
1500 if ((sack_rxmit && tp->snd_nxt != tp->snd_max)
1501 || tp->snd_nxt != tp->snd_una) {
1502 if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) {
1503 TCP_TIMER_DISARM(tp, TCPT_PERSIST);
1504 tp->t_rxtshift = 0;
1506 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur);
1508 && TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) {
1514 tp->t_rxtshift = 0;
1515 tcp_setpersist(tp);
1519 if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
1520 tp->snd_max = tp->snd_nxt + len;
1527 tcp_trace(TA_OUTPUT, tp->t_state, tp, m, 0);
1542 if (tp->t_inpcb->inp_af == AF_INET) {
1543 ip->ip_ttl = in4p_ip(tp->t_inpcb).ip_ttl;
1544 ip->ip_tos = in4p_ip(tp->t_inpcb).ip_tos | ecn_tos;
1547 else if (tp->t_inpcb->inp_af == AF_INET6) {
1548 ip->ip_ttl = in6pcb_selecthlim(tp->t_inpcb, NULL); /*XXX*/
1557 if (tp->t_family == AF_INET6) {
1564 ip6->ip6_hlim = in6pcb_selecthlim_rt(tp->t_inpcb);
1581 if (tp->t_inpcb->inp_af == AF_INET)
1582 opts = tp->t_inpcb->inp_options;
1586 (tp->t_mtudisc ? IP_MTUDISC : 0) |
1587 (so->so_options & SO_DONTROUTE), NULL, tp->t_inpcb);
1595 if (tp->t_inpcb->inp_af == AF_INET6)
1596 opts = in6p_outputopts(tp->t_inpcb);
1600 NULL, tp->t_inpcb, NULL);
1612 tcp_quench(tp->t_inpcb);
1615 error == EHOSTDOWN) && TCPS_HAVERCVDSYN(tp->t_state)) {
1616 tp->t_softerror = error;
1625 if (tp->t_flags & TF_DELACK)
1626 TCP_RESTART_DELACK(tp);
1631 if (packetlen > tp->t_pmtud_mtu_sent)
1632 tp->t_pmtud_mtu_sent = packetlen;
1636 if (tp->t_flags & TF_DELACK)
1646 if (win > 0 && SEQ_GT(tp->rcv_nxt+win, tp->rcv_adv))
1647 tp->rcv_adv = tp->rcv_nxt + win;
1648 tp->last_ack_sent = tp->rcv_nxt;
1649 tp->t_flags &= ~TF_ACKNOW;
1650 TCP_CLEAR_DELACK(tp);
1655 if (sendalot && (tp->t_congctl == &tcp_reno_ctl || --maxburst))
1661 tcp_setpersist(struct tcpcb *tp)
1663 int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> (1 + 2);
1666 if (TCP_TIMER_ISARMED(tp, TCPT_REXMT))
1671 if (t < tp->t_rttmin)
1672 t = tp->t_rttmin;
1673 TCPT_RANGESET(nticks, t * tcp_backoff[tp->t_rxtshift],
1675 TCP_TIMER_ARM(tp, TCPT_PERSIST, nticks);
1676 if (tp->t_rxtshift < TCP_MAXRXTSHIFT)
1677 tp->t_rxtshift++;