From: "cron2 (Code Review)" Date: Tue, 31 Dec 2024 15:31:15 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="9+U94woarUQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco-win: simplify do_close_link_socket() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stipa Cc: flichtenheld , plaisthos , openvpn-devel --9+U94woarUQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/81= 3?usp=3Demail ) Change subject: dco-win: simplify do_close_link_socket() ...................................................................... dco-win: simplify do_close_link_socket() c->c2.link_socket_owned is true in client mode and for the global context in the server mode - those are exactly the cases when we want to set sd to undefined when using dco-win. Change-Id: I3232dd8d855ca3f198b4ca3b2ef4f67cec49f3d4 Signed-off-by: Lev Stipakov Acked-by: Gert Doering Message-Id: <20241231145417.12128-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30= 328.html Signed-off-by: Gert Doering --- M src/openvpn/init.c 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 850cd12..2bd5518 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -4018,21 +4018,18 @@ static void do_close_link_socket(struct context *c) { - /* in dco-win case, link socket is a tun handle which is - * closed in do_close_tun(). Set it to UNDEFINED so - * we won't use WinSock API to close it. */ - if (tuntap_is_dco_win(c->c1.tuntap) && c->c2.link_sockets) - { - for (int i =3D 0; i < c->c1.link_sockets_num; i++) - { - c->c2.link_sockets[i]->sd =3D SOCKET_UNDEFINED; - } - } - if (c->c2.link_sockets && c->c2.link_socket_owned) { for (int i =3D 0; i < c->c1.link_sockets_num; i++) { + /* in dco-win case, link socket is a tun handle which is + * closed in do_close_tun(). Set it to UNDEFINED so + * we won't use WinSock API to close it. */ + if (tuntap_is_dco_win(c->c1.tuntap)) + { + c->c2.link_sockets[i]->sd =3D SOCKET_UNDEFINED; + } + link_socket_close(c->c2.link_sockets[i]); } c->c2.link_sockets =3D NULL; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/813?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: I3232dd8d855ca3f198b4ca3b2ef4f67cec49f3d4 Gerrit-Change-Number: 813 Gerrit-PatchSet: 8 Gerrit-Owner: stipa Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --9+U94woarUQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

dco-win: simplify do_close_link_socket()
c->c2.link_socket_owned is true in client mode
and for the global c= ontext in the server mode -
those are exactly the cases when we want to<= br>set sd to undefined when using dco-win.

Change-Id: I3232dd8d855ca= 3f198b4ca3b2ef4f67cec49f3d4
Signed-off-by: Lev Stipakov <lev@...1699...= .>
Acked-by: Gert Doering <gert@...1296...>
Message-Id: <= 20241231145417.12128-1-gert@...1296...>
URL: https://www.mail-archive= .com/openvpn-devel@lists.sourceforge.net/msg30328.html
Signed-off-by: Ge= rt Doering <gert@...1296...>
---
M src/openvpn/init.c
1 file= changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
ind= ex 850cd12..2bd5518 100644
--- a/src/openvpn/init.c<= br>+++ b/src/openvpn/init.c
@@ -4018,21 +4018,18 @@
static void
do_close_link_socket(struct co= ntext *c)
{
- /* in dco-win case, link socket is a tun handle which is<= br>- * closed in do_close_tun= (). Set it to UNDEFINED so
- * we won't use WinSock API to close it. */
- if (tuntap_is_dco_win(c->c1.tunta= p) && c->c2.link_sockets)
- {
- = for (int i =3D 0; i < c->c1.link_sockets_num; i++)
<= span style=3D"color: hsl(0, 100%, 40%);">- {

- c->c2.link_sockets[i]->sd= =3D SOCKET_UNDEFINED;
= - }
- }
-
if (c= ->c2.link_sockets && c->c2.link_socket_owned)
{

for (int i =3D 0; i < c->c1.link_soc= kets_num; i++)
{
+ /* in dco-win case, link socket is a tun = handle which is
+ = * closed in do_close_tun(). Set it to UNDEFINED so
+ * we won't use Win= Sock API to close it. */
+ if (tuntap_is_dco_win(c->c1.tuntap))
+ {
+ c->c2.link_sockets[i]->= ;sd =3D SOCKET_UNDEFINED;
+ }
+=
link_socket_close(c->c2.link_sockets[i]);<= /span>
}
c->c2.link_sockets = =3D NULL;

To view, visit change 813. To unsu= bscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3232dd8d855ca3f198b4ca3b2ef= 4f67cec49f3d4
Gerrit-Change-Number: 813
Gerrit-PatchSet: 8
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--9+U94woarUQ=--