Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Mike Kershaw and committed by
David S. Miller
ff4cc3ac 80ac2912

+16
+15
drivers/net/tun.c
··· 18 18 /* 19 19 * Changes: 20 20 * 21 + * Mike Kershaw <dragorn@kismetwireless.net> 2005/08/14 22 + * Add TUNSETLINK ioctl to set the link encapsulation 23 + * 21 24 * Mark Smith <markzzzsmith@yahoo.com.au> 22 25 * Use random_ether_addr() for tap MAC address. 23 26 * ··· 613 610 tun->owner = (uid_t) arg; 614 611 615 612 DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner); 613 + break; 614 + 615 + case TUNSETLINK: 616 + /* Only allow setting the type when the interface is down */ 617 + if (tun->dev->flags & IFF_UP) { 618 + DBG(KERN_INFO "%s: Linktype set failed because interface is up\n", 619 + tun->dev->name); 620 + return -EBUSY; 621 + } else { 622 + tun->dev->type = (int) arg; 623 + DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type); 624 + } 616 625 break; 617 626 618 627 #ifdef TUN_DEBUG
+1
include/linux/if_tun.h
··· 77 77 #define TUNSETIFF _IOW('T', 202, int) 78 78 #define TUNSETPERSIST _IOW('T', 203, int) 79 79 #define TUNSETOWNER _IOW('T', 204, int) 80 + #define TUNSETLINK _IOW('T', 205, int) 80 81 81 82 /* TUNSETIFF ifr flags */ 82 83 #define IFF_TUN 0x0001