From patchwork Thu Dec 19 11:39:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 949 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 with LMTP id cELKLXP8+11kDAAAIUCqbw for ; Thu, 19 Dec 2019 17:40:51 -0500 Received: from proxy11.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net with LMTP id KEPJKnP8+11zHgAAfY0hYg ; Thu, 19 Dec 2019 17:40:51 -0500 Received: from smtp30.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy11.mail.iad3b.rsapps.net with LMTP id UMV1JHP8+13ITgAARNREpw ; Thu, 19 Dec 2019 17:40:51 -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: smtp30.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: 9b4b0a96-22b0-11ea-90f2-525400502618-1-1 Received: from [216.105.38.7] ([216.105.38.7:52012] helo=lists.sourceforge.net) by smtp30.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 53/6E-03371-27CFBFD5; Thu, 19 Dec 2019 17:40:51 -0500 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1ii4Sd-00042g-4x; Thu, 19 Dec 2019 22:39:59 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ii4SV-00041d-B8 for openvpn-devel@lists.sourceforge.net; Thu, 19 Dec 2019 22:39:51 +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=fqjFB/77U+lKcZhKXoKQxvOjeRGjiEFE7NJYwB3o5iw=; b=T7IzDVnV0RXLge5BdNC28zNGcz gEbIYg9zuu0ORvnlweJX9FWl8pmJVcxeH0FyuLczwuZeFjoQV5RU4TMZZ5nu1UX/CWILHc+9vL3r4 4ccw94V3S6sNo7fsfSmc4jj/mRjyiBQae9maUi3CvM0TgVbOf2GgONEBxOrdHHpqTs8E=; 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=fqjFB/77U+lKcZhKXoKQxvOjeRGjiEFE7NJYwB3o5iw=; b=ND0kF78MB+tqsOZ3KHI+qnMnLn CFh9ZLicJ9B/PW/2eMCedK5dDpItrzTysCqzwmfTAlTdzPEoC/kJedWioNTyFt8xUVTKH3GSF033e 53qIzNSHHgWlXt23Rl2JWBYarErf0PtjnRE/aWqpJD7BO1obLheq0H8sYSwBqLgL5ysw=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1ii4ST-007tdn-5d for openvpn-devel@lists.sourceforge.net; Thu, 19 Dec 2019 22:39:51 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id CD4501002FBB; Thu, 19 Dec 2019 23:39:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1576795176; bh=fqjFB/77U+lKcZhKXoKQxvOjeRGjiEFE7NJYwB3o5iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bX8VW15NQKDTDa1grEVwlemcbUcq5SQuBd16K40JhEZ91YYmnImWxiOVMuvYWXWfE PfFP8MgtDppz6benUWRD9fgOEMyaBkS9SXvyHBKFowXTemnVextr3nzPVWhfNmjrYu JA7VJ6Bac3+fc6jqCLmY+utee1uNOaBzKjk5xMLo= 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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:99ff:8a54:cadf:8a38]) by pub5.amebis.si (Postfix) with ESMTP id D56B41002FBC; Thu, 19 Dec 2019 23:39:30 +0100 (CET) From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Thu, 19 Dec 2019 23:39:13 +0100 Message-Id: <20191219223917.1614-3-simon@rozman.si> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: <20191219223917.1614-1-simon@rozman.si> References: <20191219223917.1614-1-simon@rozman.si> 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: 1ii4ST-007tdn-5d Subject: [Openvpn-devel] [PATCH 3/7] tun.c: make wintun_register_ring_buffer() non-fatal on failures 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 Wintun allows multiple handles to be opened on it's NDIS device pipe. Just by succeeding to open the pipe does not warrant the adapter is unused. When iterating for available Wintun adapter, we will need to try registering ring buffers with each one to actually determine which one is used and which one is not. Therefore, a failure to register ring buffers should be detectable, but not M_FATAL. Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpn/tun.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 623ed37b..220dee87 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -5647,11 +5647,12 @@ register_dns_service(const struct tuntap *tt) gc_free(&gc); } -static void +static bool service_register_ring_buffers(const struct tuntap *tt) { HANDLE msg_channel = tt->options.msg_channel; ack_message_t ack; + bool ret = true; struct gc_arena gc = gc_new(); register_ring_buffers_message_t msg = { @@ -5669,13 +5670,13 @@ service_register_ring_buffers(const struct tuntap *tt) if (!send_msg_iservice(msg_channel, &msg, sizeof(msg), &ack, "Register ring buffers")) { - gc_free(&gc); - return; + ret = false; } else if (ack.error_number != NO_ERROR) { - msg(M_FATAL, "Register ring buffers failed using service: %s [status=0x%x]", + msg(M_NONFATAL, "Register ring buffers failed using service: %s [status=0x%x]", strerror_win32(ack.error_number, &gc), ack.error_number); + ret = false; } else { @@ -5683,6 +5684,7 @@ service_register_ring_buffers(const struct tuntap *tt) } gc_free(&gc); + return ret; } void @@ -5922,9 +5924,11 @@ tuntap_set_ip_addr(struct tuntap *tt, gc_free(&gc); } -static void +static bool wintun_register_ring_buffer(struct tuntap *tt) { + bool ret = true; + tt->wintun_send_ring = (struct tun_ring *)MapViewOfFile(tt->wintun_send_ring_handle, FILE_MAP_ALL_ACCESS, 0, @@ -5939,7 +5943,7 @@ wintun_register_ring_buffer(struct tuntap *tt) if (tt->options.msg_channel) { - service_register_ring_buffers(tt); + ret = service_register_ring_buffers(tt); } else { @@ -5953,13 +5957,16 @@ wintun_register_ring_buffer(struct tuntap *tt) tt->rw_handle.read, tt->rw_handle.write)) { - msg(M_FATAL, "ERROR: Failed to register ring buffers: %lu", GetLastError()); + msg(M_NONFATAL, "Failed to register ring buffers: %lu", GetLastError()); + ret = false; } if (!RevertToSelf()) { msg(M_FATAL, "ERROR: RevertToSelf error: %lu", GetLastError()); } } + + return ret; } static void @@ -6367,7 +6374,10 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun if (tt->wintun) { - wintun_register_ring_buffer(tt); + if (!wintun_register_ring_buffer(tt)) + { + msg(M_FATAL, "Failed to register ring buffers"); + } } else {