From patchwork Tue Dec 7 01:11:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2117 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.51]) by backend41.mail.ord1d.rsapps.net with LMTP id YBgQGNxPr2EoLgAAqwncew (envelope-from ) for ; Tue, 07 Dec 2021 07:13:16 -0500 Received: from proxy20.mail.iad3a.rsapps.net ([172.27.255.51]) by director9.mail.ord1d.rsapps.net with LMTP id gO+uJ9xPr2ELXQAAalYnBA (envelope-from ) for ; Tue, 07 Dec 2021 07:13:16 -0500 Received: from smtp6.gate.iad3a ([172.27.255.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy20.mail.iad3a.rsapps.net with LMTPS id iHqXH9xPr2HKVgAAtfLT2w (envelope-from ) for ; Tue, 07 Dec 2021 07:13:16 -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: smtp6.gate.iad3a.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: 0e5919a6-5757-11ec-9431-5254002f0085-1-1 Received: from [216.105.38.7] ([216.105.38.7:53824] helo=lists.sourceforge.net) by smtp6.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 99/F1-21140-CDF4FA16; Tue, 07 Dec 2021 07:13:16 -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.94.2) (envelope-from ) id 1muZKP-00009P-N0; Tue, 07 Dec 2021 12:12:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1muZKN-000096-8C for openvpn-devel@lists.sourceforge.net; Tue, 07 Dec 2021 12:12:11 +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=dRj5pe45Slsye9AapTy8UUudUWB3h68mEWtz2mk3S5Q=; b=YqDGv9icphGo8qkxGwP5+Ly/DY W4lLFmzfkc8Mmc4VkaWmsRD7ICWoizx+Clvlb0s6LeN8DSaCOlPYWXXm7SU1f1NO+d5yk/orMNCjN ghNeqLFEceX/VbkIlwAk0yx1RRZvO6JyfO/gVHt+Dpl/zEcybz9QE94tVuGMVpclQDVY=; 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=dRj5pe45Slsye9AapTy8UUudUWB3h68mEWtz2mk3S5Q=; b=VUjU2IxppOJrerCgS4J+Mi+gEk Vsu54MO5Ag6vG0wiz/waUHdCRNkAAiOVLfoRVFryHRKKhrrj+Qu/+qW3LdZ05abOgWXN6zoKv42nt uD5pmOUp8ggd/ZYVsbe0mGN7EtMvk07SpofmkVseUTk6RrWtzsFoNJL4XwNQHP9d46i8=; 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.92.3) id 1muZKJ-0008PI-8t for openvpn-devel@lists.sourceforge.net; Tue, 07 Dec 2021 12:12:10 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Tue, 7 Dec 2021 13:11:36 +0100 Message-Id: <20211207121137.3221-8-a@unstable.cc> In-Reply-To: <20211207121137.3221-1-a@unstable.cc> References: <20211207121137.3221-1-a@unstable.cc> MIME-Version: 1.0 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: From: Lev Stipakov mingw i686 has GetOverlappedResultEx() in header file but not in lib file, causing linking error. To work around this issue, introduce dco_get_overlapped_result compat macro, which is defined as GetOverlappedResultEx() for all build configurations except mingw i686. For latter case, define compat [...] Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1muZKJ-0008PI-8t Subject: [Openvpn-devel] [RFC 7/8] ovpn-dco-win: fix mingw i686 build 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: Lev Stipakov Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov mingw i686 has GetOverlappedResultEx() in header file but not in lib file, causing linking error. To work around this issue, introduce dco_get_overlapped_result compat macro, which is defined as GetOverlappedResultEx() for all build configurations except mingw i686. For latter case, define compat implementation which uses GetOverlappedResult() and Sleep(). Signed-off-by: Lev Stipakov Signed-off-by: Arne Schwabe --- src/compat/Makefile.am | 3 +- src/compat/compat-dco_get_overlapped_result.c | 44 +++++++++++++++++++ src/compat/compat.h | 6 +++ src/compat/compat.vcxproj | 1 + src/compat/compat.vcxproj.filters | 3 ++ src/openvpn/networking_windco.c | 11 +++-- 6 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 src/compat/compat-dco_get_overlapped_result.c diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am index 95eb04bb..cefc2d81 100644 --- a/src/compat/Makefile.am +++ b/src/compat/Makefile.am @@ -28,4 +28,5 @@ libcompat_la_SOURCES = \ compat-gettimeofday.c \ compat-daemon.c \ compat-strsep.c \ - compat-versionhelpers.h + compat-versionhelpers.h \ + compat-dco_get_overlapped_result.c diff --git a/src/compat/compat-dco_get_overlapped_result.c b/src/compat/compat-dco_get_overlapped_result.c new file mode 100644 index 00000000..4a52dd46 --- /dev/null +++ b/src/compat/compat-dco_get_overlapped_result.c @@ -0,0 +1,44 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2021 Lev Stipakov + * Copyright (C) 2021 OpenVPN Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING included with this + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif + +#include "compat.h" + +#if defined(__MINGW32__) && !defined(__MINGW64__) +BOOL dco_get_overlapped_result(HANDLE handle, OVERLAPPED* ov, DWORD* transferred, DWORD delay_millisec, BOOL unused) +{ + BOOL res = GetOverlappedResult(handle, ov, transferred, FALSE); + if ((res == 0) && (GetLastError() == ERROR_IO_INCOMPLETE)) + { + Sleep(delay_millisec); + } + return res; +} +#endif diff --git a/src/compat/compat.h b/src/compat/compat.h index 026974a8..274febce 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -62,4 +62,10 @@ char *strsep(char **stringp, const char *delim); #endif +#if defined(__MINGW32__) && !defined(__MINGW64__) +BOOL dco_get_overlapped_result(HANDLE handle, OVERLAPPED* ov, DWORD* transferred, DWORD delay_millisec, BOOL unused); +#else +#define dco_get_overlapped_result GetOverlappedResultEx +#endif + #endif /* COMPAT_H */ diff --git a/src/compat/compat.vcxproj b/src/compat/compat.vcxproj index fe03a51a..1dacb503 100644 --- a/src/compat/compat.vcxproj +++ b/src/compat/compat.vcxproj @@ -159,6 +159,7 @@ + diff --git a/src/compat/compat.vcxproj.filters b/src/compat/compat.vcxproj.filters index 96ca026a..73fc9f91 100644 --- a/src/compat/compat.vcxproj.filters +++ b/src/compat/compat.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + diff --git a/src/openvpn/networking_windco.c b/src/openvpn/networking_windco.c index 3c88b752..f4ec01bc 100644 --- a/src/openvpn/networking_windco.c +++ b/src/openvpn/networking_windco.c @@ -74,17 +74,22 @@ void dco_start_tun(struct tuntap* tt) int dco_connect_wait(HANDLE handle, OVERLAPPED* ov, int timeout, volatile int* signal_received) { - while (timeout-- > 0) + DWORD timeout_msec = timeout * 1000; + const int poll_interval_ms = 50; + + while (timeout_msec > 0) { + timeout_msec -= poll_interval_ms; + DWORD transferred; - if (GetOverlappedResultEx(handle, ov, &transferred, 1000, FALSE) != 0) + if (dco_get_overlapped_result(handle, ov, &transferred, poll_interval_ms, FALSE) != 0) { /* TCP connection established by dco */ return 0; } DWORD err = GetLastError(); - if (err != WAIT_TIMEOUT) + if ((err != WAIT_TIMEOUT) && (err != ERROR_IO_INCOMPLETE)) { /* dco reported connection error */ struct gc_arena gc = gc_new();