Skip to contentSkip to conversation

: add --dev-name - option to OpenVPN-1.3.2

PATCH New Christian Lademann 1 participant 1 message Mar 11, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : add --dev-name - option to OpenVPN-1.3.2

Hi, Jim,

attached I send you a patch for your kind review. It adds the capability to change the devicename of the allocated tun device (so far on Linux, only). For example:

dev-type tun
dev-name vpn_berlin

This helps administration a lot, at least from my point of view ;-)

Another bit I've changed is to make the ioctl(..., TUNSETIFF, ...) M_WARN instead of M_ERR, because Linux 2.2 doesn't seem to support this ioctl.

The patch is quite young and certanly needs more testing.

Regards,

Christian Lademann <[email protected]...>

Signature · 5 lines
*  Christian A. Lademann, ZLS Software GmbH          mailto:[email protected]...
*  ZLS Software GmbH
*  Frankfurter Strasse 59       Postfach 1628             mailto:[email protected]...
*  D-65779 Kelkheim             D-65766 Kelkheim          http://www.zls.de
*  Telefon +49-6195-9902-0      Telefax +49-6195-900600
openvpn.c +2 -2
diff -ruN openvpn-1.3.2-orig/openvpn.c openvpn-1.3.2/openvpn.c
@@ -626,7 +626,7 @@
 		     MAX_RW_SIZE_TUN (&frame));
 
       /* open the tun device */
-      open_tun (options->dev, options->dev_type, options->dev_node, options->tun_ipv6, tuntap);
+      open_tun (options->dev, options->dev_type, options->dev_node, options->dev_name, options->tun_ipv6, tuntap);
 
       /* do ifconfig */  
       if (ifconfig_order() == IFCONFIG_AFTER_TUN_OPEN)
@@ -1510,7 +1510,7 @@
 #endif
 	    )
 	  msg (M_FATAL, "Options error: options --mktun or --rmtun should only be used together with --dev");
-	tuncfg (options.dev, options.dev_type, options.dev_node,
+	tuncfg (options.dev, options.dev_type, options.dev_node, options.dev_name,
 		options.tun_ipv6, options.persist_mode);
 	goto exit;
       }
options.c +8 -0
diff -ruN openvpn-1.3.2-orig/options.c openvpn-1.3.2/options.c
@@ -67,6 +67,8 @@
   "                  does not begin with \"tun\" or \"tap\".\n"
   "--dev-node node : Explicitly set the device node rather than using\n"
   "                  /dev/net/tun, /dev/tun, /dev/tap, etc.\n"
+  "--dev-name name : Explicitly set the device name rather than using\n"
+  "                  tun0, tun1, etc.\n"
   "--tun-ipv6      : Build tun link capable of forwarding IPv6 traffic.\n"
   "--ifconfig l r  : Configure tun device to use IP address l as a local\n"
   "                  endpoint and r as a remote endpoint.  l & r should be\n"
@@ -287,6 +289,7 @@
   SHOW_STR (dev);
   SHOW_STR (dev_type);
   SHOW_STR (dev_node);
+  SHOW_STR (dev_name);
   SHOW_BOOL (tun_ipv6);
   SHOW_STR (ifconfig_local);
   SHOW_STR (ifconfig_remote);
@@ -650,6 +653,11 @@
     {
       ++i;
       options->dev_node = p2;
+    }
+  else if (streq (p1, "dev-name") && p2)
+    {
+      ++i;
+      options->dev_name = p2;
     }
   else if (streq (p1, "tun-ipv6"))
     {
options.h +1 -0
diff -ruN openvpn-1.3.2-orig/options.h openvpn-1.3.2/options.h
@@ -53,6 +53,7 @@
   const char *dev;
   const char *dev_type;
   const char *dev_node;
+  const char *dev_name;
   const char *ifconfig_local;
   const char *ifconfig_remote;
   int shaper;
tun.c +46 -19

144 lines not on this page · raw message

tun.h +4 -4
diff -ruN openvpn-1.3.2-orig/tun.h openvpn-1.3.2/tun.h
@@ -43,15 +43,15 @@
 
 void clear_tuntap (struct tuntap *tuntap);
 
-void open_tun (const char *dev, const char *dev_type, const char *dev_node, bool ipv6,
-	       struct tuntap *tt);
+void open_tun (const char *dev, const char *dev_type, const char *dev_node,
+	  const char *dev_name, bool ipv6, struct tuntap *tt);
 void close_tun (struct tuntap *tt);
 
 int write_tun (struct tuntap* tt, uint8_t *buf, int len);
 int read_tun (struct tuntap* tt, uint8_t *buf, int len);
 
-void tuncfg (const char *dev, const char *dev_type, const char *dev_node, bool ipv6,
-	     int persist_mode);
+void tuncfg (const char *dev, const char *dev_type, const char *dev_node,
+	  const char *dev_name, bool ipv6, int persist_mode);
 
 void do_ifconfig (const char *dev, const char *dev_type,
 		  const char *ifconfig_local, const char *ifconfig_remote,