Lines Matching refs:tp
127 #define TCPDEBUG1() ostate = tp ? tp->t_state : 0
128 #define TCPDEBUG2(req) if (tp && (so->so_options & SO_DEBUG)) \
129 tcp_trace(TA_USER, ostate, tp, 0, 0, req)
154 struct tcpcb *tp = NULL;
167 tp = intotcpcb(inp);
170 TCP_PROBE2(debug__user, tp, PRU_ATTACH);
186 struct tcpcb *tp;
194 tp = intotcpcb(inp);
229 if (__predict_true(tp == NULL)) {
239 "INP_TIMEWAIT && INP_DROPPED && tp != NULL"
243 "INP_TIMEWAIT && INP_DROPPED && tp != NULL"
263 tp->t_state < TCPS_SYN_SENT) {
264 tcp_discardcb(tp);
311 struct tcpcb *tp = NULL;
333 tp = intotcpcb(inp);
340 TCP_PROBE2(debug__user, tp, PRU_BIND);
353 struct tcpcb *tp = NULL;
377 tp = intotcpcb(inp);
410 TCP_PROBE2(debug__user, tp, PRU_BIND);
425 struct tcpcb *tp = NULL;
435 tp = intotcpcb(inp);
444 tcp_state_change(tp, TCPS_LISTEN);
448 tcp_offload_listen_start(tp);
453 if (IS_FASTOPEN(tp->t_flags))
454 tp->t_tfo_pending = tcp_fastopen_alloc_counter();
458 TCP_PROBE2(debug__user, tp, PRU_LISTEN);
470 struct tcpcb *tp = NULL;
482 tp = intotcpcb(inp);
495 tcp_state_change(tp, TCPS_LISTEN);
499 tcp_offload_listen_start(tp);
504 if (IS_FASTOPEN(tp->t_flags))
505 tp->t_tfo_pending = tcp_fastopen_alloc_counter();
512 TCP_PROBE2(debug__user, tp, PRU_LISTEN);
531 struct tcpcb *tp = NULL;
561 tp = intotcpcb(inp);
563 if ((error = tcp_connect(tp, nam, td)) != 0)
571 tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp));
572 error = tp->t_fb->tfb_tcp_output(tp);
575 TCP_PROBE2(debug__user, tp, PRU_CONNECT);
587 struct tcpcb *tp = NULL;
617 tp = intotcpcb(inp);
651 if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0)
659 error = tp->t_fb->tfb_tcp_output(tp);
673 if ((error = tcp6_connect(tp, nam, td)) != 0)
681 tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp));
682 error = tp->t_fb->tfb_tcp_output(tp);
695 TCP_PROBE2(debug__user, tp, PRU_CONNECT);
716 struct tcpcb *tp = NULL;
731 tp = intotcpcb(inp);
733 tcp_disconnect(tp);
736 TCP_PROBE2(debug__user, tp, PRU_DISCONNECT);
752 struct tcpcb *tp = NULL;
767 tp = intotcpcb(inp);
780 TCP_PROBE2(debug__user, tp, PRU_ACCEPT);
794 struct tcpcb *tp = NULL;
813 tp = intotcpcb(inp);
832 TCP_PROBE2(debug__user, tp, PRU_ACCEPT);
853 struct tcpcb *tp = NULL;
865 tp = intotcpcb(inp);
868 tcp_usrclosed(tp);
870 error = tp->t_fb->tfb_tcp_output(tp);
874 TCP_PROBE2(debug__user, tp, PRU_SHUTDOWN);
888 struct tcpcb *tp = NULL;
899 tp = intotcpcb(inp);
908 if (IS_FASTOPEN(tp->t_flags) &&
909 (tp->t_state == TCPS_SYN_RECEIVED))
912 if (tp->t_flags & TF_TOE)
913 tcp_offload_rcvd(tp);
916 tp->t_fb->tfb_tcp_output(tp);
920 TCP_PROBE2(debug__user, tp, PRU_RCVD);
938 struct tcpcb *tp = NULL;
978 tp = intotcpcb(inp);
980 if (nam != NULL && tp->t_state < TCPS_SYN_SENT) {
1123 if (nam && tp->t_state < TCPS_SYN_SENT) {
1131 error = tcp6_connect(tp, nam, td);
1137 error = tcp_connect(tp,
1150 if (IS_FASTOPEN(tp->t_flags))
1151 tcp_fastopen_connect(tp);
1153 tp->snd_wnd = TTCP_CLIENT_SND_WND;
1154 tcp_mss(tp, -1);
1164 tcp_usrclosed(tp);
1169 tp->t_flags |= TF_MORETOCOME;
1170 error = tp->t_fb->tfb_tcp_output(tp);
1172 tp->t_flags &= ~TF_MORETOCOME;
1195 if (nam && tp->t_state < TCPS_SYN_SENT) {
1205 if (IS_FASTOPEN(tp->t_flags))
1206 tp->t_flags &= ~TF_FASTOPEN;
1209 error = tcp6_connect(tp, nam, td);
1215 error = tcp_connect(tp,
1228 tp->snd_wnd = TTCP_CLIENT_SND_WND;
1229 tcp_mss(tp, -1);
1231 tp->snd_up = tp->snd_una + sbavail(&so->so_snd);
1233 tp->t_flags |= TF_FORCEDATA;
1234 error = tp->t_fb->tfb_tcp_output(tp);
1235 tp->t_flags &= ~TF_FORCEDATA;
1238 TCP_LOG_EVENT(tp, NULL,
1254 TCP_PROBE2(debug__user, tp, (flags & PRUS_OOB) ? PRU_SENDOOB :
1266 struct tcpcb *tp;
1277 tp = intotcpcb(inp);
1283 error = tp->t_fb->tfb_tcp_output(tp);
1296 struct tcpcb *tp = NULL;
1313 tp = intotcpcb(inp);
1315 tp = tcp_drop(tp, ECONNABORTED);
1316 if (tp == NULL)
1319 TCP_PROBE2(debug__user, tp, PRU_ABORT);
1339 struct tcpcb *tp = NULL;
1357 tp = intotcpcb(inp);
1359 tcp_disconnect(tp);
1361 TCP_PROBE2(debug__user, tp, PRU_CLOSE);
1381 struct tcpcb *tp = NULL;
1391 tp = intotcpcb(inp);
1396 tp->t_oobflags & TCPOOB_HADDATA) {
1400 if ((tp->t_oobflags & TCPOOB_HAVEDATA) == 0) {
1405 *mtod(m, caddr_t) = tp->t_iobc;
1407 tp->t_oobflags ^= (TCPOOB_HAVEDATA | TCPOOB_HADDATA);
1411 TCP_PROBE2(debug__user, tp, PRU_RCVOOB);
1474 tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
1476 struct inpcb *inp = tp->t_inpcb, *oinp;
1524 while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
1525 (TCP_MAXWIN << tp->request_r_scale) < sb_max)
1526 tp->request_r_scale++;
1530 tcp_state_change(tp, TCPS_SYN_SENT);
1531 tp->iss = tcp_new_isn(&inp->inp_inc);
1532 if (tp->t_flags & TF_REQ_TSTMP)
1533 tp->ts_offset = tcp_new_ts_offset(&inp->inp_inc);
1534 tcp_sendseqinit(tp);
1546 tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
1548 struct inpcb *inp = tp->t_inpcb;
1565 while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
1566 (TCP_MAXWIN << tp->request_r_scale) < sb_max)
1567 tp->request_r_scale++;
1571 tcp_state_change(tp, TCPS_SYN_SENT);
1572 tp->iss = tcp_new_isn(&inp->inp_inc);
1573 if (tp->t_flags & TF_REQ_TSTMP)
1574 tp->ts_offset = tcp_new_ts_offset(&inp->inp_inc);
1575 tcp_sendseqinit(tp);
1593 tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
1596 INP_WLOCK_ASSERT(tp->t_inpcb);
1599 ti->tcpi_state = tp->t_state;
1600 if ((tp->t_flags & TF_REQ_TSTMP) && (tp->t_flags & TF_RCVD_TSTMP))
1602 if (tp->t_flags & TF_SACK_PERMIT)
1604 if ((tp->t_flags & TF_REQ_SCALE) && (tp->t_flags & TF_RCVD_SCALE)) {
1606 ti->tcpi_snd_wscale = tp->snd_scale;
1607 ti->tcpi_rcv_wscale = tp->rcv_scale;
1609 if (tp->t_flags & TF_ECN_PERMIT)
1612 ti->tcpi_rto = tp->t_rxtcur * tick;
1613 ti->tcpi_last_data_recv = ((uint32_t)ticks - tp->t_rcvtime) * tick;
1614 ti->tcpi_rtt = ((u_int64_t)tp->t_srtt * tick) >> TCP_RTT_SHIFT;
1615 ti->tcpi_rttvar = ((u_int64_t)tp->t_rttvar * tick) >> TCP_RTTVAR_SHIFT;
1617 ti->tcpi_snd_ssthresh = tp->snd_ssthresh;
1618 ti->tcpi_snd_cwnd = tp->snd_cwnd;
1623 ti->tcpi_rcv_space = tp->rcv_wnd;
1624 ti->tcpi_rcv_nxt = tp->rcv_nxt;
1625 ti->tcpi_snd_wnd = tp->snd_wnd;
1627 ti->tcpi_snd_nxt = tp->snd_nxt;
1628 ti->tcpi_snd_mss = tp->t_maxseg;
1629 ti->tcpi_rcv_mss = tp->t_maxseg;
1630 ti->tcpi_snd_rexmitpack = tp->t_sndrexmitpack;
1631 ti->tcpi_rcv_ooopack = tp->t_rcvoopack;
1632 ti->tcpi_snd_zerowin = tp->t_sndzerowin;
1634 if (tp->t_flags & TF_TOE) {
1636 tcp_offload_tcp_info(tp, ti);
1654 tp = intotcpcb(inp); \
1663 struct tcpcb *tp;
1694 tp = intotcpcb(inp);
1695 if ((tp->t_state >= TCPS_SYN_SENT) &&
1703 if (tp->t_maxseg > TCP6_MSS) {
1704 tp->t_maxseg = TCP6_MSS;
1727 tp = intotcpcb(inp);
1745 if (tp->t_fb == blk) {
1751 if (tp->t_state != TCPS_CLOSED) {
1763 error = (*blk->tfb_tcp_handoff_ok)(tp);
1782 if (tp->t_fb->tfb_tcp_fb_fini) {
1787 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0);
1791 tcp_hpts_remove(tp->t_inpcb, HPTS_REMOVE_ALL);
1794 error = (*blk->tfb_tcp_fb_init)(tp);
1797 if (tp->t_fb->tfb_tcp_fb_init) {
1798 if((*tp->t_fb->tfb_tcp_fb_init)(tp) != 0) {
1808 refcount_release(&tp->t_fb->tfb_refcnt);
1809 tp->t_fb = blk;
1811 if (tp->t_flags & TF_TOE) {
1812 tcp_offload_ctloutput(tp, sopt->sopt_dir,
1821 strncpy(fsn.function_set_name, tp->t_fb->tfb_tcp_block_name,
1824 fsn.pcbcnt = tp->t_fb->tfb_refcnt;
1830 return (tp->t_fb->tfb_tcp_ctloutput(so, sopt, inp, tp));
1843 tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp, struct tcpcb *tp)
1869 if (CC_ALGO(tp)->ctl_output != NULL)
1870 error = CC_ALGO(tp)->ctl_output(tp->ccv, sopt, pbuf);
1917 tp->t_flags |= opt;
1919 tp->t_flags &= ~opt;
1922 if (tp->t_flags & TF_TOE) {
1923 tcp_offload_ctloutput(tp, sopt->sopt_dir,
1939 tp->t_flags |= TF_NOPUSH;
1940 else if (tp->t_flags & TF_NOPUSH) {
1941 tp->t_flags &= ~TF_NOPUSH;
1942 if (TCPS_HAVEESTABLISHED(tp->t_state))
1943 error = tp->t_fb->tfb_tcp_output(tp);
1955 if (optval > 0 && optval <= tp->t_maxseg &&
1957 tp->t_maxseg = optval;
1989 if (CC_ALGO(tp)->cb_destroy != NULL)
1990 CC_ALGO(tp)->cb_destroy(tp->ccv);
1991 CC_DATA(tp) = NULL;
1992 CC_ALGO(tp) = algo;
1999 algo->cb_init(tp->ccv) != 0) {
2000 CC_ALGO(tp) = &newreno_cc_algo;
2027 tp->t_keepidle = ui;
2032 if ((tp->t_state > TCPS_LISTEN) &&
2033 (tp->t_state <= TCPS_CLOSING))
2034 tcp_timer_activate(tp, TT_KEEP,
2035 TP_KEEPIDLE(tp));
2038 tp->t_keepintvl = ui;
2039 if ((tp->t_state == TCPS_FIN_WAIT_2) &&
2040 (TP_MAXIDLE(tp) > 0))
2041 tcp_timer_activate(tp, TT_2MSL,
2042 TP_MAXIDLE(tp));
2045 tp->t_keepinit = ui;
2046 if (tp->t_state == TCPS_SYN_RECEIVED ||
2047 tp->t_state == TCPS_SYN_SENT)
2048 tcp_timer_activate(tp, TT_KEEP,
2049 TP_KEEPINIT(tp));
2061 tp->t_keepcnt = ui;
2062 if ((tp->t_state == TCPS_FIN_WAIT_2) &&
2063 (TP_MAXIDLE(tp) > 0))
2064 tcp_timer_activate(tp, TT_2MSL,
2065 TP_MAXIDLE(tp));
2080 &(tp->t_outpkts) : &(tp->t_inpkts),
2101 if ((tp->t_state != TCPS_CLOSED) &&
2102 (tp->t_state != TCPS_LISTEN)) {
2107 if (tp->t_state == TCPS_LISTEN) {
2113 if (tp->t_tfo_pending == NULL)
2114 tp->t_tfo_pending =
2125 memcpy(tp->t_tfo_cookie.client,
2128 tp->t_tfo_client_cookie_len =
2132 tp->t_flags |= TF_FASTOPEN;
2134 tp->t_flags &= ~TF_FASTOPEN;
2147 error = tcp_log_state_change(tp, optval);
2162 error = tcp_log_set_id(tp, buf);
2176 error = tcp_log_dump_tp_logbuf(tp, buf,
2180 tcp_log_dump_tp_bucket_logbufs(tp, buf);
2197 tp = intotcpcb(inp);
2210 optval = tp->t_flags & TF_NODELAY;
2215 optval = tp->t_maxseg;
2220 optval = tp->t_flags & TF_NOOPT;
2225 optval = tp->t_flags & TF_NOPUSH;
2230 tcp_fill_info(tp, &ti);
2235 len = strlcpy(buf, CC_ALGO(tp)->name, TCP_CA_NAME_MAX);
2245 ui = TP_KEEPIDLE(tp) / hz;
2248 ui = TP_KEEPINTVL(tp) / hz;
2251 ui = TP_KEEPINIT(tp) / hz;
2254 ui = TP_KEEPCNT(tp);
2264 &(tp->t_outpkts) : &(tp->t_inpkts));
2270 optval = tp->t_flags & TF_FASTOPEN;
2276 optval = tp->t_logstate;
2282 error = tcp_log_getlogbuf(sopt, tp);
2285 len = tcp_log_get_id(tp, buf);
2315 struct tcpcb *tp;
2344 tp = tcp_newtcpcb(inp);
2345 if (tp == NULL) {
2351 tp->t_state = TCPS_CLOSED;
2367 tcp_disconnect(struct tcpcb *tp)
2369 struct inpcb *inp = tp->t_inpcb;
2379 if (tp->t_state < TCPS_ESTABLISHED &&
2380 !(tp->t_state > TCPS_LISTEN && IS_FASTOPEN(tp->t_flags))) {
2381 tp = tcp_close(tp);
2382 KASSERT(tp != NULL,
2385 tp = tcp_drop(tp, 0);
2386 KASSERT(tp != NULL,
2391 tcp_usrclosed(tp);
2393 tp->t_fb->tfb_tcp_output(tp);
2408 tcp_usrclosed(struct tcpcb *tp)
2412 INP_WLOCK_ASSERT(tp->t_inpcb);
2414 switch (tp->t_state) {
2417 tcp_offload_listen_stop(tp);
2419 tcp_state_change(tp, TCPS_CLOSED);
2422 tp = tcp_close(tp);
2427 KASSERT(tp != NULL,
2433 tp->t_flags |= TF_NEEDFIN;
2437 tcp_state_change(tp, TCPS_FIN_WAIT_1);
2441 tcp_state_change(tp, TCPS_LAST_ACK);
2444 if (tp->t_state >= TCPS_FIN_WAIT_2) {
2445 soisdisconnected(tp->t_inpcb->inp_socket);
2447 if (tp->t_state == TCPS_FIN_WAIT_2) {
2451 tcp_finwait2_timeout : TP_MAXIDLE(tp);
2452 tcp_timer_activate(tp, TT_2MSL, timeout);
2647 db_print_tcpcb(struct tcpcb *tp, const char *name, int indent)
2651 db_printf("%s at %p\n", name, tp);
2657 TAILQ_FIRST(&tp->t_segq), tp->t_segqlen, tp->t_dupacks);
2661 &tp->t_timers->tt_rexmt, &tp->t_timers->tt_persist, &tp->t_timers->tt_keep);
2664 db_printf("tt_2msl: %p tt_delack: %p t_inpcb: %p\n", &tp->t_timers->tt_2msl,
2665 &tp->t_timers->tt_delack, tp->t_inpcb);
2668 db_printf("t_state: %d (", tp->t_state);
2669 db_print_tstate(tp->t_state);
2673 db_printf("t_flags: 0x%x (", tp->t_flags);
2674 db_print_tflags(tp->t_flags);
2679 tp->snd_una, tp->snd_max, tp->snd_nxt);
2683 tp->snd_up, tp->snd_wl1, tp->snd_wl2);
2687 tp->iss, tp->irs, tp->rcv_nxt);
2691 tp->rcv_adv, tp->rcv_wnd, tp->rcv_up);
2695 tp->snd_wnd, tp->snd_cwnd);
2699 "0x%08x\n", tp->snd_ssthresh, tp->snd_recover);
2703 tp->t_rcvtime, tp->t_starttime);
2707 tp->t_rtttime, tp->t_rtseq);
2711 tp->t_rxtcur, tp->t_maxseg, tp->t_srtt);
2715 "t_rttbest: %u\n", tp->t_rttvar, tp->t_rxtshift, tp->t_rttmin,
2716 tp->t_rttbest);
2720 tp->t_rttupdated, tp->max_sndwnd, tp->t_softerror);
2723 db_printf("t_oobflags: 0x%x (", tp->t_oobflags);
2724 db_print_toobflags(tp->t_oobflags);
2725 db_printf(") t_iobc: 0x%02x\n", tp->t_iobc);
2729 tp->snd_scale, tp->rcv_scale, tp->request_r_scale);
2733 tp->ts_recent, tp->ts_recent_age);
2737 "%u\n", tp->ts_offset, tp->last_ack_sent, tp->snd_cwnd_prev);
2741 "t_badrxtwin: %u\n", tp->snd_ssthresh_prev,
2742 tp->snd_recover_prev, tp->t_badrxtwin);
2746 tp->snd_numholes, TAILQ_FIRST(&tp->snd_holes));
2750 "0x%08x\n", tp->snd_fack, tp->rcv_numsacks, tp->sack_newdata);
2756 tp->t_rttlow, tp->rfbuf_ts, tp->rfbuf_cnt);
2761 struct tcpcb *tp;
2767 tp = (struct tcpcb *)addr;
2769 db_print_tcpcb(tp, "tcpcb", 0);