[Openvpn-devel,S] Change in openvpn[master]: dco-win: disable DCO for server mode and unsupported driver version

Message ID e5810bf916ef3b1faaac224170e97b409fa2b034-HTML@gerrit.openvpn.net
State New
Headers show
Series [Openvpn-devel,S] Change in openvpn[master]: dco-win: disable DCO for server mode and unsupported driver version | expand

Commit Message

stipa (Code Review) Nov. 21, 2024, 6:07 p.m. UTC
Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/812?usp=email

to review the following change.


Change subject: dco-win: disable DCO for server mode and unsupported driver version
......................................................................

dco-win: disable DCO for server mode and unsupported driver version

Server mode requires multipeer functionality, which is
available starting from dco-win version 2. Disable DCO
for older drivers if mode server is specified.

Change-Id: Iea4538cee075d50de836d1ef7652985186b2527c
Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
M src/openvpn/dco.c
M src/openvpn/dco_win.c
M src/openvpn/dco_win.h
3 files changed, 20 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/12/812/1

Patch

diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
index dcc80d3..4195cf8 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c
@@ -43,6 +43,10 @@ 
 #include "tun.h"
 #include "tun_afunix.h"
 
+#if defined(_WIN32)
+#include "dco_win.h"
+#endif
+
 #ifdef HAVE_LIBCAPNG
 #include <cap-ng.h>
 #endif
@@ -255,18 +259,18 @@ 
         return false;
     }
 
-#if defined(TARGET_FREEBSD)
+#if defined(TARGET_FREEBSD) || defined(TARGET_WIN32)
     if (!proto_is_udp(ce->proto))
     {
-        msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
+        msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD and Windows.");
         return false;
     }
 #endif
 
 #if defined(_WIN32)
-    if (!ce->remote)
+    if (!ce->remote && !dco_win_supports_multipeer())
     {
-        msg(msglevel, "NOTE: --remote is not defined, disabling data channel offload.");
+        msg(msglevel, "NOTE: --remote is not defined. This DCO version doesn't support multipeer. Disabling Data Channel Offload");
         return false;
     }
 #endif
@@ -331,9 +335,9 @@ 
     }
 
 #if defined(_WIN32)
-    if (o->mode == MODE_SERVER)
+    if ((o->mode == MODE_SERVER) && !dco_win_supports_multipeer())
     {
-        msg(msglevel, "--mode server is set. Disabling Data Channel Offload");
+        msg(msglevel, "--mode server is set. This DCO version doesn't support multipeer. Disabling Data Channel Offload");
         return false;
     }
 
diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c
index 27182b5..3bc123b 100644
--- a/src/openvpn/dco_win.c
+++ b/src/openvpn/dco_win.c
@@ -523,4 +523,11 @@ 
     }
 }
 
+bool
+dco_win_supports_multipeer()
+{
+    OVPN_VERSION ver = { 0 };
+    return dco_get_version(&ver) && ver.Major >= 2;
+}
+
 #endif /* defined(_WIN32) */
diff --git a/src/openvpn/dco_win.h b/src/openvpn/dco_win.h
index 4883629..a28436c 100644
--- a/src/openvpn/dco_win.h
+++ b/src/openvpn/dco_win.h
@@ -48,6 +48,9 @@ 
 void
 dco_start_tun(struct tuntap *tt);
 
+bool
+dco_win_supports_multipeer();
+
 #else /* if defined(ENABLE_DCO) && defined(_WIN32) */
 
 static inline void