Browse code

Make "topology subnet" work on Solaris (ifconfig + route metric changes by Kazuyoshi Aizawa, adding of local "connected subnet" route by me)

Tested on OpenSolaris/i386, no impact for other TARGETs.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Kazuyoshi Aizawa <admin2@whiteboard.ne.jp>
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>

Gert Doering authored on 2010/10/31 04:03:16
Showing 2 changed files
... ...
@@ -923,16 +923,14 @@ add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s
923 923
   argv_printf (&argv, "%s add",
924 924
 		ROUTE_PATH);
925 925
 
926
-#if 0
927
-  if (r->metric_defined)
928
-    argv_printf_cat (&argv, "-rtt %d", r->metric);
929
-#endif
930
-
931 926
   argv_printf_cat (&argv, "%s -netmask %s %s",
932 927
 	      network,
933 928
 	      netmask,
934 929
 	      gateway);
935 930
 
931
+  if (r->metric_defined)
932
+    argv_printf_cat (&argv, "%d", r->metric);
933
+
936 934
   argv_msg (D_ROUTE, &argv);
937 935
   status = openvpn_execve_check (&argv, es, 0, "ERROR: Solaris route add command failed");
938 936
 
... ...
@@ -702,6 +702,19 @@ do_ifconfig (struct tuntap *tt,
702 702
 			    );
703 703
 	}
704 704
       else
705
+        if (tt->topology == TOP_SUBNET)
706
+	{
707
+          argv_printf (&argv,
708
+                              "%s %s %s %s netmask %s mtu %d up",
709
+                              IFCONFIG_PATH,
710
+                              actual,
711
+                              ifconfig_local,
712
+                              ifconfig_local,
713
+                              ifconfig_remote_netmask,
714
+                              tun_mtu
715
+                              );
716
+	}
717
+        else
705 718
           argv_printf (&argv,
706 719
                             " %s %s %s netmask %s broadcast + up",
707 720
                             IFCONFIG_PATH,
... ...
@@ -714,6 +727,20 @@ do_ifconfig (struct tuntap *tt,
714 714
       if (!openvpn_execve_check (&argv, es, 0, "Solaris ifconfig phase-2 failed"))
715 715
 	solaris_error_close (tt, es, actual);
716 716
 
717
+      if (!tun && tt->topology == TOP_SUBNET)
718
+	{
719
+	  /* Add a network route for the local tun interface */
720
+	  struct route r;
721
+	  CLEAR (r);      
722
+	  r.defined = true;       
723
+	  r.network = tt->local & tt->remote_netmask;
724
+	  r.netmask = tt->remote_netmask;
725
+	  r.gateway = tt->local;  
726
+	  r.metric_defined = true;
727
+	  r.metric = 0;
728
+	  add_route (&r, tt, 0, es);
729
+	}
730
+
717 731
       tt->did_ifconfig = true;
718 732
 
719 733
 #elif defined(TARGET_OPENBSD)