From 139cd1b14c57501bee36c1ec1dc5a037617ec29e Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Tue, 3 Jan 2017 15:38:03 -0500 Subject: [PATCH] Always release dhcp address in close_tun() on Windows. Also make sure --dhcp-pre-release results in not just dhcp_release() in open_tun() but a subsequent dhcp_renew() as well. Else dhcp transaction gets aborted as this call to release() happens after the adapter status is changed to connected. Fixes Trac #807 (but can't say the same for Trac #665 without knowing how to reproduce it) v2: Mark --dhcp-release as obsolete in manpage and option parser, and remove the unused dhcp_release variable. Enforce dhcp-renew with dhcp-pre-release while parsing the option instead of in open_tun(). Trac: #807 Signed-off-by: Selva Nair Acked-by: Gert Doering Message-Id: <1483475883-17450-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13814.html Signed-off-by: Gert Doering (cherry picked from commit db5b9b45508ea8f66ea80565279af3edd9300499) --- doc/openvpn.8 | 4 +--- src/openvpn/options.c | 6 ++---- src/openvpn/tun.c | 5 +---- src/openvpn/tun.h | 1 - 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/doc/openvpn.8 b/doc/openvpn.8 index 7bd6d9d6b..3e4c2e79a 100644 --- a/doc/openvpn.8 +++ b/doc/openvpn.8 @@ -5819,9 +5819,7 @@ flag. .TP .B \-\-dhcp\-release Ask Windows to release the TAP adapter lease on shutdown. -This option has the same caveats as -.B \-\-dhcp\-renew -above. +This option has no effect now, as it is enabled by default starting with version 2.4.1. .\"********************************************************* .TP .B \-\-register\-dns diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 5df2dba27..5eaff42c0 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -716,7 +716,6 @@ static const char usage_message[] = "--dhcp-renew : Ask Windows to renew the TAP adapter lease on startup.\n" "--dhcp-pre-release : Ask Windows to release the previous TAP adapter lease on\n" " startup.\n" - "--dhcp-release : Ask Windows to release the TAP adapter lease on shutdown.\n" "--register-dns : Run ipconfig /flushdns and ipconfig /registerdns\n" " on connection initiation.\n" "--tap-sleep n : Sleep for n seconds after TAP adapter open before\n" @@ -1214,7 +1213,6 @@ show_tuntap_options(const struct tuntap_options *o) SHOW_BOOL(dhcp_options); SHOW_BOOL(dhcp_renew); SHOW_BOOL(dhcp_pre_release); - SHOW_BOOL(dhcp_release); SHOW_STR(domain); SHOW_STR(netbios_scope); SHOW_INT(netbios_node_type); @@ -7201,11 +7199,11 @@ add_option(struct options *options, { VERIFY_PERMISSION(OPT_P_IPWIN32); options->tuntap_options.dhcp_pre_release = true; + options->tuntap_options.dhcp_renew = true; } else if (streq(p[0], "dhcp-release") && !p[1]) { - VERIFY_PERMISSION(OPT_P_IPWIN32); - options->tuntap_options.dhcp_release = true; + msg(M_WARN, "Obsolete option --dhcp-release detected. This is now on by default"); } else if (streq(p[0], "dhcp-internal") && p[1] && !p[2]) /* standalone method for internal use */ { diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index f8128449b..ec9997eda 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -6224,10 +6224,7 @@ close_tun(struct tuntap *tt) } #endif - if (tt->options.dhcp_release) - { - dhcp_release(tt); - } + dhcp_release(tt); if (tt->hand != NULL) { diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index f4b600c22..b39fe1573 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -104,7 +104,6 @@ struct tuntap_options { bool dhcp_renew; bool dhcp_pre_release; - bool dhcp_release; bool register_dns; -- 2.47.2