From patchwork Sat Jun 23 08:31:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 385 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id PkT7AEuSLlsnFwAAIUCqbw for ; Sat, 23 Jun 2018 14:32:43 -0400 Received: from proxy20.mail.ord1d.rsapps.net ([172.30.191.6]) by director12.mail.ord1d.rsapps.net (Dovecot) with LMTP id O4EKI0uSLltMCQAAIasKDg ; Sat, 23 Jun 2018 14:32:43 -0400 Received: from smtp25.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy20.mail.ord1d.rsapps.net with LMTP id qA4hI0uSLltGGQAAsk8m8w ; Sat, 23 Jun 2018 14:32:43 -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: smtp25.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: cc8095ee-7713-11e8-ba64-b8ca3a673c88-1-1 Received: from [216.105.38.7] ([216.105.38.7:41093] helo=lists.sourceforge.net) by smtp25.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 15/13-06129-3429E2B5; Sat, 23 Jun 2018 14:32:43 -0400 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 1fWnK0-0002kq-Bm; Sat, 23 Jun 2018 18:31:40 +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 1fWnJy-0002kg-Un for openvpn-devel@lists.sourceforge.net; Sat, 23 Jun 2018 18:31:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=VRGs6IqW6/hfw8Bd+ulBysdpmohUc0Qvoxb2m7Dmv0w=; b=EB3udOSaeV/3/qFGqxN5HQnwY0 zTMolZmgZZp3BXf2PNHXA0PWK6PAOzNAM+kjrPgbpetMipeGrdzRoUAXsfgjDeCMa+Lt1KoP+bvjT Xk3VwOFghKWmBxcnFAUik+x/nexKc/6pXuK89JPAMHRKflewmmrTvXL9wcvWRV0U25Jg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=VRGs6IqW6/hfw8Bd+ulBysdpmohUc0Qvoxb2m7Dmv0w=; b=mD2n0FDHExwhA5P+Pd0cd59XdQ fH8BtSzCCCNERA/ioabMvm8SeTOZw/IsQkykxE31ObE+wxJSFqphzBUZ6gL6kMPRp4QJB1lqyVjKp 6IfxGdw26bOjCe+xtcSdWL/gMs+91xP5zewFeDGfLQ4YnpQ+nUSNSQ1pF8/AMcD2HCDs=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fWnJx-006qTh-0k for openvpn-devel@lists.sourceforge.net; Sat, 23 Jun 2018 18:31:38 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sun, 24 Jun 2018 02:31:08 +0800 Message-Id: <20180623183108.18684-1-a@unstable.cc> In-Reply-To: <20180613141213.5962-1-a@unstable.cc> References: <20180613141213.5962-1-a@unstable.cc> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1fWnJx-006qTh-0k Subject: [Openvpn-devel] [PATCH v4 2/8] windows: properly configure TAP driver when no IPv4 is configured 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: , Cc: Antonio Quartulli MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli This patch ensures that the TAP driver on a windows host is still configured, even though no IPv4 has been provided. In this case the TAP driver ioctl will be invoked with a fake 0.0.0.0/0.0.0.0 IPv4 which will simply start the interface and get it to a working state. Trac: #208 Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- Changes from v2: - rebased on top ov v4 1/8 - extended commit message - moved did_ifconfig_setup check into test_routes() - added longer comment into test_routes() to explain check condition Changes from v3: - fixed typ0 in condition in test_routes(): from 'c->c1.tuntap' to 'tt' - tested on Win10 against ipv6-only and ipv6+ipv4 server (on same LAN) src/openvpn/route.c | 6 +++++- src/openvpn/tun.c | 24 +++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 8990a986..f6962848 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2642,7 +2642,11 @@ test_routes(const struct route_list *rl, const struct tuntap *tt) ret = true; adapter_up = true; - if (rl) + /* we do this test only if we have IPv4 routes to install, and if + * the tun/tap interface has seen IPv4 ifconfig - because if we + * have no IPv4, the check will always fail, failing tun init + */ + if (rl && tt->did_ifconfig_setup) { struct route_ipv4 *r; for (r = rl->routes, len = 0; r; r = r->next, ++len) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 2e1c96e6..f9b9c716 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -5703,7 +5703,10 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun msg(M_FATAL, "ERROR: --dev tun also requires --ifconfig"); } - if (tt->topology == TOP_SUBNET) + /* send 0/0/0 to the TAP driver even if we have no IPv4 configured to + * ensure it is somehow initialized. + */ + if (!tt->did_ifconfig_setup || tt->topology == TOP_SUBNET) { in_addr_t ep[3]; BOOL status; @@ -5716,12 +5719,19 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun ep, sizeof(ep), ep, sizeof(ep), &len, NULL); - msg(status ? M_INFO : M_FATAL, "Set TAP-Windows TUN subnet mode network/local/netmask = %s/%s/%s [%s]", - print_in_addr_t(ep[1], IA_NET_ORDER, &gc), - print_in_addr_t(ep[0], IA_NET_ORDER, &gc), - print_in_addr_t(ep[2], IA_NET_ORDER, &gc), - status ? "SUCCEEDED" : "FAILED"); - + if (tt->did_ifconfig_setup) + { + msg(status ? M_INFO : M_FATAL, "Set TAP-Windows TUN subnet mode network/local/netmask = %s/%s/%s [%s]", + print_in_addr_t(ep[1], IA_NET_ORDER, &gc), + print_in_addr_t(ep[0], IA_NET_ORDER, &gc), + print_in_addr_t(ep[2], IA_NET_ORDER, &gc), + status ? "SUCCEEDED" : "FAILED"); + } + else + { + msg(status ? M_INFO : M_FATAL, "Set TAP-Windows TUN with fake IPv4 [%s]", + status ? "SUCCEEDED" : "FAILED"); + } } else {