diff options
author | Selva Nair | 2017-12-05 23:28:41 -0500 |
---|---|---|
committer | Gert Doering | 2018-01-25 15:25:36 +0100 |
commit | 4229243563bcb22990f71d50e25be9ea6d44f519 (patch) | |
tree | e8910159450b40667a7cf88c59e4acae580ed982 /src/openvpn/win32.c | |
parent | d59a1c2f488cc3f4725df1e053592d53c30cf0eb (diff) | |
download | openvpn-4229243563bcb22990f71d50e25be9ea6d44f519.zip openvpn-4229243563bcb22990f71d50e25be9ea6d44f519.tar.gz |
Refactor get_interface_metric to return metric and auto flag separately
- Instead of returning metric = 0 when automatic metric is in use
return the actual metric and flag automatic metric through a
parameter. This makes the function reusable elsewhere.
- Ensure return value can be correctly cast to int and return -1 on
error.
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <1512534521-14760-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16039.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src/openvpn/win32.c')
-rw-r--r-- | src/openvpn/win32.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 95fea5d..4b20298 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1344,17 +1344,16 @@ win_wfp_block_dns(const NET_IFINDEX index, const HANDLE msg_channel) block_dns_msg_handler); if (status == 0) { - tap_metric_v4 = get_interface_metric(index, AF_INET); - tap_metric_v6 = get_interface_metric(index, AF_INET6); - if (tap_metric_v4 < 0) + int is_auto = 0; + tap_metric_v4 = get_interface_metric(index, AF_INET, &is_auto); + if (is_auto) { - /* error, should not restore metric */ - tap_metric_v4 = -1; + tap_metric_v4 = 0; } - if (tap_metric_v6 < 0) + tap_metric_v6 = get_interface_metric(index, AF_INET6, &is_auto); + if (is_auto) { - /* error, should not restore metric */ - tap_metric_v6 = -1; + tap_metric_v6 = 0; } status = set_interface_metric(index, AF_INET, BLOCK_DNS_IFACE_METRIC); if (!status) |