From patchwork Mon Aug 29 09:01:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 2735 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id 8IinAj0NDWNzSQAAIUCqbw (envelope-from ) for ; Mon, 29 Aug 2022 15:02:21 -0400 Received: from proxy7.mail.ord1c.rsapps.net ([172.28.255.1]) by director11.mail.ord1d.rsapps.net with LMTP id 8JFnAj0NDWO2FgAAvGGmqA (envelope-from ) for ; Mon, 29 Aug 2022 15:02:21 -0400 Received: from smtp15.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.ord1c.rsapps.net with LMTPS id EP7lAT0NDWP7TAAAknS3pQ (envelope-from ) for ; Mon, 29 Aug 2022 15:02:21 -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: smtp15.gate.ord1c.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: 1b129c7a-27cd-11ed-9fdf-bc305bf03694-1-1 Received: from [216.105.38.7] ([216.105.38.7:40194] helo=lists.sourceforge.net) by smtp15.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 72/F6-14998-B3D0D036; Mon, 29 Aug 2022 15:02:19 -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.95) (envelope-from ) id 1oSk0w-00036R-NC; Mon, 29 Aug 2022 19:01:38 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oSk0u-00036L-93 for openvpn-devel@lists.sourceforge.net; Mon, 29 Aug 2022 19:01:36 +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=4oiWUY9CeiASxwXkwa8U1zGeN/a1fbVPNx6YuIJdpCk=; b=S/Bl6mElZEcpByCGFH3nky9ZGC 8H4IOe5N5xhlDF8823JslYpEzJul9EiJLu+RxJ9nYKrYkCyh9kUuUpF75RM2lBwSYQYFJ3dQUmgI2 rfmWprNLA9fruFljtJ+wvIocP5VmIbjN6Ot2EJZ0p1DE9xK26NMlWN8RQn2jI9W97Jbg=; 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=4oiWUY9CeiASxwXkwa8U1zGeN/a1fbVPNx6YuIJdpCk=; b=H kLXcURf81VzmvawWDHajBuZIwetOMs/RWvszz5gWRoeN0GPrhFhwHyqztm3mHvTfGdcJ7hA+NCsj9 z+ZQiPQZt3tlwDex3je5+tNK56ozcLFUkE9i5rzj/PnYmbnt3PPJnzzBwTG8+G3MG6p7G30sOJsck Skc1CUdHpeAYtpEs=; Received: from vmail1.greenie.net ([195.30.8.66]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1oSk0s-0007eb-U1 for openvpn-devel@lists.sourceforge.net; Mon, 29 Aug 2022 19:01:36 +0000 Received: from ubuntu2004.ov.greenie.net (ubuntu2004.ov.greenie.net [IPv6:2001:608:1:995a:250:56ff:febb:2084]) by vmail1.greenie.net (8.17.1/8.16.1) with SMTP id 27TJ1OVt041685 for ; Mon, 29 Aug 2022 21:01:24 +0200 (CEST) Received: (nullmailer pid 2636093 invoked by uid 1000); Mon, 29 Aug 2022 19:01:24 -0000 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 29 Aug 2022 21:01:24 +0200 Message-Id: <20220829190124.2636045-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.4 (vmail1.greenie.net [IPv6:2001:608:1:995a:20c:29ff:feb8:10eb]); Mon, 29 Aug 2022 21:01:24 +0200 (CEST) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Linux, tun devices are created according to the following algorithm --dev tun -> try tun0, tun1, ... tun255, use first free --dev anything -> create a TUN device named "anything" (as long as "anyth [...] Content analysis details: (-2.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [195.30.8.66 listed in list.dnswl.org] 0.2 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: 1oSk0s-0007eb-U1 Subject: [Openvpn-devel] [PATCH] Adjust Linux+FreeBSD DCO device name handling to 'non DCO linux style' 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 Linux, tun devices are created according to the following algorithm --dev tun -> try tun0, tun1, ... tun255, use first free --dev anything -> create a TUN device named "anything" (as long as "anything" is not "null" or "tap[N]") DCO was following the "other platform convention", where everything not having a digit was iterated ("--dev tun-home" -> "tun-home0") - which does not work for classic tun/tap devices on the BSDs anyway, so is not the best model. Adjust open_tun_dco_generic() to document expected behaviour and do the thing. Signed-off-by: Gert Doering Acked-by: Kristof Provost Acked-by: Antonio Quartulli --- src/openvpn/tun.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 94803acd..94b0d322 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1943,12 +1943,14 @@ open_tun_dco_generic(const char *dev, const char *dev_type, } /* - * dynamic open is indicated by --dev specified without - * explicit unit number. Try opening DCO device named "[dev]n" - * where n = [0, 255]. + * unlike "open_tun_generic()", DCO on Linux and FreeBSD follows + * the device naming model of "non-DCO linux", that is: + * --dev tun -> try tun0, tun1, ... tun255, use first free + * --dev -> (try to) create a tun device named "anything" + * ("--dev tap" and "--dev null" are caught earlier and not handled here) */ - if (!tun_name_is_fixed(dev)) + if (strcmp(dev,"tun") == 0) { for (int i = 0; i < 256; ++i) {