]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Force 'def1' method when --redirect-gateway is done through service
authorSelva Nair <selva.nair@gmail.com>
Wed, 30 Nov 2016 00:39:32 +0000 (19:39 -0500)
committerGert Doering <gert@greenie.muc.de>
Wed, 30 Nov 2016 18:54:27 +0000 (19:54 +0100)
The service deletes all added routes when the client process (openvpn)
exits, causing the re-instated default route to disappear.
Fix by rewriting "--redirect-gateway" to "--redirect-gateway def1" when
routes are set using interactive service.

Only the behaviour on Windows with intereactive service is affected.

Trac: #778

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480466372-2396-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13307.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Changes.rst
src/openvpn/options.c

index aa80c103530fbed0510ef7d044f23f07f701d512..1343034e1bf92d24b9fc1d4a526e904be23534ae 100644 (file)
@@ -79,6 +79,12 @@ New interactive Windows service
     files under %USERPROFILE%\\OpenVPN\\config for use with the
     interactive service.
 
+redirect-gateway
+    if no flags are given, and the interactive service is used, "def1"
+    is implicitly set (because "delete and later reinstall the existing
+    default route" does not work well here).  If not using the service,
+    the old behaviour is kept.
+
 redirect-gateway ipv6
     OpenVPN has now feature parity between IPv4 and IPv6 for redirect
     gateway including the handling of overlapping IPv6 routes with
index eac802327071eec825fa8de85b356e9afdc3f476..038fcd3820d9ae30d5bcd250c9d3e672e26e684c 100644 (file)
@@ -2526,6 +2526,22 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
 
 }
 
+#ifdef _WIN32
+/* If iservice is in use, we need def1 method for redirect-gateway */
+static void
+remap_redirect_gateway_flags (struct options *opt)
+{
+  if (opt->routes
+      && opt->route_method == ROUTE_METHOD_SERVICE
+      && opt->routes->flags & RG_REROUTE_GW
+      && !(opt->routes->flags & RG_DEF1))
+    {
+      msg (M_INFO, "Flag 'def1' added to --redirect-gateway (iservice is in use)");
+      opt->routes->flags |= RG_DEF1;
+    }
+}
+#endif
+
 static void
 options_postprocess_mutate_invariant (struct options *options)
 {
@@ -2555,6 +2571,8 @@ options_postprocess_mutate_invariant (struct options *options)
       options->tuntap_options.ip_win32_type = IPW32_SET_MANUAL;
       options->ifconfig_noexec = false;
     }
+
+  remap_redirect_gateway_flags (options);
 #endif
 
 #if P2MP_SERVER
@@ -5707,6 +5725,10 @@ add_option (struct options *options,
              goto err;
            }
        }
+#ifdef _WIN32
+      /* we need this here to handle pushed --redirect-gateway */
+      remap_redirect_gateway_flags (options);
+#endif
       options->routes->flags |= RG_ENABLE;
     }
   else if (streq (p[0], "remote-random-hostname") && !p[1])