]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
options.c: do not force route delay when not using DHCP
authorLev Stipakov <lev@openvpn.net>
Thu, 19 Dec 2019 13:29:53 +0000 (15:29 +0200)
committerGert Doering <gert@greenie.muc.de>
Sun, 19 Jan 2020 10:18:30 +0000 (11:18 +0100)
Route delay may be only necessary when we perform
DHCP handshake. When we use IPAPI / netsh / manual,
no delay needed.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <20191219132953.375-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19257.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/options.c

index cebcbb07fbe5887f5cbe361e91d81127ccaa706a..a6f40e101b6d4d3923705067a7d13a8682c69653 100644 (file)
@@ -3001,9 +3001,18 @@ options_postprocess_mutate_invariant(struct options *options)
     }
 
 #ifdef _WIN32
+    /* when using wintun, kernel doesn't send DHCP requests, so use netsh to set IP address and netmask */
+    if (options->wintun)
+    {
+        options->tuntap_options.ip_win32_type = IPW32_SET_NETSH;
+    }
+
     if ((dev == DEV_TYPE_TUN || dev == DEV_TYPE_TAP) && !options->route_delay_defined)
     {
-        if (options->mode == MODE_POINT_TO_POINT)
+        /* delay may only be necessary when we perform DHCP handshake */
+        const bool dhcp = (options->tuntap_options.ip_win32_type == IPW32_SET_DHCP_MASQ)
+                          || (options->tuntap_options.ip_win32_type == IPW32_SET_ADAPTIVE);
+        if ((options->mode == MODE_POINT_TO_POINT) && dhcp)
         {
             options->route_delay_defined = true;
             options->route_delay = 5; /* Vista sometimes has a race without this */
@@ -3016,14 +3025,8 @@ options_postprocess_mutate_invariant(struct options *options)
         options->ifconfig_noexec = false;
     }
 
-    /* for wintun kernel doesn't send DHCP requests, so use netsh to set IP address and netmask */
-    if (options->wintun)
-    {
-        options->tuntap_options.ip_win32_type = IPW32_SET_NETSH;
-    }
-
     remap_redirect_gateway_flags(options);
-#endif
+#endif /* ifdef _WIN32 */
 
 #if P2MP_SERVER
     /*