Lines Matching refs:tp
337 static int tcp_default_fb_init(struct tcpcb *tp, void **ptr);
338 static void tcp_default_fb_fini(struct tcpcb *tp, int tcb_is_purged);
339 static int tcp_default_handoff_ok(struct tcpcb *tp);
346 static void tcp_default_switch_failed(struct tcpcb *tp);
368 tcp_record_dsack(struct tcpcb *tp, tcp_seq start, tcp_seq end, int tlp) in tcp_record_dsack() argument
371 tp->t_dsack_pack++; in tcp_record_dsack()
374 tp->t_dsack_bytes += (end - start); in tcp_record_dsack()
377 tp->t_dsack_tlp_bytes += (start - end); in tcp_record_dsack()
382 tp->t_dsack_bytes += (end - start); in tcp_record_dsack()
385 tp->t_dsack_tlp_bytes += (start - end); in tcp_record_dsack()
496 tcp_switch_back_to_default(struct tcpcb *tp) in tcp_switch_back_to_default() argument
501 KASSERT(tp->t_fb != &tcp_def_funcblk, in tcp_switch_back_to_default()
504 if (tp->t_fb->tfb_tcp_timer_stop_all != NULL) in tcp_switch_back_to_default()
505 tp->t_fb->tfb_tcp_timer_stop_all(tp); in tcp_switch_back_to_default()
514 if (tfb == tp->t_fb) { in tcp_switch_back_to_default()
519 if (tfb != NULL && (*tfb->tfb_tcp_handoff_ok)(tp)) { in tcp_switch_back_to_default()
527 (*tfb->tfb_tcp_fb_init)(tp, &ptr) == 0) { in tcp_switch_back_to_default()
529 if (tp->t_fb->tfb_tcp_fb_fini != NULL) in tcp_switch_back_to_default()
530 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0); in tcp_switch_back_to_default()
531 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_switch_back_to_default()
533 tp->t_fb = tfb; in tcp_switch_back_to_default()
534 tp->t_fb_ptr = ptr; in tcp_switch_back_to_default()
553 if ((*tfb->tfb_tcp_handoff_ok)(tp)) { in tcp_switch_back_to_default()
558 (*tfb->tfb_tcp_fb_init)(tp, &ptr)) { in tcp_switch_back_to_default()
563 if (tp->t_fb->tfb_tcp_fb_fini != NULL) in tcp_switch_back_to_default()
564 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 0); in tcp_switch_back_to_default()
565 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_switch_back_to_default()
567 tp->t_fb = tfb; in tcp_switch_back_to_default()
568 tp->t_fb_ptr = ptr; in tcp_switch_back_to_default()
1013 tcp_default_handoff_ok(struct tcpcb *tp) in tcp_default_handoff_ok() argument
1029 tcp_default_fb_init(struct tcpcb *tp, void **ptr) in tcp_default_fb_init() argument
1031 struct socket *so = tptosocket(tp); in tcp_default_fb_init()
1034 INP_WLOCK_ASSERT(tptoinpcb(tp)); in tcp_default_fb_init()
1038 KASSERT(tp->t_state < TCPS_TIME_WAIT, in tcp_default_fb_init()
1039 ("%s: connection %p in unexpected state %d", __func__, tp, in tcp_default_fb_init()
1040 tp->t_state)); in tcp_default_fb_init()
1044 tcp_lro_features_off(tp); in tcp_default_fb_init()
1047 tp->t_flags &= ~TF_GPUTINPROG; in tcp_default_fb_init()
1049 tcp_change_time_units(tp, TCP_TMR_GRANULARITY_TICKS); in tcp_default_fb_init()
1050 if ((tp->t_state == TCPS_SYN_SENT) || in tcp_default_fb_init()
1051 (tp->t_state == TCPS_SYN_RECEIVED)) in tcp_default_fb_init()
1052 rexmt = tcp_rexmit_initial * tcp_backoff[tp->t_rxtshift]; in tcp_default_fb_init()
1054 rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; in tcp_default_fb_init()
1055 if (tp->t_rxtshift == 0) in tcp_default_fb_init()
1056 tp->t_rxtcur = rexmt; in tcp_default_fb_init()
1058 TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, TCPTV_REXMTMAX); in tcp_default_fb_init()
1064 if (tp->t_state <= TCPS_LISTEN || tp->t_state >= TCPS_TIME_WAIT) in tcp_default_fb_init()
1071 if ((!TCPS_HAVEESTABLISHED(tp->t_state) || sbavail(&so->so_snd) || in tcp_default_fb_init()
1072 tp->snd_una != tp->snd_max) && !(tcp_timer_active(tp, TT_REXMT) || in tcp_default_fb_init()
1073 tcp_timer_active(tp, TT_PERSIST))) { in tcp_default_fb_init()
1079 if (TCPS_HAVEESTABLISHED(tp->t_state) && tp->snd_wnd == 0 && in tcp_default_fb_init()
1080 (int32_t)(tp->snd_nxt - tp->snd_una) < in tcp_default_fb_init()
1082 tcp_setpersist(tp); in tcp_default_fb_init()
1084 tcp_timer_activate(tp, TT_REXMT, TP_RXTCUR(tp)); in tcp_default_fb_init()
1088 if (!tcp_timer_active(tp, TT_KEEP)) in tcp_default_fb_init()
1089 tcp_timer_activate(tp, TT_KEEP, in tcp_default_fb_init()
1090 TCPS_HAVEESTABLISHED(tp->t_state) ? TP_KEEPIDLE(tp) : in tcp_default_fb_init()
1091 TP_KEEPINIT(tp)); in tcp_default_fb_init()
1097 if IN_FASTRECOVERY(tp->t_flags) { in tcp_default_fb_init()
1098 if (tp->sackhint.recover_fs == 0) in tcp_default_fb_init()
1099 tp->sackhint.recover_fs = max(1, in tcp_default_fb_init()
1100 tp->snd_nxt - tp->snd_una); in tcp_default_fb_init()
1113 tcp_default_fb_fini(struct tcpcb *tp, int tcb_is_purged) in tcp_default_fb_fini() argument
1116 INP_WLOCK_ASSERT(tptoinpcb(tp)); in tcp_default_fb_fini()
1119 tcp_log_flowend(tp); in tcp_default_fb_fini()
1121 tp->t_acktime = 0; in tcp_default_fb_fini()
1342 struct tcpcb *tp; in deregister_tcp_functions() local
1354 tp = intotcpcb(inp); in deregister_tcp_functions()
1355 if (tp == NULL || tp->t_fb != blk) in deregister_tcp_functions()
1357 tcp_switch_back_to_default(tp); in deregister_tcp_functions()
1736 tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, in tcp_respond() argument
1760 KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); in tcp_respond()
1769 if (tp != NULL) { in tcp_respond()
1770 inp = tptoinpcb(tp); in tcp_respond()
1786 port = tp->t_port; in tcp_respond()
1790 if (tp != NULL) { in tcp_respond()
1793 if (win > TCP_MAXWIN << tp->rcv_scale) in tcp_respond()
1794 win = TCP_MAXWIN << tp->rcv_scale; in tcp_respond()
1796 if ((tp->t_flags & TF_NOOPT) == 0) in tcp_respond()
1941 ect = tcp_ecn_output_established(tp, &flags, 0, false); in tcp_respond()
1957 if (tp->t_flags & TF_RCVD_TSTMP) { in tcp_respond()
1958 to.to_tsval = tcp_ts_getticks() + tp->ts_offset; in tcp_respond()
1959 to.to_tsecr = tp->ts_recent; in tcp_respond()
1964 if (tp->t_flags & TF_SIGNATURE) in tcp_respond()
2038 if (tp && (flags & TH_RST)) { in tcp_respond()
2040 tcp_log_end_status(tp, TCP_EI_STATUS_SERVER_RST); in tcp_respond()
2042 if (tp != NULL) in tcp_respond()
2043 nth->th_win = htons((u_short) (win >> tp->rcv_scale)); in tcp_respond()
2093 TCP_PROBE3(debug__output, tp, th, m); in tcp_respond()
2095 TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth); in tcp_respond()
2097 if ((tp != NULL) && tcp_bblogging_on(tp)) { in tcp_respond()
2103 log.u_bbr.inhpts = tcp_in_hpts(tp); in tcp_respond()
2105 log.u_bbr.pkts_out = tp->t_maxseg; in tcp_respond()
2108 lgb = tcp_log_event(tp, nth, NULL, NULL, TCP_LOG_OUT, in tcp_respond()
2132 (tp->t_state == TCPS_CLOSED || in tcp_respond()
2133 (tp->t_state > TCPS_LISTEN && tp->t_port != port)), in tcp_respond()
2137 ntohs(port), tcpstates[tp->t_state])); in tcp_respond()
2149 TCP_PROBE5(send, NULL, tp, ip6, tp, nth); in tcp_respond()
2159 TCP_PROBE5(send, NULL, tp, ip, tp, nth); in tcp_respond()
2172 tcp_send_challenge_ack(struct tcpcb *tp, struct tcphdr *th, struct mbuf *m) in tcp_send_challenge_ack() argument
2183 if (tp->t_challenge_ack_end < now) { in tcp_send_challenge_ack()
2184 tp->t_challenge_ack_cnt = 0; in tcp_send_challenge_ack()
2185 tp->t_challenge_ack_end = now + in tcp_send_challenge_ack()
2192 if (tp->t_challenge_ack_cnt < V_tcp_ack_war_cnt) { in tcp_send_challenge_ack()
2194 tp->t_challenge_ack_cnt++; in tcp_send_challenge_ack()
2200 tcp_respond(tp, mtod(m, void *), th, m, tp->rcv_nxt, in tcp_send_challenge_ack()
2201 tp->snd_nxt, TH_ACK); in tcp_send_challenge_ack()
2202 tp->last_ack_sent = tp->rcv_nxt; in tcp_send_challenge_ack()
2216 struct tcpcb *tp = intotcpcb(inp); in tcp_newtcpcb() local
2226 bzero(&tp->t_start_zero, t_zero_size); in tcp_newtcpcb()
2229 tp->t_ccv.tp = tp; in tcp_newtcpcb()
2239 tp->t_fb = listening_tcb->t_fb; in tcp_newtcpcb()
2241 tp->t_fb = V_tcp_func_set_ptr; in tcp_newtcpcb()
2243 refcount_acquire(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2244 KASSERT((tp->t_fb->tfb_flags & TCP_FUNC_BEING_REMOVED) == 0, in tcp_newtcpcb()
2251 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2252 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2253 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2256 CC_ALGO(tp) = CC_ALGO(listening_tcb); in tcp_newtcpcb()
2258 CC_ALGO(tp) = CC_DEFAULT_ALGO(); in tcp_newtcpcb()
2259 cc_refer(CC_ALGO(tp)); in tcp_newtcpcb()
2261 if (CC_ALGO(tp)->cb_init != NULL) in tcp_newtcpcb()
2262 if (CC_ALGO(tp)->cb_init(&tp->t_ccv, NULL) > 0) { in tcp_newtcpcb()
2263 cc_detach(tp); in tcp_newtcpcb()
2264 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2265 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2266 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2271 if (khelp_init_osd(HELPER_CLASS_TCP, &tp->t_osd)) { in tcp_newtcpcb()
2272 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_newtcpcb()
2273 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_newtcpcb()
2274 CC_DATA(tp) = NULL; in tcp_newtcpcb()
2275 cc_detach(tp); in tcp_newtcpcb()
2276 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_newtcpcb()
2277 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_newtcpcb()
2278 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2283 TAILQ_INIT(&tp->t_segq); in tcp_newtcpcb()
2284 STAILQ_INIT(&tp->t_inqueue); in tcp_newtcpcb()
2285 tp->t_maxseg = in tcp_newtcpcb()
2292 tcp_lro_features_off(tp); in tcp_newtcpcb()
2294 tp->t_hpts_cpu = HPTS_CPU_NONE; in tcp_newtcpcb()
2295 tp->t_lro_cpu = HPTS_CPU_NONE; in tcp_newtcpcb()
2297 callout_init_rw(&tp->t_callout, &inp->inp_lock, in tcp_newtcpcb()
2300 tp->t_timers[i] = SBT_MAX; in tcp_newtcpcb()
2307 tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP); in tcp_newtcpcb()
2310 tp->t_flags = TF_REQ_SCALE; in tcp_newtcpcb()
2313 tp->t_flags = TF_REQ_TSTMP; in tcp_newtcpcb()
2317 tp->t_flags |= TF_SACK_PERMIT; in tcp_newtcpcb()
2318 TAILQ_INIT(&tp->snd_holes); in tcp_newtcpcb()
2325 tp->t_srtt = TCPTV_SRTTBASE; in tcp_newtcpcb()
2326 tp->t_rttvar = ((tcp_rexmit_initial - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4; in tcp_newtcpcb()
2327 tp->t_rttmin = tcp_rexmit_min; in tcp_newtcpcb()
2328 tp->t_rxtcur = tcp_rexmit_initial; in tcp_newtcpcb()
2329 tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; in tcp_newtcpcb()
2330 tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; in tcp_newtcpcb()
2331 tp->t_rcvtime = ticks; in tcp_newtcpcb()
2333 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_TICKS; in tcp_newtcpcb()
2344 tcp_pcap_tcpcb_init(tp); in tcp_newtcpcb()
2348 tcp_log_tcpcbinit(tp); in tcp_newtcpcb()
2350 tp->t_pacing_rate = -1; in tcp_newtcpcb()
2351 if (tp->t_fb->tfb_tcp_fb_init) { in tcp_newtcpcb()
2352 if ((*tp->t_fb->tfb_tcp_fb_init)(tp, &tp->t_fb_ptr)) { in tcp_newtcpcb()
2353 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_newtcpcb()
2354 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_newtcpcb()
2355 CC_DATA(tp) = NULL; in tcp_newtcpcb()
2356 cc_detach(tp); in tcp_newtcpcb()
2358 khelp_destroy_osd(&tp->t_osd); in tcp_newtcpcb()
2360 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_newtcpcb()
2366 tp->t_stats = stats_blob_alloc(V_tcp_perconn_stats_dflt_tpl, 0); in tcp_newtcpcb()
2369 tp->t_flags |= TF_LRD; in tcp_newtcpcb()
2371 return (tp); in tcp_newtcpcb()
2380 tcp_drop(struct tcpcb *tp, int errno) in tcp_drop() argument
2382 struct socket *so = tptosocket(tp); in tcp_drop()
2385 INP_WLOCK_ASSERT(tptoinpcb(tp)); in tcp_drop()
2387 if (TCPS_HAVERCVDSYN(tp->t_state)) { in tcp_drop()
2388 tcp_state_change(tp, TCPS_CLOSED); in tcp_drop()
2390 (void)tcp_output_nodrop(tp); in tcp_drop()
2394 if (errno == ETIMEDOUT && tp->t_softerror) in tcp_drop()
2395 errno = tp->t_softerror; in tcp_drop()
2397 return (tcp_close(tp)); in tcp_drop()
2401 tcp_discardcb(struct tcpcb *tp) in tcp_discardcb() argument
2403 struct inpcb *inp = tptoinpcb(tp); in tcp_discardcb()
2404 struct socket *so = tptosocket(tp); in tcp_discardcb()
2411 MPASS(!callout_active(&tp->t_callout)); in tcp_discardcb()
2412 MPASS(TAILQ_EMPTY(&tp->snd_holes)); in tcp_discardcb()
2415 tcp_reass_flush(tp); in tcp_discardcb()
2419 if (tp->t_flags & TF_TOE) in tcp_discardcb()
2420 tcp_offload_detach(tp); in tcp_discardcb()
2424 tcp_pcap_drain(&(tp->t_inpkts)); in tcp_discardcb()
2425 tcp_pcap_drain(&(tp->t_outpkts)); in tcp_discardcb()
2429 if (CC_ALGO(tp)->cb_destroy != NULL) in tcp_discardcb()
2430 CC_ALGO(tp)->cb_destroy(&tp->t_ccv); in tcp_discardcb()
2431 CC_DATA(tp) = NULL; in tcp_discardcb()
2433 cc_detach(tp); in tcp_discardcb()
2436 khelp_destroy_osd(&tp->t_osd); in tcp_discardcb()
2439 stats_blob_destroy(tp->t_stats); in tcp_discardcb()
2442 CC_ALGO(tp) = NULL; in tcp_discardcb()
2443 if ((m = STAILQ_FIRST(&tp->t_inqueue)) != NULL) { in tcp_discardcb()
2446 STAILQ_INIT(&tp->t_inqueue); in tcp_discardcb()
2447 STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, prev) in tcp_discardcb()
2450 TCPSTATES_DEC(tp->t_state); in tcp_discardcb()
2452 if (tp->t_fb->tfb_tcp_fb_fini) in tcp_discardcb()
2453 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); in tcp_discardcb()
2454 MPASS(!tcp_in_hpts(tp)); in tcp_discardcb()
2456 tcp_log_tcpcbfini(tp); in tcp_discardcb()
2473 if (tp->t_rttupdated >= 4) { in tcp_discardcb()
2484 ssthresh = tp->snd_ssthresh; in tcp_discardcb()
2490 ssthresh = (ssthresh + tp->t_maxseg / 2) / tp->t_maxseg; in tcp_discardcb()
2493 ssthresh *= (tp->t_maxseg + in tcp_discardcb()
2507 metrics.hc_rtt = tp->t_srtt; in tcp_discardcb()
2508 metrics.hc_rttvar = tp->t_rttvar; in tcp_discardcb()
2509 metrics.hc_cwnd = tp->snd_cwnd; in tcp_discardcb()
2516 refcount_release(&tp->t_fb->tfb_refcnt); in tcp_discardcb()
2524 tcp_close(struct tcpcb *tp) in tcp_close() argument
2526 struct inpcb *inp = tptoinpcb(tp); in tcp_close()
2527 struct socket *so = tptosocket(tp); in tcp_close()
2532 if (tp->t_state == TCPS_LISTEN) in tcp_close()
2533 tcp_offload_listen_stop(tp); in tcp_close()
2540 if (tp->t_tfo_pending) { in tcp_close()
2541 tcp_fastopen_decrement_counter(tp->t_tfo_pending); in tcp_close()
2542 tp->t_tfo_pending = NULL; in tcp_close()
2544 tcp_timer_stop(tp); in tcp_close()
2545 if (tp->t_fb->tfb_tcp_timer_stop_all != NULL) in tcp_close()
2546 tp->t_fb->tfb_tcp_timer_stop_all(tp); in tcp_close()
2549 if (tp->t_state != TCPS_CLOSED) in tcp_close()
2550 tcp_state_change(tp, TCPS_CLOSED); in tcp_close()
2552 tcp_free_sackholes(tp); in tcp_close()
2560 return (tp); in tcp_close()
2574 struct tcpcb *tp; in tcp_notify() local
2578 tp = intotcpcb(inp); in tcp_notify()
2579 KASSERT(tp != NULL, ("tcp_notify: tp == NULL")); in tcp_notify()
2588 if (tp->t_state == TCPS_ESTABLISHED && in tcp_notify()
2596 } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 && in tcp_notify()
2597 tp->t_softerror) { in tcp_notify()
2598 tp = tcp_drop(tp, error); in tcp_notify()
2599 if (tp != NULL) in tcp_notify()
2604 tp->t_softerror = error; in tcp_notify()
2818 struct tcpcb *tp; in tcp_ctlinput_with_port() local
2853 tp = intotcpcb(inp); in tcp_ctlinput_with_port()
2855 if (tp->t_flags & TF_TOE && errno == EMSGSIZE) { in tcp_ctlinput_with_port()
2861 tcp_offload_pmtu_update(tp, icmp_tcp_seq, mtu); in tcp_ctlinput_with_port()
2865 if (tp->t_port != port) in tcp_ctlinput_with_port()
2867 if (SEQ_GEQ(ntohl(icmp_tcp_seq), tp->snd_una) && in tcp_ctlinput_with_port()
2868 SEQ_LT(ntohl(icmp_tcp_seq), tp->snd_max)) { in tcp_ctlinput_with_port()
2880 if (mtu < tp->t_maxseg + in tcp_ctlinput_with_port()
2971 struct tcpcb *tp; in tcp6_ctlinput_with_port() local
3042 tp = intotcpcb(inp); in tcp6_ctlinput_with_port()
3044 if (tp->t_flags & TF_TOE && errno == EMSGSIZE) { in tcp6_ctlinput_with_port()
3047 tcp_offload_pmtu_update(tp, icmp_tcp_seq, mtu); in tcp6_ctlinput_with_port()
3051 if (tp->t_port != port) in tcp6_ctlinput_with_port()
3053 if (SEQ_GEQ(ntohl(icmp_tcp_seq), tp->snd_una) && in tcp6_ctlinput_with_port()
3054 SEQ_LT(ntohl(icmp_tcp_seq), tp->snd_max)) { in tcp6_ctlinput_with_port()
3075 if (mtu < tp->t_maxseg + in tcp6_ctlinput_with_port()
3283 struct tcpcb *tp; in tcp_drop_syn_sent() local
3288 tp = intotcpcb(inp); in tcp_drop_syn_sent()
3289 if (tp->t_state != TCPS_SYN_SENT) in tcp_drop_syn_sent()
3292 if (tp->t_flags & TF_FASTOPEN) in tcp_drop_syn_sent()
3293 tcp_fastopen_disable_path(tp); in tcp_drop_syn_sent()
3295 tp = tcp_drop(tp, errno); in tcp_drop_syn_sent()
3296 if (tp != NULL) in tcp_drop_syn_sent()
3318 struct tcpcb *tp; in tcp_mtudisc() local
3323 tp = intotcpcb(inp); in tcp_mtudisc()
3324 KASSERT(tp != NULL, ("tcp_mtudisc: tp == NULL")); in tcp_mtudisc()
3326 tcp_mss_update(tp, -1, mtuoffer, NULL, NULL); in tcp_mtudisc()
3331 if (so->so_snd.sb_hiwat < tp->t_maxseg) { in tcp_mtudisc()
3332 tp->t_maxseg = so->so_snd.sb_hiwat; in tcp_mtudisc()
3333 if (tp->t_maxseg < V_tcp_mssdflt) { in tcp_mtudisc()
3339 tp->t_flags2 |= TF2_PROC_SACK_PROHIBIT; in tcp_mtudisc()
3341 tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT; in tcp_mtudisc()
3347 tp->t_rtttime = 0; in tcp_mtudisc()
3348 tp->snd_nxt = tp->snd_una; in tcp_mtudisc()
3349 tcp_free_sackholes(tp); in tcp_mtudisc()
3350 tp->snd_recover = tp->snd_max; in tcp_mtudisc()
3351 if (tp->t_flags & TF_SACK_PERMIT) in tcp_mtudisc()
3352 EXIT_FASTRECOVERY(tp->t_flags); in tcp_mtudisc()
3353 if (tp->t_fb->tfb_tcp_mtu_chg != NULL) { in tcp_mtudisc()
3360 tp->t_fb->tfb_tcp_mtu_chg(tp); in tcp_mtudisc()
3362 if (tcp_output(tp) < 0) in tcp_mtudisc()
3458 tcp6_use_min_mtu(struct tcpcb *tp) in tcp6_use_min_mtu() argument
3460 struct inpcb *inp = tptoinpcb(tp); in tcp6_use_min_mtu()
3474 if ((tp->t_state >= TCPS_SYN_SENT) && in tcp6_use_min_mtu()
3480 tp->t_maxseg > TCP6_MSS) { in tcp6_use_min_mtu()
3481 tp->t_maxseg = TCP6_MSS; in tcp6_use_min_mtu()
3482 if (tp->t_maxseg < V_tcp_mssdflt) { in tcp6_use_min_mtu()
3488 tp->t_flags2 |= TF2_PROC_SACK_PROHIBIT; in tcp6_use_min_mtu()
3490 tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT; in tcp6_use_min_mtu()
3502 tcp_maxseg(const struct tcpcb *tp) in tcp_maxseg() argument
3506 if (tp->t_flags & TF_NOOPT) in tcp_maxseg()
3507 return (tp->t_maxseg); in tcp_maxseg()
3516 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_maxseg()
3517 if (tp->t_flags & TF_RCVD_TSTMP) in tcp_maxseg()
3522 if (tp->t_flags & TF_SIGNATURE) in tcp_maxseg()
3525 if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { in tcp_maxseg()
3527 optlen += tp->rcv_numsacks * TCPOLEN_SACK; in tcp_maxseg()
3531 if (tp->t_flags & TF_REQ_TSTMP) in tcp_maxseg()
3535 if (tp->t_flags & TF_REQ_SCALE) in tcp_maxseg()
3538 if (tp->t_flags & TF_SIGNATURE) in tcp_maxseg()
3541 if (tp->t_flags & TF_SACK_PERMIT) in tcp_maxseg()
3545 return (tp->t_maxseg - optlen); in tcp_maxseg()
3550 tcp_fixed_maxseg(const struct tcpcb *tp) in tcp_fixed_maxseg() argument
3554 if (tp->t_flags & TF_NOOPT) in tcp_fixed_maxseg()
3555 return (tp->t_maxseg); in tcp_fixed_maxseg()
3565 if (TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_fixed_maxseg()
3566 if (tp->t_flags & TF_RCVD_TSTMP) in tcp_fixed_maxseg()
3571 if (tp->t_flags & TF_SIGNATURE) in tcp_fixed_maxseg()
3575 if (tp->t_flags & TF_REQ_TSTMP) in tcp_fixed_maxseg()
3579 if (tp->t_flags & TF_REQ_SCALE) in tcp_fixed_maxseg()
3582 if (tp->t_flags & TF_SIGNATURE) in tcp_fixed_maxseg()
3585 if (tp->t_flags & TF_SACK_PERMIT) in tcp_fixed_maxseg()
3589 return (tp->t_maxseg - optlen); in tcp_fixed_maxseg()
3600 struct tcpcb *tp; in sysctl_drop() local
3683 tp = intotcpcb(inp); in sysctl_drop()
3684 tp = tcp_drop(tp, ECONNABORTED); in sysctl_drop()
3685 if (tp != NULL) in sysctl_drop()
3945 tcp_state_change(struct tcpcb *tp, int newstate) in tcp_state_change() argument
3948 int pstate = tp->t_state; in tcp_state_change()
3951 TCPSTATES_DEC(tp->t_state); in tcp_state_change()
3953 tp->t_state = newstate; in tcp_state_change()
3954 TCP_PROBE6(state__change, NULL, tp, NULL, tp, NULL, pstate); in tcp_state_change()
3968 struct tcpcb *tp = intotcpcb(inp); in tcp_inptoxtp() local
3972 xt->t_state = tp->t_state; in tcp_inptoxtp()
3973 xt->t_logstate = tcp_get_bblog_state(tp); in tcp_inptoxtp()
3974 xt->t_flags = tp->t_flags; in tcp_inptoxtp()
3975 xt->t_sndzerowin = tp->t_sndzerowin; in tcp_inptoxtp()
3976 xt->t_sndrexmitpack = tp->t_sndrexmitpack; in tcp_inptoxtp()
3977 xt->t_rcvoopack = tp->t_rcvoopack; in tcp_inptoxtp()
3978 xt->t_rcv_wnd = tp->rcv_wnd; in tcp_inptoxtp()
3979 xt->t_snd_wnd = tp->snd_wnd; in tcp_inptoxtp()
3980 xt->t_snd_cwnd = tp->snd_cwnd; in tcp_inptoxtp()
3981 xt->t_snd_ssthresh = tp->snd_ssthresh; in tcp_inptoxtp()
3982 xt->t_dsack_bytes = tp->t_dsack_bytes; in tcp_inptoxtp()
3983 xt->t_dsack_tlp_bytes = tp->t_dsack_tlp_bytes; in tcp_inptoxtp()
3984 xt->t_dsack_pack = tp->t_dsack_pack; in tcp_inptoxtp()
3985 xt->t_maxseg = tp->t_maxseg; in tcp_inptoxtp()
3986 xt->xt_ecn = (tp->t_flags2 & TF2_ECN_PERMIT) ? 1 : 0 + in tcp_inptoxtp()
3987 (tp->t_flags2 & TF2_ACE_PERMIT) ? 2 : 0; in tcp_inptoxtp()
3991 if (tp->t_timers[which] != SBT_MAX) \ in tcp_inptoxtp()
3992 xt->where = (tp->t_timers[which] - now) / SBT_1MS; \ in tcp_inptoxtp()
4002 xt->t_rcvtime = 1000 * (ticks - tp->t_rcvtime) / hz; in tcp_inptoxtp()
4004 xt->xt_encaps_port = tp->t_port; in tcp_inptoxtp()
4005 bcopy(tp->t_fb->tfb_tcp_block_name, xt->xt_stack, in tcp_inptoxtp()
4007 bcopy(CC_ALGO(tp)->name, xt->xt_cc, TCP_CA_NAME_MAX); in tcp_inptoxtp()
4009 (void)tcp_log_get_id(tp, xt->xt_logid); in tcp_inptoxtp()
4017 tcp_log_end_status(struct tcpcb *tp, uint8_t status) in tcp_log_end_status() argument
4021 if ((tp == NULL) || in tcp_log_end_status()
4032 if (bit & tp->t_end_info_status) { in tcp_log_end_status()
4037 if (tp->t_end_info_bytes[i] == TCP_EI_EMPTY_SLOT) { in tcp_log_end_status()
4038 tp->t_end_info_bytes[i] = status; in tcp_log_end_status()
4039 tp->t_end_info_status |= bit; in tcp_log_end_status()
4119 tcp_default_switch_failed(struct tcpcb *tp) in tcp_default_switch_failed() argument
4131 tcp_lro_features_off(tp); in tcp_default_switch_failed()
4132 tcp_change_time_units(tp, TCP_TMR_GRANULARITY_TICKS); in tcp_default_switch_failed()
4137 tcp_do_ack_accounting(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to, uint32_t tiwin, int m… in tcp_do_ack_accounting() argument
4139 if (SEQ_LT(th->th_ack, tp->snd_una)) { in tcp_do_ack_accounting()
4142 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4143 tp->tcp_cnt_counters[ACK_SACK]++; in tcp_do_ack_accounting()
4147 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4148 tp->tcp_cnt_counters[ACK_BEHIND]++; in tcp_do_ack_accounting()
4152 } else if (th->th_ack == tp->snd_una) { in tcp_do_ack_accounting()
4155 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4156 tp->tcp_cnt_counters[ACK_SACK]++; in tcp_do_ack_accounting()
4159 } else if (tiwin != tp->snd_wnd) { in tcp_do_ack_accounting()
4160 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4161 tp->tcp_cnt_counters[ACK_RWND]++; in tcp_do_ack_accounting()
4165 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4166 tp->tcp_cnt_counters[ACK_DUPACK]++; in tcp_do_ack_accounting()
4171 if (!SEQ_GT(th->th_ack, tp->snd_max)) { in tcp_do_ack_accounting()
4172 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4173 tp->tcp_cnt_counters[CNT_OF_ACKS_IN] += (((th->th_ack - tp->snd_una) + mss - 1)/mss); in tcp_do_ack_accounting()
4177 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4178 tp->tcp_cnt_counters[ACK_CUMACK_SACK]++; in tcp_do_ack_accounting()
4182 if (tp->t_flags2 & TF2_TCP_ACCOUNTING) { in tcp_do_ack_accounting()
4183 tp->tcp_cnt_counters[ACK_CUMACK]++; in tcp_do_ack_accounting()
4192 tcp_change_time_units(struct tcpcb *tp, int granularity) in tcp_change_time_units() argument
4194 if (tp->t_tmr_granularity == granularity) { in tcp_change_time_units()
4199 KASSERT((tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS), in tcp_change_time_units()
4201 tp->t_tmr_granularity, tp)); in tcp_change_time_units()
4202 tp->t_rttlow = TICKS_2_USEC(tp->t_rttlow); in tcp_change_time_units()
4203 if (tp->t_srtt > 1) { in tcp_change_time_units()
4206 val = tp->t_srtt >> TCP_RTT_SHIFT; in tcp_change_time_units()
4207 frac = tp->t_srtt & 0x1f; in tcp_change_time_units()
4208 tp->t_srtt = TICKS_2_USEC(val); in tcp_change_time_units()
4220 tp->t_srtt += frac; in tcp_change_time_units()
4223 if (tp->t_rttvar) { in tcp_change_time_units()
4226 val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; in tcp_change_time_units()
4227 frac = tp->t_rttvar & 0x1f; in tcp_change_time_units()
4228 tp->t_rttvar = TICKS_2_USEC(val); in tcp_change_time_units()
4240 tp->t_rttvar += frac; in tcp_change_time_units()
4243 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_USEC; in tcp_change_time_units()
4246 KASSERT((tp->t_tmr_granularity == TCP_TMR_GRANULARITY_USEC), in tcp_change_time_units()
4248 tp->t_tmr_granularity, tp)); in tcp_change_time_units()
4249 if (tp->t_srtt > 1) { in tcp_change_time_units()
4252 val = USEC_2_TICKS(tp->t_srtt); in tcp_change_time_units()
4253 frac = tp->t_srtt % (HPTS_USEC_IN_SEC / hz); in tcp_change_time_units()
4254 tp->t_srtt = val << TCP_RTT_SHIFT; in tcp_change_time_units()
4267 tp->t_srtt += frac; in tcp_change_time_units()
4270 if (tp->t_rttvar) { in tcp_change_time_units()
4273 val = USEC_2_TICKS(tp->t_rttvar); in tcp_change_time_units()
4274 frac = tp->t_rttvar % (HPTS_USEC_IN_SEC / hz); in tcp_change_time_units()
4275 tp->t_rttvar = val << TCP_RTTVAR_SHIFT; in tcp_change_time_units()
4288 tp->t_rttvar += frac; in tcp_change_time_units()
4291 tp->t_rttlow = USEC_2_TICKS(tp->t_rttlow); in tcp_change_time_units()
4292 tp->t_tmr_granularity = TCP_TMR_GRANULARITY_TICKS; in tcp_change_time_units()
4297 granularity, tp); in tcp_change_time_units()
4303 tcp_handle_orphaned_packets(struct tcpcb *tp) in tcp_handle_orphaned_packets() argument
4315 if (tp->t_flags2 & TF2_MBUF_L_ACKS) in tcp_handle_orphaned_packets()
4317 if ((tp->t_flags2 & TF2_SUPPORTS_MBUFQ) == 0 && in tcp_handle_orphaned_packets()
4318 !STAILQ_EMPTY(&tp->t_inqueue)) { in tcp_handle_orphaned_packets()
4329 m = STAILQ_FIRST(&tp->t_inqueue); in tcp_handle_orphaned_packets()
4330 STAILQ_INIT(&tp->t_inqueue); in tcp_handle_orphaned_packets()
4331 STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, save) in tcp_handle_orphaned_packets()
4339 STAILQ_FOREACH_SAFE(m, &tp->t_inqueue, m_stailqpkt, save) { in tcp_handle_orphaned_packets()
4341 if (m == STAILQ_FIRST(&tp->t_inqueue)) in tcp_handle_orphaned_packets()
4342 STAILQ_REMOVE_HEAD(&tp->t_inqueue, in tcp_handle_orphaned_packets()
4345 STAILQ_REMOVE_AFTER(&tp->t_inqueue, in tcp_handle_orphaned_packets()
4380 tcp_req_log_req_info(struct tcpcb *tp, struct tcp_sendfile_track *req, in tcp_req_log_req_info() argument
4383 if (tcp_bblogging_on(tp)) { in tcp_req_log_req_info()
4388 log.u_bbr.inhpts = tcp_in_hpts(tp); in tcp_req_log_req_info()
4406 log.u_bbr.applimited = tp->t_tcpreq_closed; in tcp_req_log_req_info()
4408 log.u_bbr.applimited |= tp->t_tcpreq_open; in tcp_req_log_req_info()
4410 log.u_bbr.applimited |= tp->t_tcpreq_req; in tcp_req_log_req_info()
4412 TCP_LOG_EVENTP(tp, NULL, in tcp_req_log_req_info()
4413 &tptosocket(tp)->so_rcv, in tcp_req_log_req_info()
4414 &tptosocket(tp)->so_snd, in tcp_req_log_req_info()
4421 tcp_req_free_a_slot(struct tcpcb *tp, struct tcp_sendfile_track *ent) in tcp_req_free_a_slot() argument
4423 if (tp->t_tcpreq_req > 0) in tcp_req_free_a_slot()
4424 tp->t_tcpreq_req--; in tcp_req_free_a_slot()
4426 if (tp->t_tcpreq_open > 0) in tcp_req_free_a_slot()
4427 tp->t_tcpreq_open--; in tcp_req_free_a_slot()
4429 if (tp->t_tcpreq_closed > 0) in tcp_req_free_a_slot()
4430 tp->t_tcpreq_closed--; in tcp_req_free_a_slot()
4436 tcp_req_check_for_stale_entries(struct tcpcb *tp, uint64_t ts, int rm_oldest) in tcp_req_check_for_stale_entries() argument
4443 ent = &tp->t_tcpreq_info[i]; in tcp_req_check_for_stale_entries()
4469 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_STALE, in tcp_req_check_for_stale_entries()
4471 tcp_req_free_a_slot(tp, ent); in tcp_req_check_for_stale_entries()
4475 ent = &tp->t_tcpreq_info[oldest]; in tcp_req_check_for_stale_entries()
4476 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], i, TCP_TRK_REQ_LOG_STALE, in tcp_req_check_for_stale_entries()
4478 tcp_req_free_a_slot(tp, ent); in tcp_req_check_for_stale_entries()
4483 tcp_req_check_for_comp(struct tcpcb *tp, tcp_seq ack_point) in tcp_req_check_for_comp() argument
4489 if (tp->t_tcpreq_req == 0) in tcp_req_check_for_comp()
4491 if (tp->t_tcpreq_closed == 0) in tcp_req_check_for_comp()
4494 ent = &tp->t_tcpreq_info[i]; in tcp_req_check_for_comp()
4503 tcp_req_log_req_info(tp, ent, in tcp_req_check_for_comp()
4505 tcp_req_free_a_slot(tp, ent); in tcp_req_check_for_comp()
4513 tcp_req_is_entry_comp(struct tcpcb *tp, struct tcp_sendfile_track *ent, tcp_seq ack_point) in tcp_req_is_entry_comp() argument
4515 if (tp->t_tcpreq_req == 0) in tcp_req_is_entry_comp()
4517 if (tp->t_tcpreq_closed == 0) in tcp_req_is_entry_comp()
4528 tcp_req_find_a_req_that_is_completed_by(struct tcpcb *tp, tcp_seq th_ack, int *ip) in tcp_req_find_a_req_that_is_completed_by() argument
4538 if (tp->t_tcpreq_req == 0) { in tcp_req_find_a_req_that_is_completed_by()
4543 ent = &tp->t_tcpreq_info[i]; in tcp_req_find_a_req_that_is_completed_by()
4557 tcp_req_find_req_for_seq(struct tcpcb *tp, tcp_seq seq) in tcp_req_find_req_for_seq() argument
4562 if (tp->t_tcpreq_req == 0) { in tcp_req_find_req_for_seq()
4567 ent = &tp->t_tcpreq_info[i]; in tcp_req_find_req_for_seq()
4568 tcp_req_log_req_info(tp, ent, i, TCP_TRK_REQ_LOG_SEARCH, in tcp_req_find_req_for_seq()
4582 (tp->t_tcpreq_closed == 0)) in tcp_req_find_req_for_seq()
4601 tcp_req_alloc_req_full(struct tcpcb *tp, struct tcp_snd_req *req, uint64_t ts, int rec_dups) in tcp_req_alloc_req_full() argument
4607 tcp_req_check_for_comp(tp, tp->snd_una); in tcp_req_alloc_req_full()
4609 if (tp->t_tcpreq_req) in tcp_req_alloc_req_full()
4610 tcp_req_check_for_stale_entries(tp, ts, in tcp_req_alloc_req_full()
4611 (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ)); in tcp_req_alloc_req_full()
4613 if (tp->t_tcpreq_req) { in tcp_req_alloc_req_full()
4615 fil = &tp->t_tcpreq_info[i]; in tcp_req_alloc_req_full()
4634 if (tp->t_tcpreq_req >= MAX_TCP_TRK_REQ) { in tcp_req_alloc_req_full()
4635 tcp_trace_point(tp, TCP_TP_REQ_LOG_FAIL); in tcp_req_alloc_req_full()
4637 tcp_req_log_req_info(tp, &tp->t_tcpreq_info[i], in tcp_req_alloc_req_full()
4643 fil = &tp->t_tcpreq_info[i]; in tcp_req_alloc_req_full()
4662 fil->sbcc_at_s = tptosocket(tp)->so_snd.sb_ccc; in tcp_req_alloc_req_full()
4663 fil->start_seq = tp->snd_una + in tcp_req_alloc_req_full()
4664 tptosocket(tp)->so_snd.sb_ccc; in tcp_req_alloc_req_full()
4669 if (tptosocket(tp)->so_snd.sb_tls_info) { in tcp_req_alloc_req_full()
4675 tptosocket(tp), (fil->end - fil->start)); in tcp_req_alloc_req_full()
4677 tp->t_tcpreq_req++; in tcp_req_alloc_req_full()
4679 tp->t_tcpreq_open++; in tcp_req_alloc_req_full()
4681 tp->t_tcpreq_closed++; in tcp_req_alloc_req_full()
4682 tcp_req_log_req_info(tp, fil, i, in tcp_req_alloc_req_full()
4692 tcp_req_alloc_req(struct tcpcb *tp, union tcp_log_userdata *user, uint64_t ts) in tcp_req_alloc_req() argument
4694 (void)tcp_req_alloc_req_full(tp, &user->tcp_req, ts, 1); in tcp_req_alloc_req()
4699 tcp_log_socket_option(struct tcpcb *tp, uint32_t option_num, uint32_t option_val, int err) in tcp_log_socket_option() argument
4701 if (tcp_bblogging_on(tp)) { in tcp_log_socket_option()
4704 l = tcp_log_event(tp, NULL, in tcp_log_socket_option()
4705 &tptosocket(tp)->so_rcv, in tcp_log_socket_option()
4706 &tptosocket(tp)->so_snd, in tcp_log_socket_option()
4718 tcp_get_srtt(struct tcpcb *tp, int granularity) in tcp_get_srtt() argument
4727 srtt = tp->t_srtt; in tcp_get_srtt()
4734 if (tp->t_tmr_granularity != granularity) { in tcp_get_srtt()
4747 if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS) in tcp_get_srtt()
4754 tcp_account_for_send(struct tcpcb *tp, uint32_t len, uint8_t is_rxt, in tcp_account_for_send() argument
4759 tp->t_sndtlppack++; in tcp_account_for_send()
4760 tp->t_sndtlpbyte += len; in tcp_account_for_send()
4764 tp->t_snd_rxt_bytes += len; in tcp_account_for_send()
4766 tp->t_sndbytes += len; in tcp_account_for_send()
4772 rexmit_percent = (1000ULL * tp->t_snd_rxt_bytes) / in tcp_account_for_send()
4773 (10ULL * (tp->t_snd_rxt_bytes + tp->t_sndbytes)); in tcp_account_for_send()
4775 ktls_disable_ifnet(tp); in tcp_account_for_send()