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 <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250513151006.13617-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31631.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -137,8 +137,7 @@ routing. |
| 137 | 137 |
Set additional network parameters on supported platforms. May be specified |
| 138 | 138 |
on the client or pushed from the server. On Windows these options are |
| 139 | 139 |
handled by the ``tap-windows6`` driver by default or directly by OpenVPN |
| 140 |
- if dhcp is disabled or the ``wintun`` driver is in use. The |
|
| 141 |
- ``OpenVPN for Android`` client also handles them internally. |
|
| 140 |
+ if dhcp is disabled. The ``OpenVPN for Android`` client also handles them internally. |
|
| 142 | 141 |
|
| 143 | 142 |
On all other platforms these options are only saved in the client's |
| 144 | 143 |
environment under the name :code:`foreign_option_{n}` before the
|
| ... | ... |
@@ -252,9 +252,3 @@ Windows-Specific Options |
| 252 | 252 |
otherwise it defaulted to :code:`C:\\WINDOWS`. It is not needed to use |
| 253 | 253 |
the ``env`` keyword any more, and it will just be ignored. A warning is |
| 254 | 254 |
logged when this is found in the configuration file. |
| 255 |
- |
|
| 256 |
- Specifies which tun driver to use. Values are :code:`ovpn-dco` (default), |
|
| 257 |
- :code:`tap-windows6` and :code:`wintun`. :code:`ovpn-dco` and :code:`wintun` |
|
| 258 |
- require ``--dev tun``. :code:`wintun` also requires OpenVPN process to run |
|
| 259 |
- elevated, or be invoked using the Interactive Service. |
| ... | ... |
@@ -44,7 +44,7 @@ typedef enum {
|
| 44 | 44 |
msg_del_wfp_block, |
| 45 | 45 |
msg_register_dns, |
| 46 | 46 |
msg_enable_dhcp, |
| 47 |
- msg_register_ring_buffers, |
|
| 47 |
+ deprecated_msg_register_ring_buffers, |
|
| 48 | 48 |
msg_set_mtu, |
| 49 | 49 |
msg_add_wins_cfg, |
| 50 | 50 |
msg_del_wins_cfg, |
| ... | ... |
@@ -159,15 +159,6 @@ typedef struct {
|
| 159 | 159 |
|
| 160 | 160 |
typedef struct {
|
| 161 | 161 |
message_header_t header; |
| 162 |
- HANDLE device; |
|
| 163 |
- HANDLE send_ring_handle; |
|
| 164 |
- HANDLE receive_ring_handle; |
|
| 165 |
- HANDLE send_tail_moved; |
|
| 166 |
- HANDLE receive_tail_moved; |
|
| 167 |
-} register_ring_buffers_message_t; |
|
| 168 |
- |
|
| 169 |
-typedef struct {
|
|
| 170 |
- message_header_t header; |
|
| 171 | 162 |
interface_t iface; |
| 172 | 163 |
short family; |
| 173 | 164 |
int mtu; |
| ... | ... |
@@ -176,7 +167,6 @@ typedef struct {
|
| 176 | 176 |
typedef enum {
|
| 177 | 177 |
ADAPTER_TYPE_DCO, |
| 178 | 178 |
ADAPTER_TYPE_TAP, |
| 179 |
- ADAPTER_TYPE_WINTUN |
|
| 180 | 179 |
} adapter_type_t; |
| 181 | 180 |
|
| 182 | 181 |
typedef struct {
|
| ... | ... |
@@ -163,6 +163,6 @@ openvpn_LDADD = \ |
| 163 | 163 |
$(OPTIONAL_DL_LIBS) \ |
| 164 | 164 |
$(OPTIONAL_INOTIFY_LIBS) |
| 165 | 165 |
if WIN32 |
| 166 |
-openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h |
|
| 166 |
+openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h |
|
| 167 | 167 |
openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt |
| 168 | 168 |
endif |
| ... | ... |
@@ -359,14 +359,6 @@ dco_check_startup_option(int msglevel, const struct options *o) |
| 359 | 359 |
return false; |
| 360 | 360 |
} |
| 361 | 361 |
|
| 362 |
- if ((o->windows_driver == WINDOWS_DRIVER_WINTUN) |
|
| 363 |
- || (o->windows_driver == WINDOWS_DRIVER_TAP_WINDOWS6)) |
|
| 364 |
- {
|
|
| 365 |
- msg(msglevel, "--windows-driver is set to '%s'. Disabling Data Channel Offload", |
|
| 366 |
- print_tun_backend_driver(o->windows_driver)); |
|
| 367 |
- return false; |
|
| 368 |
- } |
|
| 369 |
- |
|
| 370 | 362 |
if ((o->mode == MODE_SERVER) && o->ce.local_list->len > 1) |
| 371 | 363 |
{
|
| 372 | 364 |
msg(msglevel, "multiple --local options defined, disabling data channel offload"); |
| ... | ... |
@@ -1308,26 +1308,11 @@ read_incoming_tun(struct context *c) |
| 1308 | 1308 |
c->c2.buf = c->c2.buffers->read_tun_buf; |
| 1309 | 1309 |
|
| 1310 | 1310 |
#ifdef _WIN32 |
| 1311 |
- if (c->c1.tuntap->backend_driver == WINDOWS_DRIVER_WINTUN) |
|
| 1312 |
- {
|
|
| 1313 |
- read_wintun(c->c1.tuntap, &c->c2.buf); |
|
| 1314 |
- if (c->c2.buf.len == -1) |
|
| 1315 |
- {
|
|
| 1316 |
- register_signal(c->sig, SIGHUP, "tun-abort"); |
|
| 1317 |
- c->persist.restart_sleep_seconds = 1; |
|
| 1318 |
- msg(M_INFO, "Wintun read error, restarting"); |
|
| 1319 |
- perf_pop(); |
|
| 1320 |
- return; |
|
| 1321 |
- } |
|
| 1322 |
- } |
|
| 1323 |
- else |
|
| 1324 |
- {
|
|
| 1325 |
- /* we cannot end up here when using dco */ |
|
| 1326 |
- ASSERT(!dco_enabled(&c->options)); |
|
| 1311 |
+ /* we cannot end up here when using dco */ |
|
| 1312 |
+ ASSERT(!dco_enabled(&c->options)); |
|
| 1327 | 1313 |
|
| 1328 |
- sockethandle_t sh = { .is_handle = true, .h = c->c1.tuntap->hand, .prepend_sa = false };
|
|
| 1329 |
- sockethandle_finalize(sh, &c->c1.tuntap->reads, &c->c2.buf, NULL); |
|
| 1330 |
- } |
|
| 1314 |
+ sockethandle_t sh = { .is_handle = true, .h = c->c1.tuntap->hand, .prepend_sa = false };
|
|
| 1315 |
+ sockethandle_finalize(sh, &c->c1.tuntap->reads, &c->c2.buf, NULL); |
|
| 1331 | 1316 |
#else /* ifdef _WIN32 */ |
| 1332 | 1317 |
ASSERT(buf_init(&c->c2.buf, c->c2.frame.buf.headroom)); |
| 1333 | 1318 |
ASSERT(buf_safe(&c->c2.buf, c->c2.frame.buf.payload_size)); |
| ... | ... |
@@ -1942,7 +1927,7 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock) |
| 1942 | 1942 |
#endif |
| 1943 | 1943 |
|
| 1944 | 1944 |
#ifdef _WIN32 |
| 1945 |
- size = write_tun_buffered(c->c1.tuntap, &c->c2.to_tun); |
|
| 1945 |
+ size = tun_write_win32(c->c1.tuntap, &c->c2.to_tun); |
|
| 1946 | 1946 |
#else |
| 1947 | 1947 |
if (c->c1.tuntap->backend_driver == DRIVER_AFUNIX) |
| 1948 | 1948 |
{
|
| ... | ... |
@@ -2148,17 +2133,6 @@ multi_io_process_flags(struct context *c, struct event_set *es, |
| 2148 | 2148 |
tuntap |= EVENT_READ; |
| 2149 | 2149 |
} |
| 2150 | 2150 |
|
| 2151 |
-#ifdef _WIN32 |
|
| 2152 |
- if (tuntap_is_wintun(c->c1.tuntap)) |
|
| 2153 |
- {
|
|
| 2154 |
- /* |
|
| 2155 |
- * With wintun we are only interested in read event. Ring buffer is |
|
| 2156 |
- * always ready for write, so we don't do wait. |
|
| 2157 |
- */ |
|
| 2158 |
- tuntap = EVENT_READ; |
|
| 2159 |
- } |
|
| 2160 |
-#endif |
|
| 2161 |
- |
|
| 2162 | 2151 |
/* |
| 2163 | 2152 |
* Configure event wait based on socket, tuntap flags. |
| 2164 | 2153 |
*/ |
| ... | ... |
@@ -2217,36 +2191,8 @@ get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned in |
| 2217 | 2217 |
} |
| 2218 | 2218 |
else |
| 2219 | 2219 |
{
|
| 2220 |
-#ifdef _WIN32 |
|
| 2221 |
- bool skip_iowait = flags & IOW_TO_TUN; |
|
| 2222 |
- if (flags & IOW_READ_TUN) |
|
| 2223 |
- {
|
|
| 2224 |
- /* |
|
| 2225 |
- * don't read from tun if we have pending write to link, |
|
| 2226 |
- * since every tun read overwrites to_link buffer filled |
|
| 2227 |
- * by previous tun read |
|
| 2228 |
- */ |
|
| 2229 |
- skip_iowait = !(flags & IOW_TO_LINK); |
|
| 2230 |
- } |
|
| 2231 |
- if (tuntap_is_wintun(c->c1.tuntap) && skip_iowait) |
|
| 2232 |
- {
|
|
| 2233 |
- unsigned int ret = 0; |
|
| 2234 |
- if (flags & IOW_TO_TUN) |
|
| 2235 |
- {
|
|
| 2236 |
- ret |= TUN_WRITE; |
|
| 2237 |
- } |
|
| 2238 |
- if (flags & IOW_READ_TUN) |
|
| 2239 |
- {
|
|
| 2240 |
- ret |= TUN_READ; |
|
| 2241 |
- } |
|
| 2242 |
- multi_io->udp_flags = ret; |
|
| 2243 |
- } |
|
| 2244 |
- else |
|
| 2245 |
-#endif /* ifdef _WIN32 */ |
|
| 2246 |
- {
|
|
| 2247 |
- /* slow path - delegate to io_wait_dowork_udp to calculate flags */ |
|
| 2248 |
- get_io_flags_dowork_udp(c, multi_io, flags); |
|
| 2249 |
- } |
|
| 2220 |
+ /* slow path - delegate to io_wait_dowork_udp to calculate flags */ |
|
| 2221 |
+ get_io_flags_dowork_udp(c, multi_io, flags); |
|
| 2250 | 2222 |
} |
| 2251 | 2223 |
} |
| 2252 | 2224 |
|
| ... | ... |
@@ -360,12 +360,6 @@ p2p_iow_flags(const struct context *c) |
| 360 | 360 |
{
|
| 361 | 361 |
flags |= IOW_TO_TUN; |
| 362 | 362 |
} |
| 363 |
-#ifdef _WIN32 |
|
| 364 |
- if (tuntap_ring_empty(c->c1.tuntap)) |
|
| 365 |
- {
|
|
| 366 |
- flags &= ~IOW_READ_TUN; |
|
| 367 |
- } |
|
| 368 |
-#endif |
|
| 369 | 363 |
return flags; |
| 370 | 364 |
} |
| 371 | 365 |
|
| ... | ... |
@@ -393,36 +387,8 @@ io_wait(struct context *c, const unsigned int flags) |
| 393 | 393 |
} |
| 394 | 394 |
else |
| 395 | 395 |
{
|
| 396 |
-#ifdef _WIN32 |
|
| 397 |
- bool skip_iowait = flags & IOW_TO_TUN; |
|
| 398 |
- if (flags & IOW_READ_TUN) |
|
| 399 |
- {
|
|
| 400 |
- /* |
|
| 401 |
- * don't read from tun if we have pending write to link, |
|
| 402 |
- * since every tun read overwrites to_link buffer filled |
|
| 403 |
- * by previous tun read |
|
| 404 |
- */ |
|
| 405 |
- skip_iowait = !(flags & IOW_TO_LINK); |
|
| 406 |
- } |
|
| 407 |
- if (tuntap_is_wintun(c->c1.tuntap) && skip_iowait) |
|
| 408 |
- {
|
|
| 409 |
- unsigned int ret = 0; |
|
| 410 |
- if (flags & IOW_TO_TUN) |
|
| 411 |
- {
|
|
| 412 |
- ret |= TUN_WRITE; |
|
| 413 |
- } |
|
| 414 |
- if (flags & IOW_READ_TUN) |
|
| 415 |
- {
|
|
| 416 |
- ret |= TUN_READ; |
|
| 417 |
- } |
|
| 418 |
- c->c2.event_set_status = ret; |
|
| 419 |
- } |
|
| 420 |
- else |
|
| 421 |
-#endif /* ifdef _WIN32 */ |
|
| 422 |
- {
|
|
| 423 |
- /* slow path */ |
|
| 424 |
- io_wait_dowork(c, flags); |
|
| 425 |
- } |
|
| 396 |
+ /* slow path */ |
|
| 397 |
+ io_wait_dowork(c, flags); |
|
| 426 | 398 |
} |
| 427 | 399 |
} |
| 428 | 400 |
|
| ... | ... |
@@ -190,20 +190,6 @@ multi_io_wait(struct multi_context *m) |
| 190 | 190 |
get_io_flags_udp(&m->top, m->multi_io, p2mp_iow_flags(m)); |
| 191 | 191 |
} |
| 192 | 192 |
|
| 193 |
-#ifdef _WIN32 |
|
| 194 |
- if (tuntap_is_wintun(m->top.c1.tuntap)) |
|
| 195 |
- {
|
|
| 196 |
- if (!tuntap_ring_empty(m->top.c1.tuntap)) |
|
| 197 |
- {
|
|
| 198 |
- /* there is data in wintun ring buffer, read it immediately */ |
|
| 199 |
- m->multi_io->esr[0].arg = MULTI_IO_TUN; |
|
| 200 |
- m->multi_io->esr[0].rwflags = EVENT_READ; |
|
| 201 |
- m->multi_io->n_esr = 1; |
|
| 202 |
- return 1; |
|
| 203 |
- } |
|
| 204 |
- persistent = NULL; |
|
| 205 |
- } |
|
| 206 |
-#endif |
|
| 207 | 193 |
tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, persistent); |
| 208 | 194 |
#if defined(ENABLE_DCO) \ |
| 209 | 195 |
&& (defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(TARGET_WIN32)) |
| ... | ... |
@@ -750,10 +750,6 @@ static const char usage_message[] = |
| 750 | 750 |
" optional parameter controls the initial state of ex.\n" |
| 751 | 751 |
"--show-net-up : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n" |
| 752 | 752 |
" after TAP adapter is up and routes have been added.\n" |
| 753 |
- "--windows-driver : Which tun driver to use?\n" |
|
| 754 |
- " ovpn-dco (default)\n" |
|
| 755 |
- " tap-windows6\n" |
|
| 756 |
- " wintun\n" |
|
| 757 | 753 |
"--block-outside-dns : Block DNS on other network adapters to prevent DNS leaks\n" |
| 758 | 754 |
"Windows Standalone Options:\n" |
| 759 | 755 |
"\n" |
| ... | ... |
@@ -2592,11 +2588,6 @@ options_postprocess_verify_ce(const struct options *options, |
| 2592 | 2592 |
prefix); |
| 2593 | 2593 |
} |
| 2594 | 2594 |
} |
| 2595 |
- |
|
| 2596 |
- if (options->windows_driver == WINDOWS_DRIVER_WINTUN && dev != DEV_TYPE_TUN) |
|
| 2597 |
- {
|
|
| 2598 |
- msg(M_USAGE, "--windows-driver wintun requires --dev tun"); |
|
| 2599 |
- } |
|
| 2600 | 2595 |
#endif /* ifdef _WIN32 */ |
| 2601 | 2596 |
|
| 2602 | 2597 |
/* |
| ... | ... |
@@ -3371,9 +3362,8 @@ options_postprocess_mutate_invariant(struct options *options) |
| 3371 | 3371 |
#ifdef _WIN32 |
| 3372 | 3372 |
const int dev = dev_type_enum(options->dev, options->dev_type); |
| 3373 | 3373 |
|
| 3374 |
- /* when using wintun/ovpn-dco, kernel doesn't send DHCP requests, so don't use it */ |
|
| 3375 |
- if ((options->windows_driver == WINDOWS_DRIVER_WINTUN |
|
| 3376 |
- || options->windows_driver == DRIVER_DCO) |
|
| 3374 |
+ /* when using ovpn-dco, kernel doesn't send DHCP requests, so don't use it */ |
|
| 3375 |
+ if ((options->windows_driver == DRIVER_DCO) |
|
| 3377 | 3376 |
&& (options->tuntap_options.ip_win32_type == IPW32_SET_DHCP_MASQ |
| 3378 | 3377 |
|| options->tuntap_options.ip_win32_type == IPW32_SET_ADAPTIVE)) |
| 3379 | 3378 |
{
|
| ... | ... |
@@ -4665,39 +4655,6 @@ options_string_extract_option(const char *options_string, const char *opt_name, |
| 4665 | 4665 |
return ret; |
| 4666 | 4666 |
} |
| 4667 | 4667 |
|
| 4668 |
-#ifdef _WIN32 |
|
| 4669 |
-/** |
|
| 4670 |
- * Parses --windows-driver config option |
|
| 4671 |
- * |
|
| 4672 |
- * @param str value of --windows-driver option |
|
| 4673 |
- * @param msglevel msglevel to report parsing error |
|
| 4674 |
- * @return enum tun_driver_type driver type, WINDOWS_DRIVER_UNSPECIFIED on unknown --windows-driver value |
|
| 4675 |
- */ |
|
| 4676 |
-static enum tun_driver_type |
|
| 4677 |
-parse_windows_driver(const char *str, const int msglevel) |
|
| 4678 |
-{
|
|
| 4679 |
- if (streq(str, "tap-windows6")) |
|
| 4680 |
- {
|
|
| 4681 |
- return WINDOWS_DRIVER_TAP_WINDOWS6; |
|
| 4682 |
- } |
|
| 4683 |
- else if (streq(str, "wintun")) |
|
| 4684 |
- {
|
|
| 4685 |
- return WINDOWS_DRIVER_WINTUN; |
|
| 4686 |
- } |
|
| 4687 |
- |
|
| 4688 |
- else if (streq(str, "ovpn-dco")) |
|
| 4689 |
- {
|
|
| 4690 |
- return DRIVER_DCO; |
|
| 4691 |
- } |
|
| 4692 |
- else |
|
| 4693 |
- {
|
|
| 4694 |
- msg(msglevel, "--windows-driver must be tap-windows6, wintun " |
|
| 4695 |
- "or ovpn-dco"); |
|
| 4696 |
- return WINDOWS_DRIVER_UNSPECIFIED; |
|
| 4697 |
- } |
|
| 4698 |
-} |
|
| 4699 |
-#endif /* ifdef _WIN32 */ |
|
| 4700 |
- |
|
| 4701 | 4668 |
/* |
| 4702 | 4669 |
* parse/print topology coding |
| 4703 | 4670 |
*/ |
| ... | ... |
@@ -6012,7 +5969,8 @@ add_option(struct options *options, |
| 6012 | 6012 |
else if (streq(p[0], "windows-driver") && p[1] && !p[2]) |
| 6013 | 6013 |
{
|
| 6014 | 6014 |
VERIFY_PERMISSION(OPT_P_GENERAL); |
| 6015 |
- options->windows_driver = parse_windows_driver(p[1], M_FATAL); |
|
| 6015 |
+ msg(M_WARN, "DEPRECATED OPTION: windows-driver: In OpenVPN 2.7, the default Windows driver is ovpn-dco. " |
|
| 6016 |
+ "If incompatible options are used, OpenVPN will fall back to tap-windows6. Wintun support has been removed."); |
|
| 6016 | 6017 |
} |
| 6017 | 6018 |
#endif |
| 6018 | 6019 |
else if (streq(p[0], "disable-dco")) |
| 6019 | 6020 |
deleted file mode 100644 |
| ... | ... |
@@ -1,125 +0,0 @@ |
| 1 |
-/* |
|
| 2 |
- * OpenVPN -- An application to securely tunnel IP networks |
|
| 3 |
- * over a single UDP port, with support for SSL/TLS-based |
|
| 4 |
- * session authentication and key exchange, |
|
| 5 |
- * packet encryption, packet authentication, and |
|
| 6 |
- * packet compression. |
|
| 7 |
- * |
|
| 8 |
- * Copyright (C) 2002-2024 OpenVPN Inc <sales@openvpn.net> |
|
| 9 |
- * 2019 Lev Stipakov <lev@openvpn.net> |
|
| 10 |
- * |
|
| 11 |
- * This program is free software; you can redistribute it and/or modify |
|
| 12 |
- * it under the terms of the GNU General Public License version 2 |
|
| 13 |
- * as published by the Free Software Foundation. |
|
| 14 |
- * |
|
| 15 |
- * This program is distributed in the hope that it will be useful, |
|
| 16 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
- * GNU General Public License for more details. |
|
| 19 |
- * |
|
| 20 |
- * You should have received a copy of the GNU General Public License along |
|
| 21 |
- * with this program; if not, write to the Free Software Foundation, Inc., |
|
| 22 |
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
| 23 |
- */ |
|
| 24 |
- |
|
| 25 |
-#ifdef _WIN32 |
|
| 26 |
-#ifndef OPENVPN_RING_BUFFER_H |
|
| 27 |
-#define OPENVPN_RING_BUFFER_H |
|
| 28 |
- |
|
| 29 |
-#include <windows.h> |
|
| 30 |
-#include <winioctl.h> |
|
| 31 |
- |
|
| 32 |
-#include <stdint.h> |
|
| 33 |
-#include <stdbool.h> |
|
| 34 |
- |
|
| 35 |
-/* |
|
| 36 |
- * Values below are taken from Wireguard Windows client |
|
| 37 |
- * https://github.com/WireGuard/wireguard-go/blob/master/tun/wintun/ring_windows.go#L14 |
|
| 38 |
- */ |
|
| 39 |
-#define WINTUN_RING_CAPACITY 0x800000 |
|
| 40 |
-#define WINTUN_RING_TRAILING_BYTES 0x10000 |
|
| 41 |
-#define WINTUN_MAX_PACKET_SIZE 0xffff |
|
| 42 |
-#define WINTUN_PACKET_ALIGN 4 |
|
| 43 |
- |
|
| 44 |
-#define TUN_IOCTL_REGISTER_RINGS CTL_CODE(51820U, 0x970U, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) |
|
| 45 |
- |
|
| 46 |
-/** |
|
| 47 |
- * Wintun ring buffer |
|
| 48 |
- * See https://github.com/WireGuard/wintun#ring-layout |
|
| 49 |
- */ |
|
| 50 |
-struct tun_ring |
|
| 51 |
-{
|
|
| 52 |
- volatile ULONG head; |
|
| 53 |
- volatile ULONG tail; |
|
| 54 |
- volatile LONG alertable; |
|
| 55 |
- UCHAR data[WINTUN_RING_CAPACITY + WINTUN_RING_TRAILING_BYTES]; |
|
| 56 |
-}; |
|
| 57 |
- |
|
| 58 |
-/** |
|
| 59 |
- * Struct for ring buffers registration |
|
| 60 |
- * See https://github.com/WireGuard/wintun#registering-rings |
|
| 61 |
- */ |
|
| 62 |
-struct tun_register_rings |
|
| 63 |
-{
|
|
| 64 |
- struct |
|
| 65 |
- {
|
|
| 66 |
- ULONG ring_size; |
|
| 67 |
- struct tun_ring *ring; |
|
| 68 |
- HANDLE tail_moved; |
|
| 69 |
- } send, receive; |
|
| 70 |
-}; |
|
| 71 |
- |
|
| 72 |
-struct TUN_PACKET_HEADER |
|
| 73 |
-{
|
|
| 74 |
- uint32_t size; |
|
| 75 |
-}; |
|
| 76 |
- |
|
| 77 |
-struct TUN_PACKET |
|
| 78 |
-{
|
|
| 79 |
- uint32_t size; |
|
| 80 |
- UCHAR data[WINTUN_MAX_PACKET_SIZE]; |
|
| 81 |
-}; |
|
| 82 |
- |
|
| 83 |
-/** |
|
| 84 |
- * Registers ring buffers used to exchange data between |
|
| 85 |
- * userspace openvpn process and wintun kernel driver, |
|
| 86 |
- * see https://github.com/WireGuard/wintun#registering-rings |
|
| 87 |
- * |
|
| 88 |
- * @param device handle to opened wintun device |
|
| 89 |
- * @param send_ring pointer to send ring |
|
| 90 |
- * @param receive_ring pointer to receive ring |
|
| 91 |
- * @param send_tail_moved event set by wintun to signal openvpn |
|
| 92 |
- * that data is available for reading in send ring |
|
| 93 |
- * @param receive_tail_moved event set by openvpn to signal wintun |
|
| 94 |
- * that data has been written to receive ring |
|
| 95 |
- * @return true if registration is successful, false otherwise - use GetLastError() |
|
| 96 |
- */ |
|
| 97 |
-static inline bool |
|
| 98 |
-register_ring_buffers(HANDLE device, |
|
| 99 |
- struct tun_ring *send_ring, |
|
| 100 |
- struct tun_ring *receive_ring, |
|
| 101 |
- HANDLE send_tail_moved, |
|
| 102 |
- HANDLE receive_tail_moved) |
|
| 103 |
-{
|
|
| 104 |
- struct tun_register_rings rr; |
|
| 105 |
- BOOL res; |
|
| 106 |
- DWORD bytes_returned; |
|
| 107 |
- |
|
| 108 |
- ZeroMemory(&rr, sizeof(rr)); |
|
| 109 |
- |
|
| 110 |
- rr.send.ring = send_ring; |
|
| 111 |
- rr.send.ring_size = sizeof(struct tun_ring); |
|
| 112 |
- rr.send.tail_moved = send_tail_moved; |
|
| 113 |
- |
|
| 114 |
- rr.receive.ring = receive_ring; |
|
| 115 |
- rr.receive.ring_size = sizeof(struct tun_ring); |
|
| 116 |
- rr.receive.tail_moved = receive_tail_moved; |
|
| 117 |
- |
|
| 118 |
- res = DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr, sizeof(rr), |
|
| 119 |
- NULL, 0, &bytes_returned, NULL); |
|
| 120 |
- |
|
| 121 |
- return res != FALSE; |
|
| 122 |
-} |
|
| 123 |
- |
|
| 124 |
-#endif /* ifndef OPENVPN_RING_BUFFER_H */ |
|
| 125 |
-#endif /* ifdef _WIN32 */ |
| ... | ... |
@@ -63,9 +63,6 @@ print_tun_backend_driver(enum tun_driver_type driver) |
| 63 | 63 |
case WINDOWS_DRIVER_TAP_WINDOWS6: |
| 64 | 64 |
return "tap-windows6"; |
| 65 | 65 |
|
| 66 |
- case WINDOWS_DRIVER_WINTUN: |
|
| 67 |
- return "wintun"; |
|
| 68 |
- |
|
| 69 | 66 |
case DRIVER_GENERIC_TUNTAP: |
| 70 | 67 |
return "tun/tap"; |
| 71 | 68 |
|
| ... | ... |
@@ -473,10 +470,6 @@ do_create_adapter_service(HANDLE msg_channel, enum tun_driver_type driver_type) |
| 473 | 473 |
t = ADAPTER_TYPE_TAP; |
| 474 | 474 |
break; |
| 475 | 475 |
|
| 476 |
- case WINDOWS_DRIVER_WINTUN: |
|
| 477 |
- t = ADAPTER_TYPE_WINTUN; |
|
| 478 |
- break; |
|
| 479 |
- |
|
| 480 | 476 |
case DRIVER_DCO: |
| 481 | 477 |
t = ADAPTER_TYPE_DCO; |
| 482 | 478 |
break; |
| ... | ... |
@@ -1040,37 +1033,8 @@ init_tun_post(struct tuntap *tt, |
| 1040 | 1040 |
overlapped_io_init(&tt->writes, frame, TRUE); |
| 1041 | 1041 |
tt->adapter_index = TUN_ADAPTER_INDEX_INVALID; |
| 1042 | 1042 |
|
| 1043 |
- if (tt->backend_driver == WINDOWS_DRIVER_WINTUN) |
|
| 1044 |
- {
|
|
| 1045 |
- tt->wintun_send_ring_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, |
|
| 1046 |
- PAGE_READWRITE, |
|
| 1047 |
- 0, |
|
| 1048 |
- sizeof(struct tun_ring), |
|
| 1049 |
- NULL); |
|
| 1050 |
- tt->wintun_receive_ring_handle = CreateFileMapping(INVALID_HANDLE_VALUE, |
|
| 1051 |
- NULL, |
|
| 1052 |
- PAGE_READWRITE, |
|
| 1053 |
- 0, |
|
| 1054 |
- sizeof(struct tun_ring), |
|
| 1055 |
- NULL); |
|
| 1056 |
- if ((tt->wintun_send_ring_handle == NULL) || (tt->wintun_receive_ring_handle == NULL)) |
|
| 1057 |
- {
|
|
| 1058 |
- msg(M_FATAL, "Cannot allocate memory for ring buffer"); |
|
| 1059 |
- } |
|
| 1060 |
- |
|
| 1061 |
- tt->rw_handle.read = CreateEvent(NULL, FALSE, FALSE, NULL); |
|
| 1062 |
- tt->rw_handle.write = CreateEvent(NULL, FALSE, FALSE, NULL); |
|
| 1063 |
- |
|
| 1064 |
- if ((tt->rw_handle.read == NULL) || (tt->rw_handle.write == NULL)) |
|
| 1065 |
- {
|
|
| 1066 |
- msg(M_FATAL, "Cannot create events for ring buffer"); |
|
| 1067 |
- } |
|
| 1068 |
- } |
|
| 1069 |
- else |
|
| 1070 |
- {
|
|
| 1071 |
- tt->rw_handle.read = tt->reads.overlapped.hEvent; |
|
| 1072 |
- tt->rw_handle.write = tt->writes.overlapped.hEvent; |
|
| 1073 |
- } |
|
| 1043 |
+ tt->rw_handle.read = tt->reads.overlapped.hEvent; |
|
| 1044 |
+ tt->rw_handle.write = tt->writes.overlapped.hEvent; |
|
| 1074 | 1045 |
#endif /* ifdef _WIN32 */ |
| 1075 | 1046 |
} |
| 1076 | 1047 |
|
| ... | ... |
@@ -4010,10 +3974,6 @@ get_tap_reg(struct gc_arena *gc) |
| 4010 | 4010 |
{
|
| 4011 | 4011 |
windows_driver = WINDOWS_DRIVER_TAP_WINDOWS6; |
| 4012 | 4012 |
} |
| 4013 |
- else if (strcasecmp(component_id, WINTUN_COMPONENT_ID) == 0) |
|
| 4014 |
- {
|
|
| 4015 |
- windows_driver = WINDOWS_DRIVER_WINTUN; |
|
| 4016 |
- } |
|
| 4017 | 4013 |
else if (strcasecmp(component_id, "ovpn-dco") == 0) |
| 4018 | 4014 |
{
|
| 4019 | 4015 |
windows_driver = DRIVER_DCO; |
| ... | ... |
@@ -4320,7 +4280,7 @@ show_tap_win_adapters(int msglev, int warnlev) |
| 4320 | 4320 |
} |
| 4321 | 4321 |
|
| 4322 | 4322 |
/* |
| 4323 |
- * Lookup a TAP-Windows or Wintun adapter by GUID. |
|
| 4323 |
+ * Lookup an adapter by GUID. |
|
| 4324 | 4324 |
*/ |
| 4325 | 4325 |
static const struct tap_reg * |
| 4326 | 4326 |
get_adapter_by_guid(const char *guid, const struct tap_reg *tap_reg) |
| ... | ... |
@@ -4375,7 +4335,7 @@ at_least_one_tap_win(const struct tap_reg *tap_reg) |
| 4375 | 4375 |
{
|
| 4376 | 4376 |
if (!tap_reg) |
| 4377 | 4377 |
{
|
| 4378 |
- msg(M_FATAL, "There are no TAP-Windows, Wintun or ovpn-dco adapters " |
|
| 4378 |
+ msg(M_FATAL, "There are no TAP-Windows or ovpn-dco adapters " |
|
| 4379 | 4379 |
"on this system. You should be able to create an adapter " |
| 4380 | 4380 |
"by using tapctl.exe utility."); |
| 4381 | 4381 |
} |
| ... | ... |
@@ -6086,46 +6046,6 @@ register_dns_service(const struct tuntap *tt) |
| 6086 | 6086 |
gc_free(&gc); |
| 6087 | 6087 |
} |
| 6088 | 6088 |
|
| 6089 |
-static bool |
|
| 6090 |
-service_register_ring_buffers(const struct tuntap *tt) |
|
| 6091 |
-{
|
|
| 6092 |
- HANDLE msg_channel = tt->options.msg_channel; |
|
| 6093 |
- ack_message_t ack; |
|
| 6094 |
- bool ret = true; |
|
| 6095 |
- struct gc_arena gc = gc_new(); |
|
| 6096 |
- |
|
| 6097 |
- register_ring_buffers_message_t msg = {
|
|
| 6098 |
- .header = {
|
|
| 6099 |
- msg_register_ring_buffers, |
|
| 6100 |
- sizeof(register_ring_buffers_message_t), |
|
| 6101 |
- 0 |
|
| 6102 |
- }, |
|
| 6103 |
- .device = tt->hand, |
|
| 6104 |
- .send_ring_handle = tt->wintun_send_ring_handle, |
|
| 6105 |
- .receive_ring_handle = tt->wintun_receive_ring_handle, |
|
| 6106 |
- .send_tail_moved = tt->rw_handle.read, |
|
| 6107 |
- .receive_tail_moved = tt->rw_handle.write |
|
| 6108 |
- }; |
|
| 6109 |
- |
|
| 6110 |
- if (!send_msg_iservice(msg_channel, &msg, sizeof(msg), &ack, "Register ring buffers")) |
|
| 6111 |
- {
|
|
| 6112 |
- ret = false; |
|
| 6113 |
- } |
|
| 6114 |
- else if (ack.error_number != NO_ERROR) |
|
| 6115 |
- {
|
|
| 6116 |
- msg(M_NONFATAL, "Register ring buffers failed using service: %s [status=0x%x]", |
|
| 6117 |
- strerror_win32(ack.error_number, &gc), ack.error_number); |
|
| 6118 |
- ret = false; |
|
| 6119 |
- } |
|
| 6120 |
- else |
|
| 6121 |
- {
|
|
| 6122 |
- msg(M_INFO, "Ring buffers registered via service"); |
|
| 6123 |
- } |
|
| 6124 |
- |
|
| 6125 |
- gc_free(&gc); |
|
| 6126 |
- return ret; |
|
| 6127 |
-} |
|
| 6128 |
- |
|
| 6129 | 6089 |
void |
| 6130 | 6090 |
fork_register_dns_action(struct tuntap *tt) |
| 6131 | 6091 |
{
|
| ... | ... |
@@ -6363,58 +6283,6 @@ tuntap_set_ip_addr(struct tuntap *tt, |
| 6363 | 6363 |
gc_free(&gc); |
| 6364 | 6364 |
} |
| 6365 | 6365 |
|
| 6366 |
-static bool |
|
| 6367 |
-wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid) |
|
| 6368 |
-{
|
|
| 6369 |
- bool ret = true; |
|
| 6370 |
- |
|
| 6371 |
- tt->wintun_send_ring = (struct tun_ring *)MapViewOfFile(tt->wintun_send_ring_handle, |
|
| 6372 |
- FILE_MAP_ALL_ACCESS, |
|
| 6373 |
- 0, |
|
| 6374 |
- 0, |
|
| 6375 |
- sizeof(struct tun_ring)); |
|
| 6376 |
- |
|
| 6377 |
- tt->wintun_receive_ring = (struct tun_ring *)MapViewOfFile(tt->wintun_receive_ring_handle, |
|
| 6378 |
- FILE_MAP_ALL_ACCESS, |
|
| 6379 |
- 0, |
|
| 6380 |
- 0, |
|
| 6381 |
- sizeof(struct tun_ring)); |
|
| 6382 |
- |
|
| 6383 |
- if (tt->options.msg_channel) |
|
| 6384 |
- {
|
|
| 6385 |
- ret = service_register_ring_buffers(tt); |
|
| 6386 |
- } |
|
| 6387 |
- else |
|
| 6388 |
- {
|
|
| 6389 |
- if (!register_ring_buffers(tt->hand, |
|
| 6390 |
- tt->wintun_send_ring, |
|
| 6391 |
- tt->wintun_receive_ring, |
|
| 6392 |
- tt->rw_handle.read, |
|
| 6393 |
- tt->rw_handle.write)) |
|
| 6394 |
- {
|
|
| 6395 |
- switch (GetLastError()) |
|
| 6396 |
- {
|
|
| 6397 |
- case ERROR_ACCESS_DENIED: |
|
| 6398 |
- msg(M_FATAL, "ERROR: Wintun requires SYSTEM privileges and therefore " |
|
| 6399 |
- "should be used with interactive service. If you want to " |
|
| 6400 |
- "use openvpn from command line, you need to do SYSTEM " |
|
| 6401 |
- "elevation yourself (for example with psexec)."); |
|
| 6402 |
- break; |
|
| 6403 |
- |
|
| 6404 |
- case ERROR_ALREADY_INITIALIZED: |
|
| 6405 |
- msg(M_NONFATAL, "Adapter %s is already in use", device_guid); |
|
| 6406 |
- break; |
|
| 6407 |
- |
|
| 6408 |
- default: |
|
| 6409 |
- msg(M_NONFATAL | M_ERRNO, "Failed to register ring buffers"); |
|
| 6410 |
- } |
|
| 6411 |
- ret = false; |
|
| 6412 |
- } |
|
| 6413 |
- |
|
| 6414 |
- } |
|
| 6415 |
- return ret; |
|
| 6416 |
-} |
|
| 6417 |
- |
|
| 6418 | 6366 |
static void |
| 6419 | 6367 |
tuntap_set_connected(const struct tuntap *tt) |
| 6420 | 6368 |
{
|
| ... | ... |
@@ -6574,8 +6442,7 @@ tun_try_open_device(struct tuntap *tt, const char *device_guid, const struct dev |
| 6574 | 6574 |
const char *path = NULL; |
| 6575 | 6575 |
char tuntap_device_path[256]; |
| 6576 | 6576 |
|
| 6577 |
- if (tt->backend_driver == WINDOWS_DRIVER_WINTUN |
|
| 6578 |
- || tt->backend_driver == DRIVER_DCO) |
|
| 6577 |
+ if (tt->backend_driver == DRIVER_DCO) |
|
| 6579 | 6578 |
{
|
| 6580 | 6579 |
const struct device_instance_id_interface *dev_if; |
| 6581 | 6580 |
|
| ... | ... |
@@ -6629,18 +6496,6 @@ tun_try_open_device(struct tuntap *tt, const char *device_guid, const struct dev |
| 6629 | 6629 |
return false; |
| 6630 | 6630 |
} |
| 6631 | 6631 |
|
| 6632 |
- if (tt->backend_driver == WINDOWS_DRIVER_WINTUN) |
|
| 6633 |
- {
|
|
| 6634 |
- /* Wintun adapter may be considered "open" after ring buffers are successfuly registered. */ |
|
| 6635 |
- if (!wintun_register_ring_buffer(tt, device_guid)) |
|
| 6636 |
- {
|
|
| 6637 |
- msg(D_TUNTAP_INFO, "Failed to register %s adapter ring buffers", device_guid); |
|
| 6638 |
- CloseHandle(tt->hand); |
|
| 6639 |
- tt->hand = NULL; |
|
| 6640 |
- return false; |
|
| 6641 |
- } |
|
| 6642 |
- } |
|
| 6643 |
- |
|
| 6644 | 6632 |
return true; |
| 6645 | 6633 |
} |
| 6646 | 6634 |
|
| ... | ... |
@@ -6988,16 +6843,6 @@ close_tun_handle(struct tuntap *tt) |
| 6988 | 6988 |
} |
| 6989 | 6989 |
tt->hand = NULL; |
| 6990 | 6990 |
} |
| 6991 |
- |
|
| 6992 |
- if (tt->backend_driver == WINDOWS_DRIVER_WINTUN) |
|
| 6993 |
- {
|
|
| 6994 |
- CloseHandle(tt->rw_handle.read); |
|
| 6995 |
- CloseHandle(tt->rw_handle.write); |
|
| 6996 |
- UnmapViewOfFile(tt->wintun_send_ring); |
|
| 6997 |
- UnmapViewOfFile(tt->wintun_receive_ring); |
|
| 6998 |
- CloseHandle(tt->wintun_send_ring_handle); |
|
| 6999 |
- CloseHandle(tt->wintun_receive_ring_handle); |
|
| 7000 |
- } |
|
| 7001 | 6991 |
} |
| 7002 | 6992 |
|
| 7003 | 6993 |
void |
| ... | ... |
@@ -39,13 +39,11 @@ |
| 39 | 39 |
#include "proto.h" |
| 40 | 40 |
#include "misc.h" |
| 41 | 41 |
#include "networking.h" |
| 42 |
-#include "ring_buffer.h" |
|
| 43 | 42 |
#include "dco.h" |
| 44 | 43 |
|
| 45 | 44 |
enum tun_driver_type {
|
| 46 | 45 |
WINDOWS_DRIVER_UNSPECIFIED, |
| 47 | 46 |
WINDOWS_DRIVER_TAP_WINDOWS6, |
| 48 |
- WINDOWS_DRIVER_WINTUN, |
|
| 49 | 47 |
DRIVER_GENERIC_TUNTAP, |
| 50 | 48 |
/** using an AF_UNIX socket to pass packets from/to an external program. |
| 51 | 49 |
* This is always defined. We error out if a user tries to open this type |
| ... | ... |
@@ -58,7 +56,6 @@ enum tun_driver_type {
|
| 58 | 58 |
}; |
| 59 | 59 |
|
| 60 | 60 |
#ifdef _WIN32 |
| 61 |
-#define WINTUN_COMPONENT_ID "wintun" |
|
| 62 | 61 |
#define DCO_WIN_REFERENCE_STRING "ovpn-dco" |
| 63 | 62 |
#endif |
| 64 | 63 |
|
| ... | ... |
@@ -233,11 +230,7 @@ struct tuntap |
| 233 | 233 |
|
| 234 | 234 |
int standby_iter; |
| 235 | 235 |
|
| 236 |
- HANDLE wintun_send_ring_handle; |
|
| 237 |
- HANDLE wintun_receive_ring_handle; |
|
| 238 |
- struct tun_ring *wintun_send_ring; |
|
| 239 |
- struct tun_ring *wintun_receive_ring; |
|
| 240 |
-#else /* ifdef _WIN32 */ |
|
| 236 |
+ #else /* ifdef _WIN32 */ |
|
| 241 | 237 |
int fd; /* file descriptor for TUN/TAP dev */ |
| 242 | 238 |
#endif /* ifdef _WIN32 */ |
| 243 | 239 |
|
| ... | ... |
@@ -262,20 +255,6 @@ tuntap_defined(const struct tuntap *tt) |
| 262 | 262 |
#endif |
| 263 | 263 |
} |
| 264 | 264 |
|
| 265 |
-#ifdef _WIN32 |
|
| 266 |
-static inline bool |
|
| 267 |
-tuntap_is_wintun(struct tuntap *tt) |
|
| 268 |
-{
|
|
| 269 |
- return tt && tt->backend_driver == WINDOWS_DRIVER_WINTUN; |
|
| 270 |
-} |
|
| 271 |
- |
|
| 272 |
-static inline bool |
|
| 273 |
-tuntap_ring_empty(struct tuntap *tt) |
|
| 274 |
-{
|
|
| 275 |
- return tuntap_is_wintun(tt) && (tt->wintun_send_ring->head == tt->wintun_send_ring->tail); |
|
| 276 |
-} |
|
| 277 |
-#endif |
|
| 278 |
- |
|
| 279 | 265 |
/* |
| 280 | 266 |
* Function prototypes |
| 281 | 267 |
*/ |
| ... | ... |
@@ -526,74 +505,6 @@ tuntap_abort(int status) |
| 526 | 526 |
|
| 527 | 527 |
int tun_write_win32(struct tuntap *tt, struct buffer *buf); |
| 528 | 528 |
|
| 529 |
-static inline ULONG |
|
| 530 |
-wintun_ring_packet_align(ULONG size) |
|
| 531 |
-{
|
|
| 532 |
- return (size + (WINTUN_PACKET_ALIGN - 1)) & ~(WINTUN_PACKET_ALIGN - 1); |
|
| 533 |
-} |
|
| 534 |
- |
|
| 535 |
-static inline ULONG |
|
| 536 |
-wintun_ring_wrap(ULONG value) |
|
| 537 |
-{
|
|
| 538 |
- return value & (WINTUN_RING_CAPACITY - 1); |
|
| 539 |
-} |
|
| 540 |
- |
|
| 541 |
-static inline void |
|
| 542 |
-read_wintun(struct tuntap *tt, struct buffer *buf) |
|
| 543 |
-{
|
|
| 544 |
- struct tun_ring *ring = tt->wintun_send_ring; |
|
| 545 |
- ULONG head = ring->head; |
|
| 546 |
- ULONG tail = ring->tail; |
|
| 547 |
- ULONG content_len; |
|
| 548 |
- struct TUN_PACKET *packet; |
|
| 549 |
- ULONG aligned_packet_size; |
|
| 550 |
- |
|
| 551 |
- *buf = tt->reads.buf_init; |
|
| 552 |
- buf->len = 0; |
|
| 553 |
- |
|
| 554 |
- if ((head >= WINTUN_RING_CAPACITY) || (tail >= WINTUN_RING_CAPACITY)) |
|
| 555 |
- {
|
|
| 556 |
- msg(M_INFO, "Wintun: ring capacity exceeded"); |
|
| 557 |
- buf->len = -1; |
|
| 558 |
- return; |
|
| 559 |
- } |
|
| 560 |
- |
|
| 561 |
- if (head == tail) |
|
| 562 |
- {
|
|
| 563 |
- /* nothing to read */ |
|
| 564 |
- return; |
|
| 565 |
- } |
|
| 566 |
- |
|
| 567 |
- content_len = wintun_ring_wrap(tail - head); |
|
| 568 |
- if (content_len < sizeof(struct TUN_PACKET_HEADER)) |
|
| 569 |
- {
|
|
| 570 |
- msg(M_INFO, "Wintun: incomplete packet header in send ring"); |
|
| 571 |
- buf->len = -1; |
|
| 572 |
- return; |
|
| 573 |
- } |
|
| 574 |
- |
|
| 575 |
- packet = (struct TUN_PACKET *) &ring->data[head]; |
|
| 576 |
- if (packet->size > WINTUN_MAX_PACKET_SIZE) |
|
| 577 |
- {
|
|
| 578 |
- msg(M_INFO, "Wintun: packet too big in send ring"); |
|
| 579 |
- buf->len = -1; |
|
| 580 |
- return; |
|
| 581 |
- } |
|
| 582 |
- |
|
| 583 |
- aligned_packet_size = wintun_ring_packet_align(sizeof(struct TUN_PACKET_HEADER) + packet->size); |
|
| 584 |
- if (aligned_packet_size > content_len) |
|
| 585 |
- {
|
|
| 586 |
- msg(M_INFO, "Wintun: incomplete packet in send ring"); |
|
| 587 |
- buf->len = -1; |
|
| 588 |
- return; |
|
| 589 |
- } |
|
| 590 |
- |
|
| 591 |
- buf_write(buf, packet->data, packet->size); |
|
| 592 |
- |
|
| 593 |
- head = wintun_ring_wrap(head + aligned_packet_size); |
|
| 594 |
- ring->head = head; |
|
| 595 |
-} |
|
| 596 |
- |
|
| 597 | 529 |
static inline bool |
| 598 | 530 |
is_ip_packet_valid(const struct buffer *buf) |
| 599 | 531 |
{
|
| ... | ... |
@@ -621,65 +532,6 @@ is_ip_packet_valid(const struct buffer *buf) |
| 621 | 621 |
return true; |
| 622 | 622 |
} |
| 623 | 623 |
|
| 624 |
-static inline int |
|
| 625 |
-write_wintun(struct tuntap *tt, struct buffer *buf) |
|
| 626 |
-{
|
|
| 627 |
- struct tun_ring *ring = tt->wintun_receive_ring; |
|
| 628 |
- ULONG head = ring->head; |
|
| 629 |
- ULONG tail = ring->tail; |
|
| 630 |
- ULONG aligned_packet_size; |
|
| 631 |
- ULONG buf_space; |
|
| 632 |
- struct TUN_PACKET *packet; |
|
| 633 |
- |
|
| 634 |
- /* wintun marks ring as corrupted (overcapacity) if it receives invalid IP packet */ |
|
| 635 |
- if (!is_ip_packet_valid(buf)) |
|
| 636 |
- {
|
|
| 637 |
- msg(D_LOW, "write_wintun(): drop invalid IP packet"); |
|
| 638 |
- return 0; |
|
| 639 |
- } |
|
| 640 |
- |
|
| 641 |
- if ((head >= WINTUN_RING_CAPACITY) || (tail >= WINTUN_RING_CAPACITY)) |
|
| 642 |
- {
|
|
| 643 |
- msg(M_INFO, "write_wintun(): head/tail value is over capacity"); |
|
| 644 |
- return -1; |
|
| 645 |
- } |
|
| 646 |
- |
|
| 647 |
- aligned_packet_size = wintun_ring_packet_align(sizeof(struct TUN_PACKET_HEADER) + BLEN(buf)); |
|
| 648 |
- buf_space = wintun_ring_wrap(head - tail - WINTUN_PACKET_ALIGN); |
|
| 649 |
- if (aligned_packet_size > buf_space) |
|
| 650 |
- {
|
|
| 651 |
- msg(M_INFO, "write_wintun(): ring is full"); |
|
| 652 |
- return 0; |
|
| 653 |
- } |
|
| 654 |
- |
|
| 655 |
- /* copy packet size and data into ring */ |
|
| 656 |
- packet = (struct TUN_PACKET * )&ring->data[tail]; |
|
| 657 |
- packet->size = BLEN(buf); |
|
| 658 |
- memcpy(packet->data, BPTR(buf), BLEN(buf)); |
|
| 659 |
- |
|
| 660 |
- /* move ring tail */ |
|
| 661 |
- ring->tail = wintun_ring_wrap(tail + aligned_packet_size); |
|
| 662 |
- if (ring->alertable != 0) |
|
| 663 |
- {
|
|
| 664 |
- SetEvent(tt->rw_handle.write); |
|
| 665 |
- } |
|
| 666 |
- |
|
| 667 |
- return BLEN(buf); |
|
| 668 |
-} |
|
| 669 |
- |
|
| 670 |
-static inline int |
|
| 671 |
-write_tun_buffered(struct tuntap *tt, struct buffer *buf) |
|
| 672 |
-{
|
|
| 673 |
- if (tt->backend_driver == WINDOWS_DRIVER_WINTUN) |
|
| 674 |
- {
|
|
| 675 |
- return write_wintun(tt, buf); |
|
| 676 |
- } |
|
| 677 |
- else |
|
| 678 |
- {
|
|
| 679 |
- return tun_write_win32(tt, buf); |
|
| 680 |
- } |
|
| 681 |
-} |
|
| 682 |
- |
|
| 683 | 624 |
static inline bool |
| 684 | 625 |
tuntap_is_dco_win(struct tuntap *tt) |
| 685 | 626 |
{
|
| ... | ... |
@@ -320,11 +320,6 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) |
| 320 | 320 |
L"ACTIVETAPWINDOWS6ADAPTERS"); |
| 321 | 321 |
find_adapters( |
| 322 | 322 |
hInstall, |
| 323 |
- L"Wintun" L"\0", |
|
| 324 |
- L"WINTUNADAPTERS", |
|
| 325 |
- L"ACTIVEWINTUNADAPTERS"); |
|
| 326 |
- find_adapters( |
|
| 327 |
- hInstall, |
|
| 328 | 323 |
L"ovpn-dco" L"\0", |
| 329 | 324 |
L"OVPNDCOADAPTERS", |
| 330 | 325 |
L"ACTIVEOVPNDCOADAPTERS"); |
| ... | ... |
@@ -88,10 +88,6 @@ extern "C" {
|
| 88 | 88 |
* ACTIVETAPWINDOWS6ADAPTERS properties with semicolon delimited list of all installed adapter |
| 89 | 89 |
* GUIDs and active adapter GUIDs respectively. |
| 90 | 90 |
* |
| 91 |
- * - Finds existing Wintun adapters and set WINTUNADAPTERS and ACTIVEWINTUNADAPTERS properties |
|
| 92 |
- * with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs |
|
| 93 |
- * respectively. |
|
| 94 |
- * |
|
| 95 | 91 |
* - Finds existing ovpn-dco adapters and set OVPNDCOADAPTERS and ACTIVEOVPNDCOADAPTERS properties |
| 96 | 92 |
* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs |
| 97 | 93 |
* respectively. |
| ... | ... |
@@ -40,7 +40,6 @@ |
| 40 | 40 |
#include "openvpn-msg.h" |
| 41 | 41 |
#include "validate.h" |
| 42 | 42 |
#include "wfp_block.h" |
| 43 |
-#include "ring_buffer.h" |
|
| 44 | 43 |
|
| 45 | 44 |
#define IO_TIMEOUT 2000 /*ms*/ |
| 46 | 45 |
|
| ... | ... |
@@ -90,7 +89,6 @@ typedef enum {
|
| 90 | 90 |
undo_dns6, |
| 91 | 91 |
undo_nrpt, |
| 92 | 92 |
undo_domains, |
| 93 |
- undo_ring_buffer, |
|
| 94 | 93 |
undo_wins, |
| 95 | 94 |
_undo_type_max |
| 96 | 95 |
} undo_type_t; |
| ... | ... |
@@ -108,11 +106,6 @@ typedef struct {
|
| 108 | 108 |
PWSTR domains; |
| 109 | 109 |
} dns_domains_undo_data_t; |
| 110 | 110 |
|
| 111 |
-typedef struct {
|
|
| 112 |
- struct tun_ring *send_ring; |
|
| 113 |
- struct tun_ring *receive_ring; |
|
| 114 |
-} ring_buffer_maps_t; |
|
| 115 |
- |
|
| 116 | 111 |
typedef union {
|
| 117 | 112 |
message_header_t header; |
| 118 | 113 |
address_message_t address; |
| ... | ... |
@@ -122,7 +115,6 @@ typedef union {
|
| 122 | 122 |
dns_cfg_message_t dns; |
| 123 | 123 |
nrpt_dns_cfg_message_t nrpt_dns; |
| 124 | 124 |
enable_dhcp_message_t dhcp; |
| 125 |
- register_ring_buffers_message_t rrb; |
|
| 126 | 125 |
set_mtu_message_t mtu; |
| 127 | 126 |
wins_cfg_message_t wins; |
| 128 | 127 |
create_adapter_message_t create_adapter; |
| ... | ... |
@@ -188,23 +180,6 @@ CloseHandleEx(LPHANDLE handle) |
| 188 | 188 |
return INVALID_HANDLE_VALUE; |
| 189 | 189 |
} |
| 190 | 190 |
|
| 191 |
-static void |
|
| 192 |
-OvpnUnmapViewOfFile(struct tun_ring **ring) |
|
| 193 |
-{
|
|
| 194 |
- if (ring && *ring) |
|
| 195 |
- {
|
|
| 196 |
- UnmapViewOfFile(*ring); |
|
| 197 |
- *ring = NULL; |
|
| 198 |
- } |
|
| 199 |
-} |
|
| 200 |
- |
|
| 201 |
-static void |
|
| 202 |
-UnmapRingBuffer(ring_buffer_maps_t *ring_buffer_maps) |
|
| 203 |
-{
|
|
| 204 |
- OvpnUnmapViewOfFile(&ring_buffer_maps->send_ring); |
|
| 205 |
- OvpnUnmapViewOfFile(&ring_buffer_maps->receive_ring); |
|
| 206 |
-} |
|
| 207 |
- |
|
| 208 | 191 |
static HANDLE |
| 209 | 192 |
InitOverlapped(LPOVERLAPPED overlapped) |
| 210 | 193 |
{
|
| ... | ... |
@@ -213,7 +188,6 @@ InitOverlapped(LPOVERLAPPED overlapped) |
| 213 | 213 |
return overlapped->hEvent; |
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 |
- |
|
| 217 | 216 |
static BOOL |
| 218 | 217 |
ResetOverlapped(LPOVERLAPPED overlapped) |
| 219 | 218 |
{
|
| ... | ... |
@@ -2973,119 +2947,6 @@ HandleEnableDHCPMessage(const enable_dhcp_message_t *dhcp) |
| 2973 | 2973 |
} |
| 2974 | 2974 |
|
| 2975 | 2975 |
static DWORD |
| 2976 |
-OvpnDuplicateHandle(HANDLE ovpn_proc, HANDLE orig_handle, HANDLE *new_handle) |
|
| 2977 |
-{
|
|
| 2978 |
- DWORD err = ERROR_SUCCESS; |
|
| 2979 |
- |
|
| 2980 |
- if (!DuplicateHandle(ovpn_proc, orig_handle, GetCurrentProcess(), new_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) |
|
| 2981 |
- {
|
|
| 2982 |
- err = GetLastError(); |
|
| 2983 |
- MsgToEventLog(M_SYSERR, L"Could not duplicate handle"); |
|
| 2984 |
- return err; |
|
| 2985 |
- } |
|
| 2986 |
- |
|
| 2987 |
- return err; |
|
| 2988 |
-} |
|
| 2989 |
- |
|
| 2990 |
-static DWORD |
|
| 2991 |
-DuplicateAndMapRing(HANDLE ovpn_proc, HANDLE orig_handle, struct tun_ring **ring) |
|
| 2992 |
-{
|
|
| 2993 |
- DWORD err = ERROR_SUCCESS; |
|
| 2994 |
- |
|
| 2995 |
- HANDLE dup_handle = NULL; |
|
| 2996 |
- |
|
| 2997 |
- err = OvpnDuplicateHandle(ovpn_proc, orig_handle, &dup_handle); |
|
| 2998 |
- if (err != ERROR_SUCCESS) |
|
| 2999 |
- {
|
|
| 3000 |
- return err; |
|
| 3001 |
- } |
|
| 3002 |
- *ring = (struct tun_ring *)MapViewOfFile(dup_handle, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(struct tun_ring)); |
|
| 3003 |
- CloseHandleEx(&dup_handle); |
|
| 3004 |
- if (*ring == NULL) |
|
| 3005 |
- {
|
|
| 3006 |
- err = GetLastError(); |
|
| 3007 |
- MsgToEventLog(M_SYSERR, L"Could not map shared memory"); |
|
| 3008 |
- return err; |
|
| 3009 |
- } |
|
| 3010 |
- |
|
| 3011 |
- return err; |
|
| 3012 |
-} |
|
| 3013 |
- |
|
| 3014 |
-static DWORD |
|
| 3015 |
-HandleRegisterRingBuffers(const register_ring_buffers_message_t *rrb, HANDLE ovpn_proc, |
|
| 3016 |
- undo_lists_t *lists) |
|
| 3017 |
-{
|
|
| 3018 |
- DWORD err = 0; |
|
| 3019 |
- |
|
| 3020 |
- ring_buffer_maps_t *ring_buffer_maps = RemoveListItem(&(*lists)[undo_ring_buffer], CmpAny, NULL); |
|
| 3021 |
- |
|
| 3022 |
- if (ring_buffer_maps) |
|
| 3023 |
- {
|
|
| 3024 |
- UnmapRingBuffer(ring_buffer_maps); |
|
| 3025 |
- } |
|
| 3026 |
- else if ((ring_buffer_maps = calloc(1, sizeof(*ring_buffer_maps))) == NULL) |
|
| 3027 |
- {
|
|
| 3028 |
- return ERROR_OUTOFMEMORY; |
|
| 3029 |
- } |
|
| 3030 |
- |
|
| 3031 |
- HANDLE device = NULL; |
|
| 3032 |
- HANDLE send_tail_moved = NULL; |
|
| 3033 |
- HANDLE receive_tail_moved = NULL; |
|
| 3034 |
- |
|
| 3035 |
- err = OvpnDuplicateHandle(ovpn_proc, rrb->device, &device); |
|
| 3036 |
- if (err != ERROR_SUCCESS) |
|
| 3037 |
- {
|
|
| 3038 |
- goto out; |
|
| 3039 |
- } |
|
| 3040 |
- |
|
| 3041 |
- err = DuplicateAndMapRing(ovpn_proc, rrb->send_ring_handle, &ring_buffer_maps->send_ring); |
|
| 3042 |
- if (err != ERROR_SUCCESS) |
|
| 3043 |
- {
|
|
| 3044 |
- goto out; |
|
| 3045 |
- } |
|
| 3046 |
- |
|
| 3047 |
- err = DuplicateAndMapRing(ovpn_proc, rrb->receive_ring_handle, &ring_buffer_maps->receive_ring); |
|
| 3048 |
- if (err != ERROR_SUCCESS) |
|
| 3049 |
- {
|
|
| 3050 |
- goto out; |
|
| 3051 |
- } |
|
| 3052 |
- |
|
| 3053 |
- err = OvpnDuplicateHandle(ovpn_proc, rrb->send_tail_moved, &send_tail_moved); |
|
| 3054 |
- if (err != ERROR_SUCCESS) |
|
| 3055 |
- {
|
|
| 3056 |
- goto out; |
|
| 3057 |
- } |
|
| 3058 |
- |
|
| 3059 |
- err = OvpnDuplicateHandle(ovpn_proc, rrb->receive_tail_moved, &receive_tail_moved); |
|
| 3060 |
- if (err != ERROR_SUCCESS) |
|
| 3061 |
- {
|
|
| 3062 |
- goto out; |
|
| 3063 |
- } |
|
| 3064 |
- |
|
| 3065 |
- if (!register_ring_buffers(device, ring_buffer_maps->send_ring, |
|
| 3066 |
- ring_buffer_maps->receive_ring, |
|
| 3067 |
- send_tail_moved, receive_tail_moved)) |
|
| 3068 |
- {
|
|
| 3069 |
- err = GetLastError(); |
|
| 3070 |
- MsgToEventLog(M_SYSERR, L"Could not register ring buffers"); |
|
| 3071 |
- goto out; |
|
| 3072 |
- } |
|
| 3073 |
- |
|
| 3074 |
- err = AddListItem(&(*lists)[undo_ring_buffer], ring_buffer_maps); |
|
| 3075 |
- |
|
| 3076 |
-out: |
|
| 3077 |
- if (err != ERROR_SUCCESS && ring_buffer_maps) |
|
| 3078 |
- {
|
|
| 3079 |
- UnmapRingBuffer(ring_buffer_maps); |
|
| 3080 |
- free(ring_buffer_maps); |
|
| 3081 |
- } |
|
| 3082 |
- CloseHandleEx(&device); |
|
| 3083 |
- CloseHandleEx(&send_tail_moved); |
|
| 3084 |
- CloseHandleEx(&receive_tail_moved); |
|
| 3085 |
- return err; |
|
| 3086 |
-} |
|
| 3087 |
- |
|
| 3088 |
-static DWORD |
|
| 3089 | 2976 |
HandleMTUMessage(const set_mtu_message_t *mtu) |
| 3090 | 2977 |
{
|
| 3091 | 2978 |
DWORD err = 0; |
| ... | ... |
@@ -3130,10 +2991,6 @@ HandleCreateAdapterMessage(const create_adapter_message_t *msg) |
| 3130 | 3130 |
hwid = L"root\\tap0901"; |
| 3131 | 3131 |
break; |
| 3132 | 3132 |
|
| 3133 |
- case ADAPTER_TYPE_WINTUN: |
|
| 3134 |
- hwid = L"wintun"; |
|
| 3135 |
- break; |
|
| 3136 |
- |
|
| 3137 | 3133 |
default: |
| 3138 | 3134 |
return ERROR_INVALID_PARAMETER; |
| 3139 | 3135 |
} |
| ... | ... |
@@ -3238,14 +3095,6 @@ HandleMessage(HANDLE pipe, PPROCESS_INFORMATION proc_info, |
| 3238 | 3238 |
} |
| 3239 | 3239 |
break; |
| 3240 | 3240 |
|
| 3241 |
- case msg_register_ring_buffers: |
|
| 3242 |
- if (msg.header.size == sizeof(msg.rrb)) |
|
| 3243 |
- {
|
|
| 3244 |
- HANDLE ovpn_hnd = proc_info->hProcess; |
|
| 3245 |
- ack.error_number = HandleRegisterRingBuffers(&msg.rrb, ovpn_hnd, lists); |
|
| 3246 |
- } |
|
| 3247 |
- break; |
|
| 3248 |
- |
|
| 3249 | 3241 |
case msg_set_mtu: |
| 3250 | 3242 |
if (msg.header.size == sizeof(msg.mtu)) |
| 3251 | 3243 |
{
|
| ... | ... |
@@ -3327,10 +3176,6 @@ Undo(undo_lists_t *lists) |
| 3327 | 3327 |
} |
| 3328 | 3328 |
break; |
| 3329 | 3329 |
|
| 3330 |
- case undo_ring_buffer: |
|
| 3331 |
- UnmapRingBuffer(item->data); |
|
| 3332 |
- break; |
|
| 3333 |
- |
|
| 3334 | 3330 |
case _undo_type_max: |
| 3335 | 3331 |
/* unreachable */ |
| 3336 | 3332 |
break; |
| ... | ... |
@@ -75,8 +75,8 @@ static const WCHAR usage_message_create[] = |
| 75 | 75 |
L" Note: This name can also be specified as OpenVPN's --dev-node \n" |
| 76 | 76 |
L" option. \n" |
| 77 | 77 |
L"--hwid <hwid> Adapter hardware ID. Default value is root\\tap0901, which \n" |
| 78 |
- L" describes tap-windows6 driver. To work with wintun or ovpn-dco \n" |
|
| 79 |
- L" driver, specify 'wintun' or 'ovpn-dco'. \n" |
|
| 78 |
+ L" describes tap-windows6 driver. To work with ovpn-dco driver, \n" |
|
| 79 |
+ L" driver, specify 'ovpn-dco'. \n" |
|
| 80 | 80 |
L"\n" |
| 81 | 81 |
L"Output:\n" |
| 82 | 82 |
L"\n" |
| ... | ... |
@@ -94,7 +94,7 @@ static const WCHAR usage_message_list[] = |
| 94 | 94 |
L"\n" |
| 95 | 95 |
L"Options:\n" |
| 96 | 96 |
L"\n" |
| 97 |
- L"--hwid <hwid> Adapter hardware ID. By default, root\\tap0901, tap0901, wintun and \n" |
|
| 97 |
+ L"--hwid <hwid> Adapter hardware ID. By default, root\\tap0901, tap0901 and \n" |
|
| 98 | 98 |
L" ovpn-dco adapters are listed. Use this switch to limit the list.\n" |
| 99 | 99 |
L"\n" |
| 100 | 100 |
L"Output:\n" |
| ... | ... |
@@ -167,10 +167,6 @@ get_unique_adapter_name(LPCWSTR hwid, struct tap_adapter_node *adapter_list) |
| 167 | 167 |
{
|
| 168 | 168 |
base_name = L"OpenVPN Data Channel Offload"; |
| 169 | 169 |
} |
| 170 |
- else if (wcsicmp(hwid, L"wintun") == 0) |
|
| 171 |
- {
|
|
| 172 |
- base_name = L"OpenVPN Wintun"; |
|
| 173 |
- } |
|
| 174 | 170 |
else if (wcsicmp(hwid, L"root\\" _L(TAP_WIN_COMPONENT_ID)) == 0) |
| 175 | 171 |
{
|
| 176 | 172 |
base_name = L"OpenVPN TAP-Windows6"; |
| ... | ... |
@@ -351,7 +347,6 @@ create_delete_adapter: |
| 351 | 351 |
WCHAR szzHwId[0x100] = |
| 352 | 352 |
L"root\\" _L(TAP_WIN_COMPONENT_ID) L"\0" |
| 353 | 353 |
_L(TAP_WIN_COMPONENT_ID) L"\0" |
| 354 |
- L"Wintun\0" |
|
| 355 | 354 |
L"ovpn-dco\0"; |
| 356 | 355 |
|
| 357 | 356 |
/* Parse options. */ |
| ... | ... |
@@ -38,7 +38,7 @@ |
| 38 | 38 |
* description of the device. This pointer is optional and can be NULL. |
| 39 | 39 |
* |
| 40 | 40 |
* @param szHwId A pointer to a NULL-terminated string that supplies the hardware id |
| 41 |
- * of the device (e.g. "root\\tap0901", "Wintun"). |
|
| 41 |
+ * of the device (e.g. "root\\tap0901"). |
|
| 42 | 42 |
* |
| 43 | 43 |
* @param pbRebootRequired A pointer to a BOOL flag. If the device requires a system restart, |
| 44 | 44 |
* this flag is set to TRUE. Otherwise, the flag is left unmodified. This |