Skip to contentSkip to conversation

Add IPv6 gateway support for Linux, FreeBSD, and Darwin

PATCH In review Scott Zeid 2 participants 2 messages Aug 30, 2011 – Jun 10, 2012

lore
Share & tools
lore

Scott Zeid

author
#0 lore raw

PATCH 1/1 Add IPv6 gateway support for Linux, FreeBSD, and Darwin

This patch adds IPv6 gateway configuration for Linux, FreeBSD, and Darwin. Apparently this functionality already exists on Win32, Solaris, OpenBSD, and NetBSD.

This patch does not implement the --route-ipv6-gateway option; it only implements adding the gateway in add_route_ipv6().

I am only able to test this patch on Linux; the FreeBSD and Darwin code was guessed by reading the respective route(8) man pages.

(Thoughts: Some platforms do not specify the TUN/TAP interface in the route commands. Is this intentional?)

---
 route.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
route.c +11 -8
index d632b45..7f7b6fc 100644
@@ -1537,20 +1537,22 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
 
 #if defined(TARGET_LINUX)
 #ifdef CONFIG_FEATURE_IPROUTE
-  argv_printf (&argv, "%s -6 route add %s/%d dev %s",
+  argv_printf (&argv, "%s -6 route add %s/%d dev %s via %s",
   	      iproute_path,
 	      network,
 	      r6->netbits,
-	      device);
+	      device,
+	      gateway);
   if (r6->metric_defined)
     argv_printf_cat (&argv, " metric %d", r6->metric);
 
 #else
-  argv_printf (&argv, "%s -A inet6 add %s/%d dev %s",
+  argv_printf (&argv, "%s -A inet6 add %s/%d dev %s gw %s",
 		ROUTE_PATH,
 	      network,
 	      r6->netbits,
-	      device);
+	      device,
+	      gateway);
   if (r6->metric_defined)
     argv_printf_cat (&argv, " metric %d", r6->metric);
 #endif  /*CONFIG_FEATURE_IPROUTE*/
@@ -1613,20 +1615,21 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
 
 #elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY)
 
-  argv_printf (&argv, "%s add -inet6 %s/%d -iface %s",
+  argv_printf (&argv, "%s add -inet6 %s/%d -iface %s %s",
 		ROUTE_PATH,
 	        network,
 	        r6->netbits,
-	        device );
+	        device,
+		gateway );
 
   argv_msg (D_ROUTE, &argv);
   status = openvpn_execve_check (&argv, es, 0, "ERROR: *BSD route add -inet6 command failed");
 
 #elif defined(TARGET_DARWIN) 
 
-  argv_printf (&argv, "%s add -inet6 %s -prefixlen %d -iface %s",
+  argv_printf (&argv, "%s add -inet6 %s -prefixlen %d -iface %s %s",
 		ROUTE_PATH,
-	        network, r6->netbits, device );
+	        network, r6->netbits, device, gateway );
 
   argv_msg (D_ROUTE, &argv);
   status = openvpn_execve_check (&argv, es, 0, "ERROR: MacOS X route add -inet6 command failed");
Signature · 1 line
1.7.4.1
#1 lore raw

Hi,

sorry for never replying to your mail. It was on my TODO list, and David regularily reminded me that it was there, but well...

Quoted 9 lines · Scott Zeid

This patch adds IPv6 gateway configuration for Linux, FreeBSD, and Darwin. Apparently this functionality already exists on Win32, Solaris, OpenBSD, and NetBSD.

This patch does not implement the --route-ipv6-gateway option; it only implements adding the gateway in add_route_ipv6().

I am only able to test this patch on Linux; the FreeBSD and Darwin code was guessed by reading the respective route(8) man pages.

I have now solved the underlying issue in a slightly different way - only add the gateway spec if needed (aka: tap interface and not directly connected network). Patch has been sent to the just just now.

The BSD code didn't work the way you had it, because their route tool is a bit weird - "-iface dev" must not be combined with a gateway spec
- if you do that, you end up with completely weird entries in the routing table that do not work at all. So the code now does either-or, depending on interface type.

Quoted 2 lines

(Thoughts: Some platforms do not specify the TUN/TAP interface in the route commands. Is this intentional?)

This is more "lamentable" than intentional - it's because I could not find a way to actually specify the TUN interface for the route, or because the documented way did not work.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...