Lines Matching refs:tp

269 static void tcp_sbrcv_grow_rwin(struct tcpcb *tp, struct sockbuf *sb);
330 int tcp_freeq(struct tcpcb *tp);
479 tcp_fillheaders(tp, ip_ptr, tcp_ptr)
480 struct tcpcb *tp;
484 struct inpcb *inp = tp->t_inpcb;
539 tcp_maketemplate(tp)
540 struct tcpcb *tp;
551 tcp_fillheaders(tp, (void *)&n->tt_ipgen, (void *)&n->tt_t);
571 struct tcpcb *tp,
602 if (tp) {
604 win = tcp_sbspace(tp);
605 if (win > (int32_t)TCP_MAXWIN << tp->rcv_scale)
606 win = (int32_t)TCP_MAXWIN << tp->rcv_scale;
610 ro6 = &tp->t_inpcb->in6p_route;
613 ro = &tp->t_inpcb->inp_route;
696 if (tp != NULL && tp->t_inpcb != NULL) {
701 mac_mbuf_label_associate_inpcb(tp->t_inpcb, m);
716 if (tp)
717 nth->th_win = htons((u_short) (win >> tp->rcv_scale));
729 ip6->ip6_hlim = in6_selecthlim(tp ? tp->t_inpcb : NULL,
742 if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
743 tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
746 if (ipsec_bypass == 0 && ipsec_setsocket(m, tp ? tp->t_inpcb->inp_socket : NULL) != 0) {
752 if (tp != NULL) {
757 set_packet_service_class(m, tp->t_inpcb->inp_socket,
761 m->m_pkthdr.m_flowhash = tp->t_inpcb->inp_flowhash;
783 tp->t_inpcb->in6p_last_outifp) {
784 tp->t_inpcb->in6p_last_outifp = outif;
800 inp_route_copyout(tp->t_inpcb, &sro);
810 tp->t_inpcb->inp_last_outifp)
811 tp->t_inpcb->inp_last_outifp = outif;
813 inp_route_copyin(tp->t_inpcb, &sro);
831 register struct tcpcb *tp;
841 tp = &it->tcb;
844 tp = (struct tcpcb *)(void *)inp->inp_saved_ppcb;
846 bzero((char *) tp, sizeof(struct tcpcb));
847 LIST_INIT(&tp->t_segq);
848 tp->t_maxseg = tp->t_maxopd =
855 tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
856 tp->sack_enable = tcp_do_sack;
857 TAILQ_INIT(&tp->snd_holes);
858 tp->t_inpcb = inp; /* XXX */
864 tp->t_srtt = TCPTV_SRTTBASE;
865 tp->t_rttvar = ((TCPTV_RTOBASE - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4;
866 tp->t_rttmin = tcp_TCPTV_MIN;
867 tp->t_rxtcur = TCPTV_RTOBASE;
872 tp->tcp_cc_index = TCP_CC_ALGO_NEWRENO_INDEX;
873 if (CC_ALGO(tp)->init != NULL) {
874 CC_ALGO(tp)->init(tp);
877 tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
878 tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
879 tp->snd_ssthresh_prev = TCP_MAXWIN << TCP_MAX_WINSHIFT;
880 tp->t_rcvtime = tcp_now;
881 tp->tentry.timer_start = tcp_now;
882 tp->t_persist_timeout = tcp_max_persist_timeout;
883 tp->t_persist_stop = 0;
884 tp->t_flagsext |= TF_RCVUNACK_WAITSS;
891 inp->inp_ppcb = (caddr_t)tp;
892 return (tp); /* XXX */
901 tcp_drop(tp, errno)
902 register struct tcpcb *tp;
905 struct socket *so = tp->t_inpcb->inp_socket;
907 struct inpcb *inp = tp->t_inpcb;
910 if (TCPS_HAVERCVDSYN(tp->t_state)) {
912 struct tcpcb *, tp, int32_t, TCPS_CLOSED);
913 tp->t_state = TCPS_CLOSED;
914 (void) tcp_output(tp);
918 if (errno == ETIMEDOUT && tp->t_softerror)
919 errno = tp->t_softerror;
921 return (tcp_close(tp));
925 tcp_getrt_rtt(struct tcpcb *tp, struct rtentry *rt)
928 int isnetlocal = (tp->t_flags & TF_LOCAL);
936 tp->t_rttmin = rtt / (RTM_RTTUNIT / TCP_RETRANSHZ);
938 tp->t_rttmin = isnetlocal ? tcp_TCPTV_MIN : TCPTV_REXMTMIN;
939 tp->t_srtt = rtt / (RTM_RTTUNIT / (TCP_RETRANSHZ * TCP_RTT_SCALE));
942 tp->t_rttvar = rt->rt_rmx.rmx_rttvar /
947 tp->t_rttvar =
948 tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE;
950 TCPT_RANGESET(tp->t_rxtcur,
951 ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
952 tp->t_rttmin, TCPTV_REXMTMAX,
953 TCP_ADD_REXMTSLOP(tp));
964 tcp_close(tp)
965 register struct tcpcb *tp;
967 struct inpcb *inp = tp->t_inpcb;
978 tcp_canceltimers(tp);
979 KERNEL_DEBUG(DBG_FNC_TCP_CLOSE | DBG_FUNC_START, tp,0,0,0,0);
993 if ((tp->t_flags & TF_CLOSING) ||
995 tp->t_flags |= TF_CLOSING;
999 if (CC_ALGO(tp)->cleanup != NULL) {
1000 CC_ALGO(tp)->cleanup(tp);
1022 if (tp->t_rttupdated >= 16) {
1040 if (tp->t_state >= TCPS_CLOSE_WAIT) {
1042 struct tcpcb *, tp, int32_t, TCPS_CLOSING);
1043 tp->t_state = TCPS_CLOSING;
1050 i = tp->t_srtt *
1066 i = tp->t_rttvar *
1089 i = tp->snd_ssthresh;
1101 i = (i + tp->t_maxseg / 2) / tp->t_maxseg;
1104 i *= (u_int32_t)(tp->t_maxseg +
1138 (void) tcp_freeq(tp);
1140 tcp_free_sackholes(tp);
1141 if (tp->t_bwmeas != NULL) {
1142 tcp_bwmeas_free(tp);
1146 if (tp->t_pktlist_head != NULL)
1147 m_freem_list(tp->t_pktlist_head);
1148 TCP_PKTLIST_CLEAR(tp);
1152 inp->inp_saved_ppcb = (caddr_t) tp;
1162 if (tp->t_flagsext & TF_LRO_OFFLOADED) {
1166 tp->t_flagsext &= ~TF_LRO_OFFLOADED;
1184 tcp_freeq(tp)
1185 struct tcpcb *tp;
1191 while((q = LIST_FIRST(&tp->t_segq)) != NULL) {
1251 struct tcpcb *tp;
1256 tp = (struct tcpcb *)inp->inp_ppcb;
1265 if (tp->t_state == TCPS_ESTABLISHED &&
1269 } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 &&
1270 tp->t_softerror)
1271 tcp_drop(tp, error);
1273 tp->t_softerror = error;
1282 tcp_bwmeas_alloc(struct tcpcb *tp)
1292 elm->bw_minsize = elm->bw_minsizepkts * tp->t_maxseg;
1293 elm->bw_maxsize = elm->bw_maxsizepkts * tp->t_maxseg;
1298 tcp_bwmeas_free(struct tcpcb* tp)
1300 zfree(tcp_bwmeas_zone, tp->t_bwmeas);
1301 tp->t_bwmeas = NULL;
1302 tp->t_flagsext &= ~(TF_MEASURESNDBW);
1310 tcpcb_to_otcpcb(struct tcpcb *tp, struct otcpcb *otp)
1314 otp->t_segq = (u_int32_t)(uintptr_t)tp->t_segq.lh_first;
1315 otp->t_dupacks = tp->t_dupacks;
1317 otp->t_timer[i] = tp->t_timer[i];
1318 otp->t_inpcb = (_TCPCB_PTR(struct inpcb *))(uintptr_t)tp->t_inpcb;
1319 otp->t_state = tp->t_state;
1320 otp->t_flags = tp->t_flags;
1321 otp->t_force = tp->t_force;
1322 otp->snd_una = tp->snd_una;
1323 otp->snd_max = tp->snd_max;
1324 otp->snd_nxt = tp->snd_nxt;
1325 otp->snd_up = tp->snd_up;
1326 otp->snd_wl1 = tp->snd_wl1;
1327 otp->snd_wl2 = tp->snd_wl2;
1328 otp->iss = tp->iss;
1329 otp->irs = tp->irs;
1330 otp->rcv_nxt = tp->rcv_nxt;
1331 otp->rcv_adv = tp->rcv_adv;
1332 otp->rcv_wnd = tp->rcv_wnd;
1333 otp->rcv_up = tp->rcv_up;
1334 otp->snd_wnd = tp->snd_wnd;
1335 otp->snd_cwnd = tp->snd_cwnd;
1336 otp->snd_ssthresh = tp->snd_ssthresh;
1337 otp->t_maxopd = tp->t_maxopd;
1338 otp->t_rcvtime = tp->t_rcvtime;
1339 otp->t_starttime = tp->t_starttime;
1340 otp->t_rtttime = tp->t_rtttime;
1341 otp->t_rtseq = tp->t_rtseq;
1342 otp->t_rxtcur = tp->t_rxtcur;
1343 otp->t_maxseg = tp->t_maxseg;
1344 otp->t_srtt = tp->t_srtt;
1345 otp->t_rttvar = tp->t_rttvar;
1346 otp->t_rxtshift = tp->t_rxtshift;
1347 otp->t_rttmin = tp->t_rttmin;
1348 otp->t_rttupdated = tp->t_rttupdated;
1349 otp->max_sndwnd = tp->max_sndwnd;
1350 otp->t_softerror = tp->t_softerror;
1351 otp->t_oobflags = tp->t_oobflags;
1352 otp->t_iobc = tp->t_iobc;
1353 otp->snd_scale = tp->snd_scale;
1354 otp->rcv_scale = tp->rcv_scale;
1355 otp->request_r_scale = tp->request_r_scale;
1356 otp->requested_s_scale = tp->requested_s_scale;
1357 otp->ts_recent = tp->ts_recent;
1358 otp->ts_recent_age = tp->ts_recent_age;
1359 otp->last_ack_sent = tp->last_ack_sent;
1360 otp->cc_send = tp->cc_send;
1361 otp->cc_recv = tp->cc_recv;
1362 otp->snd_recover = tp->snd_recover;
1363 otp->snd_cwnd_prev = tp->snd_cwnd_prev;
1364 otp->snd_ssthresh_prev = tp->snd_ssthresh_prev;
1365 otp->t_badrxtwin = tp->t_badrxtwin;
1497 tcpcb_to_xtcpcb64(struct tcpcb *tp, struct xtcpcb64 *otp)
1501 otp->t_segq = (u_int32_t)(uintptr_t)tp->t_segq.lh_first;
1502 otp->t_dupacks = tp->t_dupacks;
1504 otp->t_timer[i] = tp->t_timer[i];
1505 otp->t_state = tp->t_state;
1506 otp->t_flags = tp->t_flags;
1507 otp->t_force = tp->t_force;
1508 otp->snd_una = tp->snd_una;
1509 otp->snd_max = tp->snd_max;
1510 otp->snd_nxt = tp->snd_nxt;
1511 otp->snd_up = tp->snd_up;
1512 otp->snd_wl1 = tp->snd_wl1;
1513 otp->snd_wl2 = tp->snd_wl2;
1514 otp->iss = tp->iss;
1515 otp->irs = tp->irs;
1516 otp->rcv_nxt = tp->rcv_nxt;
1517 otp->rcv_adv = tp->rcv_adv;
1518 otp->rcv_wnd = tp->rcv_wnd;
1519 otp->rcv_up = tp->rcv_up;
1520 otp->snd_wnd = tp->snd_wnd;
1521 otp->snd_cwnd = tp->snd_cwnd;
1522 otp->snd_ssthresh = tp->snd_ssthresh;
1523 otp->t_maxopd = tp->t_maxopd;
1524 otp->t_rcvtime = tp->t_rcvtime;
1525 otp->t_starttime = tp->t_starttime;
1526 otp->t_rtttime = tp->t_rtttime;
1527 otp->t_rtseq = tp->t_rtseq;
1528 otp->t_rxtcur = tp->t_rxtcur;
1529 otp->t_maxseg = tp->t_maxseg;
1530 otp->t_srtt = tp->t_srtt;
1531 otp->t_rttvar = tp->t_rttvar;
1532 otp->t_rxtshift = tp->t_rxtshift;
1533 otp->t_rttmin = tp->t_rttmin;
1534 otp->t_rttupdated = tp->t_rttupdated;
1535 otp->max_sndwnd = tp->max_sndwnd;
1536 otp->t_softerror = tp->t_softerror;
1537 otp->t_oobflags = tp->t_oobflags;
1538 otp->t_iobc = tp->t_iobc;
1539 otp->snd_scale = tp->snd_scale;
1540 otp->rcv_scale = tp->rcv_scale;
1541 otp->request_r_scale = tp->request_r_scale;
1542 otp->requested_s_scale = tp->requested_s_scale;
1543 otp->ts_recent = tp->ts_recent;
1544 otp->ts_recent_age = tp->ts_recent_age;
1545 otp->last_ack_sent = tp->last_ack_sent;
1546 otp->cc_send = tp->cc_send;
1547 otp->cc_recv = tp->cc_recv;
1548 otp->snd_recover = tp->snd_recover;
1549 otp->snd_cwnd_prev = tp->snd_cwnd_prev;
1550 otp->snd_ssthresh_prev = tp->snd_ssthresh_prev;
1551 otp->t_badrxtwin = tp->t_badrxtwin;
1715 struct tcpcb *tp;
1755 tp = intotcpcb(inp);
1756 if (SEQ_GEQ(icmp_tcp_seq, tp->snd_una) &&
1757 SEQ_LT(icmp_tcp_seq, tp->snd_max)) {
1934 tcp_new_isn(tp)
1935 struct tcpcb *tp;
1945 if (((tp->t_state == TCPS_LISTEN) || (tp->t_state == TCPS_TIME_WAIT))
1969 MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_fport, sizeof(u_short));
1970 MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_lport, sizeof(u_short));
1972 if ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) {
1973 MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->in6p_faddr,
1975 MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->in6p_laddr,
1980 MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_faddr,
1982 MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_laddr,
2003 struct tcpcb *tp = intotcpcb(inp);
2005 if (tp && tp->t_state == TCPS_SYN_SENT)
2006 tcp_drop(tp, errno);
2021 struct tcpcb *tp = intotcpcb(inp);
2028 int isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
2031 if (tp) {
2039 tp->t_maxopd = tp->t_maxseg =
2085 if (tp->t_maxopd <= mss)
2087 tp->t_maxopd = mss;
2089 if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
2090 (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP)
2096 tp->t_maxseg = mss;
2101 if (CC_ALGO(tp)->cwnd_init != NULL)
2102 CC_ALGO(tp)->cwnd_init(tp);
2104 tp->t_rtttime = 0;
2105 tp->snd_nxt = tp->snd_una;
2106 tcp_output(tp);
2124 struct tcpcb *tp;
2169 tp = intotcpcb(inp);
2173 tp->t_flags &= ~TF_PMTUD;
2175 tp->t_flags |= TF_PMTUD;
2179 tp->t_state == TCPS_SYN_SENT && rt != NULL && rt->rt_ifp != NULL &&
2182 tp->t_flags &= ~TF_REQ_SCALE;
2189 tcp_set_tso(tp, rt->rt_ifp);
2206 struct tcpcb *tp;
2252 tp = intotcpcb(inp);
2264 tp->t_flags &= ~TF_PMTUD;
2266 tp->t_flags |= TF_PMTUD;
2270 tp->t_state == TCPS_SYN_SENT && rt != NULL && rt->rt_ifp != NULL &&
2273 tp->t_flags &= ~TF_REQ_SCALE;
2280 tcp_set_tso(tp, rt->rt_ifp);
2293 ipsec_hdrsiz_tcp(tp)
2294 struct tcpcb *tp;
2305 if ((tp == NULL) || ((inp = tp->t_inpcb) == NULL))
2317 tcp_fillheaders(tp, ip6, th);
2325 tcp_fillheaders(tp, ip, th);
2474 tcp_sbrcv_grow_rwin(struct tcpcb *tp, struct sockbuf *sb) {
2475 u_int32_t rcvbufinc = tp->t_maxseg << tcp_autorcvbuf_inc_shift;
2478 (tp->t_flags & TF_SLOWLINK) == 0 &&
2486 tcp_sbspace(struct tcpcb *tp)
2488 struct sockbuf *sb = &tp->t_inpcb->inp_socket->so_rcv;
2491 tcp_sbrcv_grow_rwin(tp, sb);
2503 if (space < tp->t_maxseg)
2508 if (((tp->t_flags & TF_SLOWLINK) != 0) && slowlink_wsize > 0 )
2517 tcp_set_tso(tp, ifp)
2518 struct tcpcb *tp;
2522 struct inpcb *inp = tp->t_inpcb;
2527 tp->t_flags |= TF_TSO;
2529 tp->tso_max_segment_size = ifp->if_tso_v6_mtu;
2531 tp->tso_max_segment_size = TCP_MAXWIN;
2533 tp->t_flags &= ~TF_TSO;
2540 tp->t_flags |= TF_TSO;
2542 tp->tso_max_segment_size = ifp->if_tso_v4_mtu;
2544 tp->tso_max_segment_size = TCP_MAXWIN;
2546 tp->t_flags &= ~TF_TSO;
2601 tcp_set_max_rwinscale(struct tcpcb *tp, struct socket *so) {
2604 tp->request_r_scale = max(tcp_win_scale, tp->request_r_scale);
2608 while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
2609 (TCP_MAXWIN << tp->request_r_scale) < maxsockbufsize)
2610 tp->request_r_scale++;
2611 tp->request_r_scale = min(tp->request_r_scale, TCP_MAX_WINSHIFT);
2618 struct tcpcb *tp = NULL;
2621 tp = intotcpcb(inp);
2625 (tp->snd_nxt - tp->snd_una);
2632 if (notsent <= tp->t_notsent_lowat) {
2640 if ((tp->t_flags & TF_NODELAY) == 0 &&
2641 notsent > 0 && notsent < tp->t_maxseg) {