From patchwork Wed Jul 22 03:28:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1325 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.27.255.54]) by backend30.mail.ord1d.rsapps.net with LMTP id KOpjJVg/GF+/UgAAIUCqbw for ; Wed, 22 Jul 2020 09:30:00 -0400 Received: from proxy19.mail.iad3a.rsapps.net ([172.27.255.54]) by director7.mail.ord1d.rsapps.net with LMTP id YBsGJFg/GF9zagAAovjBpQ (envelope-from ) for ; Wed, 22 Jul 2020 09:30:00 -0400 Received: from smtp38.gate.iad3a ([172.27.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy19.mail.iad3a.rsapps.net with LMTP id iNQRHlg/GF/mCAAAXy6Yeg ; Wed, 22 Jul 2020 09:30:00 -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: smtp38.gate.iad3a.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: 70266c20-cc1f-11ea-a412-525400000c92-1-1 Received: from [216.105.38.7] ([216.105.38.7:57254] helo=lists.sourceforge.net) by smtp38.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id EE/E9-12730-75F381F5; Wed, 22 Jul 2020 09:29:59 -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 1jyEo5-0006Zr-EP; Wed, 22 Jul 2020 13:29:13 +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 1jyEo1-0006Zg-38 for openvpn-devel@lists.sourceforge.net; Wed, 22 Jul 2020 13:29:09 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=I6SzkkMw23NqPbn8wepxcy6SiByKoRK6//7iPyksS2Q=; b=LYrU8/RDQR5tHTxrdaSv8J0gsl usMRcY2fvT0A1YXvtjOeUfvMVTLGL/JnsfKDEmT3rJvRwsZxdd2zcZfMYM2OwIct4ZjInHzDyzI5M 5PvGo108tuiBmrJ877IoDFqC8lu1ILbnAlBEUdqNcSx11BzEyyXxlqRVNTpND+sLt2oQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=I6SzkkMw23NqPbn8wepxcy6SiByKoRK6//7iPyksS2Q=; b=E BW6qJJJwsD29JTYb93t8HfRko3dLRc1a8IjRyXjw8JSCN+d6je/dq7drkgf8/kYhm1s9tjhIFNOWz uSWO4k4cR97XbPqEdsYLkSA0zIpVX21pYKQKiklatJAiz8NlbjsuFkkVMt0y03J+FF9ff/hzw+7cN UuTxSmduFwqlxaSU=; 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 1jyEny-004lX0-RI for openvpn-devel@lists.sourceforge.net; Wed, 22 Jul 2020 13:29:09 +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 06MDSqv0013285 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 22 Jul 2020 15:28:52 +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 06MDSq0b048552 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Wed, 22 Jul 2020 15:28:52 +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 06MDSqSt048551 for openvpn-devel@lists.sourceforge.net; Wed, 22 Jul 2020 15:28:52 +0200 (CEST) (envelope-from gert) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 22 Jul 2020 15:28:52 +0200 Message-Id: <20200722132852.48508-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.27.0 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]); Wed, 22 Jul 2020 15:28:53 +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: 1jyEny-004lX0-RI 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. 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) Trac: 1226 Signed-off-by: Gert Doering --- src/openvpn/tun.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index e96368ca..2d3ba623 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1038,6 +1038,23 @@ 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 + /* FreeBSD 12 grew some sort of race condition where sometimes + * the IPv6 side of a tun interface is stuck in "IFDISABLED" + * in "ifconfig tun0" output, and the assigned IPv6 address is not + * working ("tentative"). Workaround in here, for now. + * + * the sleep is needed because there is a race condition, so turning + * it off immediately can lead to "kernel turns it on again, stuck!!" + */ + 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... */