From patchwork Fri Jul 31 00:06:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1347 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id EG2lKHbtI1+bdQAAIUCqbw for ; Fri, 31 Jul 2020 06:07:50 -0400 Received: from proxy15.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id IJCCJ3btI1/BRAAAIasKDg (envelope-from ) for ; Fri, 31 Jul 2020 06:07:50 -0400 Received: from smtp27.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.iad3b.rsapps.net with LMTP id QDR1IHbtI1+ALgAAhyf7VQ ; Fri, 31 Jul 2020 06:07:50 -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: smtp27.gate.iad3b.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=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: b053ceda-d315-11ea-a48f-5254006b1ac1-1-1 Received: from [216.105.38.7] ([216.105.38.7:37072] helo=lists.sourceforge.net) by smtp27.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 2F/32-27158-57DE32F5; Fri, 31 Jul 2020 06:07:50 -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 1k1RwC-0007rK-Rq; Fri, 31 Jul 2020 10:06:52 +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 1k1RwB-0007rD-Ho for openvpn-devel@lists.sourceforge.net; Fri, 31 Jul 2020 10:06:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=qfm2PJv1D+KkCxGZVesFv/Zwr5Iz7siu5LdiU2sIFRA=; b=Vuq3oXQtQQq8plLvBtF/wk3SoN vT1LXHLayYS38abZpsZeeSlgrrHimvo1H9IdJgwgqFfff1NShAxh96r+NnV2XLZ/NbvLZ39/eNOEC KXLS3G1REHJY78QrRwQps0W0GbSywRcr1a7npmgRuTDHk2N9hoVSZRxWe3orl7j/Ft9s=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding: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=qfm2PJv1D+KkCxGZVesFv/Zwr5Iz7siu5LdiU2sIFRA=; b=j08inlGutY8MpdPgU1NHpCGHOz Vq+OSBngnbH/Qp3IgWKcBJB4P9A5bEqh/rwy5Fy+AMaIxM+g1IqKbuavLFFIuFfFIptEePj82Cs5k Odx6VrDYHF3pFAH7DreP+kpGDd/cekyeVQ/TCWWhtgxu0xsa3ypa3PRLNBAWHvXzXTNM=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1k1Rw7-0059yA-KI for openvpn-devel@lists.sourceforge.net; Fri, 31 Jul 2020 10:06:51 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1k1Rvp-000L28-Gs for openvpn-devel@lists.sourceforge.net; Fri, 31 Jul 2020 12:06:29 +0200 Received: (nullmailer pid 24656 invoked by uid 10006); Fri, 31 Jul 2020 10:06:29 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 31 Jul 2020 12:06:29 +0200 Message-Id: <20200731100629.24611-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 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: rfc2549.org] 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: 1k1Rw7-0059yA-KI Subject: [Openvpn-devel] [PATCH] Skip existing interfaces on opening the first available utun on macOS 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This avoids the error messages trying to open already used utuns. Signed-off-by: Arne Schwabe Acked-by: Lev Stipakov --- src/openvpn/tun.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index cc7b65cf..b9e444b6 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3023,6 +3023,13 @@ open_darwin_utun(const char *dev, const char *dev_type, const char *dev_node, st { for (utunnum = 0; utunnum<255; utunnum++) { + char ifname[20]; + /* if the interface exists silently skip it */ + ASSERT(snprintf(ifname, sizeof(ifname), "utun%d", utunnum)); + if (if_nametoindex(ifname)) + { + continue; + } fd = utun_open_helper(ctlInfo, utunnum); /* Break if the fd is valid, * or if early initialization failed (-2) */