From: Gianmarco De Gregori Date: Thu, 10 Apr 2025 21:50:29 +0000 (+0200) Subject: Fix dco_win and multisocket interaction X-Git-Tag: v2.7_alpha1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d551f9e05340ff49d40d27d48012615de567a0c;p=thirdparty%2Fopenvpn.git Fix dco_win and multisocket interaction The recent introduction of the multisocket support did not account for some Windows-specific DCO paths. This patch restores correct behavior on Windows. Key changes: - Add WIN32 guards around DCO-specifc code. - Disable wait_signal() when running in server mode, as it conflicts with the event engine since Windows handles signals as I/Os. - Ensure correct socket handling for TCP vs UDP. Github: closes openvpn/OpenVPN#720 Change-Id: I719b1aa2d2f4d63dc9c18d8e313fba339e3e4b0c Signed-off-by: Gianmarco De Gregori Acked-by: Lev Stipakov Message-Id: <20250410215037.11878-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31419.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index af1d0085..0b8b2629 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2072,7 +2072,7 @@ multi_io_process_flags(struct context *c, struct event_set *es, /* * Calculate the flags based on the provided 'flags' argument. */ - if (flags & IOW_WAIT_SIGNAL) + if ((c->options.mode != MODE_SERVER) && (flags & IOW_WAIT_SIGNAL)) { wait_signal(es, (void *)err_shift); } diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index 1d62ea65..86c5160f 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -181,7 +181,8 @@ multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsig if (mi) { - if (defer || mbuf_defined(mi->tcp_link_out_deferred)) + if ((defer && !proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto)) + || mbuf_defined(mi->tcp_link_out_deferred)) { /* save to queue */ struct buffer *buf = &mi->context.c2.to_link; diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index f1751ff6..f4ca4df5 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -176,10 +176,13 @@ multi_io_wait(struct multi_context *m) int status, i; unsigned int *persistent = &m->multi_io->tun_rwflags; - for (i = 0; i < m->top.c1.link_sockets_num; i++) + if (!tuntap_is_dco_win(m->top.c1.tuntap)) { - socket_set_listen_persistent(m->top.c2.link_sockets[i], m->multi_io->es, - &m->top.c2.link_sockets[i]->ev_arg); + for (i = 0; i < m->top.c1.link_sockets_num; i++) + { + socket_set_listen_persistent(m->top.c2.link_sockets[i], m->multi_io->es, + &m->top.c2.link_sockets[i]->ev_arg); + } } if (has_udp_in_local_list(&m->top.options)) @@ -202,7 +205,8 @@ multi_io_wait(struct multi_context *m) } #endif tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, persistent); -#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) +#if defined(ENABLE_DCO) \ + && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(TARGET_WIN32)) dco_event_set(&m->top.c1.tuntap->dco, m->multi_io->es, MULTI_IO_DCO); #endif @@ -535,7 +539,8 @@ multi_io_process_io(struct multi_context *m) multi_io_action(m, mi, TA_INITIAL, false); } } -#if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD)) +#if defined(ENABLE_DCO) \ + && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(TARGET_WIN32)) /* incoming data on DCO? */ else if (e->arg == MULTI_IO_DCO) {