Skip to contentSkip to conversation

openvpn-2.1_beta8 ifconfig problems with subnet topology on FreeBSD [solved]

Openvpn-devel bennyben admin 1 participant 1 message Feb 2, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

After testing this version on my FreeBSD, I got the error message :

Fri Jan 27 12:11:13 2006 us=835111 OPTIONS IMPORT: timers and/or timeouts modified
Fri Jan 27 12:11:13 2006 us=835260 OPTIONS IMPORT: --ifconfig/up options modified
Fri Jan 27 12:11:13 2006 us=835373 OPTIONS IMPORT: route options modified
Fri Jan 27 12:11:13 2006 us=835483 OPTIONS IMPORT: route-related options modified
Fri Jan 27 12:11:13 2006 us=835593 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified Fri Jan 27 12:11:13 2006 us=836087 gw xx.xx.xx.xx
Fri Jan 27 12:11:13 2006 us=836302 ROUTE DEBUG: default_gateway=xx.xx.xx.xx
Fri Jan 27 12:11:13 2006 us=838416 TUN/TAP device /dev/tun0 opened
Fri Jan 27 12:11:13 2006 us=838634 /sbin/ifconfig tun0 172.18.48.15 netmask 255.255.240.0 mtu 1500 up Fri Jan 27 12:11:13 2006 us=838932 SYSTEM[2] '/sbin/ifconfig tun0 172.18.48.15 netmask 255.255.240.0 mtu 1500 up'
ifconfig: ioctl (SIOCAIFADDR): Destination address required
Fri Jan 27 12:11:13 2006 us=861902 SYSTEM return=256
Fri Jan 27 12:11:13 2006 us=862216 FreeBSD ifconfig failed: shell command exited with error status: 1 Fri Jan 27 12:11:13 2006 us=862353 Exiting

It seems that it's a problem already solved for MacOS X. I also patched the tun.c file, and now, it works well.

Attached, the patch.
Enjoy, and add it to the repository if you like.
TODO: test openvpn under other BSD and Unices.

Thanks,
Benoit Bourdin

tun.c +25 -2
diff -uNr openvpn-2.1_beta8/tun.c openvpn-2.1_beta8-freebsd/tun.c
@@ -795,18 +795,41 @@
 			  ifconfig_remote_netmask,
 			  tun_mtu
 			  );
-      else
-	openvpn_snprintf (command_line, sizeof (command_line),
+      else {
+	if (tt->topology == TOP_SUBNET)
+            openvpn_snprintf (command_line, sizeof (command_line),
+                              IFCONFIG_PATH " %s %s %s netmask %s mtu %d up",
+                              actual,
+                              ifconfig_local,
+                              ifconfig_local,
+                              ifconfig_remote_netmask,
+                              tun_mtu
+                              );
+	else
+  	    openvpn_snprintf (command_line, sizeof (command_line),
 			  IFCONFIG_PATH " %s %s netmask %s mtu %d up",
 			  actual,
 			  ifconfig_local,
 			  ifconfig_remote_netmask,
 			  tun_mtu
 			  );
+      }
 	
       msg (M_INFO, "%s", command_line);
       system_check (command_line, es, S_FATAL, "FreeBSD ifconfig failed");
       tt->did_ifconfig = true;
+
+	/* Add a network route for the local tun interface */
+      if (!tun && tt->topology == TOP_SUBNET)
+        {               
+          struct route r;
+          CLEAR (r);      
+          r.defined = true;       
+          r.network = tt->local & tt->remote_netmask;
+          r.netmask = tt->remote_netmask;
+          r.gateway = tt->local;  
+          add_route (&r, tt, 0, es);
+        }
 
 #elif defined (WIN32)
       {