]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[TUNTAP]: Allow setting the linktype of the tap device from userspace
authorMike Kershaw <dragorn@kismetwireless.net>
Fri, 2 Sep 2005 00:40:05 +0000 (17:40 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Sep 2005 00:40:05 +0000 (17:40 -0700)
Currently tun/tap only supports the EN10MB ARP type.  For use with
wireless and other networking types it should be possible to set the
ARP type via an ioctl.

Patch v2: Included check that the tap interface is down before changing the
link type out from underneath it

Signed-off-by: Mike Kershaw <dragorn@kismetwireless.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c
include/linux/if_tun.h

index effab0b9adca176b6b6a3b9fd553b256d9f1c850..50b8c6754b1ef333a225406a7465e9fdd2985dd6 100644 (file)
@@ -18,6 +18,9 @@
 /*
  *  Changes:
  *
+ *  Mike Kershaw <dragorn@kismetwireless.net> 2005/08/14
+ *    Add TUNSETLINK ioctl to set the link encapsulation
+ *
  *  Mark Smith <markzzzsmith@yahoo.com.au>
  *   Use random_ether_addr() for tap MAC address.
  *
@@ -612,6 +615,18 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
                DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);
                break;
 
+       case TUNSETLINK:
+               /* Only allow setting the type when the interface is down */
+               if (tun->dev->flags & IFF_UP) {
+                       DBG(KERN_INFO "%s: Linktype set failed because interface is up\n",
+                               tun->dev->name);
+                       return -EBUSY;
+               } else {
+                       tun->dev->type = (int) arg;
+                       DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type);
+               }
+               break;
+
 #ifdef TUN_DEBUG
        case TUNSETDEBUG:
                tun->debug = arg;
index 096a85a58ae5e4919e8379c8763d2c0f50e5887c..88aef7b86ef43be6b5b2408aa233f559fa88c115 100644 (file)
@@ -77,6 +77,7 @@ struct tun_struct {
 #define TUNSETIFF     _IOW('T', 202, int) 
 #define TUNSETPERSIST _IOW('T', 203, int) 
 #define TUNSETOWNER   _IOW('T', 204, int)
+#define TUNSETLINK    _IOW('T', 205, int)
 
 /* TUNSETIFF ifr flags */
 #define IFF_TUN                0x0001