aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kershaw <dragorn@kismetwireless.net>2005-09-01 20:40:05 -0400
committerDavid S. Miller <davem@davemloft.net>2005-09-01 20:40:05 -0400
commitff4cc3ac93e1d0369928fd60ec1fe82417afc576 (patch)
treec8f9380cfaedfd9f63f8e2eb0fff2d660aa81bab
parent80ac2912f846c01d702774bb6aa7100ec71e88b9 (diff)
[TUNTAP]: Allow setting the linktype of the tap device from userspace
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>
-rw-r--r--drivers/net/tun.c15
-rw-r--r--include/linux/if_tun.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index effab0b9adca..50b8c6754b1e 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -18,6 +18,9 @@
18/* 18/*
19 * Changes: 19 * Changes:
20 * 20 *
21 * Mike Kershaw <dragorn@kismetwireless.net> 2005/08/14
22 * Add TUNSETLINK ioctl to set the link encapsulation
23 *
21 * Mark Smith <markzzzsmith@yahoo.com.au> 24 * Mark Smith <markzzzsmith@yahoo.com.au>
22 * Use random_ether_addr() for tap MAC address. 25 * Use random_ether_addr() for tap MAC address.
23 * 26 *
@@ -612,6 +615,18 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
612 DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner); 615 DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);
613 break; 616 break;
614 617
618 case TUNSETLINK:
619 /* Only allow setting the type when the interface is down */
620 if (tun->dev->flags & IFF_UP) {
621 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n",
622 tun->dev->name);
623 return -EBUSY;
624 } else {
625 tun->dev->type = (int) arg;
626 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type);
627 }
628 break;
629
615#ifdef TUN_DEBUG 630#ifdef TUN_DEBUG
616 case TUNSETDEBUG: 631 case TUNSETDEBUG:
617 tun->debug = arg; 632 tun->debug = arg;
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index 096a85a58ae5..88aef7b86ef4 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -77,6 +77,7 @@ struct tun_struct {
77#define TUNSETIFF _IOW('T', 202, int) 77#define TUNSETIFF _IOW('T', 202, int)
78#define TUNSETPERSIST _IOW('T', 203, int) 78#define TUNSETPERSIST _IOW('T', 203, int)
79#define TUNSETOWNER _IOW('T', 204, int) 79#define TUNSETOWNER _IOW('T', 204, int)
80#define TUNSETLINK _IOW('T', 205, int)
80 81
81/* TUNSETIFF ifr flags */ 82/* TUNSETIFF ifr flags */
82#define IFF_TUN 0x0001 83#define IFF_TUN 0x0001