diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1680,7 +1680,7 @@ (tp->t_flags & TF_NOOPT))) { tp->t_flags &= ~TF_SACK_PERMIT; } - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { if ((to.to_flags & TOF_FASTOPEN) && !(tp->t_flags & TF_NOOPT)) { uint16_t mss; @@ -1989,7 +1989,7 @@ tcp_log_end_status(tp, TCP_EI_STATUS_RST_IN_FRONT); goto dropwithreset; } - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { /* * When a TFO connection is in SYN_RECEIVED, the * only valid packets are the initial SYN, a @@ -2063,7 +2063,7 @@ * If not all the data that was sent in the TFO SYN * has been acked, resend the remainder right away. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->snd_una != tp->snd_max)) { tp->snd_nxt = th->th_ack; tfo_partial_ack = 1; @@ -2419,7 +2419,7 @@ if (tp->t_state == TCPS_SYN_RECEIVED || (tp->t_flags & TF_NEEDSYN)) { if (tp->t_state == TCPS_SYN_RECEIVED && - IS_FASTOPEN(tp->t_flags)) { + (tp->t_flags & TF_FASTOPEN)) { tp->snd_wnd = tiwin; cc_conn_init(tp); } @@ -2467,7 +2467,7 @@ * SYN-RECEIVED* -> FIN-WAIT-1 */ tp->t_starttime = ticks; - if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { + if ((tp->t_flags & TF_FASTOPEN) && tp->t_tfo_pending) { tcp_fastopen_decrement_counter(tp->t_tfo_pending); tp->t_tfo_pending = NULL; } @@ -2486,7 +2486,7 @@ * snd_cwnd reduction that occurs when a TFO SYN|ACK * is retransmitted. */ - if (!IS_FASTOPEN(tp->t_flags)) + if (!(tp->t_flags & TF_FASTOPEN)) cc_conn_init(tp); tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); } @@ -3167,7 +3167,7 @@ * connection then we just ignore the text. */ tfo_syn = ((tp->t_state == TCPS_SYN_RECEIVED) && - IS_FASTOPEN(tp->t_flags)); + (tp->t_flags & TF_FASTOPEN)); if ((tlen || (thflags & TH_FIN) || (tfo_syn && tlen > 0)) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { tcp_seq save_start = th->th_seq; diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -239,10 +239,10 @@ * only allow the initial SYN or SYN|ACK and those sent * by the retransmit timer. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && ((tp->t_state == TCPS_SYN_SENT) || - (tp->t_state == TCPS_SYN_RECEIVED)) && - SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN or SYN|ACK sent */ + (tp->t_state == TCPS_SYN_RECEIVED)) && + SEQ_GT(tp->snd_max, tp->snd_una) && /* SYN or SYN|ACK sent */ (tp->snd_nxt != tp->snd_una)) /* not a retransmit */ return (0); @@ -436,7 +436,7 @@ * When sending additional segments following a TFO SYN|ACK, * do not include the SYN bit. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_state == TCPS_SYN_RECEIVED)) flags &= ~TH_SYN; off--, len++; @@ -464,7 +464,7 @@ * * - When the socket is in the CLOSED state (RST is being sent) */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (((flags & TH_SYN) && (tp->t_rxtshift > 0)) || ((tp->t_state == TCPS_SYN_SENT) && (tp->t_tfo_client_cookie_len == 0)) || @@ -801,7 +801,7 @@ * have caused the original SYN or SYN|ACK to have * been dropped by a middlebox. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_rxtshift == 0)) { if (tp->t_state == TCPS_SYN_RECEIVED) { to.to_tfo_len = TCP_FASTOPEN_COOKIE_LEN; @@ -875,7 +875,7 @@ * If we wanted a TFO option to be added, but it was unable * to fit, ensure no data is sent. */ - if (IS_FASTOPEN(tp->t_flags) && wanted_cookie && + if ((tp->t_flags & TF_FASTOPEN) && wanted_cookie && !(to.to_flags & TOF_FASTOPEN)) len = 0; } diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -8188,7 +8188,7 @@ * then we just ignore the text. */ tfo_syn = ((tp->t_state == TCPS_SYN_RECEIVED) && - IS_FASTOPEN(tp->t_flags)); + (tp->t_flags & TF_FASTOPEN)); if ((tlen || (thflags & TH_FIN) || (tfo_syn && tlen > 0)) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { tcp_seq save_start = th->th_seq; @@ -8773,7 +8773,7 @@ * If not all the data that was sent in the TFO SYN * has been acked, resend the remainder right away. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->snd_una != tp->snd_max)) { tp->snd_nxt = th->th_ack; tfo_partial = 1; @@ -8939,7 +8939,7 @@ ctf_do_dropwithreset(m, tp, th, BANDLIM_RST_OPENPORT, tlen); return (1); } - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { /* * When a TFO connection is in SYN_RECEIVED, the only valid * packets are the initial SYN, a retransmit/copy of the @@ -9015,7 +9015,7 @@ * processing; else drop segment and return. */ if ((thflags & TH_ACK) == 0) { - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { cc_conn_init(tp); } return (bbr_process_data(m, th, so, tp, drop_hdrlen, tlen, @@ -9052,7 +9052,7 @@ /* Drop off any SYN in the send map (probably not there) */ if (thflags & TH_ACK) bbr_log_syn(tp, to); - if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { + if ((tp->t_flags & TF_FASTOPEN) && tp->t_tfo_pending) { tcp_fastopen_decrement_counter(tp->t_tfo_pending); tp->t_tfo_pending = NULL; } @@ -9074,7 +9074,7 @@ * is not harmless as it would undo the snd_cwnd reduction * that occurs when a TFO SYN|ACK is retransmitted. */ - if (!IS_FASTOPEN(tp->t_flags)) + if (!(tp->t_flags & TF_FASTOPEN)) cc_conn_init(tp); } /* @@ -11408,7 +11408,7 @@ if ((tp->t_flags & TF_SACK_PERMIT) && (to.to_flags & TOF_SACKPERM) == 0) tp->t_flags &= ~TF_SACK_PERMIT; - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { if (to.to_flags & TOF_FASTOPEN) { uint16_t mss; @@ -12062,7 +12062,7 @@ * For TFO connections in SYN_RECEIVED, only allow the initial * SYN|ACK and those sent by the retransmit timer. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && ((tp->t_state == TCPS_SYN_RECEIVED) || (tp->t_state == TCPS_SYN_SENT)) && SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN or SYN|ACK sent */ @@ -12381,7 +12381,7 @@ * When sending additional segments following a TFO SYN|ACK, * do not include the SYN bit. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_state == TCPS_SYN_RECEIVED)) flags &= ~TH_SYN; sb_offset--, len++; @@ -12412,7 +12412,7 @@ * actively created socket * - When the socket is in the CLOSED state (RST is being sent) */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (((flags & TH_SYN) && (tp->t_rxtshift > 0)) || ((tp->t_state == TCPS_SYN_SENT) && (tp->t_tfo_client_cookie_len == 0)) || @@ -12422,7 +12422,7 @@ rsm = NULL; } /* Without fast-open there should never be data sent on a SYN */ - if ((flags & TH_SYN) && (!IS_FASTOPEN(tp->t_flags))) + if ((flags & TH_SYN) && !(tp->t_flags & TF_FASTOPEN)) len = 0; if (len <= 0) { /* @@ -12846,7 +12846,7 @@ * have caused the original SYN or SYN|ACK to have * been dropped by a middlebox. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_rxtshift == 0)) { if (tp->t_state == TCPS_SYN_RECEIVED) { to.to_tfo_len = TCP_FASTOPEN_COOKIE_LEN; @@ -12902,7 +12902,7 @@ * If we wanted a TFO option to be added, but it was unable * to fit, ensure no data is sent. */ - if (IS_FASTOPEN(tp->t_flags) && wanted_cookie && + if ((tp->t_flags & TF_FASTOPEN) && wanted_cookie && !(to.to_flags & TOF_FASTOPEN)) len = 0; } diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -13585,7 +13585,7 @@ * then we just ignore the text. */ tfo_syn = ((tp->t_state == TCPS_SYN_RECEIVED) && - IS_FASTOPEN(tp->t_flags)); + (tp->t_flags & TF_FASTOPEN)); if ((tlen || (thflags & TH_FIN) || (tfo_syn && tlen > 0)) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { tcp_seq save_start = th->th_seq; @@ -14194,7 +14194,7 @@ * If not all the data that was sent in the TFO SYN * has been acked, resend the remainder right away. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->snd_una != tp->snd_max)) { /* Was it a partial ack? */ if (SEQ_LT(th->th_ack, tp->snd_max)) @@ -14373,7 +14373,7 @@ ctf_do_dropwithreset(m, tp, th, BANDLIM_RST_OPENPORT, tlen); return (1); } - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { /* * When a TFO connection is in SYN_RECEIVED, the * only valid packets are the initial SYN, a @@ -14454,7 +14454,7 @@ * processing; else drop segment and return. */ if ((thflags & TH_ACK) == 0) { - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { rack_cc_conn_init(tp); } return (rack_process_data(m, th, so, tp, drop_hdrlen, tlen, @@ -14475,7 +14475,7 @@ * FIN-WAIT-1 */ tp->t_starttime = ticks; - if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { + if ((tp->t_flags & TF_FASTOPEN) && tp->t_tfo_pending) { tcp_fastopen_decrement_counter(tp->t_tfo_pending); tp->t_tfo_pending = NULL; } @@ -14492,7 +14492,7 @@ * is not harmless as it would undo the snd_cwnd reduction * that occurs when a TFO SYN|ACK is retransmitted. */ - if (!IS_FASTOPEN(tp->t_flags)) + if (!(tp->t_flags & TF_FASTOPEN)) rack_cc_conn_init(tp); } /* @@ -18198,7 +18198,7 @@ if ((tp->t_flags & TF_SACK_PERMIT) && (to.to_flags & TOF_SACKPERM) == 0) tp->t_flags &= ~TF_SACK_PERMIT; - if (IS_FASTOPEN(tp->t_flags)) { + if (tp->t_flags & TF_FASTOPEN) { if (to.to_flags & TOF_FASTOPEN) { uint16_t mss; @@ -21346,7 +21346,7 @@ * For TFO connections in SYN_RECEIVED, only allow the initial * SYN|ACK and those sent by the retransmit timer. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_state == TCPS_SYN_RECEIVED) && SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN|ACK sent */ (rack->r_ctl.rc_resend == NULL)) { /* not a retransmit */ @@ -21494,7 +21494,7 @@ * only allow the initial SYN or SYN|ACK and those sent * by the retransmit timer. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && ((tp->t_state == TCPS_SYN_RECEIVED) || (tp->t_state == TCPS_SYN_SENT)) && SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN or SYN|ACK sent */ @@ -21949,7 +21949,8 @@ } SOCKBUF_LOCK(sb); if ((sack_rxmit == 0) && - (TCPS_HAVEESTABLISHED(tp->t_state) || IS_FASTOPEN(tp->t_flags))) { + (TCPS_HAVEESTABLISHED(tp->t_state) || + (tp->t_flags & TF_FASTOPEN))) { /* * We are not retransmitting (sack_rxmit is 0) so we * are sending new data. This is always based on snd_max. @@ -22075,7 +22076,7 @@ * no data please. */ if ((sack_rxmit == 0) && - (!IS_FASTOPEN(tp->t_flags))){ + !(tp->t_flags & TF_FASTOPEN)) { len = 0; sb_offset = 0; } @@ -22135,7 +22136,7 @@ * When sending additional segments following a TFO SYN|ACK, * do not include the SYN bit. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_state == TCPS_SYN_RECEIVED)) flags &= ~TH_SYN; } @@ -22160,7 +22161,7 @@ * * - When the socket is in the CLOSED state (RST is being sent) */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (((flags & TH_SYN) && (tp->t_rxtshift > 0)) || ((tp->t_state == TCPS_SYN_SENT) && (tp->t_tfo_client_cookie_len == 0)) || @@ -22169,7 +22170,7 @@ len = 0; } /* Without fast-open there should never be data sent on a SYN */ - if ((flags & TH_SYN) && (!IS_FASTOPEN(tp->t_flags))) { + if ((flags & TH_SYN) && !(tp->t_flags & TF_FASTOPEN)) { len = 0; } if ((len > segsiz) && (tcp_dsack_block_exists(tp))) { @@ -22498,7 +22499,7 @@ { int app_limited = CTF_JR_SENT_DATA; - if ((IS_FASTOPEN(tp->t_flags) == 0) && + if ((tp->t_flags & TF_FASTOPEN) == 0 && (flags & TH_FIN) && (len == 0) && (sbused(sb) == (tp->snd_max - tp->snd_una)) && @@ -22866,7 +22867,7 @@ * have caused the original SYN or SYN|ACK to have * been dropped by a middlebox. */ - if (IS_FASTOPEN(tp->t_flags) && + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_rxtshift == 0)) { if (tp->t_state == TCPS_SYN_RECEIVED) { to.to_tfo_len = TCP_FASTOPEN_COOKIE_LEN; @@ -22964,7 +22965,7 @@ * If we wanted a TFO option to be added, but it was unable * to fit, ensure no data is sent. */ - if (IS_FASTOPEN(tp->t_flags) && wanted_cookie && + if ((tp->t_flags & TF_FASTOPEN) && wanted_cookie && !(to.to_flags & TOF_FASTOPEN)) len = 0; } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -3282,7 +3282,7 @@ if (tp->t_state != TCPS_SYN_SENT) return (inp); - if (IS_FASTOPEN(tp->t_flags)) + if (tp->t_flags & TF_FASTOPEN) tcp_fastopen_disable_path(tp); tp = tcp_drop(tp, errno); diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1447,7 +1447,7 @@ win = so->sol_sbrcv_hiwat; ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); - if (V_tcp_fastopen_server_enable && IS_FASTOPEN(tp->t_flags) && + if (V_tcp_fastopen_server_enable && (tp->t_flags & TF_FASTOPEN) && (tp->t_tfo_pending != NULL) && (to->to_flags & TOF_FASTOPEN)) { /* diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -397,7 +397,7 @@ } SOCK_UNLOCK(so); - if (IS_FASTOPEN(tp->t_flags)) + if (tp->t_flags & TF_FASTOPEN) tp->t_tfo_pending = tcp_fastopen_alloc_counter(); out: @@ -454,7 +454,7 @@ } SOCK_UNLOCK(so); - if (IS_FASTOPEN(tp->t_flags)) + if (tp->t_flags & TF_FASTOPEN) tp->t_tfo_pending = tcp_fastopen_alloc_counter(); if (error != 0) @@ -887,8 +887,7 @@ * application response data, or failing that, when the DELACK timer * expires. */ - if (IS_FASTOPEN(tp->t_flags) && - (tp->t_state == TCPS_SYN_RECEIVED)) + if ((tp->t_flags & TF_FASTOPEN) && (tp->t_state == TCPS_SYN_RECEIVED)) goto out; #ifdef TCP_OFFLOAD if (tp->t_flags & TF_TOE) @@ -1095,7 +1094,7 @@ sbflush(&so->so_snd); goto out; } - if (IS_FASTOPEN(tp->t_flags)) + if (tp->t_flags & TF_FASTOPEN) tcp_fastopen_connect(tp); else { tp->snd_wnd = TTCP_CLIENT_SND_WND; @@ -1161,7 +1160,7 @@ /* * Not going to contemplate SYN|URG */ - if (IS_FASTOPEN(tp->t_flags)) + if (tp->t_flags & TF_FASTOPEN) tp->t_flags &= ~TF_FASTOPEN; #ifdef INET6 if (isipv6) @@ -1578,7 +1577,7 @@ default: break; } - if (IS_FASTOPEN(tp->t_flags)) + if (tp->t_flags & TF_FASTOPEN) ti->tcpi_options |= TCPI_OPT_TFO; ti->tcpi_rto = tp->t_rxtcur * tick; @@ -2685,7 +2684,7 @@ * socket is still open. */ if (tp->t_state < TCPS_ESTABLISHED && - !(tp->t_state > TCPS_LISTEN && IS_FASTOPEN(tp->t_flags))) { + !(tp->t_state > TCPS_LISTEN && (tp->t_flags & TF_FASTOPEN))) { tp = tcp_close(tp); KASSERT(tp != NULL, ("tcp_disconnect: tcp_close() returned NULL")); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -812,14 +812,6 @@ #define ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY) #define EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY | TF_FASTRECOVERY) -#if defined(_KERNEL) -#if !defined(TCP_RFC7413) -#define IS_FASTOPEN(t_flags) (false) -#else -#define IS_FASTOPEN(t_flags) (t_flags & TF_FASTOPEN) -#endif -#endif - #define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una) /*