From patchwork Wed Jun 13 04:12:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 374 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id zFRoI6gmIVvlfAAAIUCqbw for ; Wed, 13 Jun 2018 10:14:00 -0400 Received: from proxy18.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net (Dovecot) with LMTP id W2F7L6gmIVs6FAAAfY0hYg ; Wed, 13 Jun 2018 10:14:00 -0400 Received: from smtp1.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy18.mail.iad3b.rsapps.net with LMTP id eLjELagmIVsRTwAA3NpJmQ ; Wed, 13 Jun 2018 10:14: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: smtp1.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 044e4f96-6f14-11e8-915b-5254008fd675-1-1 Received: from [216.105.38.7] ([216.105.38.7:48007] helo=lists.sourceforge.net) by smtp1.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 64/96-21102-8A6212B5; Wed, 13 Jun 2018 10:14:00 -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 1fT6WC-0000U4-9R; Wed, 13 Jun 2018 14:13:00 +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 1fT6WA-0000Tt-Te for openvpn-devel@lists.sourceforge.net; Wed, 13 Jun 2018 14:12:58 +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=NZ3iPTx4UAGS3nYdfJFroMQqRex1CJRBbiZbTRKuOPU=; b=ZYriTH8HvYJVWK/uwdJgcfu3yp xcQ1xZ8ueCHFJ8QlulWyr1NqzJwe8tuWRwGW5Ps4xYdjNflb9O/J58ocdyJKJaP5OG8CzR5kWj0cs Pk7yrWhcNJUF+d27pt0cnLaUz9EiW7UGTpVpXQSlMHpGFrReQPjNdeD1Z28Kq539rLok=; 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=NZ3iPTx4UAGS3nYdfJFroMQqRex1CJRBbiZbTRKuOPU=; b=cxPSY4V88pCZtzSJP5X3zFUSmL j2MPlobmbnqAGrrZlvKPEre9EZGLB0Ppjd3RliuyAoFWAFBANjCJEYQr803xvRiWBbX0SCwB6EHT6 6njs2cY81LoRcguorwv2AKi0bxUxwXkR+vOBp5cQxPZUZVigotsmoqRFLZ25Zi6RQKgw=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fT6W9-002xSk-3M for openvpn-devel@lists.sourceforge.net; Wed, 13 Jun 2018 14:12:58 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Wed, 13 Jun 2018 22:12:13 +0800 Message-Id: <20180613141213.5962-1-a@unstable.cc> In-Reply-To: <20180608052017.6696-3-a@unstable.cc> References: <20180608052017.6696-3-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: 1fT6W9-002xSk-3M Subject: [Openvpn-devel] [PATCH v3 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 --- 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 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..be07bd65 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 && c->c1.tuntap->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 878fd845..c0d1ac18 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 {