From: "stipa (Code Review)" Date: Fri, 9 Aug 2024 12:03:28 +0000 References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="XZNHAau4+hg="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Use a more robust way to get dco-win version List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --XZNHAau4+hg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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/+/723?usp=3Demail to review the following change. Change subject: Use a more robust way to get dco-win version ...................................................................... Use a more robust way to get dco-win version The current way doesn't work if the device is already in use. Starting from 1.3.0, dco-win creates a non-exclusive control device \\.\ovpn-dco-ver which can be opened by multiple apps and supports a single IOCTL to get a version number. https://github.com/OpenVPN/ovpn-dco-win/pull/76 This will be expecially handy later when checking which features driver supports. Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf Signed-off-by: Lev Stipakov --- M src/openvpn/dco_win.c 1 file changed, 10 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/723/1 diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index e3ada76..3ec946f 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -389,9 +389,16 @@ OVPN_VERSION version; ZeroMemory(&version, sizeof(OVPN_VERSION)); - /* try to open device by symbolic name */ - HANDLE h =3D CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_WRIT= E, - 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | = FILE_FLAG_OVERLAPPED, NULL); + /* first, try a non-exclusive control device, available from 1.3.0 */ + HANDLE h =3D CreateFile("\\\\.\\ovpn-dco-ver", GENERIC_READ, + 0, NULL, OPEN_EXISTING, 0, NULL); + + if (h =3D=3D INVALID_HANDLE_VALUE) + { + /* fallback to a "normal" device, this will fail if device is alre= ady in use */ + h =3D CreateFile("\\\\.\\ovpn-dco", GENERIC_READ, + 0, NULL, OPEN_EXISTING, 0, NULL); + } if (h =3D=3D INVALID_HANDLE_VALUE) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/723?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: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de832bf Gerrit-Change-Number: 723 Gerrit-PatchSet: 1 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --XZNHAau4+hg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

stipa would like plaisthos and flichtenheld to review t= his change.

Vi= ew Change

Use a more robust way to get dco-win version

The curre= nt way doesn't work if the device is already in use.

Starting fr= om 1.3.0, dco-win creates a non-exclusive
control device \\.\ovpn-dco-ve= r which can be opened by
multiple apps and supports a single IOCTL to ge= t
a version number.

https://github.com/OpenVPN/ovpn-dco-win/pull/= 76

This will be expecially handy later when checking which
featur= es driver supports.

Change-Id: Ieb6f3a9d14d76000c1caf8ee1e959c6d0de8= 32bf
Signed-off-by: Lev Stipakov <lev@...515...>
---
M src/o= penvpn/dco_win.c
1 file changed, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/23/723/1
diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.cindex e3ada76..3ec946f 100644
--- a/src/openvpn/dco_= win.c
+++ b/src/openvpn/dco_win.c
@@ -389,9= +389,16 @@
OVPN_VERSION version;
= ZeroMemory(&version, sizeof(OVPN_VERSION));
- /* try to open device by s= ymbolic name */
- HA= NDLE h =3D CreateFile("\\\\.\\ovpn-dco", GENERIC_READ | GENERIC_W= RITE,
- = 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAP= PED, NULL);
+ /* f= irst, try a non-exclusive control device, available from 1.3.0 */+ HANDLE h =3D CreateFile(&= quot;\\\\.\\ovpn-dco-ver", GENERIC_READ,
+ 0, NULL, OPEN_EXISTING,= 0, NULL);
++ if (h =3D=3D INVALID_HAN= DLE_VALUE)
+ {
+ /* fallback to = a "normal" device, this will fail if device is already in use */<= /span>
+ h =3D Create= File("\\\\.\\ovpn-dco", GENERIC_READ,
+ 0, NULL, OPEN_EXISTING, = 0, NULL);
+ }

if (h =3D=3D INVALID_HANDLE_VALUE)
{

To view, visit change 723.= To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ieb6f3a9d14d76000c1caf8ee1e9= 59c6d0de832bf
Gerrit-Change-Number: 723
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>= ;
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: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--XZNHAau4+hg=--