Lines Matching refs:tp

355 static void tcp_remove_timer(struct tcpcb *tp);
357 static u_int32_t tcp_run_conn_timer(struct tcpcb *tp, u_int16_t *mode,
361 static inline void tcp_update_mss_core(struct tcpcb *tp, struct ifnet *ifp);
442 #define TIMER_IS_ON_LIST(tp) ((tp)->t_flags & TF_TIMER_ONLIST) argument
448 static void add_to_time_wait_locked(struct tcpcb *tp, uint32_t delay);
546 add_to_time_wait_locked(struct tcpcb *tp, uint32_t delay) in add_to_time_wait_locked() argument
549 struct inpcb *inp = tp->t_inpcb; in add_to_time_wait_locked()
563 TAILQ_REMOVE(&tcp_tw_tailq, tp, t_twentry); in add_to_time_wait_locked()
571 if (TIMER_IS_ON_LIST(tp)) { in add_to_time_wait_locked()
572 tcp_remove_timer(tp); in add_to_time_wait_locked()
574 tp->t_timer[TCPT_2MSL] = timer; in add_to_time_wait_locked()
576 TAILQ_INSERT_TAIL(&tcp_tw_tailq, tp, t_twentry); in add_to_time_wait_locked()
580 add_to_time_wait(struct tcpcb *tp, uint32_t delay) in add_to_time_wait() argument
582 if (tp->t_inpcb->inp_socket->so_options & SO_NOWAKEFROMSLEEP) { in add_to_time_wait()
583 socket_post_kev_msg_closed(tp->t_inpcb->inp_socket); in add_to_time_wait()
586 tcp_del_fsw_flow(tp); in add_to_time_wait()
589 nstat_pcb_detach(tp->t_inpcb); in add_to_time_wait()
592 if ((tp->t_inpcb->inp_socket->so_flags & SOF_CONTENT_FILTER) != 0) { in add_to_time_wait()
594 (void) cfil_sock_tcp_add_time_wait(tp->t_inpcb->inp_socket); in add_to_time_wait()
598 add_to_time_wait_now(tp, delay); in add_to_time_wait()
603 add_to_time_wait_now(struct tcpcb *tp, uint32_t delay) in add_to_time_wait_now() argument
608 socket_unlock(tp->t_inpcb->inp_socket, 0); in add_to_time_wait_now()
610 socket_lock(tp->t_inpcb->inp_socket, 0); in add_to_time_wait_now()
612 add_to_time_wait_locked(tp, delay); in add_to_time_wait_now()
622 struct tcpcb *tp = intotcpcb(inp); in tcp_remove_from_time_wait() local
624 TAILQ_REMOVE(&tcp_tw_tailq, tp, t_twentry); in tcp_remove_from_time_wait()
633 struct tcpcb *tp; in tcp_garbage_collect() local
636 tp = intotcpcb(inp); in tcp_garbage_collect()
639 mp_so = mptetoso(tptomptp(tp)->mpt_mpte); in tcp_garbage_collect()
657 tptomptp(tp)->mpt_mpte->mpte_mppcb->mpp_inside++; in tcp_garbage_collect()
681 if (istimewait && TSTMP_GEQ(tcp_now, tp->t_timer[TCPT_2MSL]) && in tcp_garbage_collect()
682 tp->t_state != TCPS_CLOSED) { in tcp_garbage_collect()
685 tcp_close(tp); in tcp_garbage_collect()
699 ((tp != NULL) && (tp->t_state == TCPS_CLOSED) && in tcp_garbage_collect()
738 struct tcpcb *, tp, int32_t, TCPS_CLOSED); in tcp_garbage_collect()
746 if (TIMER_IS_ON_LIST(tp)) { in tcp_garbage_collect()
747 tcp_remove_timer(tp); in tcp_garbage_collect()
759 mptcp_subflow_del(tptomptp(tp)->mpt_mpte, tp->t_mpsub); in tcp_garbage_collect()
871 tcp_canceltimers(struct tcpcb *tp) in tcp_canceltimers() argument
875 tcp_remove_timer(tp); in tcp_canceltimers()
877 tp->t_timer[i] = 0; in tcp_canceltimers()
879 tp->tentry.timer_start = tcp_now; in tcp_canceltimers()
880 tp->tentry.index = TCPT_NONE; in tcp_canceltimers()
892 tcp_rexmt_save_state(struct tcpcb *tp) in tcp_rexmt_save_state() argument
895 if (TSTMP_SUPPORTED(tp)) { in tcp_rexmt_save_state()
900 fsize = tp->snd_max - tp->snd_una; in tcp_rexmt_save_state()
901 tp->snd_ssthresh_prev = max(fsize, tp->snd_ssthresh); in tcp_rexmt_save_state()
902 tp->snd_recover_prev = tp->snd_recover; in tcp_rexmt_save_state()
914 tp->snd_cwnd_prev = tp->snd_cwnd; in tcp_rexmt_save_state()
915 tp->snd_ssthresh_prev = tp->snd_ssthresh; in tcp_rexmt_save_state()
916 tp->snd_recover_prev = tp->snd_recover; in tcp_rexmt_save_state()
917 if (IN_FASTRECOVERY(tp)) { in tcp_rexmt_save_state()
918 tp->t_flags |= TF_WASFRECOVERY; in tcp_rexmt_save_state()
920 tp->t_flags &= ~TF_WASFRECOVERY; in tcp_rexmt_save_state()
923 tp->t_srtt_prev = (tp->t_srtt >> TCP_RTT_SHIFT) + 2; in tcp_rexmt_save_state()
924 tp->t_rttvar_prev = (tp->t_rttvar >> TCP_RTTVAR_SHIFT); in tcp_rexmt_save_state()
925 tp->t_flagsext &= ~(TF_RECOMPUTE_RTT); in tcp_rexmt_save_state()
933 tcp_pmtud_revert_segment_size(struct tcpcb *tp) in tcp_pmtud_revert_segment_size() argument
937 VERIFY(tp->t_pmtud_saved_maxopd > 0); in tcp_pmtud_revert_segment_size()
938 tp->t_flags |= TF_PMTUD; in tcp_pmtud_revert_segment_size()
939 tp->t_flags &= ~TF_BLACKHOLE; in tcp_pmtud_revert_segment_size()
940 optlen = tp->t_maxopd - tp->t_maxseg; in tcp_pmtud_revert_segment_size()
941 tp->t_maxopd = tp->t_pmtud_saved_maxopd; in tcp_pmtud_revert_segment_size()
942 tp->t_maxseg = tp->t_maxopd - optlen; in tcp_pmtud_revert_segment_size()
948 if (CC_ALGO(tp)->cwnd_init != NULL) { in tcp_pmtud_revert_segment_size()
949 CC_ALGO(tp)->cwnd_init(tp); in tcp_pmtud_revert_segment_size()
952 if (TCP_USE_RLEDBAT(tp, tp->t_inpcb->inp_socket) && in tcp_pmtud_revert_segment_size()
954 tcp_cc_rledbat.rwnd_init(tp); in tcp_pmtud_revert_segment_size()
957 tp->t_pmtud_start_ts = 0; in tcp_pmtud_revert_segment_size()
961 tcp_update_mss_locked(tp->t_inpcb->inp_socket, NULL); in tcp_pmtud_revert_segment_size()
965 tcp_pmtud_black_holed_next_mss(struct tcpcb *tp) in tcp_pmtud_black_holed_next_mss() argument
968 if (tp->t_maxopd > tcp_pmtud_black_hole_mss) { in tcp_pmtud_black_holed_next_mss()
971 if (tp->t_inpcb->inp_vflag & INP_IPV4) { in tcp_pmtud_black_holed_next_mss()
992 tcp_send_keep_alive(struct tcpcb *tp) in tcp_send_keep_alive() argument
998 t_template = tcp_maketemplate(tp, &m); in tcp_send_keep_alive()
1000 struct inpcb *inp = tp->t_inpcb; in tcp_send_keep_alive()
1011 if (tp->t_inpcb->inp_flags & INP_BOUND_IF) { in tcp_send_keep_alive()
1012 tra.ifscope = tp->t_inpcb->inp_boundifp->if_index; in tcp_send_keep_alive()
1016 tcp_respond(tp, t_template->tt_ipgen, in tcp_send_keep_alive()
1018 tp->rcv_nxt, tp->snd_una - 1, 0, &tra); in tcp_send_keep_alive()
1030 tcp_timers(struct tcpcb *tp, int timer) in tcp_timers() argument
1036 struct ifnet *outifp = tp->t_inpcb->inp_last_outifp; in tcp_timers()
1038 so = tp->t_inpcb->inp_socket; in tcp_timers()
1039 idle_time = tcp_now - tp->t_rcvtime; in tcp_timers()
1051 tcp_free_sackholes(tp); in tcp_timers()
1052 if (tp->t_state != TCPS_TIME_WAIT && in tcp_timers()
1053 tp->t_state != TCPS_FIN_WAIT_2 && in tcp_timers()
1054 ((idle_time > 0) && (idle_time < TCP_CONN_MAXIDLE(tp)))) { in tcp_timers()
1055 tp->t_timer[TCPT_2MSL] = OFFSET_FROM_START(tp, in tcp_timers()
1056 (u_int32_t)TCP_CONN_KEEPINTVL(tp)); in tcp_timers()
1058 if (tp->t_state == TCPS_FIN_WAIT_2) { in tcp_timers()
1059 TCP_LOG_DROP_PCB(NULL, NULL, tp, false, in tcp_timers()
1062 tp = tcp_drop(tp, 0); in tcp_timers()
1064 tp = tcp_close(tp); in tcp_timers()
1066 return tp; in tcp_timers()
1079 if (accsleep_ms > tp->t_accsleep_ms) { in tcp_timers()
1080 last_sleep_ms = accsleep_ms - tp->t_accsleep_ms; in tcp_timers()
1093 if (++tp->t_rxtshift > TCP_MAXRXTSHIFT || in tcp_timers()
1094 (tp->t_rxt_conndroptime > 0 && tp->t_rxtstart > 0 && in tcp_timers()
1095 (tcp_now - tp->t_rxtstart) >= tp->t_rxt_conndroptime) || in tcp_timers()
1096 ((tp->t_flagsext & TF_RXTFINDROP) != 0 && in tcp_timers()
1097 (tp->t_flags & TF_SENTFIN) != 0 && tp->t_rxtshift >= 4) || in tcp_timers()
1098 (tp->t_rxtshift > 4 && last_sleep_ms >= TCP_SLEEP_TOO_LONG)) { in tcp_timers()
1099 if (tp->t_state == TCPS_ESTABLISHED && in tcp_timers()
1100 tp->t_rxt_minimum_timeout > 0) { in tcp_timers()
1107 if (TSTMP_LT(tcp_now, (tp->t_rxtstart + in tcp_timers()
1108 tp->t_rxt_minimum_timeout))) { in tcp_timers()
1109 tp->t_rxtshift = TCP_MAXRXTSHIFT - 1; in tcp_timers()
1113 if ((tp->t_flagsext & TF_RXTFINDROP) != 0) { in tcp_timers()
1120 if (tp->t_rxtshift >= TCP_MAXRXTSHIFT) { in tcp_timers()
1121 if (TCP_ECN_ENABLED(tp)) { in tcp_timers()
1122 INP_INC_IFNET_STAT(tp->t_inpcb, in tcp_timers()
1125 INP_INC_IFNET_STAT(tp->t_inpcb, in tcp_timers()
1129 tp->t_rxtshift = TCP_MAXRXTSHIFT; in tcp_timers()
1133 if (TCP_ECN_ENABLED(tp) && in tcp_timers()
1134 tp->t_state == TCPS_ESTABLISHED) { in tcp_timers()
1135 tcp_heuristic_ecn_droprxmt(tp); in tcp_timers()
1138 TCP_LOG_DROP_PCB(NULL, NULL, tp, false, in tcp_timers()
1140 tp = tcp_drop(tp, tp->t_softerror ? in tcp_timers()
1141 tp->t_softerror : ETIMEDOUT); in tcp_timers()
1147 tp->t_accsleep_ms = accsleep_ms; in tcp_timers()
1149 if (tp->t_rxtshift == 1 && in tcp_timers()
1150 tp->t_state == TCPS_ESTABLISHED) { in tcp_timers()
1152 tp->t_rxtstart = tcp_now; in tcp_timers()
1159 tcp_rexmt_save_state(tp); in tcp_timers()
1160 tcp_ccdbg_trace(tp, NULL, TCP_CC_FIRST_REXMT); in tcp_timers()
1163 if ((tp->t_rxtshift >= mptcp_fail_thresh) && in tcp_timers()
1164 (tp->t_state == TCPS_ESTABLISHED) && in tcp_timers()
1165 (tp->t_mpflags & TMPF_MPTCP_TRUE)) { in tcp_timers()
1169 if (TCPS_HAVEESTABLISHED(tp->t_state) && in tcp_timers()
1171 struct mptses *mpte = tptomptp(tp)->mpt_mpte; in tcp_timers()
1180 if (tp->t_adaptive_wtimo > 0 && in tcp_timers()
1181 tp->t_rxtshift > tp->t_adaptive_wtimo && in tcp_timers()
1182 TCPS_HAVEESTABLISHED(tp->t_state)) { in tcp_timers()
1193 if (tp->t_flagsext & TF_SENT_TLPROBE) { in tcp_timers()
1194 tp->t_flagsext &= ~(TF_SENT_TLPROBE); in tcp_timers()
1198 if (tp->t_flagsext & TF_DELAY_RECOVERY) { in tcp_timers()
1205 tp->t_reorderwin = 0; in tcp_timers()
1206 tp->t_timer[TCPT_DELAYFR] = 0; in tcp_timers()
1207 tp->t_flagsext &= ~(TF_DELAY_RECOVERY); in tcp_timers()
1210 if (!(tp->t_flagsext & TF_FASTOPEN_FORCE_ENABLE) && in tcp_timers()
1211 tp->t_state == TCPS_SYN_RECEIVED) { in tcp_timers()
1212 tcp_disable_tfo(tp); in tcp_timers()
1215 if (!(tp->t_flagsext & TF_FASTOPEN_FORCE_ENABLE) && in tcp_timers()
1216 !(tp->t_tfo_flags & TFO_F_HEURISTIC_DONE) && in tcp_timers()
1217 (tp->t_tfo_stats & TFO_S_SYN_DATA_SENT) && in tcp_timers()
1218 !(tp->t_tfo_flags & TFO_F_NO_SNDPROBING) && in tcp_timers()
1219 ((tp->t_state != TCPS_SYN_SENT && tp->t_rxtshift > 1) || in tcp_timers()
1220 tp->t_rxtshift > 4)) { in tcp_timers()
1230 tcp_heuristic_tfo_middlebox(tp); in tcp_timers()
1238 tp->t_tfo_stats |= TFO_S_SEND_BLACKHOLE; in tcp_timers()
1242 if (!(tp->t_flagsext & TF_FASTOPEN_FORCE_ENABLE) && in tcp_timers()
1243 !(tp->t_tfo_flags & TFO_F_HEURISTIC_DONE) && in tcp_timers()
1244 (tp->t_tfo_stats & TFO_S_SYN_DATA_ACKED) && in tcp_timers()
1245 tp->t_rxtshift > 3) { in tcp_timers()
1246 if (TSTMP_GT(tp->t_sndtime - 10 * TCP_RETRANSHZ, tp->t_rcvtime)) { in tcp_timers()
1247 tcp_heuristic_tfo_middlebox(tp); in tcp_timers()
1257 if (tp->t_state == TCPS_SYN_SENT) { in tcp_timers()
1258 rexmt = TCP_REXMTVAL(tp) * tcp_syn_backoff[tp->t_rxtshift]; in tcp_timers()
1259 tp->t_stat.synrxtshift = tp->t_rxtshift; in tcp_timers()
1260 tp->t_stat.rxmitsyns++; in tcp_timers()
1263 if (TFO_ENABLED(tp) && in tcp_timers()
1264 !(tp->t_flagsext & TF_FASTOPEN_FORCE_ENABLE)) { in tcp_timers()
1265 tcp_disable_tfo(tp); in tcp_timers()
1266 tp->t_tfo_flags |= TFO_F_SYN_LOSS; in tcp_timers()
1269 rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; in tcp_timers()
1272 TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, TCPTV_REXMTMAX, in tcp_timers()
1273 TCP_ADD_REXMTSLOP(tp)); in tcp_timers()
1274 tp->t_timer[TCPT_REXMT] = OFFSET_FROM_START(tp, tp->t_rxtcur); in tcp_timers()
1276 TCP_LOG_RTT_INFO(tp); in tcp_timers()
1278 if (INP_WAIT_FOR_IF_FEEDBACK(tp->t_inpcb)) { in tcp_timers()
1282 tcp_free_sackholes(tp); in tcp_timers()
1283 if (TCP_RACK_ENABLED(tp)) { in tcp_timers()
1284 tcp_segs_clear_sacked(tp); in tcp_timers()
1285 tcp_rack_loss_on_rto(tp, true); in tcp_timers()
1291 !(tp->t_flagsext & TF_NOBLACKHOLE_DETECTION) && in tcp_timers()
1292 (tp->t_state == TCPS_ESTABLISHED)) { in tcp_timers()
1293 if ((tp->t_flags & TF_PMTUD) && in tcp_timers()
1294 tp->t_pmtud_lastseg_size > tcp_pmtud_black_holed_next_mss(tp) && in tcp_timers()
1295 tp->t_rxtshift == 2) { in tcp_timers()
1303 tp->t_flags &= ~TF_PMTUD; in tcp_timers()
1305 tp->t_flags |= TF_BLACKHOLE; in tcp_timers()
1306 optlen = tp->t_maxopd - tp->t_maxseg; in tcp_timers()
1308 tp->t_pmtud_saved_maxopd = tp->t_maxopd; in tcp_timers()
1309 tp->t_pmtud_start_ts = tcp_now; in tcp_timers()
1310 if (tp->t_pmtud_start_ts == 0) { in tcp_timers()
1311 tp->t_pmtud_start_ts++; in tcp_timers()
1314 tp->t_maxopd = tcp_pmtud_black_holed_next_mss(tp); in tcp_timers()
1315 tp->t_maxseg = tp->t_maxopd - optlen; in tcp_timers()
1321 if (CC_ALGO(tp)->cwnd_init != NULL) { in tcp_timers()
1322 CC_ALGO(tp)->cwnd_init(tp); in tcp_timers()
1324 tp->snd_cwnd = tp->t_maxseg; in tcp_timers()
1326 if (TCP_USE_RLEDBAT(tp, so) && in tcp_timers()
1328 tcp_cc_rledbat.rwnd_init(tp); in tcp_timers()
1338 if ((tp->t_flags & TF_BLACKHOLE) && in tcp_timers()
1339 (tp->t_rxtshift > 4)) { in tcp_timers()
1340 tcp_pmtud_revert_segment_size(tp); in tcp_timers()
1341 tp->snd_cwnd = tp->t_maxseg; in tcp_timers()
1355 if (tp->t_state == TCPS_SYN_SENT && in tcp_timers()
1356 tp->t_rxtshift == tcp_broken_peer_syn_rxmit_thres) { in tcp_timers()
1357 tp->t_flags &= ~(TF_REQ_SCALE | TF_REQ_TSTMP); in tcp_timers()
1368 if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) { in tcp_timers()
1369 if (!(tp->t_inpcb->inp_vflag & INP_IPV4)) { in tcp_timers()
1370 in6_losing(tp->t_inpcb); in tcp_timers()
1372 in_losing(tp->t_inpcb); in tcp_timers()
1374 tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT); in tcp_timers()
1375 tp->t_srtt = 0; in tcp_timers()
1377 tp->snd_nxt = tp->snd_una; in tcp_timers()
1382 tp->snd_recover = tp->snd_max; in tcp_timers()
1386 tp->t_flags |= TF_ACKNOW; in tcp_timers()
1393 if (tp->t_state >= TCPS_ESTABLISHED || (outifp != NULL && in tcp_timers()
1395 tp->t_rtttime = 0; in tcp_timers()
1398 if (!IN_FASTRECOVERY(tp) && tp->t_rxtshift == 1) { in tcp_timers()
1408 if (tp->t_rxtshift == 1 && in tcp_timers()
1409 CC_ALGO(tp)->after_timeout != NULL) { in tcp_timers()
1410 CC_ALGO(tp)->after_timeout(tp); in tcp_timers()
1416 if (!TCP_ACC_ECN_ON(tp) && TCP_ECN_ENABLED(tp)) { in tcp_timers()
1417 tp->ecn_flags |= TE_SENDCWR; in tcp_timers()
1421 EXIT_FASTRECOVERY(tp); in tcp_timers()
1424 tp->t_flagsext &= ~TF_CWND_NONVALIDATED; in tcp_timers()
1428 tcp_ccdbg_trace(tp, NULL, TCP_CC_REXMT_TIMEOUT); in tcp_timers()
1430 (void) tcp_output(tp); in tcp_timers()
1450 if ((tp->t_rxtshift == TCP_MAXRXTSHIFT && in tcp_timers()
1452 idle_time >= TCP_REXMTVAL(tp) * tcp_totbackoff)) || in tcp_timers()
1453 ((tp->t_persist_stop != 0) && in tcp_timers()
1454 TSTMP_LEQ(tp->t_persist_stop, tcp_now))) { in tcp_timers()
1455 TCP_LOG_DROP_PCB(NULL, NULL, tp, false, "persist timeout drop"); in tcp_timers()
1459 tp = tcp_drop(tp, ETIMEDOUT); in tcp_timers()
1462 tcp_setpersist(tp); in tcp_timers()
1463 tp->t_flagsext |= TF_FORCE; in tcp_timers()
1464 (void) tcp_output(tp); in tcp_timers()
1465 tp->t_flagsext &= ~TF_FORCE; in tcp_timers()
1474 if (tp->t_inpcb->inp_socket->so_flags & SOF_FLOW_DIVERT) { in tcp_timers()
1485 struct mptcb *mp_tp = tptomptp(tp); in tcp_timers()
1486 if ((tp->t_mpflags & TMPF_MPTCP_TRUE) && in tcp_timers()
1487 (tp->t_state > TCPS_ESTABLISHED)) { in tcp_timers()
1495 if (tp->t_state < TCPS_ESTABLISHED) { in tcp_timers()
1499 (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) || in tcp_timers()
1500 (tp->t_flagsext & TF_DETECT_READSTALL) || in tcp_timers()
1501 (tp->t_tfo_probe_state == TFO_PROBE_PROBING)) && in tcp_timers()
1502 (tp->t_state <= TCPS_CLOSING || tp->t_state == TCPS_FIN_WAIT_2)) { in tcp_timers()
1503 if (idle_time >= TCP_CONN_KEEPIDLE(tp) + TCP_CONN_MAXIDLE(tp)) { in tcp_timers()
1504 TCP_LOG_DROP_PCB(NULL, NULL, tp, false, in tcp_timers()
1509 if (tcp_send_keep_alive(tp)) { in tcp_timers()
1510 if (tp->t_flagsext & TF_DETECT_READSTALL) { in tcp_timers()
1511 tp->t_rtimo_probes++; in tcp_timers()
1514 TCP_LOG_KEEP_ALIVE(tp, idle_time); in tcp_timers()
1517 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp, in tcp_timers()
1518 TCP_CONN_KEEPINTVL(tp)); in tcp_timers()
1520 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp, in tcp_timers()
1521 TCP_CONN_KEEPIDLE(tp)); in tcp_timers()
1523 if (tp->t_flagsext & TF_DETECT_READSTALL) { in tcp_timers()
1532 if (tp->t_adaptive_rtimo > 0) { in tcp_timers()
1533 if (tp->t_rtimo_probes > tp->t_adaptive_rtimo) { in tcp_timers()
1538 tcp_keepalive_reset(tp); in tcp_timers()
1544 tp->t_rtimo_probes <= TCP_CONNECTIVITY_PROBES_MAX) { in tcp_timers()
1547 tp->t_flagsext &= ~TF_DETECT_READSTALL; in tcp_timers()
1550 int ind = min(tp->t_rtimo_probes, in tcp_timers()
1552 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START( in tcp_timers()
1553 tp, tcp_backoff[ind] * TCP_REXMTVAL(tp)); in tcp_timers()
1556 if (tp->t_tfo_probe_state == TFO_PROBE_PROBING) { in tcp_timers()
1559 tp->t_tfo_probes++; in tcp_timers()
1560 ind = min(tp->t_tfo_probes, TCP_MAXRXTSHIFT); in tcp_timers()
1569 tp->t_timer[TCPT_KEEP] = min(OFFSET_FROM_START( in tcp_timers()
1570 tp, tcp_backoff[ind] * TCP_REXMTVAL(tp)), in tcp_timers()
1571 tp->t_timer[TCPT_KEEP]); in tcp_timers()
1572 } else if (!(tp->t_flagsext & TF_FASTOPEN_FORCE_ENABLE) && in tcp_timers()
1573 !(tp->t_tfo_flags & TFO_F_HEURISTIC_DONE) && in tcp_timers()
1574 tp->t_tfo_probe_state == TFO_PROBE_WAIT_DATA) { in tcp_timers()
1576 tcp_heuristic_tfo_middlebox(tp); in tcp_timers()
1582 tp->t_tfo_stats |= TFO_S_RECV_BLACKHOLE; in tcp_timers()
1587 if (tcp_delack_enabled && (tp->t_flags & TF_DELACK)) { in tcp_timers()
1588 tp->t_flags &= ~TF_DELACK; in tcp_timers()
1589 tp->t_timer[TCPT_DELACK] = 0; in tcp_timers()
1590 tp->t_flags |= TF_ACKNOW; in tcp_timers()
1601 if ((tp->t_flags & TF_STRETCHACK)) { in tcp_timers()
1602 if (tp->t_unacksegs > 1 && in tcp_timers()
1603 tp->t_unacksegs < maxseg_unacked) { in tcp_timers()
1604 tp->t_stretchack_delayed++; in tcp_timers()
1607 if (tp->t_stretchack_delayed > in tcp_timers()
1609 tp->t_flagsext |= TF_DISABLE_STRETCHACK; in tcp_timers()
1614 tp->rcv_nostrack_ts = tcp_now; in tcp_timers()
1616 tp->t_stretchack_delayed = 0; in tcp_timers()
1617 tp->rcv_nostrack_pkts = 0; in tcp_timers()
1619 tcp_reset_stretch_ack(tp); in tcp_timers()
1621 tp->t_forced_acks = TCP_FORCED_ACKS_COUNT; in tcp_timers()
1629 CLEAR_IAJ_STATE(tp); in tcp_timers()
1632 tp->t_stat.delayed_acks_sent++; in tcp_timers()
1633 (void) tcp_output(tp); in tcp_timers()
1639 if ((tp->t_state == TCPS_ESTABLISHED) && in tcp_timers()
1640 (tp->t_mpflags & TMPF_PREESTABLISHED) && in tcp_timers()
1641 (tp->t_mpflags & TMPF_JOINED_FLOW)) { in tcp_timers()
1642 if (++tp->t_mprxtshift > TCP_MAXRXTSHIFT) { in tcp_timers()
1647 tp = tcp_drop(tp, tp->t_softerror ? in tcp_timers()
1648 tp->t_softerror : ETIMEDOUT); in tcp_timers()
1652 tp->t_mpflags |= TMPF_SND_JACK; in tcp_timers()
1653 tp->t_flags |= TF_ACKNOW; in tcp_timers()
1659 (void) tcp_output(tp); in tcp_timers()
1664 struct mptses *mpte = tptomptp(tp)->mpt_mpte; in tcp_timers()
1666 tp->t_timer[TCPT_CELLICON] = 0; in tcp_timers()
1678 tp->t_timer[TCPT_CELLICON] = OFFSET_FROM_START(tp, MPTCP_CELLICON_TOGGLE_RATE); in tcp_timers()
1689 if (!(tp->t_flagsext & TF_IF_PROBING)) { in tcp_timers()
1690 tp->t_flagsext &= ~(TF_SENT_TLPROBE); in tcp_timers()
1696 if ((tp->t_state != TCPS_ESTABLISHED || in tcp_timers()
1697 tp->t_rxtshift > 0 || in tcp_timers()
1698 tp->snd_max == tp->snd_una || in tcp_timers()
1699 !SACK_ENABLED(tp) || IN_FASTRECOVERY(tp)) && in tcp_timers()
1700 !(tp->t_flagsext & TF_IF_PROBING)) { in tcp_timers()
1710 if (tp->t_flagsext & TF_IF_PROBING) { in tcp_timers()
1711 tp->t_rxtshift = 0; in tcp_timers()
1712 if (tp->t_state == TCPS_SYN_SENT) { in tcp_timers()
1713 tp->t_stat.synrxtshift = tp->t_rxtshift; in tcp_timers()
1718 tp->t_srtt = TCPTV_SRTTBASE; in tcp_timers()
1719 tp->t_rttvar = in tcp_timers()
1721 tp->t_rttmin = TCPTV_REXMTMIN; in tcp_timers()
1722 TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp), in tcp_timers()
1723 tp->t_rttmin, TCPTV_REXMTMAX, TCP_ADD_REXMTSLOP(tp)); in tcp_timers()
1724 TCP_LOG_RTT_INFO(tp); in tcp_timers()
1727 if (tp->t_state == TCPS_SYN_SENT) { in tcp_timers()
1732 tp->snd_nxt = tp->snd_una; in tcp_timers()
1737 tp->snd_recover = tp->snd_max; in tcp_timers()
1741 tp->t_flags |= TF_ACKNOW; in tcp_timers()
1744 tp->t_rtttime = 0; in tcp_timers()
1746 tp->t_flagsext |= TF_TLP_IS_RETRANS; in tcp_timers()
1756 snd_len = min(so->so_snd.sb_cc, tp->snd_wnd) in tcp_timers()
1757 - (tp->snd_max - tp->snd_una); in tcp_timers()
1759 tp->snd_nxt = tp->snd_max; in tcp_timers()
1760 tp->t_flagsext &= ~TF_TLP_IS_RETRANS; in tcp_timers()
1762 snd_len = min((tp->snd_max - tp->snd_una), in tcp_timers()
1763 tp->t_maxseg); in tcp_timers()
1764 tp->snd_nxt = tp->snd_max - snd_len; in tcp_timers()
1765 tp->t_flagsext |= TF_TLP_IS_RETRANS; in tcp_timers()
1770 if (tp->t_flagsext & TF_IF_PROBING) { in tcp_timers()
1775 tp->t_rtttime = 0; in tcp_timers()
1777 if (!(tp->t_flagsext & TF_IF_PROBING)) { in tcp_timers()
1778 tp->t_flagsext |= TF_SENT_TLPROBE; in tcp_timers()
1779 tp->t_tlpstart = tcp_now; in tcp_timers()
1782 tp->snd_cwnd += tp->t_maxseg; in tcp_timers()
1789 tp->t_timer[TCPT_REXMT] = 0; in tcp_timers()
1790 ret = tcp_output(tp); in tcp_timers()
1793 if ((tp->t_flagsext & TF_IF_PROBING) && in tcp_timers()
1794 ((IFNET_IS_COMPANION_LINK(tp->t_inpcb->inp_last_outifp)) || in tcp_timers()
1795 tp->t_state == TCPS_SYN_SENT)) { in tcp_timers()
1798 tp->t_timer[TCPT_REXMT] = 0; in tcp_timers()
1799 tcp_set_lotimer_index(tp); in tcp_timers()
1806 tp->t_state == TCPS_SYN_SENT ? "SYN" : "data", in tcp_timers()
1807 ntohs(tp->t_inpcb->inp_lport), in tcp_timers()
1808 ntohs(tp->t_inpcb->inp_fport), in tcp_timers()
1809 if_name(tp->t_inpcb->inp_last_outifp), in tcp_timers()
1810 tp->t_inpcb->inp_last_outifp->if_index, in tcp_timers()
1822 if (tp->t_timer[TCPT_REXMT] == 0 && tp->t_timer[TCPT_PERSIST] == 0 && in tcp_timers()
1823 (tp->t_inpcb->inp_socket->so_snd.sb_cc != 0 || tp->t_state == TCPS_SYN_SENT || in tcp_timers()
1824 tp->t_state == TCPS_SYN_RECEIVED)) { in tcp_timers()
1825 tp->t_timer[TCPT_REXMT] = in tcp_timers()
1826 OFFSET_FROM_START(tp, tp->t_rxtcur); in tcp_timers()
1832 ntohs(tp->t_inpcb->inp_lport), in tcp_timers()
1833 ntohs(tp->t_inpcb->inp_fport), in tcp_timers()
1834 tp->t_state, in tcp_timers()
1835 tp->t_timer[TCPT_REXMT]); in tcp_timers()
1837 tcp_check_timer_state(tp); in tcp_timers()
1839 tp->snd_cwnd -= tp->t_maxseg; in tcp_timers()
1841 if (!(tp->t_flagsext & TF_IF_PROBING)) { in tcp_timers()
1842 tp->t_tlphighrxt = tp->snd_nxt; in tcp_timers()
1843 tp->t_tlphightrxt_persist = tp->snd_nxt; in tcp_timers()
1848 tp->t_flagsext &= ~TF_DELAY_RECOVERY; in tcp_timers()
1856 if (IN_FASTRECOVERY(tp) || in tcp_timers()
1857 SEQ_GEQ(tp->snd_una, tp->snd_recover) || in tcp_timers()
1858 tp->t_rxtshift > 0) { in tcp_timers()
1862 VERIFY(SACK_ENABLED(tp)); in tcp_timers()
1863 tcp_rexmt_save_state(tp); in tcp_timers()
1864 if (CC_ALGO(tp)->pre_fr != NULL) { in tcp_timers()
1865 CC_ALGO(tp)->pre_fr(tp); in tcp_timers()
1866 if (!TCP_ACC_ECN_ON(tp) && TCP_ECN_ENABLED(tp)) { in tcp_timers()
1867 tp->ecn_flags |= TE_SENDCWR; in tcp_timers()
1870 ENTER_FASTRECOVERY(tp); in tcp_timers()
1872 tp->t_timer[TCPT_REXMT] = 0; in tcp_timers()
1874 tp->t_sack_recovery_episode++; in tcp_timers()
1875 tp->snd_cwnd = tp->t_maxseg; in tcp_timers()
1876 tcp_ccdbg_trace(tp, NULL, TCP_CC_ENTER_FASTRECOVERY); in tcp_timers()
1877 (void) tcp_output(tp); in tcp_timers()
1884 tp = tcp_drop(tp, ETIMEDOUT); in tcp_timers()
1887 if (TCP_RACK_ENABLED(tp)) { in tcp_timers()
1888 tcp_rack_reordering_timeout(tp, 0); in tcp_timers()
1892 return tp; in tcp_timers()
1897 tcp_remove_timer(struct tcpcb *tp) in tcp_remove_timer() argument
1901 socket_lock_assert_owned(tp->t_inpcb->inp_socket); in tcp_remove_timer()
1902 if (!(TIMER_IS_ON_LIST(tp))) { in tcp_remove_timer()
1907 if (listp->next_te != NULL && listp->next_te == &tp->tentry) { in tcp_remove_timer()
1908 listp->next_te = LIST_NEXT(&tp->tentry, le); in tcp_remove_timer()
1911 LIST_REMOVE(&tp->tentry, le); in tcp_remove_timer()
1912 tp->t_flags &= ~(TF_TIMER_ONLIST); in tcp_remove_timer()
1916 tp->tentry.le.le_next = NULL; in tcp_remove_timer()
1917 tp->tentry.le.le_prev = NULL; in tcp_remove_timer()
2001 tcp_run_conn_timer(struct tcpcb *tp, u_int16_t *te_mode, in tcp_run_conn_timer() argument
2011 VERIFY(tp != NULL); in tcp_run_conn_timer()
2015 socket_lock(tp->t_inpcb->inp_socket, 1); in tcp_run_conn_timer()
2017 so = tp->t_inpcb->inp_socket; in tcp_run_conn_timer()
2019 if (in_pcb_checkstate(tp->t_inpcb, WNT_RELEASE, 1) in tcp_run_conn_timer()
2021 if (TIMER_IS_ON_LIST(tp)) { in tcp_run_conn_timer()
2022 tcp_remove_timer(tp); in tcp_run_conn_timer()
2035 if (TCP_IF_STATE_CHANGED(tp, probe_if_index)) { in tcp_run_conn_timer()
2036 tp->t_flagsext |= TF_IF_PROBING; in tcp_run_conn_timer()
2037 tcp_timers(tp, TCPT_PTO); in tcp_run_conn_timer()
2038 tp->t_timer[TCPT_PTO] = 0; in tcp_run_conn_timer()
2039 tp->t_flagsext &= ~TF_IF_PROBING; in tcp_run_conn_timer()
2047 if ((index = tp->tentry.index) == TCPT_NONE) { in tcp_run_conn_timer()
2051 timer_val = tp->t_timer[index]; in tcp_run_conn_timer()
2053 diff = timer_diff(tp->tentry.runtime, 0, tcp_now, 0); in tcp_run_conn_timer()
2055 if (tp->tentry.index != TCPT_NONE) { in tcp_run_conn_timer()
2057 *(te_mode) = tp->tentry.mode; in tcp_run_conn_timer()
2062 tp->t_timer[index] = 0; in tcp_run_conn_timer()
2064 tp = tcp_timers(tp, index); in tcp_run_conn_timer()
2065 if (tp == NULL) { in tcp_run_conn_timer()
2074 tp->tentry.mode = 0; in tcp_run_conn_timer()
2076 if (tp->t_timer[i] != 0) { in tcp_run_conn_timer()
2077 diff = timer_diff(tp->tentry.timer_start, in tcp_run_conn_timer()
2078 tp->t_timer[i], tcp_now, 0); in tcp_run_conn_timer()
2083 tp->t_timer[i] = diff; in tcp_run_conn_timer()
2089 TCP_SET_TIMER_MODE(tp->tentry.mode, i); in tcp_run_conn_timer()
2094 tp->tentry.timer_start = tcp_now; in tcp_run_conn_timer()
2095 tp->tentry.index = lo_index; in tcp_run_conn_timer()
2096 VERIFY(tp->tentry.index == TCPT_NONE || tp->tentry.mode > 0); in tcp_run_conn_timer()
2098 if (tp->tentry.index != TCPT_NONE) { in tcp_run_conn_timer()
2099 tp->tentry.runtime = tp->tentry.timer_start + in tcp_run_conn_timer()
2100 tp->t_timer[tp->tentry.index]; in tcp_run_conn_timer()
2101 if (tp->tentry.runtime == 0) { in tcp_run_conn_timer()
2102 tp->tentry.runtime++; in tcp_run_conn_timer()
2110 tp->t_timer[i] = 0; in tcp_run_conn_timer()
2111 tp = tcp_timers(tp, i); in tcp_run_conn_timer()
2112 if (tp == NULL) { in tcp_run_conn_timer()
2119 tcp_set_lotimer_index(tp); in tcp_run_conn_timer()
2122 if (tp->tentry.index < TCPT_NONE) { in tcp_run_conn_timer()
2123 offset = tp->t_timer[tp->tentry.index]; in tcp_run_conn_timer()
2124 *(te_mode) = tp->tentry.mode; in tcp_run_conn_timer()
2128 if (tp != NULL && tp->tentry.index == TCPT_NONE) { in tcp_run_conn_timer()
2129 tcp_remove_timer(tp); in tcp_run_conn_timer()
2143 struct tcpcb *__single tp; in tcp_run_timerlist() local
2180 tp = TIMERENTRY_TO_TP(te); in tcp_run_timerlist()
2186 !TCP_IF_STATE_CHANGED(tp, listp->probe_if_index)) { in tcp_run_timerlist()
2199 if (in_pcb_checkstate(tp->t_inpcb, WNT_ACQUIRE, 0) in tcp_run_timerlist()
2206 socket_lock(tp->t_inpcb->inp_socket, 1); in tcp_run_timerlist()
2207 tcp_remove_timer(tp); in tcp_run_timerlist()
2208 socket_unlock(tp->t_inpcb->inp_socket, 1); in tcp_run_timerlist()
2222 VERIFY_NEXT_LINK(&tp->tentry, le); in tcp_run_timerlist()
2223 VERIFY_PREV_LINK(&tp->tentry, le); in tcp_run_timerlist()
2227 offset = tcp_run_conn_timer(tp, &te_mode, in tcp_run_timerlist()
2308 tcp_sched_timers(struct tcpcb *tp) in tcp_sched_timers() argument
2310 struct tcptimerentry *te = &tp->tentry; in tcp_sched_timers()
2317 if (tp->t_inpcb->inp_state == INPCB_STATE_DEAD) { in tcp_sched_timers()
2319 if (TIMER_IS_ON_LIST(tp)) { in tcp_sched_timers()
2320 tcp_remove_timer(tp); in tcp_sched_timers()
2327 tcp_remove_timer(tp); in tcp_sched_timers()
2341 if (!TIMER_IS_ON_LIST(tp)) { in tcp_sched_timers()
2347 if (!TIMER_IS_ON_LIST(tp)) { in tcp_sched_timers()
2349 tp->t_flags |= TF_TIMER_ONLIST; in tcp_sched_timers()
2433 tcp_set_lotimer_index(struct tcpcb *tp) in tcp_set_lotimer_index() argument
2438 if (tp->t_timer[i] != 0) { in tcp_set_lotimer_index()
2440 if (lo_timer == 0 || tp->t_timer[i] < lo_timer) { in tcp_set_lotimer_index()
2441 lo_timer = tp->t_timer[i]; in tcp_set_lotimer_index()
2446 tp->tentry.index = lo_index; in tcp_set_lotimer_index()
2447 tp->tentry.mode = mode; in tcp_set_lotimer_index()
2448 VERIFY(tp->tentry.index == TCPT_NONE || tp->tentry.mode > 0); in tcp_set_lotimer_index()
2450 if (tp->tentry.index != TCPT_NONE) { in tcp_set_lotimer_index()
2451 tp->tentry.runtime = tp->tentry.timer_start in tcp_set_lotimer_index()
2452 + tp->t_timer[tp->tentry.index]; in tcp_set_lotimer_index()
2453 if (tp->tentry.runtime == 0) { in tcp_set_lotimer_index()
2454 tp->tentry.runtime++; in tcp_set_lotimer_index()
2460 tcp_check_timer_state(struct tcpcb *tp) in tcp_check_timer_state() argument
2462 socket_lock_assert_owned(tp->t_inpcb->inp_socket); in tcp_check_timer_state()
2464 if (tp->t_inpcb->inp_flags2 & INP2_TIMEWAIT) { in tcp_check_timer_state()
2468 tcp_set_lotimer_index(tp); in tcp_check_timer_state()
2470 tcp_sched_timers(tp); in tcp_check_timer_state()
2794 tcp_enable_read_probe(struct tcpcb *tp, struct ifnet *ifp) in tcp_enable_read_probe() argument
2796 if (tp->t_state == TCPS_ESTABLISHED && in tcp_enable_read_probe()
2797 tp->snd_max == tp->snd_una && in tcp_enable_read_probe()
2798 tp->t_inpcb->inp_last_outifp == ifp && in tcp_enable_read_probe()
2799 !(tp->t_flagsext & TF_DETECT_READSTALL) && in tcp_enable_read_probe()
2800 tp->t_rtimo_probes == 0) { in tcp_enable_read_probe()
2801 tp->t_flagsext |= TF_DETECT_READSTALL; in tcp_enable_read_probe()
2802 tp->t_rtimo_probes = 0; in tcp_enable_read_probe()
2803 tp->t_timer[TCPT_KEEP] = OFFSET_FROM_START(tp, in tcp_enable_read_probe()
2805 if (tp->tentry.index == TCPT_NONE) { in tcp_enable_read_probe()
2806 tp->tentry.index = TCPT_KEEP; in tcp_enable_read_probe()
2807 tp->tentry.runtime = tcp_now + in tcp_enable_read_probe()
2813 diff = timer_diff(tp->tentry.runtime, 0, in tcp_enable_read_probe()
2816 tp->tentry.index = TCPT_KEEP; in tcp_enable_read_probe()
2817 tp->tentry.runtime = tcp_now + in tcp_enable_read_probe()
2819 if (tp->tentry.runtime == 0) { in tcp_enable_read_probe()
2820 tp->tentry.runtime++; in tcp_enable_read_probe()
2831 tcp_disable_read_probe(struct tcpcb *tp) in tcp_disable_read_probe() argument
2833 if (tp->t_adaptive_rtimo == 0 && in tcp_disable_read_probe()
2834 ((tp->t_flagsext & TF_DETECT_READSTALL) || in tcp_disable_read_probe()
2835 tp->t_rtimo_probes > 0)) { in tcp_disable_read_probe()
2836 tcp_keepalive_reset(tp); in tcp_disable_read_probe()
2838 if (tp->t_mpsub) { in tcp_disable_read_probe()
2839 mptcp_reset_keepalive(tp); in tcp_disable_read_probe()
2870 struct tcpcb *tp = NULL; in tcp_probe_connectivity() local
2885 tp = intotcpcb(inp); in tcp_probe_connectivity()
2887 tcp_enable_read_probe(tp, ifp); in tcp_probe_connectivity()
2889 tcp_disable_read_probe(tp); in tcp_probe_connectivity()
2922 tcp_update_mss_core(struct tcpcb *tp, struct ifnet *ifp) in tcp_update_mss_core() argument
2928 optlen = tp->t_maxopd - tp->t_maxseg; in tcp_update_mss_core()
2932 tp->t_cached_maxopd > 0 && in tcp_update_mss_core()
2933 tp->t_maxopd < tp->t_cached_maxopd) { in tcp_update_mss_core()
2934 tp->t_maxopd = tp->t_cached_maxopd; in tcp_update_mss_core()
2938 tp->t_maxopd > tcp_mss_rec_medium) { in tcp_update_mss_core()
2939 tp->t_cached_maxopd = tp->t_maxopd; in tcp_update_mss_core()
2940 tp->t_maxopd = tcp_mss_rec_medium; in tcp_update_mss_core()
2944 tp->t_maxopd > tcp_mss_rec_low) { in tcp_update_mss_core()
2945 tp->t_cached_maxopd = tp->t_maxopd; in tcp_update_mss_core()
2946 tp->t_maxopd = tcp_mss_rec_low; in tcp_update_mss_core()
2949 tp->t_maxseg = tp->t_maxopd - optlen; in tcp_update_mss_core()
2954 if (tp->t_maxopd == tp->t_cached_maxopd) { in tcp_update_mss_core()
2955 tp->t_cached_maxopd = 0; in tcp_update_mss_core()
2964 struct tcpcb *tp = intotcpcb(inp); in tcp_update_mss_locked() local
2977 if (tp->t_state <= TCPS_CLOSE_WAIT) { in tcp_update_mss_locked()
2982 if (tp->t_flags & TF_BLACKHOLE) { in tcp_update_mss_locked()
2988 tcp_update_mss_core(tp, ifp); in tcp_update_mss_locked()