]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Implement on-link route adding for iproute2
authorPhilipp Hagemeister <phihag@phihag.de>
Fri, 26 Sep 2014 16:11:01 +0000 (18:11 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 14 Oct 2014 13:26:27 +0000 (15:26 +0200)
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
Currently, when compiling with --enable-iproute2 , OpenVPN does not
create a correct route when the user is connected to the Internet
without a gateway (e.g. via ppp). This patch implements the
corresponding FIXME.

Signed-off-by: Philipp Hagemeister <phihag@phihag.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <54259015.2030005@phihag.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9056
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/route.c

index 5428e76dd596a13937bbe27c72733cb42fc24590..e76c2bd8ffb04c2407f6fa0f31953fc855d19e27 100644 (file)
@@ -1285,15 +1285,18 @@ add_route (struct route_ipv4 *r,
 
 #if defined(TARGET_LINUX)
 #ifdef ENABLE_IPROUTE
-  /* FIXME -- add on-link support for ENABLE_IPROUTE */
-  argv_printf (&argv, "%s route add %s/%d via %s",
+  argv_printf (&argv, "%s route add %s/%d",
              iproute_path,
              network,
-             count_netmask_bits(netmask),
-             gateway);
+             count_netmask_bits(netmask));
+
   if (r->flags & RT_METRIC_DEFINED)
     argv_printf_cat (&argv, "metric %d", r->metric);
 
+  if (is_on_link (is_local_route, flags, rgi))
+    argv_printf_cat (&argv, "dev %s", rgi->iface);
+  else
+    argv_printf_cat (&argv, "via %s", gateway);
 #else
   argv_printf (&argv, "%s add -net %s netmask %s",
               ROUTE_PATH,