From: "stipa (Code Review)" Date: Tue, 13 May 2025 15:06:37 +0000 In-Reply-To: References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296... Message-ID: <08269078fb4ed8555a9bfa8b9f5ea6f23564610f-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="YyUypzQcD6s="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: win: remove Wintun support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --YyUypzQcD6s= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, plaisthos, stipa. Hello cron2, flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1021?usp=3Demail to look at the new patch set (#5). The following approvals got outdated and were removed: Code-Review-1 by cron2 Change subject: win: remove Wintun support ...................................................................... win: remove Wintun support Since DCO supports modern ciphers and server mode, there is no reason to support Wintun anymore. This also removes --windows-driver option support. The default driver is DCO, as it has been since 2.6. If for some reasons one doesn't want to use it, --disable-dco multiplatform option will switch to tap-windows6. Change-Id: I43ec390040bffeec05270271ea7fb54fb219c536 Signed-off-by: Lev Stipakov --- M doc/man-sections/vpn-network-options.rst M doc/man-sections/windows-options.rst M include/openvpn-msg.h M src/openvpn/Makefile.am M src/openvpn/dco.c M src/openvpn/forward.c M src/openvpn/forward.h M src/openvpn/mudp.c M src/openvpn/multi_io.c M src/openvpn/options.c D src/openvpn/ring_buffer.h M src/openvpn/tun.c M src/openvpn/tun.h M src/openvpnmsica/openvpnmsica.c M src/openvpnmsica/openvpnmsica.h M src/openvpnserv/CMakeLists.txt M src/openvpnserv/Makefile.am M src/openvpnserv/interactive.c M src/tapctl/main.c M src/tapctl/tap.h 20 files changed, 27 insertions(+), 801 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/1021/5 diff --git a/doc/man-sections/vpn-network-options.rst b/doc/man-sections/vp= n-network-options.rst index 67f7e1f..40b8c19 100644 --- a/doc/man-sections/vpn-network-options.rst +++ b/doc/man-sections/vpn-network-options.rst @@ -137,8 +137,7 @@ Set additional network parameters on supported platforms. May be specifi= ed on the client or pushed from the server. On Windows these options are handled by the ``tap-windows6`` driver by default or directly by OpenVPN - if dhcp is disabled or the ``wintun`` driver is in use. The - ``OpenVPN for Android`` client also handles them internally. + if dhcp is disabled. The ``OpenVPN for Android`` client also handles the= m internally. On all other platforms these options are only saved in the client's environment under the name :code:`foreign_option_{n}` before the diff --git a/doc/man-sections/windows-options.rst b/doc/man-sections/window= s-options.rst index 1955869..af2fb45 100644 --- a/doc/man-sections/windows-options.rst +++ b/doc/man-sections/windows-options.rst @@ -252,9 +252,3 @@ otherwise it defaulted to :code:`C:\\WINDOWS`. It is not needed to use the ``env`` keyword any more, and it will just be ignored. A warning is logged when this is found in the configuration file. - ---windows-driver drv - Specifies which tun driver to use. Values are :code:`ovpn-dco` (default), - :code:`tap-windows6` and :code:`wintun`. :code:`ovpn-dco` and :code:`win= tun` - require ``--dev tun``. :code:`wintun` also requires OpenVPN process to r= un - elevated, or be invoked using the Interactive Service. diff --git a/include/openvpn-msg.h b/include/openvpn-msg.h index 2cf8d40..34b133b 100644 --- a/include/openvpn-msg.h +++ b/include/openvpn-msg.h @@ -44,7 +44,7 @@ msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, - msg_register_ring_buffers, + deprecated_msg_register_ring_buffers, msg_set_mtu, msg_add_wins_cfg, msg_del_wins_cfg, @@ -159,15 +159,6 @@ typedef struct { message_header_t header; - HANDLE device; - HANDLE send_ring_handle; - HANDLE receive_ring_handle; - HANDLE send_tail_moved; - HANDLE receive_tail_moved; -} register_ring_buffers_message_t; - -typedef struct { - message_header_t header; interface_t iface; short family; int mtu; @@ -176,7 +167,6 @@ typedef enum { ADAPTER_TYPE_DCO, ADAPTER_TYPE_TAP, - ADAPTER_TYPE_WINTUN } adapter_type_t; typedef struct { diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am index 37af683..3c1a875 100644 --- a/src/openvpn/Makefile.am +++ b/src/openvpn/Makefile.am @@ -163,6 +163,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES +=3D openvpn_win32_resources.rc wfp_block.c wfp_block.h ri= ng_buffer.h +openvpn_SOURCES +=3D openvpn_win32_resources.rc wfp_block.c wfp_block.h openvpn_LDADD +=3D -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm= -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 7ad9cb3..c61cbda 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -359,14 +359,6 @@ return false; } - if ((o->windows_driver =3D=3D WINDOWS_DRIVER_WINTUN) - || (o->windows_driver =3D=3D WINDOWS_DRIVER_TAP_WINDOWS6)) - { - msg(msglevel, "--windows-driver is set to '%s'. Disabling Data Cha= nnel Offload", - print_tun_backend_driver(o->windows_driver)); - return false; - } - if ((o->mode =3D=3D MODE_SERVER) && o->ce.local_list->len > 1) { msg(msglevel, "multiple --local options defined, disabling data ch= annel offload"); diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 0b8b262..ed4cdb4 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1308,26 +1308,11 @@ c->c2.buf =3D c->c2.buffers->read_tun_buf; #ifdef _WIN32 - if (c->c1.tuntap->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN) - { - read_wintun(c->c1.tuntap, &c->c2.buf); - if (c->c2.buf.len =3D=3D -1) - { - register_signal(c->sig, SIGHUP, "tun-abort"); - c->persist.restart_sleep_seconds =3D 1; - msg(M_INFO, "Wintun read error, restarting"); - perf_pop(); - return; - } - } - else - { - /* we cannot end up here when using dco */ - ASSERT(!dco_enabled(&c->options)); + /* we cannot end up here when using dco */ + ASSERT(!dco_enabled(&c->options)); - sockethandle_t sh =3D { .is_handle =3D true, .h =3D c->c1.tuntap->= hand, .prepend_sa =3D false }; - sockethandle_finalize(sh, &c->c1.tuntap->reads, &c->c2.buf, NULL); - } + sockethandle_t sh =3D { .is_handle =3D true, .h =3D c->c1.tuntap->hand= , .prepend_sa =3D false }; + sockethandle_finalize(sh, &c->c1.tuntap->reads, &c->c2.buf, NULL); #else /* ifdef _WIN32 */ ASSERT(buf_init(&c->c2.buf, c->c2.frame.buf.headroom)); ASSERT(buf_safe(&c->c2.buf, c->c2.frame.buf.payload_size)); @@ -1942,7 +1927,7 @@ #endif #ifdef _WIN32 - size =3D write_tun_buffered(c->c1.tuntap, &c->c2.to_tun); + size =3D tun_write_win32(c->c1.tuntap, &c->c2.to_tun); #else if (c->c1.tuntap->backend_driver =3D=3D DRIVER_AFUNIX) { @@ -2148,17 +2133,6 @@ tuntap |=3D EVENT_READ; } -#ifdef _WIN32 - if (tuntap_is_wintun(c->c1.tuntap)) - { - /* - * With wintun we are only interested in read event. Ring buffer is - * always ready for write, so we don't do wait. - */ - tuntap =3D EVENT_READ; - } -#endif - /* * Configure event wait based on socket, tuntap flags. */ @@ -2217,36 +2191,8 @@ } else { -#ifdef _WIN32 - bool skip_iowait =3D flags & IOW_TO_TUN; - if (flags & IOW_READ_TUN) - { - /* - * don't read from tun if we have pending write to link, - * since every tun read overwrites to_link buffer filled - * by previous tun read - */ - skip_iowait =3D !(flags & IOW_TO_LINK); - } - if (tuntap_is_wintun(c->c1.tuntap) && skip_iowait) - { - unsigned int ret =3D 0; - if (flags & IOW_TO_TUN) - { - ret |=3D TUN_WRITE; - } - if (flags & IOW_READ_TUN) - { - ret |=3D TUN_READ; - } - multi_io->udp_flags =3D ret; - } - else -#endif /* ifdef _WIN32 */ - { - /* slow path - delegate to io_wait_dowork_udp to calculate fla= gs */ - get_io_flags_dowork_udp(c, multi_io, flags); - } + /* slow path - delegate to io_wait_dowork_udp to calculate flags */ + get_io_flags_dowork_udp(c, multi_io, flags); } } diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 77892d6..74c6036 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -360,12 +360,6 @@ { flags |=3D IOW_TO_TUN; } -#ifdef _WIN32 - if (tuntap_ring_empty(c->c1.tuntap)) - { - flags &=3D ~IOW_READ_TUN; - } -#endif return flags; } @@ -393,36 +387,8 @@ } else { -#ifdef _WIN32 - bool skip_iowait =3D flags & IOW_TO_TUN; - if (flags & IOW_READ_TUN) - { - /* - * don't read from tun if we have pending write to link, - * since every tun read overwrites to_link buffer filled - * by previous tun read - */ - skip_iowait =3D !(flags & IOW_TO_LINK); - } - if (tuntap_is_wintun(c->c1.tuntap) && skip_iowait) - { - unsigned int ret =3D 0; - if (flags & IOW_TO_TUN) - { - ret |=3D TUN_WRITE; - } - if (flags & IOW_READ_TUN) - { - ret |=3D TUN_READ; - } - c->c2.event_set_status =3D ret; - } - else -#endif /* ifdef _WIN32 */ - { - /* slow path */ - io_wait_dowork(c, flags); - } + /* slow path */ + io_wait_dowork(c, flags); } } diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 54dfc72..7158d5c 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -457,11 +457,5 @@ { flags |=3D IOW_READ; } -#ifdef _WIN32 - if (tuntap_ring_empty(m->top.c1.tuntap)) - { - flags &=3D ~IOW_READ_TUN; - } -#endif return flags; } diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index f4ca4df..7f47319 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -190,20 +190,6 @@ get_io_flags_udp(&m->top, m->multi_io, p2mp_iow_flags(m)); } -#ifdef _WIN32 - if (tuntap_is_wintun(m->top.c1.tuntap)) - { - if (!tuntap_ring_empty(m->top.c1.tuntap)) - { - /* there is data in wintun ring buffer, read it immediately */ - m->multi_io->esr[0].arg =3D MULTI_IO_TUN; - m->multi_io->esr[0].rwflags =3D EVENT_READ; - m->multi_io->n_esr =3D 1; - return 1; - } - persistent =3D NULL; - } -#endif tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, p= ersistent); #if defined(ENABLE_DCO) \ && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(TARGET= _WIN32)) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 02970a7..55b923c 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -750,10 +750,6 @@ " optional parameter controls the initial state = of ex.\n" "--show-net-up : Show " PACKAGE_NAME "'s view of routing table and n= et adapter list\n" " after TAP adapter is up and routes have been added.= \n" - "--windows-driver : Which tun driver to use?\n" - " ovpn-dco (default)\n" - " tap-windows6\n" - " wintun\n" "--block-outside-dns : Block DNS on other network adapters to preven= t DNS leaks\n" "Windows Standalone Options:\n" "\n" @@ -2592,11 +2588,6 @@ prefix); } } - - if (options->windows_driver =3D=3D WINDOWS_DRIVER_WINTUN && dev !=3D D= EV_TYPE_TUN) - { - msg(M_USAGE, "--windows-driver wintun requires --dev tun"); - } #endif /* ifdef _WIN32 */ /* @@ -3371,9 +3362,8 @@ #ifdef _WIN32 const int dev =3D dev_type_enum(options->dev, options->dev_type); - /* when using wintun/ovpn-dco, kernel doesn't send DHCP requests, so d= on't use it */ - if ((options->windows_driver =3D=3D WINDOWS_DRIVER_WINTUN - || options->windows_driver =3D=3D DRIVER_DCO) + /* when using ovpn-dco, kernel doesn't send DHCP requests, so don't us= e it */ + if ((options->windows_driver =3D=3D DRIVER_DCO) && (options->tuntap_options.ip_win32_type =3D=3D IPW32_SET_DHCP_MA= SQ || options->tuntap_options.ip_win32_type =3D=3D IPW32_SET_ADAP= TIVE)) { @@ -4665,39 +4655,6 @@ return ret; } -#ifdef _WIN32 -/** - * Parses --windows-driver config option - * - * @param str value of --windows-driver option - * @param msglevel msglevel to report parsing error - * @return enum tun_driver_type driver type, WINDOWS_DRIVER_UNSPECIFIED o= n unknown --windows-driver value - */ -static enum tun_driver_type -parse_windows_driver(const char *str, const int msglevel) -{ - if (streq(str, "tap-windows6")) - { - return WINDOWS_DRIVER_TAP_WINDOWS6; - } - else if (streq(str, "wintun")) - { - return WINDOWS_DRIVER_WINTUN; - } - - else if (streq(str, "ovpn-dco")) - { - return DRIVER_DCO; - } - else - { - msg(msglevel, "--windows-driver must be tap-windows6, wintun " - "or ovpn-dco"); - return WINDOWS_DRIVER_UNSPECIFIED; - } -} -#endif /* ifdef _WIN32 */ - /* * parse/print topology coding */ @@ -6012,7 +5969,8 @@ else if (streq(p[0], "windows-driver") && p[1] && !p[2]) { VERIFY_PERMISSION(OPT_P_GENERAL); - options->windows_driver =3D parse_windows_driver(p[1], M_FATAL); + msg(M_WARN, "DEPRECATED OPTION: windows-driver: In OpenVPN 2.7, th= e default Windows driver is ovpn-dco. " + "If incompatible options are used, OpenVPN will fall back to t= ap-windows6. Wintun support has been removed."); } #endif else if (streq(p[0], "disable-dco")) diff --git a/src/openvpn/ring_buffer.h b/src/openvpn/ring_buffer.h deleted file mode 100644 index c536980..0000000 --- a/src/openvpn/ring_buffer.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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) 2002-2024 OpenVPN Inc - * 2019 Lev Stipakov - * - * 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; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef _WIN32 -#ifndef OPENVPN_RING_BUFFER_H -#define OPENVPN_RING_BUFFER_H - -#include -#include - -#include -#include - -/* - * Values below are taken from Wireguard Windows client - * https://github.com/WireGuard/wireguard-go/blob/master/tun/wintun/ring_w= indows.go#L14 - */ -#define WINTUN_RING_CAPACITY 0x800000 -#define WINTUN_RING_TRAILING_BYTES 0x10000 -#define WINTUN_MAX_PACKET_SIZE 0xffff -#define WINTUN_PACKET_ALIGN 4 - -#define TUN_IOCTL_REGISTER_RINGS CTL_CODE(51820U, 0x970U, METHOD_BUFFERED,= FILE_READ_DATA | FILE_WRITE_DATA) - -/** - * Wintun ring buffer - * See https://github.com/WireGuard/wintun#ring-layout - */ -struct tun_ring -{ - volatile ULONG head; - volatile ULONG tail; - volatile LONG alertable; - UCHAR data[WINTUN_RING_CAPACITY + WINTUN_RING_TRAILING_BYTES]; -}; - -/** - * Struct for ring buffers registration - * See https://github.com/WireGuard/wintun#registering-rings - */ -struct tun_register_rings -{ - struct - { - ULONG ring_size; - struct tun_ring *ring; - HANDLE tail_moved; - } send, receive; -}; - -struct TUN_PACKET_HEADER -{ - uint32_t size; -}; - -struct TUN_PACKET -{ - uint32_t size; - UCHAR data[WINTUN_MAX_PACKET_SIZE]; -}; - -/** - * Registers ring buffers used to exchange data between - * userspace openvpn process and wintun kernel driver, - * see https://github.com/WireGuard/wintun#registering-rings - * - * @param device handle to opened wintun device - * @param send_ring pointer to send ring - * @param receive_ring pointer to receive ring - * @param send_tail_moved event set by wintun to signal openvpn - * that data is available for reading in send r= ing - * @param receive_tail_moved event set by openvpn to signal wintun - * that data has been written to receive ring - * @return true if registration is successful, false ot= herwise - use GetLastError() - */ -static inline bool -register_ring_buffers(HANDLE device, - struct tun_ring *send_ring, - struct tun_ring *receive_ring, - HANDLE send_tail_moved, - HANDLE receive_tail_moved) -{ - struct tun_register_rings rr; - BOOL res; - DWORD bytes_returned; - - ZeroMemory(&rr, sizeof(rr)); - - rr.send.ring =3D send_ring; - rr.send.ring_size =3D sizeof(struct tun_ring); - rr.send.tail_moved =3D send_tail_moved; - - rr.receive.ring =3D receive_ring; - rr.receive.ring_size =3D sizeof(struct tun_ring); - rr.receive.tail_moved =3D receive_tail_moved; - - res =3D DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr, sizeof(= rr), - NULL, 0, &bytes_returned, NULL); - - return res !=3D FALSE; -} - -#endif /* ifndef OPENVPN_RING_BUFFER_H */ -#endif /* ifdef _WIN32 */ diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 6a2043e..d7c38a1 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -63,9 +63,6 @@ case WINDOWS_DRIVER_TAP_WINDOWS6: return "tap-windows6"; - case WINDOWS_DRIVER_WINTUN: - return "wintun"; - case DRIVER_GENERIC_TUNTAP: return "tun/tap"; @@ -473,10 +470,6 @@ t =3D ADAPTER_TYPE_TAP; break; - case WINDOWS_DRIVER_WINTUN: - t =3D ADAPTER_TYPE_WINTUN; - break; - case DRIVER_DCO: t =3D ADAPTER_TYPE_DCO; break; @@ -1040,37 +1033,8 @@ overlapped_io_init(&tt->writes, frame, TRUE); tt->adapter_index =3D TUN_ADAPTER_INDEX_INVALID; - if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN) - { - tt->wintun_send_ring_handle =3D CreateFileMapping(INVALID_HANDLE_V= ALUE, NULL, - PAGE_READWRITE, - 0, - sizeof(struct tun_= ring), - NULL); - tt->wintun_receive_ring_handle =3D CreateFileMapping(INVALID_HANDL= E_VALUE, - NULL, - PAGE_READWRITE, - 0, - sizeof(struct t= un_ring), - NULL); - if ((tt->wintun_send_ring_handle =3D=3D NULL) || (tt->wintun_recei= ve_ring_handle =3D=3D NULL)) - { - msg(M_FATAL, "Cannot allocate memory for ring buffer"); - } - - tt->rw_handle.read =3D CreateEvent(NULL, FALSE, FALSE, NULL); - tt->rw_handle.write =3D CreateEvent(NULL, FALSE, FALSE, NULL); - - if ((tt->rw_handle.read =3D=3D NULL) || (tt->rw_handle.write =3D= =3D NULL)) - { - msg(M_FATAL, "Cannot create events for ring buffer"); - } - } - else - { - tt->rw_handle.read =3D tt->reads.overlapped.hEvent; - tt->rw_handle.write =3D tt->writes.overlapped.hEvent; - } + tt->rw_handle.read =3D tt->reads.overlapped.hEvent; + tt->rw_handle.write =3D tt->writes.overlapped.hEvent; #endif /* ifdef _WIN32 */ } @@ -4010,10 +3974,6 @@ { windows_driver =3D WINDOWS_DRIVER_TAP_WINDOWS6; } - else if (strcasecmp(component_id, WINTUN_COMPONENT_ID)= =3D=3D 0) - { - windows_driver =3D WINDOWS_DRIVER_WINTUN; - } else if (strcasecmp(component_id, "ovpn-dco") =3D=3D 0) { windows_driver =3D DRIVER_DCO; @@ -4320,7 +4280,7 @@ } /* - * Lookup a TAP-Windows or Wintun adapter by GUID. + * Lookup an adapter by GUID. */ static const struct tap_reg * get_adapter_by_guid(const char *guid, const struct tap_reg *tap_reg) @@ -4375,7 +4335,7 @@ { if (!tap_reg) { - msg(M_FATAL, "There are no TAP-Windows, Wintun or ovpn-dco adapter= s " + msg(M_FATAL, "There are no TAP-Windows or ovpn-dco adapters " "on this system. You should be able to create an adapter " "by using tapctl.exe utility."); } @@ -6086,46 +6046,6 @@ gc_free(&gc); } -static bool -service_register_ring_buffers(const struct tuntap *tt) -{ - HANDLE msg_channel =3D tt->options.msg_channel; - ack_message_t ack; - bool ret =3D true; - struct gc_arena gc =3D gc_new(); - - register_ring_buffers_message_t msg =3D { - .header =3D { - msg_register_ring_buffers, - sizeof(register_ring_buffers_message_t), - 0 - }, - .device =3D tt->hand, - .send_ring_handle =3D tt->wintun_send_ring_handle, - .receive_ring_handle =3D tt->wintun_receive_ring_handle, - .send_tail_moved =3D tt->rw_handle.read, - .receive_tail_moved =3D tt->rw_handle.write - }; - - if (!send_msg_iservice(msg_channel, &msg, sizeof(msg), &ack, "Register= ring buffers")) - { - ret =3D false; - } - else if (ack.error_number !=3D NO_ERROR) - { - msg(M_NONFATAL, "Register ring buffers failed using service: %s [s= tatus=3D0x%x]", - strerror_win32(ack.error_number, &gc), ack.error_number); - ret =3D false; - } - else - { - msg(M_INFO, "Ring buffers registered via service"); - } - - gc_free(&gc); - return ret; -} - void fork_register_dns_action(struct tuntap *tt) { @@ -6363,58 +6283,6 @@ gc_free(&gc); } -static bool -wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid) -{ - bool ret =3D true; - - tt->wintun_send_ring =3D (struct tun_ring *)MapViewOfFile(tt->wintun_s= end_ring_handle, - FILE_MAP_ALL_A= CCESS, - 0, - 0, - sizeof(struct = tun_ring)); - - tt->wintun_receive_ring =3D (struct tun_ring *)MapViewOfFile(tt->wintu= n_receive_ring_handle, - FILE_MAP_AL= L_ACCESS, - 0, - 0, - sizeof(stru= ct tun_ring)); - - if (tt->options.msg_channel) - { - ret =3D service_register_ring_buffers(tt); - } - else - { - if (!register_ring_buffers(tt->hand, - tt->wintun_send_ring, - tt->wintun_receive_ring, - tt->rw_handle.read, - tt->rw_handle.write)) - { - switch (GetLastError()) - { - case ERROR_ACCESS_DENIED: - msg(M_FATAL, "ERROR: Wintun requires SYSTEM privilege= s and therefore " - "should be used with interactive service. If you w= ant to " - "use openvpn from command line, you need to do SYS= TEM " - "elevation yourself (for example with psexec)."); - break; - - case ERROR_ALREADY_INITIALIZED: - msg(M_NONFATAL, "Adapter %s is already in use", device= _guid); - break; - - default: - msg(M_NONFATAL | M_ERRNO, "Failed to register ring buf= fers"); - } - ret =3D false; - } - - } - return ret; -} - static void tuntap_set_connected(const struct tuntap *tt) { @@ -6574,8 +6442,7 @@ const char *path =3D NULL; char tuntap_device_path[256]; - if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN - || tt->backend_driver =3D=3D DRIVER_DCO) + if (tt->backend_driver =3D=3D DRIVER_DCO) { const struct device_instance_id_interface *dev_if; @@ -6629,18 +6496,6 @@ return false; } - if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN) - { - /* Wintun adapter may be considered "open" after ring buffers are = successfuly registered. */ - if (!wintun_register_ring_buffer(tt, device_guid)) - { - msg(D_TUNTAP_INFO, "Failed to register %s adapter ring buffers= ", device_guid); - CloseHandle(tt->hand); - tt->hand =3D NULL; - return false; - } - } - return true; } @@ -6988,16 +6843,6 @@ } tt->hand =3D NULL; } - - if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN) - { - CloseHandle(tt->rw_handle.read); - CloseHandle(tt->rw_handle.write); - UnmapViewOfFile(tt->wintun_send_ring); - UnmapViewOfFile(tt->wintun_receive_ring); - CloseHandle(tt->wintun_send_ring_handle); - CloseHandle(tt->wintun_receive_ring_handle); - } } void diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index bcc23b4..de1876a 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -39,13 +39,11 @@ #include "proto.h" #include "misc.h" #include "networking.h" -#include "ring_buffer.h" #include "dco.h" =20 enum tun_driver_type { WINDOWS_DRIVER_UNSPECIFIED, WINDOWS_DRIVER_TAP_WINDOWS6, - WINDOWS_DRIVER_WINTUN, DRIVER_GENERIC_TUNTAP, /** using an AF_UNIX socket to pass packets from/to an external progra= m. * This is always defined. We error out if a user tries to open this = type @@ -58,7 +56,6 @@ }; #ifdef _WIN32 -#define WINTUN_COMPONENT_ID "wintun" #define DCO_WIN_REFERENCE_STRING "ovpn-dco" #endif @@ -233,11 +230,7 @@ int standby_iter; - HANDLE wintun_send_ring_handle; - HANDLE wintun_receive_ring_handle; - struct tun_ring *wintun_send_ring; - struct tun_ring *wintun_receive_ring; -#else /* ifdef _WIN32 */ + #else /* ifdef _WIN32 */ int fd; /* file descriptor for TUN/TAP dev */ #endif /* ifdef _WIN32 */ @@ -262,20 +255,6 @@ #endif } -#ifdef _WIN32 -static inline bool -tuntap_is_wintun(struct tuntap *tt) -{ - return tt && tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN; -} - -static inline bool -tuntap_ring_empty(struct tuntap *tt) -{ - return tuntap_is_wintun(tt) && (tt->wintun_send_ring->head =3D=3D tt->= wintun_send_ring->tail); -} -#endif - /* * Function prototypes */ @@ -526,74 +505,6 @@ int tun_write_win32(struct tuntap *tt, struct buffer *buf); -static inline ULONG -wintun_ring_packet_align(ULONG size) -{ - return (size + (WINTUN_PACKET_ALIGN - 1)) & ~(WINTUN_PACKET_ALIGN - 1); -} - -static inline ULONG -wintun_ring_wrap(ULONG value) -{ - return value & (WINTUN_RING_CAPACITY - 1); -} - -static inline void -read_wintun(struct tuntap *tt, struct buffer *buf) -{ - struct tun_ring *ring =3D tt->wintun_send_ring; - ULONG head =3D ring->head; - ULONG tail =3D ring->tail; - ULONG content_len; - struct TUN_PACKET *packet; - ULONG aligned_packet_size; - - *buf =3D tt->reads.buf_init; - buf->len =3D 0; - - if ((head >=3D WINTUN_RING_CAPACITY) || (tail >=3D WINTUN_RING_CAPACIT= Y)) - { - msg(M_INFO, "Wintun: ring capacity exceeded"); - buf->len =3D -1; - return; - } - - if (head =3D=3D tail) - { - /* nothing to read */ - return; - } - - content_len =3D wintun_ring_wrap(tail - head); - if (content_len < sizeof(struct TUN_PACKET_HEADER)) - { - msg(M_INFO, "Wintun: incomplete packet header in send ring"); - buf->len =3D -1; - return; - } - - packet =3D (struct TUN_PACKET *) &ring->data[head]; - if (packet->size > WINTUN_MAX_PACKET_SIZE) - { - msg(M_INFO, "Wintun: packet too big in send ring"); - buf->len =3D -1; - return; - } - - aligned_packet_size =3D wintun_ring_packet_align(sizeof(struct TUN_PAC= KET_HEADER) + packet->size); - if (aligned_packet_size > content_len) - { - msg(M_INFO, "Wintun: incomplete packet in send ring"); - buf->len =3D -1; - return; - } - - buf_write(buf, packet->data, packet->size); - - head =3D wintun_ring_wrap(head + aligned_packet_size); - ring->head =3D head; -} - static inline bool is_ip_packet_valid(const struct buffer *buf) { @@ -621,65 +532,6 @@ return true; } -static inline int -write_wintun(struct tuntap *tt, struct buffer *buf) -{ - struct tun_ring *ring =3D tt->wintun_receive_ring; - ULONG head =3D ring->head; - ULONG tail =3D ring->tail; - ULONG aligned_packet_size; - ULONG buf_space; - struct TUN_PACKET *packet; - - /* wintun marks ring as corrupted (overcapacity) if it receives invali= d IP packet */ - if (!is_ip_packet_valid(buf)) - { - msg(D_LOW, "write_wintun(): drop invalid IP packet"); - return 0; - } - - if ((head >=3D WINTUN_RING_CAPACITY) || (tail >=3D WINTUN_RING_CAPACIT= Y)) - { - msg(M_INFO, "write_wintun(): head/tail value is over capacity"); - return -1; - } - - aligned_packet_size =3D wintun_ring_packet_align(sizeof(struct TUN_PAC= KET_HEADER) + BLEN(buf)); - buf_space =3D wintun_ring_wrap(head - tail - WINTUN_PACKET_ALIGN); - if (aligned_packet_size > buf_space) - { - msg(M_INFO, "write_wintun(): ring is full"); - return 0; - } - - /* copy packet size and data into ring */ - packet =3D (struct TUN_PACKET * )&ring->data[tail]; - packet->size =3D BLEN(buf); - memcpy(packet->data, BPTR(buf), BLEN(buf)); - - /* move ring tail */ - ring->tail =3D wintun_ring_wrap(tail + aligned_packet_size); - if (ring->alertable !=3D 0) - { - SetEvent(tt->rw_handle.write); - } - - return BLEN(buf); -} - -static inline int -write_tun_buffered(struct tuntap *tt, struct buffer *buf) -{ - if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN) - { - return write_wintun(tt, buf); - } - else - { - return tun_write_win32(tt, buf); - } -} - static inline bool tuntap_is_dco_win(struct tuntap *tt) { diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsic= a.c index 30db644..4ff1b70 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -320,11 +320,6 @@ L"ACTIVETAPWINDOWS6ADAPTERS"); find_adapters( hInstall, - L"Wintun" L"\0", - L"WINTUNADAPTERS", - L"ACTIVEWINTUNADAPTERS"); - find_adapters( - hInstall, L"ovpn-dco" L"\0", L"OVPNDCOADAPTERS", L"ACTIVEOVPNDCOADAPTERS"); diff --git a/src/openvpnmsica/openvpnmsica.h b/src/openvpnmsica/openvpnmsic= a.h index 761aa47..9898067 100644 --- a/src/openvpnmsica/openvpnmsica.h +++ b/src/openvpnmsica/openvpnmsica.h @@ -88,10 +88,6 @@ * ACTIVETAPWINDOWS6ADAPTERS properties with semicolon delimited list of= all installed adapter * GUIDs and active adapter GUIDs respectively. * - * - Finds existing Wintun adapters and set WINTUNADAPTERS and ACTIVEWINTU= NADAPTERS properties - * with semicolon delimited list of all installed adapter GUIDs and acti= ve adapter GUIDs - * respectively. - * * - Finds existing ovpn-dco adapters and set OVPNDCOADAPTERS and ACTIVEOV= PNDCOADAPTERS properties * with semicolon delimited list of all installed adapter GUIDs and acti= ve adapter GUIDs * respectively. diff --git a/src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt index 44a40fe..7e3efb2 100644 --- a/src/openvpnserv/CMakeLists.txt +++ b/src/openvpnserv/CMakeLists.txt @@ -20,7 +20,6 @@ ../tapctl/basic.h ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc - ../openvpn/ring_buffer.h ) target_compile_options(openvpnserv PRIVATE -D_UNICODE diff --git a/src/openvpnserv/Makefile.am b/src/openvpnserv/Makefile.am index f053f40..852746d 100644 --- a/src/openvpnserv/Makefile.am +++ b/src/openvpnserv/Makefile.am @@ -36,5 +36,4 @@ service.c service.h \ validate.c validate.h \ $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block= .h \ - openvpnserv_resources.rc \ - $(top_srcdir)/src/openvpn/ring_buffer.h + openvpnserv_resources.rc diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 8a7b50d..5f842bd 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -40,7 +40,6 @@ #include "openvpn-msg.h" #include "validate.h" #include "wfp_block.h" -#include "ring_buffer.h" #define IO_TIMEOUT 2000 /*ms*/ @@ -90,7 +89,6 @@ undo_dns6, undo_nrpt, undo_domains, - undo_ring_buffer, undo_wins, _undo_type_max } undo_type_t; @@ -108,11 +106,6 @@ PWSTR domains; } dns_domains_undo_data_t; -typedef struct { - struct tun_ring *send_ring; - struct tun_ring *receive_ring; -} ring_buffer_maps_t; - typedef union { message_header_t header; address_message_t address; @@ -122,7 +115,6 @@ dns_cfg_message_t dns; nrpt_dns_cfg_message_t nrpt_dns; enable_dhcp_message_t dhcp; - register_ring_buffers_message_t rrb; set_mtu_message_t mtu; wins_cfg_message_t wins; create_adapter_message_t create_adapter; @@ -188,23 +180,6 @@ return INVALID_HANDLE_VALUE; } -static void -OvpnUnmapViewOfFile(struct tun_ring **ring) -{ - if (ring && *ring) - { - UnmapViewOfFile(*ring); - *ring =3D NULL; - } -} - -static void -UnmapRingBuffer(ring_buffer_maps_t *ring_buffer_maps) -{ - OvpnUnmapViewOfFile(&ring_buffer_maps->send_ring); - OvpnUnmapViewOfFile(&ring_buffer_maps->receive_ring); -} - static HANDLE InitOverlapped(LPOVERLAPPED overlapped) { @@ -213,7 +188,6 @@ return overlapped->hEvent; } - static BOOL ResetOverlapped(LPOVERLAPPED overlapped) { @@ -2973,119 +2947,6 @@ } static DWORD -OvpnDuplicateHandle(HANDLE ovpn_proc, HANDLE orig_handle, HANDLE *new_hand= le) -{ - DWORD err =3D ERROR_SUCCESS; - - if (!DuplicateHandle(ovpn_proc, orig_handle, GetCurrentProcess(), new_= handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - err =3D GetLastError(); - MsgToEventLog(M_SYSERR, L"Could not duplicate handle"); - return err; - } - - return err; -} - -static DWORD -DuplicateAndMapRing(HANDLE ovpn_proc, HANDLE orig_handle, struct tun_ring = **ring) -{ - DWORD err =3D ERROR_SUCCESS; - - HANDLE dup_handle =3D NULL; - - err =3D OvpnDuplicateHandle(ovpn_proc, orig_handle, &dup_handle); - if (err !=3D ERROR_SUCCESS) - { - return err; - } - *ring =3D (struct tun_ring *)MapViewOfFile(dup_handle, FILE_MAP_ALL_AC= CESS, 0, 0, sizeof(struct tun_ring)); - CloseHandleEx(&dup_handle); - if (*ring =3D=3D NULL) - { - err =3D GetLastError(); - MsgToEventLog(M_SYSERR, L"Could not map shared memory"); - return err; - } - - return err; -} - -static DWORD -HandleRegisterRingBuffers(const register_ring_buffers_message_t *rrb, HAND= LE ovpn_proc, - undo_lists_t *lists) -{ - DWORD err =3D 0; - - ring_buffer_maps_t *ring_buffer_maps =3D RemoveListItem(&(*lists)[undo= _ring_buffer], CmpAny, NULL); - - if (ring_buffer_maps) - { - UnmapRingBuffer(ring_buffer_maps); - } - else if ((ring_buffer_maps =3D calloc(1, sizeof(*ring_buffer_maps))) = =3D=3D NULL) - { - return ERROR_OUTOFMEMORY; - } - - HANDLE device =3D NULL; - HANDLE send_tail_moved =3D NULL; - HANDLE receive_tail_moved =3D NULL; - - err =3D OvpnDuplicateHandle(ovpn_proc, rrb->device, &device); - if (err !=3D ERROR_SUCCESS) - { - goto out; - } - - err =3D DuplicateAndMapRing(ovpn_proc, rrb->send_ring_handle, &ring_bu= ffer_maps->send_ring); - if (err !=3D ERROR_SUCCESS) - { - goto out; - } - - err =3D DuplicateAndMapRing(ovpn_proc, rrb->receive_ring_handle, &ring= _buffer_maps->receive_ring); - if (err !=3D ERROR_SUCCESS) - { - goto out; - } - - err =3D OvpnDuplicateHandle(ovpn_proc, rrb->send_tail_moved, &send_tai= l_moved); - if (err !=3D ERROR_SUCCESS) - { - goto out; - } - - err =3D OvpnDuplicateHandle(ovpn_proc, rrb->receive_tail_moved, &recei= ve_tail_moved); - if (err !=3D ERROR_SUCCESS) - { - goto out; - } - - if (!register_ring_buffers(device, ring_buffer_maps->send_ring, - ring_buffer_maps->receive_ring, - send_tail_moved, receive_tail_moved)) - { - err =3D GetLastError(); - MsgToEventLog(M_SYSERR, L"Could not register ring buffers"); - goto out; - } - - err =3D AddListItem(&(*lists)[undo_ring_buffer], ring_buffer_maps); - -out: - if (err !=3D ERROR_SUCCESS && ring_buffer_maps) - { - UnmapRingBuffer(ring_buffer_maps); - free(ring_buffer_maps); - } - CloseHandleEx(&device); - CloseHandleEx(&send_tail_moved); - CloseHandleEx(&receive_tail_moved); - return err; -} - -static DWORD HandleMTUMessage(const set_mtu_message_t *mtu) { DWORD err =3D 0; @@ -3130,10 +2991,6 @@ hwid =3D L"root\\tap0901"; break; - case ADAPTER_TYPE_WINTUN: - hwid =3D L"wintun"; - break; - default: return ERROR_INVALID_PARAMETER; } @@ -3238,14 +3095,6 @@ } break; - case msg_register_ring_buffers: - if (msg.header.size =3D=3D sizeof(msg.rrb)) - { - HANDLE ovpn_hnd =3D proc_info->hProcess; - ack.error_number =3D HandleRegisterRingBuffers(&msg.rrb, o= vpn_hnd, lists); - } - break; - case msg_set_mtu: if (msg.header.size =3D=3D sizeof(msg.mtu)) { @@ -3327,10 +3176,6 @@ } break; - case undo_ring_buffer: - UnmapRingBuffer(item->data); - break; - case _undo_type_max: /* unreachable */ break; diff --git a/src/tapctl/main.c b/src/tapctl/main.c index 551a8e6..4569b87 100644 --- a/src/tapctl/main.c +++ b/src/tapctl/main.c @@ -75,8 +75,8 @@ L" Note: This name can also be specified as OpenVPN's --= dev-node \n" L" option. = \n" L"--hwid Adapter hardware ID. Default value is root\\tap0901, = which \n" - L" describes tap-windows6 driver. To work with wintun or= ovpn-dco \n" - L" driver, specify 'wintun' or 'ovpn-dco'. = \n" + L" describes tap-windows6 driver. To work with ovpn-dco = driver, \n" + L" driver, specify 'ovpn-dco'. = \n" L"\n" L"Output:\n" L"\n" @@ -94,7 +94,7 @@ L"\n" L"Options:\n" L"\n" - L"--hwid Adapter hardware ID. By default, root\\tap0901, tap09= 01, wintun and \n" + L"--hwid Adapter hardware ID. By default, root\\tap0901, tap09= 01 and \n" L" ovpn-dco adapters are listed. Use this switch to limi= t the list.\n" L"\n" L"Output:\n" @@ -167,10 +167,6 @@ { base_name =3D L"OpenVPN Data Channel Offload"; } - else if (wcsicmp(hwid, L"wintun") =3D=3D 0) - { - base_name =3D L"OpenVPN Wintun"; - } else if (wcsicmp(hwid, L"root\\" _L(TAP_WIN_COMPONENT_ID)) =3D=3D 0) { base_name =3D L"OpenVPN TAP-Windows6"; @@ -351,7 +347,6 @@ WCHAR szzHwId[0x100] =3D L"root\\" _L(TAP_WIN_COMPONENT_ID) L"\0" _L(TAP_WIN_COMPONENT_ID) L"\0" - L"Wintun\0" L"ovpn-dco\0"; /* Parse options. */ diff --git a/src/tapctl/tap.h b/src/tapctl/tap.h index 38ea824..c35176c 100644 --- a/src/tapctl/tap.h +++ b/src/tapctl/tap.h @@ -38,7 +38,7 @@ * description of the device. This pointer is optiona= l and can be NULL. * * @param szHwId A pointer to a NULL-terminated string that supplie= s the hardware id - * of the device (e.g. "root\\tap0901", "Wintun"). + * of the device (e.g. "root\\tap0901"). * * @param pbRebootRequired A pointer to a BOOL flag. If the device requir= es a system restart, * this flag is set to TRUE. Otherwise, the flag is l= eft unmodified. This -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1021?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I43ec390040bffeec05270271ea7fb54fb219c536 Gerrit-Change-Number: 1021 Gerrit-PatchSet: 5 Gerrit-Owner: stipa Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld Gerrit-Attention: stipa Gerrit-MessageType: newpatchset --YyUypzQcD6s= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: cron2, flichtenheld, plaisthos, s= tipa.

stipa uploaded patch set #5 to this change.

View Change

The following approvals got outdated and were removed: Code-Review-1 by cron2

win: remove Wintun support

Since DCO supports= modern ciphers and server mode,
there is no reason to support Wintun an= ymore.

This also removes --windows-driver option support. The
def= ault driver is DCO, as it has been since 2.6. If for
some reasons one do= esn't want to use it, --disable-dco
multiplatform option will switch= to tap-windows6.

Change-Id: I43ec390040bffeec05270271ea7fb54fb219c5= 36
Signed-off-by: Lev Stipakov <lev@...515...>
---
M doc/man= -sections/vpn-network-options.rst
M doc/man-sections/windows-options.rst=
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/d= co.c
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/openvpn= /mudp.c
M src/openvpn/multi_io.c
M src/openvpn/options.c
D src/ope= nvpn/ring_buffer.h
M src/openvpn/tun.c
M src/openvpn/tun.h
M src/o= penvpnmsica/openvpnmsica.c
M src/openvpnmsica/openvpnmsica.h
M src/op= envpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpns= erv/interactive.c
M src/tapctl/main.c
M src/tapctl/tap.h
20 files = changed, 27 insertions(+), 801 deletions(-)

git pull ssh://gerrit=
.openvpn.net:29418/openvpn refs/changes/21/1021/5
diff --git a/doc/=
man-sections/vpn-network-options.rst b/doc/man-sections/vpn-network-options=
.rst
index 67f7e1f..40b8c19 100644
--- a/do= c/man-sections/vpn-network-options.rst
+++ b/doc/man-sectio= ns/vpn-network-options.rst
@@ -137,8 +137,7 @@
Set additional network parameters on supported platforms. May be spe= cified
on the client or pushed from the server. On Windo= ws these options are
handled by the ``tap-windows6`` dri= ver by default or directly by OpenVPN
- if dhcp is disabled or the ``wintun`` driver is in use. T= he
- ``OpenVPN for And= roid`` client also handles them internally.
+ if dhcp is disabled. The ``OpenVPN for Android`` = client also handles them internally.

O= n all other platforms these options are only saved in the client's
environment under the name :code:`foreign_option_{n}` before= the
diff --git a/doc/man-sections/windows-options.rst b/do= c/man-sections/windows-options.rst
index 1955869..af2fb45 1= 00644
--- a/doc/man-sections/windows-options.rst
= +++ b/doc/man-sections/windows-options.rst
@@ -252,9 = +252,3 @@
otherwise it defaulted to :code:`C:\\WINDOWS`.= It is not needed to use
the ``env`` keyword any more, a= nd it will just be ignored. A warning is
logged when thi= s is found in the configuration file.
-
---windows-driver drv
- Specifies which tun driver to use. Value= s are :code:`ovpn-dco` (default),
- :code:`tap-windows6` and :code:`wintun`. :code:`ovpn-dco` and= :code:`wintun`
- requ= ire ``--dev tun``. :code:`wintun` also requires OpenVPN process to run
- elevated, or be invoked = using the Interactive Service.
diff --git a/include/openvpn= -msg.h b/include/openvpn-msg.h
index 2cf8d40..34b133b 10064= 4
--- a/include/openvpn-msg.h
+++ b/include= /openvpn-msg.h
@@ -44,7 +44,7 @@
msg_d= el_wfp_block,
msg_register_dns,
m= sg_enable_dhcp,
- ms= g_register_ring_buffers,
+ deprecated_msg_register_ring_buffers,
msg_set= _mtu,
msg_add_wins_cfg,
msg_del_w= ins_cfg,
@@ -159,15 +159,6 @@

<= span> typedef struct {

message_header_t header;=
- HANDLE device;- HANDLE send_ring_handle;

- HANDLE receive_ring_= handle;
- HANDLE sen= d_tail_moved;
- HAND= LE receive_tail_moved;
= -} register_ring_buffers_message_t;
-
-typedef= struct {
- message_= header_t header;
interface_t iface;
= short family;
int mtu;
@@ -176,7 +1= 67,6 @@
typedef enum {
ADAPTER_TYPE_D= CO,
ADAPTER_TYPE_TAP,
- ADAPTER_TYPE_WINTUN
} adapter_typ= e_t;

typedef struct {
di= ff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
index 37af683..3c1a875 100644
--- a/src/openvpn/Makefile.= am
+++ b/src/openvpn/Makefile.am
@@ -163,6 = +163,6 @@
$(OPTIONAL_DL_LIBS) \
$(OPTIO= NAL_INOTIFY_LIBS)
if WIN32
-openvpn_SOURCES +=3D openvpn_win32_resources.rc wfp_b= lock.c wfp_block.h ring_buffer.h
+openvpn_SOURCES +=3D openvpn_win32_resources.rc wfp_block.c wf= p_block.h
openvpn_LDADD +=3D -lgdi32 -lws2_32 -lwininet -l= crypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt=
endif
diff --git a/src/openvpn/dco.c b/sr= c/openvpn/dco.c
index 7ad9cb3..c61cbda 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c@@ -359,14 +359,6 @@
return false;<= br> }

- if ((o->windows_driver =3D=3D WINDOWS_DRIVER_WINTUN)

- || (o->windows= _driver =3D=3D WINDOWS_DRIVER_TAP_WINDOWS6))
- {
- msg(msglevel, "--windows-driver is set to '%s'.= Disabling Data Channel Offload",
- print_tun_backend_driver(o->windows_driver)= );
- return fals= e;
- }
-
if ((o->mo= de =3D=3D MODE_SERVER) && o->ce.local_list->len > 1)
{
msg(msglevel, "multiple --l= ocal options defined, disabling data channel offload");
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c

index 0b8b262..ed4cdb4 100644
--- a/src/openvpn/forward.c=
+++ b/src/openvpn/forward.c
@@ -1308,26 +1= 308,11 @@
c->c2.buf =3D c->c2.buffers->read_t= un_buf;

#ifdef _WIN32
- if (c->c1.tuntap->backend_driv= er =3D=3D WINDOWS_DRIVER_WINTUN)
- {
- = read_wintun(c->c1.tuntap, &c->c2.buf);
- if (c->c2.buf.len =3D=3D -1)

- {
- register_signal(c->sig= , SIGHUP, "tun-abort");
- c->persist.restart_sleep_seconds =3D 1;- msg(M_INFO, "= Wintun read error, restarting");
- perf_pop();
- return;
- }
- }
- else
- {
- /* we cannot end up here when usi= ng dco */
- ASSE= RT(!dco_enabled(&c->options));
+ /* we cannot end up here when using dco */
= + ASSERT(!dco_enabled(&c= ->options));

- sockethandle_t sh =3D { .is_handle =3D true, .h =3D c-&= gt;c1.tuntap->hand, .prepend_sa =3D false };
- sockethandle_finalize(sh, &c->c1.t= untap->reads, &c->c2.buf, NULL);
- }
+ sockethandle_t sh =3D { .is_handle =3D true, .h =3D c->c1.tun= tap->hand, .prepend_sa =3D false };
+ sockethandle_finalize(sh, &c->c1.tuntap->r= eads, &c->c2.buf, NULL);
#else /* ifdef _WIN32 */<= /span>
ASSERT(buf_init(&c->c2.buf, c->c2.frame.buf.= headroom));
ASSERT(buf_safe(&c->c2.buf, c->c= 2.frame.buf.payload_size));
@@ -1942,7 +1927,7 @@ #endif

#ifdef _WIN32
<= span style=3D"color: hsl(0, 100%, 40%);">- size =3D write_tun_buffer= ed(c->c1.tuntap, &c->c2.to_tun);

+ size =3D tun_write_win32(c->c1.tuntap, &a= mp;c->c2.to_tun);
#else
if (c-= >c1.tuntap->backend_driver =3D=3D DRIVER_AFUNIX)
= {
@@ -2148,17 +2133,6 @@
tunt= ap |=3D EVENT_READ;
}

-#ifdef _WIN32

- if (tuntap_is_wintun(c->c1.tuntap))<= /span>
- {
- /*
- * With wintun we are only interested in = read event. Ring buffer is
- * always ready for write, so we don't do wait.
= - */
- tuntap =3D EVENT_READ;
<= span style=3D"color: hsl(0, 100%, 40%);">- }

-#endif
-
/*
* Configure event= wait based on socket, tuntap flags.
*/
@@ -2217,36 +2191,8 @@
}
else<= /span>
{
= -#ifdef _WIN32
- = bool skip_iowait =3D flags & IOW_TO_TUN;
- if (flags & IOW_READ_TUN)
- {

- /*
- * don't read from tun if we have pend= ing write to link,
- = * since every tun read overwrites to_link buffer filled- * by previous tun = read
- */
- skip_iowait= =3D !(flags & IOW_TO_LINK);
- }
- = if (tuntap_is_wintun(c->c1.tuntap) && skip_iowait)=
- {
- unsigned int ret =3D 0;

- if (flags &= ; IOW_TO_TUN)
- = {
- = ret |=3D TUN_WRITE;
- = }
- = if (flags & IOW_READ_TUN)
- {
- ret |=3D TUN_READ;
- }
- multi_io->udp_flags =3D ret;
- }
- else
-#endif /* ifdef _WIN32 */
- {
-= /* slow path - delegate to io_wait_dowork_udp to calculate flag= s */
- get_i= o_flags_dowork_udp(c, multi_io, flags);
- }
+ /* slow path - delegate to io_wait_dowork_udp to calculate = flags */
+ get= _io_flags_dowork_udp(c, multi_io, flags);
}
= }

diff --git a/src/openvpn/forward= .h b/src/openvpn/forward.h
index 77892d6..74c6036 100644
--- a/src/openvpn/forward.h
+++ b/src/openvpn= /forward.h
@@ -360,12 +360,6 @@
{
flags |=3D IOW_TO_TUN;
}-#ifdef _WIN32
- if (tuntap_ring_empty(c->c1.tun= tap))
- {
= - flags &=3D ~IOW_READ= _TUN;
- }
= -#endif
retu= rn flags;
}

@@ -393,36 += 387,8 @@
}
else
= {
-#ifdef _WIN32
- bool skip_iowait= =3D flags & IOW_TO_TUN;
- if (flags & IOW_READ_TUN)
- {
- /*
- * don't read from tun if we have pending write to link= ,
- * since= every tun read overwrites to_link buffer filled
- * by previous tun read
- */

- skip_iowait =3D !(flags &= ; IOW_TO_LINK);
- = }
- if (tuntap= _is_wintun(c->c1.tuntap) && skip_iowait)
- {
- unsigned int ret =3D 0;
- if (flags & IOW_TO_TUN)
- {- ret |=3D TUN_WR= ITE;
- }
- if (flags &am= p; IOW_READ_TUN)
- = {
- = ret |=3D TUN_READ;
-= }
- = c->c2.event_set_status =3D ret;
- }
- else
-#end= if /* ifdef _WIN32 */
-= {
- = /* slow path */
- = io_wait_dowork(c, flags);
- }
+= /* slow path */
+ io_wait_dowork(c, flags);
}
}


diff --git a/src/openvpn/mudp.c b/sr= c/openvpn/mudp.c
index 54dfc72..7158d5c 100644
--- a/src/openvpn/mudp.c

+++ b/src/openvpn/mudp.c
@@ -457,11 +457,5 @@
{
= flags |=3D IOW_READ;
}
-#ifdef _WIN32
- if (tuntap_ring_empty(m->top.c1.tuntap))- {
- flags &=3D ~IOW_READ_TUN;- }
-#endif
return flags;
}
diff --git a/src/openvpn/multi_io.c b/src/op= envpn/multi_io.c
index f4ca4df..7f47319 100644
--- a/src/openvpn/multi_io.c

+++ b/src/openvpn/multi_io= .c
@@ -190,20 +190,6 @@
get_io_fla= gs_udp(&m->top, m->multi_io, p2mp_iow_flags(m));
= }

- i= f (tuntap_is_wintun(m->top.c1.tuntap))
- {
- if (!tuntap_ring_empty(m->top.c1.tuntap))
- {
- /* there is data in wintun ring buffer, = read it immediately */
= - m->multi_io->esr[0].arg =3D MULTI_IO_TUN;
- m->multi_io->esr[0= ].rwflags =3D EVENT_READ;

- m->multi_io->n_esr =3D 1;
- return 1;
- }
- persistent =3D NULL;
- }
-#endif
tun_set(m->top.c1.tuntap, m->multi_i= o->es, EVENT_READ, MULTI_IO_TUN, persistent);
#if defin= ed(ENABLE_DCO) \
&& (defined(TARGET_LINUX) || = defined(TARGET_FREEBSD) || defined(TARGET_WIN32))
diff --gi= t a/src/openvpn/options.c b/src/openvpn/options.c
index 029= 70a7..55b923c 100644
--- a/src/openvpn/options.c
= +++ b/src/openvpn/options.c
@@ -750,10 +750,6 @@
" optional parameter controls t= he initial state of ex.\n"
"--show-net-up = : Show " PACKAGE_NAME "'s view of routing table and net adapt= er list\n"
" after TAP adap= ter is up and routes have been added.\n"
- "--windows-driver : Which tun driver to = use?\n"
- "= ; ovpn-dco (default)\n"
- " tap-windows6\n&qu= ot;
- " = wintun\n"
"--block-outside-dns = : Block DNS on other network adapters to prevent DNS leaks\n"=
"Windows Standalone Options:\n"
= "\n"
@@ -2592,11 +2588,6 @@
= prefix);
}
}
-
- if (options->windows_driver =3D=3D W= INDOWS_DRIVER_WINTUN && dev !=3D DEV_TYPE_TUN)
- {
- msg(M_USAGE, "--windows-driver wintun require= s --dev tun");
- = }
#endif /* ifdef _WIN32 */

= /*
@@ -3371,9 +3362,8 @@
#ifdef= _WIN32
const int dev =3D dev_type_enum(options->de= v, options->dev_type);

- /* when using wintun/ovpn-dco, kernel doesn't= send DHCP requests, so don't use it */
- if ((options->windows_driver =3D=3D WINDOWS_DR= IVER_WINTUN
- |= | options->windows_driver =3D=3D DRIVER_DCO)
+ /* when using ovpn-dco, kernel doesn't = send DHCP requests, so don't use it */
+ if ((options->windows_driver =3D=3D DRIVER_DC= O)
&& (options->tuntap_options.ip_win32= _type =3D=3D IPW32_SET_DHCP_MASQ
|| options-&g= t;tuntap_options.ip_win32_type =3D=3D IPW32_SET_ADAPTIVE))
= {
@@ -4665,39 +4655,6 @@
return r= et;
}

-#ifdef _WIN32
-/**
- * Pars= es --windows-driver config option
- *
- * @par= am str value of --windows-driver option
- * @param msglevel msglevel to report parsing erro= r
- * @return enum tun_= driver_type driver type, WINDOWS_DRIVER_UNSPECIFIED on unknown --windows-d= river value
- */=
-static enum tun_driver_type<= /span>
-parse_windows_driver(c= onst char *str, const int msglevel)
-{
- if= (streq(str, "tap-windows6"))
- {
- return WINDOWS_DRIVER_TAP_WINDOWS6;
- }
- else if (streq(str, "wintun"))
- {
- return WINDOWS_DRIVER_WINTUN;
- }
-
- e= lse if (streq(str, "ovpn-dco"))
- {
- return DRIVER_DCO;
- }
- els= e
- {
- msg(msglevel, "--window= s-driver must be tap-windows6, wintun "

- "or ovpn-dco");
- return WINDOWS_DRIVER_UNSPEC= IFIED;

- }-}
-#endif /* ifdef _WIN32 */
-
/*
* parse/= print topology coding
*/
@@ -6012,7 +5969= ,8 @@
else if (streq(p[0], "windows-driver")= && p[1] && !p[2])
{
= VERIFY_PERMISSION(OPT_P_GENERAL);
- options->windows_driver =3D parse_windows_dr= iver(p[1], M_FATAL);
= + msg(M_WARN, "DEPRECATED OPTION: windows-driver: In OpenVPN 2.= 7, the default Windows driver is ovpn-dco. "
+ "If incompatible options are= used, OpenVPN will fall back to tap-windows6. Wintun support has been remo= ved.");
}
#endif
else if (streq(p[0], "disable-dco"))

diff -= -git a/src/openvpn/ring_buffer.h b/src/openvpn/ring_buffer.h
deleted file mode 100644

index c536980..0000000--- a/src/openvpn/ring_buffer.h
+++ /dev/null=
@@ -1,125 +0,0 @@
-/*
- * OpenVPN -= - An application to securely tunnel IP networks
- * over a single UDP port, with suppo= rt for SSL/TLS-based
- = * session authentication and key exchange,
- * packet encryption, packet a= uthentication, and
- * = packet compression.
- *
- * Copyr= ight (C) 2002-2024 OpenVPN Inc <sales@...515...>
- * 2019 Lev Stipakov <le= v@...515...>
- *
- * 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 WARR= ANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS= E. See the
- * GNU Ge= neral Public License for more details.
- *
- *= You should have received a copy of the GNU General Public License along
- * with this program; = if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston= , MA 02110-1301 USA.
- = */
-
-#ifdef _WIN32
-#ifndef OPENVPN_RING_BUFFER_H
-#define OPENVPN_RING_BUFFER_H
= -
-#include <windows.h>
-#include <winioctl.h>
-
-#include <stdint.h>
-#include <stdbool.h>
-
-= /*
- * Values below are= taken from Wireguard Windows client
- * https://github.com/WireGuard/wireguard-go/blob/master/tun= /wintun/ring_windows.go#L14
- */
-#define WINT= UN_RING_CAPACITY 0x800000
-#define WINTUN_RING_TRAILING_BYTES 0x10000
-#define WINTUN_MAX_PACKET_SIZE 0xffff=
-#define WINTUN_PACKET= _ALIGN 4
-
-#define TUN_IOCTL_REGISTER= _RINGS CTL_CODE(51820U, 0x970U, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRIT= E_DATA)
-
-/**

- * Wintun ring buffer
- * See https://github.com/WireGuard/wintun#ring-layou= t
- */
-struct tun_ring
-{
- volatile ULONG head;
- volatile ULONG tail;
- volatile LONG alertable;
- UCHAR data[WINTUN_RING_CAPACITY + WINTUN_RING_= TRAILING_BYTES];
-};
-
-/**
- * Struct for ring buffers registration
- * See https://github.com/WireGuard/wintun#= registering-rings
- */<= /span>
-struct tun_register_ri= ngs
-{
- struct
- {
- ULONG ring_size;
- struct tun_ring *ring;
- HANDLE tail_moved;
- } send, receive;
-};
-
-struct TUN_PAC= KET_HEADER
-{- uint32_t size;
-};

-
= -struct TUN_PACKET
-{
- uint32_t size;
- UCHAR data[WINTUN_MAX_= PACKET_SIZE];
-};
-
-/**
- * Registers ring buffers used to exchange data between
= - * userspace openvpn process and= wintun kernel driver,
= - * see https://github.com/WireGuard/wintun#registering-rings
- *

- * @param device handle to opened wintun = device
- * @param send_= ring pointer to send ring
- * @param receive_ring pointer to receive ring<= br>- * @param send_tail_moved = event set by wintun to signal openvpn
- * that data is available for r= eading in send ring
- *= @param receive_tail_moved event set by openvpn to signal wintun- * t= hat data has been written to receive ring
- * @return true if registration is s= uccessful, false otherwise - use GetLastError()
- */
-static inline bool
-register_ring_buffers(HANDLE device,
- struct tun_ring *send_ring,
- struc= t tun_ring *receive_ring,
- HANDLE send_tail_moved,
- HANDLE receive_tail_moved= )
-{
- struct tun_register_rings rr;=
- BOOL res;
- DWORD bytes_returned;

= -
- ZeroMemory(&rr, sizeof(rr));
-
- rr.send.ring =3D send_ring;
- rr.send.ring_size =3D sizeof(struct tun_ring)= ;
- rr.send.tail_mov= ed =3D send_tail_moved;
-
- rr.receive.ring= =3D receive_ring;
- = rr.receive.ring_size =3D sizeof(struct tun_ring);
- rr.receive.tail_moved =3D receive_tail_mov= ed;
-
- res =3D DeviceIoControl(device, TUN= _IOCTL_REGISTER_RINGS, &rr, sizeof(rr),
- NULL, 0, &bytes_returne= d, NULL);
-
<= span style=3D"color: hsl(0, 100%, 40%);">- return res !=3D FALSE;
=
-}
-
-#endif /* ifndef OPENVPN_RING_BUFFER_H */
-#endif /* ifdef _WIN32 */
diff --= git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 6a2043e..= d7c38a1 100644
--- a/src/openvpn/tun.c
+++ = b/src/openvpn/tun.c
@@ -63,9 +63,6 @@
= case WINDOWS_DRIVER_TAP_WINDOWS6:
return &= quot;tap-windows6";

- case WINDOWS_DRIVER_WINTUN:
- return "wintun";
-
= case DRIVER_GENERIC_TUNTAP:
return "tu= n/tap";

@@ -473,10 +470,6 @@<= br> t =3D ADAPTER_TYPE_TAP;
= break;

- t =3D ADAPTER_TYPE_WINTUN;
- break;
-
case DRIVER_DCO:<= /span>
t =3D ADAPTER_TYPE_DCO;
= break;
@@ -1040,37 +1033,8 @@
o= verlapped_io_init(&tt->writes, frame, TRUE);
tt= ->adapter_index =3D TUN_ADAPTER_INDEX_INVALID;
<= br>- if (tt->backend_driver= =3D=3D WINDOWS_DRIVER_WINTUN)
- {
- = tt->wintun_send_ring_handle =3D CreateFileMapping(INVALID_HANDLE_VALUE,= NULL,
- = PAGE_READWRITE,
- = 0,
- = sizeof(struct tun_ring= ),
- = NULL);
- tt->wintun_receive_ring_handle =3D CreateF= ileMapping(INVALID_HANDLE_VALUE,
- NULL,=
- = PAGE_READWRITE,
- = 0,
- = sizeof(struct tun_r= ing),
- = NULL);
- if ((tt->wintun_send_ring_handle =3D= =3D NULL) || (tt->wintun_receive_ring_handle =3D=3D NULL))
- {

- msg(M_FATAL, "Cannot allocate = memory for ring buffer");
- }
-
- tt->rw_handle= .read =3D CreateEvent(NULL, FALSE, FALSE, NULL);
- tt->rw_handle.write =3D CreateEvent(N= ULL, FALSE, FALSE, NULL);
-
- if ((tt-&= gt;rw_handle.read =3D=3D NULL) || (tt->rw_handle.write =3D=3D NULL))
- {
- msg(M_FATAL, "Cannot= create events for ring buffer");

- }
- }
- else
- {
- tt->rw_handle.read =3D tt->= ;reads.overlapped.hEvent;
- tt->rw_handle.write =3D tt->writes.overlapped.hEvent;
- }
+ tt->rw_handle.read =3D tt->re= ads.overlapped.hEvent;
- else if (strcasecmp(com= ponent_id, WINTUN_COMPONENT_ID) =3D=3D 0)
- {
- windows_driver =3D WINDOWS_DRIV= ER_WINTUN;
- = }
else if (strcasecmp(compone= nt_id, "ovpn-dco") =3D=3D 0)
= {
windows_driver =3D DRIVER_DCO;<= /span>
@@ -4320,7 +4280,7 @@
}
<= /span>
/*
- *= Lookup a TAP-Windows or Wintun adapter by GUID.
+ * Lookup an adapter by GUID.
= */
static const struct tap_reg *
get_ad= apter_by_guid(const char *guid, const struct tap_reg *tap_reg)
@@ -4375,7 +4335,7 @@

{
if (!tap_= reg)
{
- msg(M_FATAL, "There are no TAP-Windows, Wintun or ovpn-d= co adapters "
+ = msg(M_FATAL, "There are no TAP-Windows or ovpn-dco adapters &qu= ot;
"on this system. You should be able = to create an adapter "
"by using tap= ctl.exe utility.");
}
@@ -6086,46= +6046,6 @@
gc_free(&gc);
}

-static bo= ol
-service_register_ri= ng_buffers(const struct tuntap *tt)
-{
- HA= NDLE msg_channel =3D tt->options.msg_channel;
- ack_message_t ack;
- bool ret =3D true;
- struct gc_arena gc =3D gc_new();-
- register_ring_buffers_message_t msg =3D {=
- .header =3D {=
- msg_register_rin= g_buffers,
- = sizeof(register_ring_buffers_message_t),
- 0
- },
= - .device =3D tt->hand,
- .send_ring_handle =3D tt->wintun_send_ring_handle,
- .receive_ring_h= andle =3D tt->wintun_receive_ring_handle,
- .send_tail_moved =3D tt->rw_handle.read,<= /span>
- .receive_tail_= moved =3D tt->rw_handle.write
- };
-
- if (!send_msg_iservic= e(msg_channel, &msg, sizeof(msg), &ack, "Register ring buffers= "))
- {<= br>- ret =3D false;=
- }
- else if (ack.error_number !=3D NO_ERROR= )
- {
- msg(M_NONFATAL, "Regist= er ring buffers failed using service: %s [status=3D0x%x]",

<= span style=3D"color: hsl(0, 100%, 40%);">- strerror_win32(ack.er= ror_number, &gc), ack.error_number);

- ret =3D false;
- }
- else
- {
- msg(M_INFO, "= ;Ring buffers registered via service");
- }
-
- gc_free(&a= mp;gc);
- return ret= ;
-}
-
void
= fork_register_dns_action(struct tuntap *tt)
{
@@ -6363,58 +6283,6 @@

gc_free(&gc); }

-static bool
-wint= un_register_ring_buffer(struct tuntap *tt, const char *device_guid)<= br>-{
- bool ret =3D true;
-
- tt->wintun_send_ring =3D (struct tun_ring *)MapViewOfFile(tt-&= gt;wintun_send_ring_handle,
- FILE_MAP_= ALL_ACCESS,
- = 0,
- = 0,
- = sizeof(struct tun= _ring));
-
- tt->wintun_receive_ring =3D= (struct tun_ring *)MapViewOfFile(tt->wintun_receive_ring_handle,
=
- = FILE_MAP_ALL_ACCESS,
- = 0,
- = sizeof(struct tun_ring));
-

- if (tt->options.msg_channel)
- {
- ret =3D service_register_ring_buffers(tt);- }
- else
- {
-= if (!register_ring_buffers(tt->hand,
- tt->wintun_= send_ring,
- = tt->wintun_receive_ring,
- tt->r= w_handle.read,
- = tt->rw_handle.write))
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:<= br>- msg(M_FAT= AL, "ERROR: Wintun requires SYSTEM privileges and therefore "
- = "should be used with interactive service. If you want to "=
- &quo= t;use openvpn from command line, you need to do SYSTEM "
- "eleva= tion yourself (for example with psexec).");

- break;
-
- case ERROR_ALREADY_INITIALIZED:
- msg(M_NONFATAL, &q= uot;Adapter %s is already in use", device_guid);
- break;
-
- default:
- msg(M_NONFATAL | M_ERRNO, "Fail= ed to register ring buffers");
- }
- ret =3D false;
- }
-<= /span>
- }
- return ret;
-}
-
static void
tuntap_set_conne= cted(const struct tuntap *tt)
{
@@ -6574,8= +6442,7 @@
const char *path =3D NULL;
char tuntap_device_path[256];


- if (tt->backend_driver =3D=3D WINDOW= S_DRIVER_WINTUN
- = || tt->backend_driver =3D=3D DRIVER_DCO)
+ if (tt->backend_driver =3D=3D DRIVER_DCO)<= /span>
{
const struct device_instanc= e_id_interface *dev_if;

@@ -6629,18 +6496= ,6 @@
return false;
}<= br>
- if (tt-= >backend_driver =3D=3D WINDOWS_DRIVER_WINTUN)
- {
- /* Wintun adapter may be considered "open" aft= er ring buffers are successfuly registered. */
- if (!wintun_register_ring_buffer(tt, devic= e_guid))
- {
- msg(D_TUNTAP_= INFO, "Failed to register %s adapter ring buffers", device_guid);=
- CloseHand= le(tt->hand);
- = tt->hand =3D NULL;
- return false;
- }
- = }
-
= return true;
}

@@ -= 6988,16 +6843,6 @@
}
tt-&= gt;hand =3D NULL;
}
-
- = if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN)
- {
- CloseHandle(tt->rw_handle.read);
<= span style=3D"color: hsl(0, 100%, 40%);">- CloseHandle(tt->rw_han= dle.write);

- Un= mapViewOfFile(tt->wintun_send_ring);
- UnmapViewOfFile(tt->wintun_receive_ring);
- CloseHandle(tt->= ;wintun_send_ring_handle);
- CloseHandle(tt->wintun_receive_ring_handle);
- }

}
<= span>

void
diff --git a/src/openvpn/tun.h= b/src/openvpn/tun.h
index bcc23b4..de1876a 100644--- a/src/openvpn/tun.h
+++ b/src/openvpn/tun.h
@@ -39,13 +39,11 @@
#include "proto.h&qu= ot;
#include "misc.h"
#include = "networking.h"
- WIND= OWS_DRIVER_WINTUN,
DRIVER_GENERIC_TUNTAP,
/** using an AF_UNIX socket to pass packets from/to an external pr= ogram.

* This is always defined. We error out if a u= ser tries to open this type
@@ -58,7 +56,6 @@
};


#ifdef _WIN32
-#define WINTUN_COMPONENT_ID "wintun&= quot;
#define DCO_WIN_REFERENCE_STRING "ovpn-dco"= ;
#endif

@@ -233,11 +230= ,7 @@

int standby_iter;

- HANDLE wintu= n_send_ring_handle;
- = HANDLE wintun_receive_ring_handle;
- struct tun_ring *wintun_send_ring;
- struct tun_ring *wintun_receive_ring;
-#else /* ifdef _WIN32 = */
+ #else /* ifd= ef _WIN32 */
int fd; /* file descriptor for TUN/TAP de= v */
#endif /* ifdef _WIN32 */
@@ -262,20 +255,6 @@
#endif
}

-#ifdef _= WIN32
-static inline bo= ol
-tuntap_is_wintun(st= ruct tuntap *tt)
-{
- return tt && = tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN;
-}
-
-static in= line bool
-tuntap_ring_= empty(struct tuntap *tt)
- return tuntap= _is_wintun(tt) && (tt->wintun_send_ring->head =3D=3D tt->w= intun_send_ring->tail);
-}
-#endif-
/* * Function prototypes
*/
@@ -526= ,74 +505,6 @@

int tun_write_win32(struct= tuntap *tt, struct buffer *buf);

-static inline ULONG
-wintun_ring_packet_align(ULONG size)=
-{
- return (size + (WINTUN_PACKET_ALIGN - 1)) &a= mp; ~(WINTUN_PACKET_ALIGN - 1);
-}
--static inline ULONG
<= span style=3D"color: hsl(0, 100%, 40%);">-wintun_ring_wrap(ULONG value)
-{
- return value & (WINTUN_RING_CAPACIT= Y - 1);
-}
-

-static inline void
-read_wintun(struct tuntap *tt, struct buffer *buf)<= br>-{
- struct tun_ring *ring =3D tt->wintun_send_= ring;
- ULONG head = =3D ring->head;
- = ULONG tail =3D ring->tail;
- ULONG content_len;
- struct TUN_PACKET *packet;
- ULONG aligned_packet_size;
-
- *buf =3D tt->reads.buf_init;
- buf->len =3D 0;
-
= - if ((head >=3D WINTUN_RING_CAPACITY) || (tail >=3D WINTUN_RING_C= APACITY))
- {=
- msg(M_INFO, "Wi= ntun: ring capacity exceeded");
- buf->len =3D -1;
- return;
- }
-<= /span>
- if (head =3D=3D ta= il)
- {
- /* nothing to read */
- return;
= - }
-
- content_len =3D wintun_ring_wrap(tail - head);
- if (content_len < sizeof(struct T= UN_PACKET_HEADER))
- = {
- msg(M_INFO,= "Wintun: incomplete packet header in send ring");
- buf->len =3D -1;
- return;
- }

-
- packet =3D (struct TUN_PACKET *) &ring->data[head];
= - if (packet->size > WIN= TUN_MAX_PACKET_SIZE)
- = {
- msg(M_INF= O, "Wintun: packet too big in send ring");
- buf->len =3D -1;
- return;

- }
-
- a= ligned_packet_size =3D wintun_ring_packet_align(sizeof(struct TUN_PACKET_HE= ADER) + packet->size);
- if (aligned_packet_size > content_len)
- {
- msg(M_INFO, "Wintun: incomplete packet in send rin= g");
- buf-= >len =3D -1;
- = return;
- }=
-
- buf_write(buf, packet->data, packet->si= ze);
-
- head =3D wintun_ring_wrap(head + a= ligned_packet_size);
- = ring->head =3D head;
-}
-
static inline bool

is_ip_packet_valid(const struct buff= er *buf)
{
@@ -621,65 +532,6 @@
= return true;
}

-static inline int

-write_wintun(struct tuntap *tt, struct b= uffer *buf)
-{- struct tun_ring *ring =3D = tt->wintun_receive_ring;
- ULONG head =3D ring->head;
- ULONG tail =3D ring->tail;
- ULONG aligned_packet_size;
- ULONG buf_space;

- struct TUN_PACKET *packet;
-
- /* wintun marks ring as corrupted (overcapa= city) if it receives invalid IP packet */
- if (!is_ip_packet_valid(buf))
- {
- msg(D_LOW, "write_wintun(): drop invalid IP pa= cket");
- r= eturn 0;
- }<= br>-
- if ((head >=3D WINTUN_RING_CAPACITY) || (ta= il >=3D WINTUN_RING_CAPACITY))
- {
- = msg(M_INFO, "write_wintun(): head/tail value is over capacity"= ;);
- return -1;=
- }
-

- aligned_packet_size =3D wintun_ring_packet_align(sizeo= f(struct TUN_PACKET_HEADER) + BLEN(buf));
- buf_space =3D wintun_ring_wrap(head - tail - WINTUN= _PACKET_ALIGN);
- if= (aligned_packet_size > buf_space)
- {
-= msg(M_INFO, "write_wintun(): ring is full");
- return 0;

- }
-
-= /* copy packet size and data into ring */
- packet =3D (struct TUN_PACKET * )&ring->= data[tail];
- packet= ->size =3D BLEN(buf);
-
- /* move ring tail */
- ring->tail =3D wintun_ring_wrap(tail + aligned_packet_= size);
- if (ring-&g= t;alertable !=3D 0)
- = {
- SetEvent(t= t->rw_handle.write);
- }
-
- return BLEN(buf);

-}

-
-s= tatic inline int
-write= _tun_buffered(struct tuntap *tt, struct buffer *buf)
-{
- if (tt->backend_driver =3D=3D WINDOWS_DRIVER_WINTUN)
- {
- return write_wintun(tt, buf);
- }
- else
- {
- return tun_write_win32(tt, buf);
- }
-}
-
<= span> static inline bool

tuntap_is_dco_win(struct tuntap *= tt)
{
diff --git a/src/openvpnmsica/openvp= nmsica.c b/src/openvpnmsica/openvpnmsica.c
index 30db644..4= ff1b70 100644
--- a/src/openvpnmsica/openvpnmsica.c<= br>+++ b/src/openvpnmsica/openvpnmsica.c
@@ -320,11 += 320,6 @@
L"ACTIVETAPWINDOWS6ADAPTERS");<= /span>
find_adapters(
hInstall,
- L"Wintun"= ; L"\0",
- = L"WINTUNADAPTERS",
- L"ACTIVEWINTUNADAPTERS");
- find_adapters(
- hInstall,
= L"ovpn-dco" L"\0",
L"OVPN= DCOADAPTERS",
L"ACTIVEOVPNDCOADAPTERS&qu= ot;);
diff --git a/src/openvpnmsica/openvpnmsica.h b/src/op= envpnmsica/openvpnmsica.h
index 761aa47..9898067 100644
--- a/src/openvpnmsica/openvpnmsica.h
+++ b/sr= c/openvpnmsica/openvpnmsica.h
@@ -88,10 +88,6 @@
= * ACTIVETAPWINDOWS6ADAPTERS properties with semicolon delimited l= ist of all installed adapter
* GUIDs and active adapter= GUIDs respectively.
*
- * - Finds existing Wintun adapters and set WINTUNADAPTE= RS and ACTIVEWINTUNADAPTERS properties
- * with semicolon delimited list of all installed adapte= r GUIDs and active adapter GUIDs
- * respectively.
- *
* - Finds existing ovpn-dco adapters and set O= VPNDCOADAPTERS and ACTIVEOVPNDCOADAPTERS properties
* w= ith semicolon delimited list of all installed adapter GUIDs and active adap= ter GUIDs
* respectively.
diff --git a/= src/openvpnserv/CMakeLists.txt b/src/openvpnserv/CMakeLists.txt
<= span>index 44a40fe..7e3efb2 100644

--- a/src/openvpnserv/CM= akeLists.txt
+++ b/src/openvpnserv/CMakeLists.txt@@ -20,7 +20,6 @@
../tapctl/basic.h
<= span> ../openvpn/wfp_block.c ../openvpn/wfp_block.h

= openvpnserv_resources.rc
- ../openvpn/ring_buffer.h
)
t= arget_compile_options(openvpnserv PRIVATE
-D_UNICODE
diff --git a/src/openvpnserv/Makefile.am b/src/openvpnserv/M= akefile.am
index f053f40..852746d 100644
--= - a/src/openvpnserv/Makefile.am
+++ b/src/openvpnserv/Makef= ile.am
@@ -36,5 +36,4 @@
service.c servic= e.h \
validate.c validate.h \
$(top_src= dir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \=
- openvpnserv_resources.rc \<= /span>
- $(top_srcdir)/src/ope= nvpn/ring_buffer.h
+ = openvpnserv_resources.rc
diff --git a/src/openvpnserv/inter= active.c b/src/openvpnserv/interactive.c
index 8a7b50d..5f8= 42bd 100644
--- a/src/openvpnserv/interactive.c
<= span>+++ b/src/openvpnserv/interactive.c

@@ -40,7 +40,6 @@<= /span>
#include "openvpn-msg.h"
#inclu= de "validate.h"
#include "wfp_block.h"=
-#include "ring_b= uffer.h"

#define IO_TIMEOUT 2000 /= *ms*/

@@ -90,7 +89,6 @@
= undo_dns6,
undo_nrpt,
undo_do= mains,
- undo_ring_b= uffer,
undo_wins,
_undo_type_max<= /span>
} undo_type_t;
@@ -108,11 +106,6 @@=
PWSTR domains;
} dns_domains_undo_data_t;

-typed= ef struct {
- struct= tun_ring *send_ring;
-= struct tun_ring *receive_ring;
-} ring_buffer_maps_t;
-
typedef union {
message= _header_t header;
address_message_t address;@@ -122,7 +115,6 @@
dns_cfg_message_t dns;
nrpt_dns_cfg_message_t nrpt_dns;
enab= le_dhcp_message_t dhcp;
- register_ring_buffers_message_t rrb;
set_mtu_mes= sage_t mtu;
wins_cfg_message_t wins;
= create_adapter_message_t create_adapter;
@@ -188,23 +18= 0,6 @@
return INVALID_HANDLE_VALUE;
}=

-sta= tic void
-OvpnUnmapView= OfFile(struct tun_ring **ring)
-{
- if (rin= g && *ring)
- = {
- UnmapViewO= fFile(*ring);
- = *ring =3D NULL;
- }<= /span>
-}
-
-static void
-UnmapRingBuffer(ring_buffer_maps_t *ring_buffer_maps)
-{
- OvpnUnmapViewOfFile(&ring_buffer_maps->send_ring);=
- OvpnUnmapViewOfFi= le(&ring_buffer_maps->receive_ring);
-}
-
static HANDLE
InitOverlapped(LPOVERLAP= PED overlapped)
{
@@ -213,7 +188,6 @@
return overlapped->hEvent;
}
-
static BOOL

ResetOverlapped(LPOVERLAPPED overlapped)<= /span>
{
@@ -2973,119 +2947,6 @@
= }

static DWORD
-OvpnDuplicateHandle(HANDLE ovpn_proc, HANDLE o= rig_handle, HANDLE *new_handle)
-{
- DWORD = err =3D ERROR_SUCCESS;
= -
- if (!DuplicateHa= ndle(ovpn_proc, orig_handle, GetCurrentProcess(), new_handle, 0, FALSE, DUP= LICATE_SAME_ACCESS))
- = {
- err =3D G= etLastError();
- = MsgToEventLog(M_SYSERR, L"Could not duplicate handle");- return err;
= - }
-
- return err;
-= }
-
-static DWORD
-DuplicateAndMapRing(HANDLE ovpn_proc, HANDLE orig_= handle, struct tun_ring **ring)
-{
- DWORD = err =3D ERROR_SUCCESS;
= -
- HANDLE dup_handl= e =3D NULL;
-- err =3D OvpnDuplicateHandle= (ovpn_proc, orig_handle, &dup_handle);
- if (err !=3D ERROR_SUCCESS)
- {
- return err;
- }
- = *ring =3D (struct tun_ring *)MapViewOfFile(dup_handle, FILE_MAP_ALL_ACCES= S, 0, 0, sizeof(struct tun_ring));
- CloseHandleEx(&dup_handle);
- if (*ring =3D=3D NULL)
- {
- err =3D GetLastError();
- MsgToEventLog(M_SYSERR, L"Could not = map shared memory");
- return err;
- }
-
- return err;

-}
-
-static = DWORD
-HandleRegisterRi= ngBuffers(const register_ring_buffers_message_t *rrb, HANDLE ovpn_proc,
- = undo_lists_t *lists)
-= {
- DWORD err =3D 0;=
-
- ring_buffer_maps_t *ring_buffer_maps = =3D RemoveListItem(&(*lists)[undo_ring_buffer], CmpAny, NULL);-
- if (ring_buffer_maps)
- {
- UnmapRingBuffer(ring_buffer_maps);
- }
- else if ((ring_buffer_maps =3D calloc(1, sizeof(*ring_= buffer_maps))) =3D=3D NULL)
- {
- re= turn ERROR_OUTOFMEMORY;
- }
-
- HANDLE device =3D NULL;
<= br>- HANDLE send_tail_moved = =3D NULL;
- HANDLE r= eceive_tail_moved =3D NULL;
-
- err =3D Ovp= nDuplicateHandle(ovpn_proc, rrb->device, &device);
- if (err !=3D ERROR_SUCCESS)<= br>- {
- goto out;
- }
-
- err = =3D DuplicateAndMapRing(ovpn_proc, rrb->send_ring_handle, &ring_buff= er_maps->send_ring);
- if (err !=3D ERROR_SUCCESS)
- {
- = goto out;
- }
-
- err =3D DuplicateAndMapRing(ovpn_proc, = rrb->receive_ring_handle, &ring_buffer_maps->receive_ring);
- if (err !=3D ERROR_SUCC= ESS)
- {
<= span style=3D"color: hsl(0, 100%, 40%);">- goto out;

- }

-
= - err =3D OvpnDuplicateHandle(ovpn_proc, rrb->send_tail_moved, &s= end_tail_moved);
- i= f (err !=3D ERROR_SUCCESS)
- {
- got= o out;
- }-
- err =3D OvpnDuplicateHandle(ovpn_proc, rrb->r= eceive_tail_moved, &receive_tail_moved);
- if (err !=3D ERROR_SUCCESS)
- {
- goto out;
- }
-
- if (!register_ring_b= uffers(device, ring_buffer_maps->send_ring,
- ring_buffer_maps-&g= t;receive_ring,
- = send_tail_moved, receive_tail_moved))
- {

- err =3D GetLastError();
- MsgToEventLog(M_SYSERR, L"C= ould not register ring buffers");
- goto out;
- }
-
- err =3D AddListItem(= &(*lists)[undo_ring_buffer], ring_buffer_maps);
-
-out:
- if= (err !=3D ERROR_SUCCESS && ring_buffer_maps)
- {
- UnmapRingBuffer(ring_buffer_maps);
- free(ring_buffer_maps);=
- }
- CloseHandleEx(&device);
<= span style=3D"color: hsl(0, 100%, 40%);">- CloseHandleEx(&send_tail_= moved);

- CloseHandl= eEx(&receive_tail_moved);
- return err;
-}
-
-static DWORD
HandleMTU= Message(const set_mtu_message_t *mtu)
{
= DWORD err =3D 0;
@@ -3130,10 +2991,6 @@
= hwid =3D L"root\\tap0901";
= break;

- case ADAPTER_TYPE_WINTUN:
- hwid =3D L"wintun";
- break;

-
default:
return ERROR_INVALID_PARAMETER;
= }
@@ -3238,14 +3095,6 @@
}<= /span>
break;

- case msg_register_ring_buffers:
- if (msg.heade= r.size =3D=3D sizeof(msg.rrb))
- {
= - HANDLE ovpn_hnd =3D proc_info->hProcess;
- ack.error_number =3D= HandleRegisterRingBuffers(&msg.rrb, ovpn_hnd, lists);

- }
- break;
-
case msg_set_mtu:
if (msg.header.size =3D=3D sizeof(msg.mtu))<= br> {
@@ -3327,10 +3176,6 @@
}

break;

- = case undo_ring_buffer:
- UnmapRingBuffer(item->data);
- break;
-
= case _undo_type_max:
/* unreachable= */
break;
diff --git = a/src/tapctl/main.c b/src/tapctl/main.c
index 551a8e6..4569= b87 100644
--- a/src/tapctl/main.c
+++ b/sr= c/tapctl/main.c
@@ -75,8 +75,8 @@
L&qu= ot; Note: This name can also be specified as OpenVPN's --= dev-node \n"
L" option. = \n"
L"--hwid <hwid> Adapter hardware ID. Default value is ro= ot\\tap0901, which \n"

- L" describes tap-windows6 driver. To work= with wintun or ovpn-dco \n"
- L" driver, specify 'wintun' or = 'ovpn-dco'. \n"
+ L" describes tap-w= indows6 driver. To work with ovpn-dco driver, \n"
+ L" driver, spe= cify 'ovpn-dco'. \n"
L"\n"
L"Output:\n"=
L"\n"
@@ -94,7 +94,7 @@
L"\n"
L"Options:\n&qu= ot;
L"\n"
- L"--hwid <hwid> Adapter hardware ID. By = default, root\\tap0901, tap0901, wintun and \n"
+ L"--hwid <hwid> Adapter h= ardware ID. By default, root\\tap0901, tap0901 and \n"
L" ovpn-dco adapters are listed. Use this switch t= o limit the list.\n"

L"\n"
L"Output:\n"

@@ -167,10 +167,6 @@=
{
base_name =3D L"OpenVPN Data= Channel Offload";
}
- else if (wcsicmp(hwid, L"wintun") = =3D=3D 0)
- {=
- base_name =3D L"= ;OpenVPN Wintun";
= - }
else if (wcsicmp(hwid, L"root\\" _L(T= AP_WIN_COMPONENT_ID)) =3D=3D 0)
{
= base_name =3D L"OpenVPN TAP-Windows6";
@@ -3= 51,7 +347,6 @@
WCHAR szzHwId[0x100] =3D
= L"root\\" _L(TAP_WIN_COMPONENT_ID) L"\0&q= uot;
_L(TAP_WIN_COMPONENT_ID) L"\0"<= /span>
- L"Win= tun\0"
L"ovpn-dco\0";
/* Parse options. */
diff= --git a/src/tapctl/tap.h b/src/tapctl/tap.h
index 38ea824.= .c35176c 100644
--- a/src/tapctl/tap.h
+++ = b/src/tapctl/tap.h
@@ -38,7 +38,7 @@
* = description of the device. This pointer is optional and = can be NULL.
*
* @param szHwId A= pointer to a NULL-terminated string that supplies the hardware id- * of the= device (e.g. "root\\tap0901", "Wintun").
+ * of the de= vice (e.g. "root\\tap0901").

*
= * @param pbRebootRequired A pointer to a BOOL flag. If the device requir= es a system restart,
* this flag is = set to TRUE. Otherwise, the flag is left unmodified. This
<= /span>

To view, visit change 1021. To unsubscribe, or for help writ= ing mail filters, visit sett= ings.

<= link itemprop=3D"url" href=3D"http://gerrit.openvpn.net/c/openvpn/+/1021?us= p=3Demail"/>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43ec390040bffeec05270271ea7= fb54fb219c536
Gerrit-Change-Number: 1021
Gerrit-PatchSet: 5
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: stipa <lstipakov@...1663...= .>
Gerrit-MessageType: newpatchset
--YyUypzQcD6s=--