From owner-svn-src-head@freebsd.org Wed Sep 12 10:27:59 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEAAE108EDB1; Wed, 12 Sep 2018 10:27:59 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4E98B7C665; Wed, 12 Sep 2018 10:27:59 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A97C2538B; Wed, 12 Sep 2018 10:27:59 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w8CARxlA084627; Wed, 12 Sep 2018 10:27:59 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8CARxi4084626; Wed, 12 Sep 2018 10:27:59 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201809121027.w8CARxi4084626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Wed, 12 Sep 2018 10:27:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338614 - head/sys/netinet/tcp_stacks X-SVN-Group: head X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: head/sys/netinet/tcp_stacks X-SVN-Commit-Revision: 338614 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Sep 2018 10:27:59 -0000 Author: tuexen Date: Wed Sep 12 10:27:58 2018 New Revision: 338614 URL: https://svnweb.freebsd.org/changeset/base/338614 Log: Fix TCP Fast Open for the TCP RACK stack. * Fix a bug where the SYN handling during established state was applied to a front state. * Move a check for retransmission after the timer handling. This was suppressing timer based retransmissions. * Fix an off-by one byte in the sequence number of retransmissions. * Apply fixes corresponding to https://svnweb.freebsd.org/changeset/base/336934 Reviewed by: rrs@ Approved by: re (kib@) MFC after: 1 month Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16912 Modified: head/sys/netinet/tcp_stacks/rack.c Modified: head/sys/netinet/tcp_stacks/rack.c ============================================================================== --- head/sys/netinet/tcp_stacks/rack.c Wed Sep 12 10:09:59 2018 (r338613) +++ head/sys/netinet/tcp_stacks/rack.c Wed Sep 12 10:27:58 2018 (r338614) @@ -5401,14 +5401,6 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, st if (thflags & TH_RST) return (rack_process_rst(m, th, so, tp)); /* - * RFC5961 Section 4.2 Send challenge ACK for any SYN in - * synchronized state. - */ - if (thflags & TH_SYN) { - rack_challenge_ack(m, th, tp, &ret_val); - return (ret_val); - } - /* * RFC 1323 PAWS: If we have a timestamp reply on this segment and * it's less than ts_recent, drop it. */ @@ -5478,6 +5470,16 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, st * FIN-WAIT-1 */ tp->t_starttime = ticks; + if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { + tcp_fastopen_decrement_counter(tp->t_tfo_pending); + tp->t_tfo_pending = NULL; + + /* + * Account for the ACK of our SYN prior to + * regular ACK processing below. + */ + tp->snd_una++; + } if (tp->t_flags & TF_NEEDFIN) { tcp_state_change(tp, TCPS_FIN_WAIT_1); tp->t_flags &= ~TF_NEEDFIN; @@ -5485,16 +5487,6 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, st tcp_state_change(tp, TCPS_ESTABLISHED); TCP_PROBE5(accept__established, NULL, tp, mtod(m, const char *), tp, th); - if (IS_FASTOPEN(tp->t_flags) && tp->t_tfo_pending) { - tcp_fastopen_decrement_counter(tp->t_tfo_pending); - tp->t_tfo_pending = NULL; - - /* - * Account for the ACK of our SYN prior to regular - * ACK processing below. - */ - tp->snd_una++; - } /* * TFO connections call cc_conn_init() during SYN * processing. Calling it again here for such connections @@ -6924,16 +6916,6 @@ rack_output(struct tcpcb *tp) if (tp->t_flags & TF_TOE) return (tcp_offload_output(tp)); #endif - - /* - * 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) && - (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 */ - return (0); #ifdef INET6 if (rack->r_state) { /* Use the cache line loaded if possible */ @@ -6976,6 +6958,17 @@ rack_output(struct tcpcb *tp) rack->r_wanted_output = 0; rack->r_timer_override = 0; /* + * For TFO connections in SYN_SENT or SYN_RECEIVED, + * only allow the initial SYN or SYN|ACK and those sent + * by the retransmit timer. + */ + if (IS_FASTOPEN(tp->t_flags) && + ((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 */ + (tp->t_rxtshift == 0)) /* not a retransmit */ + return (0); + /* * Determine length of data that should be transmitted, and flags * that will be used. If there is some data or critical controls * (SYN, RST) to send, then transmit; otherwise, investigate @@ -7353,8 +7346,10 @@ again: (((flags & TH_SYN) && (tp->t_rxtshift > 0)) || ((tp->t_state == TCPS_SYN_SENT) && (tp->t_tfo_client_cookie_len == 0)) || - (flags & TH_RST))) + (flags & TH_RST))) { + sack_rxmit = 0; len = 0; + } /* Without fast-open there should never be data sent on a SYN */ if ((flags & TH_SYN) && (!IS_FASTOPEN(tp->t_flags))) len = 0;