From patchwork Thu Jul 23 02:19:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1326 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id SE+MNqeAGV8RAwAAIUCqbw for ; Thu, 23 Jul 2020 08:20:55 -0400 Received: from proxy17.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id eERONqeAGV8PNwAAvGGmqA (envelope-from ) for ; Thu, 23 Jul 2020 08:20:55 -0400 Received: from smtp18.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy17.mail.ord1d.rsapps.net with LMTP id wPQFNqeAGV8EMgAAWC7mWg ; Thu, 23 Jul 2020 08:20:55 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp18.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: f49841a8-ccde-11ea-8308-5254005167a7-1-1 Received: from [216.105.38.7] ([216.105.38.7:47352] helo=lists.sourceforge.net) by smtp18.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 1B/2E-27589-7A0891F5; Thu, 23 Jul 2020 08:20:55 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jyaCi-0003sF-2p; Thu, 23 Jul 2020 12:20:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyaCg-0003rt-0G for openvpn-devel@lists.sourceforge.net; Thu, 23 Jul 2020 12:20:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2g4nZhazbKEFhcLr9eIJujm00BJC4uBlkZJ5iaKq5g8=; b=bk3rlFGoZXJzYsBTP/DLpu++wt qHRFWiQjNKCZfxlKf69GEv8zqV0I9W1Ui6L/lLCGtzp0HJ1Zk2EYlbNR8UsZ/uROOtYhMD4Oo9ACS hn32dsAJIeBOan7KkjmGai54a7JJI/mVb3AQLeIkWLLZGhradEvt0sv3sGDnD+C5Pd1M=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=2g4nZhazbKEFhcLr9eIJujm00BJC4uBlkZJ5iaKq5g8=; b=cIa4mxxO5w4ayqYl1KHoKVjcZ8 FUsKu7fwE4RfFHiKT3yDzjclM63PFw/QSc2ZAiVXMmfVfc8qQz2S84aE0qVgz8iTj2A4pQ6jZYtGN NAAIC1MaDIcMBxZ2iET+U9bVQkwv92BuEA7bbmbLGR/N/QGKGAiYE63aY2b46cRboXI4=; Received: from vmail1.greenie.net ([195.30.8.66]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jyaCd-006E6x-GA for openvpn-devel@lists.sourceforge.net; Thu, 23 Jul 2020 12:20:01 +0000 Received: from fbsd-tc.ov.greenie.net (fbsd-tc.ov.greenie.net [IPv6:2001:608:0:814:0:0:f000:21]) by vmail1.greenie.net (8.15.2/8.12.11) with ESMTPS id 06NCJoOB041854 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 23 Jul 2020 14:19:50 +0200 (CEST) Received: from fbsd-tc.ov.greenie.net (localhost [127.0.0.1]) by fbsd-tc.ov.greenie.net (8.15.2/8.15.2) with ESMTPS id 06NCJoCH078267 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Thu, 23 Jul 2020 14:19:50 +0200 (CEST) (envelope-from gert@fbsd-tc.ov.greenie.net) Received: (from gert@localhost) by fbsd-tc.ov.greenie.net (8.15.2/8.15.2/Submit) id 06NCJn9R078266 for openvpn-devel@lists.sourceforge.net; Thu, 23 Jul 2020 14:19:50 +0200 (CEST) (envelope-from gert) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 23 Jul 2020 14:19:49 +0200 Message-Id: <20200723121949.78223-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200722132852.48508-1-gert@greenie.muc.de> References: <20200722132852.48508-1-gert@greenie.muc.de> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (vmail1.greenie.net [IPv6:2001:608:1:995a:20c:29ff:feb8:10eb]); Thu, 23 Jul 2020 14:19:50 +0200 (CEST) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: muc.de] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1jyaCd-006E6x-GA Subject: [Openvpn-devel] [PATCH] Workaround FreeBSD 12+ race condition on tun/tap open with IPv6. X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox On FreeBSD 12 (tested and verified on 12.1-RELEASE-p2), after "ifconfig inet6" for a tun/tap interface, there sometimes is a race condition where the "IFDISABLED" flag shows up after a short time frame, under a second, and never clears itself. This disables use of the configured IPv6 address on the interface, breaking IPv6 over tun/tap operation. This only happens if ipv6_activate_all_interfaces="YES" is not set in /etc/rc.conf - but there might be reasons why this is not so. As a workaround until this can be fixed on the FreeBSD side (or a better workaround is found), sleep(1) after ifconfig, then call "ifconfig $dev inet6 -ifdisable". Yes, this is massively ugly but makes the problem completely go away for my test systems. (The same effect can be achieved with an --up script that does this, but it's even less pretty - see trac ticket) FreeBSD: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248172 v2: reword text, refer to FreeBSD bug with much more details Trac: 1226 Signed-off-by: Gert Doering Acked-By: Arne Schwabe --- src/openvpn/tun.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index e96368ca..bbccc1cc 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1038,6 +1038,29 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, openvpn_execve_check(&argv, es, S_FATAL, "generic BSD ifconfig inet6 failed"); +#if defined(TARGET_FREEBSD) && __FreeBSD_version >= 1200000 + /* On FreeBSD 12 and up, there is ipv6_activate_all_interfaces="YES" + * in rc.conf, which is not set by default. If it is *not* set, + * "all new interfaces that are not already up" are configured by + * devd + /etc/pccard_ether as "inet6 ifdisabled". + * + * The "is this interface already up?" test is a non-zero time window + * which we manage to hit with our ifconfig often enough to cause + * frequent fails in the openvpn test environment. + * + * Thus: assume that the system might interfere, wait for things to + * settle (it's a very short time window), and remove -ifdisable again. + * + * See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248172 + */ + sleep(1); + argv_printf(&argv, "%s %s inet6 -ifdisabled", IFCONFIG_PATH, ifname); + argv_msg(M_INFO, &argv); + + openvpn_execve_check(&argv, es, S_FATAL, + "FreeBSD BSD 'ifconfig inet6 -ifdisabled' failed"); +#endif + #if defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) \ || defined(TARGET_DARWIN) /* and, hooray, we explicitly need to add a route... */