]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Always release dhcp address in close_tun() on Windows.
authorSelva Nair <selva.nair@gmail.com>
Tue, 3 Jan 2017 20:38:03 +0000 (15:38 -0500)
committerGert Doering <gert@greenie.muc.de>
Mon, 9 Jan 2017 19:49:47 +0000 (20:49 +0100)
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>
(cherry picked from commit db5b9b45508ea8f66ea80565279af3edd9300499)

doc/openvpn.8
src/openvpn/options.c
src/openvpn/tun.c
src/openvpn/tun.h

index 7bd6d9d6b64cb2d7b8889d929987c34587ff359a..3e4c2e79af9e9dd6525c1f45592a9a867dee4c0e 100644 (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
index 5df2dba2737a9f94e93dbbcd6b1d5163b0723c2e..5eaff42c0dcfda1e92ee9732ea60c7ab88d69fd2 100644 (file)
@@ -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 */
     {
index f8128449b8b00f1833fc15a8c124c0fc3fdf9834..ec9997edacfe5a8a84bbedf859e8f11329b2e372 100644 (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)
         {
index f4b600c22fbfae7474a44710188cbe702d846f6b..b39fe157355b2319ace9f23a755b3418a2eef770 100644 (file)
@@ -104,7 +104,6 @@ struct tuntap_options {
 
     bool dhcp_renew;
     bool dhcp_pre_release;
-    bool dhcp_release;
 
     bool register_dns;