From: "stipa (Code Review)" Date: Mon, 18 Dec 2023 15:17:31 +0000 In-Reply-To: References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <94892bbc3b365fe3275072d615b0282dc0d3e160-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="m3e8LO4MEKM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: tun.c: don't attempt to delete DNS and WINS servers if they're not set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: d12fk , openvpn-devel --m3e8LO4MEKM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos, stipa. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=3Demail to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review-1 by flichtenheld Change subject: tun.c: don't attempt to delete DNS and WINS servers if they= 're not set ...................................................................... tun.c: don't attempt to delete DNS and WINS servers if they're not set Commits 1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service") added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added. However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds. This change fixes this by improving check "has DNS/WINS been pushed?". While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values. Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a Signed-off-by: Lev Stipakov --- M src/openvpn/tun.c 1 file changed, 12 insertions(+), 23 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/482/2 diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index f1b8699..8e96149 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -147,17 +147,16 @@ return ret; } -static bool +static void do_dns_domain_service(bool add, const struct tuntap *tt) { - bool ret =3D false; ack_message_t ack; struct gc_arena gc =3D gc_new(); HANDLE pipe =3D tt->options.msg_channel; if (!tt->options.domain) /* no domain to add or delete */ { - return true; + goto out; } /* Use dns_cfg_msg with addr_len =3D 0 for setting only the DOMAIN */ @@ -195,17 +194,14 @@ } msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted")); - ret =3D true; out: gc_free(&gc); - return ret; } -static bool +static void do_dns_service(bool add, const short family, const struct tuntap *tt) { - bool ret =3D false; ack_message_t ack; struct gc_arena gc =3D gc_new(); HANDLE pipe =3D tt->options.msg_channel; @@ -213,9 +209,10 @@ int addr_len =3D add ? len : 0; const char *ip_proto_name =3D family =3D=3D AF_INET6 ? "IPv6" : "IPv4"; - if (addr_len =3D=3D 0 && add) /* no addresses to add */ + if (len =3D=3D 0) { - return true; + /* nothing to do */ + goto out; } /* Use dns_cfg_msg with domain =3D "" for setting only the DNS servers= */ @@ -272,26 +269,23 @@ } msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "= set" : "deleted")); - ret =3D true; out: gc_free(&gc); - return ret; } -static bool +static void do_wins_service(bool add, const struct tuntap *tt) { - bool ret =3D false; ack_message_t ack; struct gc_arena gc =3D gc_new(); HANDLE pipe =3D tt->options.msg_channel; - int len =3D tt->options.wins_len; - int addr_len =3D add ? len : 0; + int addr_len =3D add ? tt->options.wins_len : 0; - if (addr_len =3D=3D 0 && add) /* no addresses to add */ + if (tt->options.wins_len =3D=3D 0) { - return true; + /* nothing to do */ + goto out; } wins_cfg_message_t wins =3D { @@ -338,11 +332,9 @@ } msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted")= ); - ret =3D true; out: gc_free(&gc); - return ret; } static bool @@ -7019,10 +7011,7 @@ { do_dns_domain_service(false, tt); } - if (tt->options.dns6_len > 0) - { - do_dns_service(false, AF_INET6, tt); - } + do_dns_service(false, AF_INET6, tt); delete_route_connected_v6_net(tt); do_address_service(false, AF_INET6, tt); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?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: I21a36d24f8e213c780f55acbe3e4df555c93542a Gerrit-Change-Number: 482 Gerrit-PatchSet: 2 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: d12fk Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: stipa Gerrit-MessageType: newpatchset --m3e8LO4MEKM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

stipa uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Code-Review-1 by flichtenheld

tun.c: don't attempt to delete DNS and WI=
NS servers if they're not set

Commits

1c4a47f7 ("= ;wintun: set adapter properties via interactive service")
18826= de5 ("Set WINS servers via interactice service")

added fun= ctionality of add/remove DNS/WINS via interactive
service, which is used= mostly by dco-win and wintun (tap-windows6
normally uses DHCP). There i= s a check in code - if DNS/WINS addresses
are not pushed, nothing is add= ed.

However, due to bug we always attempted to remove DNS/WINS,
e= ven if nothing was added. Removing WINS, for example, could take
up to 3= seconds.

This change fixes this by improving check "has DNS/WI= NS been pushed?".

While on it, convert do_XXX_service() functio= ns to "void" from "bool",
since we never check their= return values.

Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a=
Signed-off-by: Lev Stipakov <lev@...515...>
---
M src/openv= pn/tun.c
1 file changed, 12 insertions(+), 23 deletions(-)

=
git=
 pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/482/2
= diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index f1= b8699..8e96149 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -147,17 +147,16 @@
= return ret;
}

-static bool
+static void
do_dns_domain_se= rvice(bool add, const struct tuntap *tt)
{
- bool ret =3D false;
ack_message_t ack;
struct gc_arena gc =3D gc_n= ew();
HANDLE pipe =3D tt->options.msg_channel;

if (!tt->options.domain) /* no domai= n to add or delete */
{
- return true;
+ goto out;
}
=
/* Use dns_cfg_msg with addr_len =3D 0 for set= ting only the DOMAIN */
@@ -195,17 +194,14 @@
}


msg(M_INFO, "DNS doma= in %s using service", (add ? "set" : "deleted"));<= /span>
- ret =3D true;

out:
gc_free(&gc);<= /span>
- return ret;=
}

-static bool
= +static void
do_dns_service(bool add, const short family, = const struct tuntap *tt)
{
- bool ret =3D false;
ack_mess= age_t ack;
struct gc_arena gc =3D gc_new();
= HANDLE pipe =3D tt->options.msg_channel;
@@ -= 213,9 +209,10 @@
int addr_len =3D add ? len : 0;

const char *ip_proto_name =3D family =3D=3D AF_INET6 ? &quo= t;IPv6" : "IPv4";

- if (addr_len =3D=3D 0 && add) /* n= o addresses to add */
+ if (len =3D=3D 0)
{
- return true;
+ /* nothing to do */
+ goto out;
}<= /span>

/* Use dns_cfg_msg with domain =3D &= quot;" for setting only the DNS servers */
@@ -272,26 = +269,23 @@
}

ms= g(M_INFO, "%s dns servers %s using service", ip_proto_name, (add = ? "set" : "deleted"));
- ret =3D true;

o= ut:
gc_free(&gc);
- return ret;
}

-static bool
<= span style=3D"color: hsl(120, 100%, 40%);">+static void

do= _wins_service(bool add, const struct tuntap *tt)
{<= br>- bool ret =3D false;

ack_message_t ack;
struct gc_arena gc = =3D gc_new();
HANDLE pipe =3D tt->options.msg_chann= el;
- int len =3D tt= ->options.wins_len;
= - int addr_len =3D add ? len : 0;
+ int addr_len =3D add ? tt->options.wins_len : 0;

- if= (addr_len =3D=3D 0 && add) /* no addresses to add */
+ if (tt->options.wins_len = =3D=3D 0)

{
- return true;
+ /* nothing to do */
+ goto out;
}

wins_cfg_message_t wins =3D {
@@ -= 338,11 +332,9 @@
}

= msg(M_INFO, "WINS servers %s using service", (add ? "set= " : "deleted"));
- ret =3D true;

out:<= br> gc_free(&gc);
- return ret;
}

static bool
@@ -7019,10 +7011,7 @@
= {
do_dns_domain_service(false, t= t);
}
- if (tt->options.dns6_len > 0)
- {
- do_dns_service(false, AF_IN= ET6, tt);
- = }
+ do_dns= _service(false, AF_INET6, tt);
delete_route_co= nnected_v6_net(tt);
do_address_service(false, = AF_INET6, tt);
}

=

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e= 4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: d12fk <heiko@...515...>
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-MessageType: newpatchset
--m3e8LO4MEKM=--