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 <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
This commit is contained in:
Selva Nair 2017-01-03 15:38:03 -05:00 committed by Gert Doering
parent ef910e3e3a
commit db5b9b4550
4 changed files with 4 additions and 12 deletions

View file

@ -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

View file

@ -715,7 +715,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"
@ -1212,7 +1211,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);
@ -7185,11 +7183,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 */
{

View file

@ -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)
{

View file

@ -104,7 +104,6 @@ struct tuntap_options {
bool dhcp_renew;
bool dhcp_pre_release;
bool dhcp_release;
bool register_dns;