From patchwork Fri Dec 20 05:11:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 956 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id uMFLJnfz/F1hOAAAIUCqbw for ; Fri, 20 Dec 2019 11:14:47 -0500 Received: from proxy10.mail.iad3b.rsapps.net ([172.31.255.6]) by director9.mail.ord1d.rsapps.net with LMTP id 6EoxI3fz/F1qJwAAalYnBA ; Fri, 20 Dec 2019 11:14:47 -0500 Received: from smtp28.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy10.mail.iad3b.rsapps.net with LMTP id QGBcHHfz/F1FAwAA/F5p9A ; Fri, 20 Dec 2019 11:14:47 -0500 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: smtp28.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; dkim=fail (signature verification failed) header.d=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: d6ee21da-2343-11ea-9a1b-525400c8cd63-1-1 Received: from [216.105.38.7] ([216.105.38.7:59322] helo=lists.sourceforge.net) by smtp28.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id F4/BC-16807-673FCFD5; Fri, 20 Dec 2019 11:14:47 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1iiKuZ-0002pY-IW; Fri, 20 Dec 2019 16:13:55 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1iiKuX-0002p6-BW for openvpn-devel@lists.sourceforge.net; Fri, 20 Dec 2019 16:13:53 +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:Cc:To:From:Sender:Reply-To: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=vQV9FlihCLONdv5dpvIJuR1bYBcaplxc+kJd74x4Whs=; b=VwNvTb3qP9W7RUfoZs/pcXLDUU MhE9l2YViFbAL26Nc2XU0Op06+3Gk90MHPFTY0AQsJKzswmi2tGlFy8TH/kfzluFaal0tIqubKPF/ so2SAENfIZ/KxczOh4NdTkUN2fIfElvqDja0Xnl80bswjhbaLvFH1Kl2mmApOkv3Lv94=; 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:Cc:To:From:Sender:Reply-To: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=vQV9FlihCLONdv5dpvIJuR1bYBcaplxc+kJd74x4Whs=; b=fUlIlfXWP4aPJ4TGxepfwL79KR ThcWMiaDggUoBoxnr9swlvxCcwNrMUfFvVzE5C9/xJJkdV9moCU9IL7T3cw52jZxOlYlj/3DfVQD4 vNhoHNMjstphouzna6jGkx2w0pSXl/LQv5vPZbBsXTgXCvWdSpIOnAkqZMG/FvVTJ7T8=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1iiKuV-00BKmS-7K for openvpn-devel@lists.sourceforge.net; Fri, 20 Dec 2019 16:13:53 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id 1D2221004499; Fri, 20 Dec 2019 17:13:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1576858420; bh=vQV9FlihCLONdv5dpvIJuR1bYBcaplxc+kJd74x4Whs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Atv41uWITFNg+4ISN04Xq3faZ0DU6Kvc/hjCtssgm9CpKZXXb38b3WfaGUgNOmCph 6fQq9x/VMQXek1Nm64UEUKHSxbx9lZe7RczcymUgbLQj6UTWZb4dBmSTfkFto0nmOg ywZbbY65vKA5UMMMmZ8OGVXlASqQZvkK3UUeuo/I= X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:a050:acdc:f245:eef3]) by pub5.amebis.si (Postfix) with ESMTP id 7A66B1002FBD; Fri, 20 Dec 2019 17:13:33 +0100 (CET) From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Fri, 20 Dec 2019 17:11:15 +0100 Message-Id: <20191220161117.1434-5-simon@rozman.si> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: References: MIME-Version: 1.0 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: rozman.si] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1iiKuV-00BKmS-7K Subject: [Openvpn-devel] [PATCH v2 5/7] wintun: add support for --dev-node 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 Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpn/tun.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index f56682ef..18f06bb6 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -6196,7 +6196,6 @@ static void tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_guid) { struct gc_arena gc = gc_new(); - char tuntap_device_path[256]; const struct tap_reg* tap_reg = get_tap_reg(&gc); const struct panel_reg* panel_reg = get_panel_reg(&gc); const struct device_instance_id_interface* device_instance_id_interface = get_device_instance_id_interface(&gc); @@ -6209,31 +6208,34 @@ tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_gui */ if (dev_node) { + bool is_picked_device_wintun = false; + /* Get the device GUID for the device specified with --dev-node. */ - *device_guid = get_device_guid(dev_node, actual_buffer, sizeof(actual_buffer), NULL, tap_reg, panel_reg, &gc); + *device_guid = get_device_guid(dev_node, actual_buffer, sizeof(actual_buffer), &is_picked_device_wintun, tap_reg, panel_reg, &gc); if (!*device_guid) { - msg(M_FATAL, "TAP-Windows adapter '%s' not found", dev_node); + msg(M_FATAL, "Adapter '%s' not found", dev_node); } - /* Open Windows TAP-Windows adapter */ - openvpn_snprintf(tuntap_device_path, sizeof(tuntap_device_path), "%s%s%s", - USERMODEDEVICEDIR, - *device_guid, - TAP_WIN_SUFFIX); - - tt->hand = CreateFile(tuntap_device_path, - GENERIC_READ | GENERIC_WRITE, - 0, /* was: FILE_SHARE_READ */ - 0, - OPEN_EXISTING, - FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, - 0); + if (tt->wintun) + { + if (!is_picked_device_wintun) + { + msg(M_FATAL, "Adapter '%s' is TAP-Windows, Wintun expected. If you want to use this device, remove --windows-driver wintun.", dev_node); + } + } + else + { + if (is_picked_device_wintun) + { + msg(M_FATAL, "Adapter '%s' is Wintun, TAP-Windows expected. If you want to use this device, add --windows-driver wintun.", dev_node); + } + } - if (tt->hand == INVALID_HANDLE_VALUE) + if (!tun_try_open_device(tt, *device_guid, device_instance_id_interface)) { - msg(M_ERR, "CreateFile failed on TAP device: %s", tuntap_device_path); + msg(M_FATAL, "Failed to open %s adapter: %s", tt->wintun ? "Wintun" : "TAP-Windows", dev_node); } } else