From: "selvanair (Code Review)" Date: Wed, 23 Apr 2025 22:25:52 +0000 In-Reply-To: References: Reply-To: selva.nair@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277... Message-ID: <904dff3f91b309d62be0770ee72f15a9126c40f4-EmailReviewComments-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/UAlukQ8PbU="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: win: create adapter on demand List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stipa Cc: plaisthos , flichtenheld , openvpn-devel --/UAlukQ8PbU= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos, stipa. selvanair has posted comments on this change. ( http://gerrit.openvpn.net/c= /openvpn/+/943?usp=3Demail ) Change subject: win: create adapter on demand ...................................................................... Patch Set 2: Code-Review+2 (4 comments) File src/openvpn/tun.c: http://gerrit.openvpn.net/c/openvpn/+/943/comment/cb1bafd2_52f5f731 : PS2, Line 3781: static struct device_instance_id_interface * This change is not required nor advisable. Same with panel_reg and tap_reg = below. Instead define them as const where used -- see below. http://gerrit.openvpn.net/c/openvpn/+/943/comment/d1ebab33_cae54f35 : PS2, Line 6656: struct device_instance_id_interface *device_instance_id= _interface =3D get_device_instance_id_interface(gc); Define these three as "const struct ...". One can still re-assign them as r= equired below. http://gerrit.openvpn.net/c/openvpn/+/943/comment/ebac2853_5ed7005b : PS2, Line 6707: if (adapter_created || (h && !do_create_ada= pter_service(h, tt->backend_driver))) I think we need not limit this using the adapter_created flag. There is a k= ind of "race condition" where the created adapter may get opened by another= openvpn.exe process before this one gets a chance to open it. Especially s= o with service created instances which all startup together. In such cases it should be okay to create a new one again in the next round= of this while loop. That will work transparently if adapter_created is not= set and checked. If some protection against a run-away loop is needed, we = could keep it as a number instead of as a bool -- like, do not create > 10 = adapters in a run! http://gerrit.openvpn.net/c/openvpn/+/943/comment/7ae3b2cb_836cd3b3 : PS2, Line 6731: if (tun_try_open_device(tt, *device_guid, devic= e_instance_id_interface)) I think we should not limit this using the adapter_created flag here. There= is a kind of "race condition" where the created adapter may get opened by = another openvpn.exe process before this one gets a chance to open it. Espec= ially so with service created instances which all startup together. In such cases it should be okay to create again inn the second round which = will work transparently if adapter_created is not set and checked. If some = protectin against a run-away loop is needed, we could keep it as a number i= nstead of as a bool -- like, do not create > 10 adapters! -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?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: I621d44ec6b0facc524875c15ddfd11ec47b06c15 Gerrit-Change-Number: 943 Gerrit-PatchSet: 2 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-Reviewer: selvanair Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: stipa Gerrit-Comment-Date: Wed, 23 Apr 2025 22:25:52 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment --/UAlukQ8PbU= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos, stipa. <= /p>

Patch set 2:Code-Review +2=

Vi= ew Change

4 comments:

  • File src/openvpn/tun.c:

    • Patch Set #2, Line 3781: static struct device_ins= tance_id_interface *

      This change is not required nor advisable. Same with panel_r= eg and tap_reg below.
      Instead define them as const where used -- see bel= ow.

    • Patch Set #2, Line 6656: struct device_instance_id_interface *device_inst= ance_id_interface =3D get_device_instance_id_interface(gc);

      Define these three as= "const struct ...". One can still re-assign them as required bel= ow.

    • Patch Set #2, Line 6707: if (adapter_created || (h &&= !do_create_adapter_service(h, tt->backend_driver)))

      I think we need not limi= t this using the adapter_created flag. There is a kind of "race condit= ion" where the created adapter may get opened by another openvpn.exe p= rocess before this one gets a chance to open it. Especially so with service= created instances which all startup together.

      In such cases it should be okay to create= a new one again in the next round of this while loop. That will work trans= parently if adapter_created is not set and checked. If some protection agai= nst a run-away loop is needed, we could keep it as a number instead of as a= bool -- like, do not create > 10 adapters in a run!

    • = Patch Set #2, Line 6731: if (tun_try_open_device(tt, *device_guid, device_instance_id_= interface))

      I think we should not limit this using the adapter_created flag here.= There is a kind of "race condition" where the created adapter ma= y get opened by another openvpn.exe process before this one gets a chance t= o open it. Especially so with service created instances which all startup t= ogether.

      In s= uch cases it should be okay to create again inn the second round which will= work transparently if adapter_created is not set and checked. If some prot= ectin against a run-away loop is needed, we could keep it as a number inste= ad of as a bool -- like, do not create > 10 adapters!

  • =

To view, visit change 943. To unsubscribe, or for help writing mail filt= ers, visit settings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddf= d11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: selvanair <selva.nair@...1665...= 77...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: stipa <lstipakov@...1663...= .>
Gerrit-Comment-Date: Wed, 23 Apr 2025 22:25:52= +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
--/UAlukQ8PbU=--