[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Google
 
Web openvpn.net

[Openvpn-devel] [PATCH] Stick routes to interfaces for Linux


  • Subject: [Openvpn-devel] [PATCH] Stick routes to interfaces for Linux
  • From: Roy Marples <uberlord@xxxxxxxxxx>
  • Date: Fri, 7 Apr 2006 20:30:52 +0100

Hi List!

In some instances, Linux requires routes being stuck to interfaces instead of 
floating. Mainly in virtual environments like Xen and Qemu.

Attached is a patch that addresses this issue.

Thanks

-- 
Roy Marples <uberlord@xxxxxxxxxx>
Gentoo Linux Developer
--- openvpn-2.0.6/route.c	2006-04-07 14:59:40.311648814 +0100
+++ openvpn-2.0.6/route.c	2006-04-07 14:57:28.860077986 +0100
@@ -685,18 +685,20 @@ add_route (struct route *r, const struct
 
 #if defined(TARGET_LINUX)
 #ifdef CONFIG_FEATURE_IPROUTE
-  buf_printf (&buf, IPROUTE_PATH " route add %s/%d via %s",
+  buf_printf (&buf, IPROUTE_PATH " route add %s/%d via %s dev %s",
 	      network,
 	      count_netmask_bits(netmask),
-	      gateway);
+	      gateway,
+	      tt->actual_name);
   if (r->metric_defined)
     buf_printf (&buf, " metric %d", r->metric);
 
 #else
-  buf_printf (&buf, ROUTE_PATH " add -net %s netmask %s gw %s",
+  buf_printf (&buf, ROUTE_PATH " add -net %s netmask %s gw %s dev %s",
 	      network,
 	      netmask,
-	      gateway);
+	      gateway,
+	      tt->actual_name);
   if (r->metric_defined)
     buf_printf (&buf, " metric %d", r->metric);
 #endif  /*CONFIG_FEATURE_IPROUTE*/
@@ -792,7 +794,7 @@ add_route (struct route *r, const struct
     buf_printf (&buf, " -rtt %d", r->metric);
 #endif
 
-  buf_printf (&buf, " -net %s %s -netmask %s",
+  buf_printf (&buf, " -net %s %s -netmask %s dev",
 	      network,
 	      gateway,
 	      netmask);
@@ -830,14 +832,16 @@ delete_route (const struct route *r, con
 
 #if defined(TARGET_LINUX)
 #ifdef CONFIG_FEATURE_IPROUTE
-  buf_printf (&buf, IPROUTE_PATH " route del %s/%d",
+  buf_printf (&buf, IPROUTE_PATH " route del %s/%d dev %s",
 	      network,
-	      count_netmask_bits(netmask));
+	      count_netmask_bits(netmask),
+	      tt->actual_name);
 #else
 
-  buf_printf (&buf, ROUTE_PATH " del -net %s netmask %s",
+  buf_printf (&buf, ROUTE_PATH " del -net %s netmask %s dev %s",
 	      network,
-	      netmask);
+	      netmask,
+	      tt->actual_name);
 #endif /*CONFIG_FEATURE_IPROUTE*/
   if (r->metric_defined)
     buf_printf (&buf, " metric %d", r->metric);