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/+/482?usp=email
to review the following change.
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. 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 <[email protected]>
---
M src/openvpn/tun.c
1 file changed, 13 insertions(+), 23 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/482/1
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index f1b8699..9104d46 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 = false;
ack_message_t ack;
struct gc_arena gc = gc_new();
HANDLE pipe = 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 = 0 for setting only the DOMAIN */
@@ -195,17 +194,14 @@
}
msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted"));
- ret = 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 = false;
ack_message_t ack;
struct gc_arena gc = gc_new();
HANDLE pipe = tt->options.msg_channel;
@@ -213,9 +209,11 @@
int addr_len = add ? len : 0;
const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4";
- if (addr_len == 0 && add) /* no addresses to add */
+ if (((family == AF_INET6) && (tt->options.dns6_len == 0))
+ || ((family == AF_INET) && (tt->options.dns_len == 0)))
{
- return true;
+ /* nothing to do */
+ goto out;
}
/* Use dns_cfg_msg with domain = "" for setting only the DNS servers */
@@ -272,26 +270,23 @@
}
msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set"
: "deleted"));
- ret = true;
out:
gc_free(&gc);
- return ret;
}
-static bool
+static void
do_wins_service(bool add, const struct tuntap *tt)
{
- bool ret = false;
ack_message_t ack;
struct gc_arena gc = gc_new();
HANDLE pipe = tt->options.msg_channel;
- int len = tt->options.wins_len;
- int addr_len = add ? len : 0;
+ int addr_len = add ? tt->options.wins_len : 0;
- if (addr_len == 0 && add) /* no addresses to add */
+ if (tt->options.wins_len == 0)
{
- return true;
+ /* nothing to do */
+ goto out;
}
wins_cfg_message_t wins = {
@@ -338,11 +333,9 @@
}
msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted"));
- ret = true;
out:
gc_free(&gc);
- return ret;
}
static bool
@@ -7019,10 +7012,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=email
To unsubscribe, or for help writing mail filters, visit
http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel