From owner-svn-src-stable-12@freebsd.org Thu Sep 10 12:54:47 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6EDE43D65B9; Thu, 10 Sep 2020 12:54:47 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BnJkb2MTbz3yjh; Thu, 10 Sep 2020 12:54:47 +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 2DB291313B; Thu, 10 Sep 2020 12:54:47 +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 08ACslA1056977; Thu, 10 Sep 2020 12:54:47 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08ACskT1056975; Thu, 10 Sep 2020 12:54:46 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <202009101254.08ACskT1056975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Thu, 10 Sep 2020 12:54:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r365569 - stable/12/sys/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: stable/12/sys/netinet X-SVN-Commit-Revision: 365569 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2020 12:54:47 -0000 Author: tuexen Date: Thu Sep 10 12:54:46 2020 New Revision: 365569 URL: https://svnweb.freebsd.org/changeset/base/365569 Log: MFC r359926: Improve the TCP blackhole detection. The principle is to reduce the MSS in two steps and try each candidate two times. However, if two candidates are the same (which is the case in TCP/IPv6), this candidate was tested four times. This patch ensures that each candidate actually reduced the MSS and is only tested 2 times. This reduces the time window of missclassifying a temporary outage as an MTU issue. Modified: stable/12/sys/netinet/tcp_timer.c stable/12/sys/netinet/tcp_var.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet/tcp_timer.c ============================================================================== --- stable/12/sys/netinet/tcp_timer.c Thu Sep 10 12:52:50 2020 (r365568) +++ stable/12/sys/netinet/tcp_timer.c Thu Sep 10 12:54:46 2020 (r365569) @@ -698,16 +698,40 @@ tcp_timer_rexmt(void * xtp) (V_tcp_pmtud_blackhole_detect == 3 && isipv6)) && ((tp->t_state == TCPS_ESTABLISHED) || (tp->t_state == TCPS_FIN_WAIT_1))) { - /* - * Idea here is that at each stage of mtu probe (usually, 1448 - * -> 1188 -> 524) should be given 2 chances to recover before - * further clamping down. 'tp->t_rxtshift % 2 == 0' should - * take care of that. - */ + if (tp->t_rxtshift == 1) { + /* + * We enter blackhole detection after the first + * unsuccessful timer based retransmission. + * Then we reduce up to two times the MSS, each + * candidate giving two tries of retransmissions. + * But we give a candidate only two tries, if it + * actually reduces the MSS. + */ + tp->t_blackhole_enter = 2; + tp->t_blackhole_exit = tp->t_blackhole_enter; + if (isipv6) { +#ifdef INET6 + if (tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss) + tp->t_blackhole_exit += 2; + if (tp->t_maxseg > V_tcp_v6mssdflt && + V_tcp_v6pmtud_blackhole_mss > V_tcp_v6mssdflt) + tp->t_blackhole_exit += 2; +#endif + } else { +#ifdef INET + if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss) + tp->t_blackhole_exit += 2; + if (tp->t_maxseg > V_tcp_mssdflt && + V_tcp_pmtud_blackhole_mss > V_tcp_mssdflt) + tp->t_blackhole_exit += 2; +#endif + } + } if (((tp->t_flags2 & (TF2_PLPMTU_PMTUD|TF2_PLPMTU_MAXSEGSNT)) == (TF2_PLPMTU_PMTUD|TF2_PLPMTU_MAXSEGSNT)) && - (tp->t_rxtshift >= 2 && tp->t_rxtshift < 6 && - tp->t_rxtshift % 2 == 0)) { + (tp->t_rxtshift >= tp->t_blackhole_enter && + tp->t_rxtshift < tp->t_blackhole_exit && + (tp->t_rxtshift - tp->t_blackhole_enter) % 2 == 0)) { /* * Enter Path MTU Black-hole Detection mechanism: * - Disable Path MTU Discovery (IP "DF" bit). @@ -727,7 +751,8 @@ tcp_timer_rexmt(void * xtp) */ #ifdef INET6 if (isipv6 && - tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss) { + tp->t_maxseg > V_tcp_v6pmtud_blackhole_mss && + V_tcp_v6pmtud_blackhole_mss > V_tcp_v6mssdflt) { /* Use the sysctl tuneable blackhole MSS. */ tp->t_maxseg = V_tcp_v6pmtud_blackhole_mss; TCPSTAT_INC(tcps_pmtud_blackhole_activated); @@ -746,7 +771,8 @@ tcp_timer_rexmt(void * xtp) else #endif #ifdef INET - if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss) { + if (tp->t_maxseg > V_tcp_pmtud_blackhole_mss && + V_tcp_pmtud_blackhole_mss > V_tcp_mssdflt) { /* Use the sysctl tuneable blackhole MSS. */ tp->t_maxseg = V_tcp_pmtud_blackhole_mss; TCPSTAT_INC(tcps_pmtud_blackhole_activated); @@ -773,11 +799,9 @@ tcp_timer_rexmt(void * xtp) * with a lowered MTU, maybe this isn't a blackhole and * we restore the previous MSS and blackhole detection * flags. - * The limit '6' is determined by giving each probe - * stage (1448, 1188, 524) 2 chances to recover. */ if ((tp->t_flags2 & TF2_PLPMTU_BLACKHOLE) && - (tp->t_rxtshift >= 6)) { + (tp->t_rxtshift >= tp->t_blackhole_exit)) { tp->t_flags2 |= TF2_PLPMTU_PMTUD; tp->t_flags2 &= ~TF2_PLPMTU_BLACKHOLE; tp->t_maxseg = tp->t_pmtud_saved_maxseg; Modified: stable/12/sys/netinet/tcp_var.h ============================================================================== --- stable/12/sys/netinet/tcp_var.h Thu Sep 10 12:52:50 2020 (r365568) +++ stable/12/sys/netinet/tcp_var.h Thu Sep 10 12:54:46 2020 (r365569) @@ -169,6 +169,8 @@ struct tcpcb { u_int t_starttime; /* time connection was established */ u_int t_pmtud_saved_maxseg; /* pre-blackhole MSS */ + int t_blackhole_enter; /* when to enter blackhole detection */ + int t_blackhole_exit; /* when to exit blackhole detection */ u_int t_rttmin; /* minimum rtt allowed */ u_int t_rttbest; /* best rtt we've seen */