--- linux-2.4.0-test1.orig/drivers/net/ethertap.c Sat Jun 3 15:47:02 2000 +++ linux-2.4.0-test1/drivers/net/ethertap.c Sat Jun 3 11:16:13 2000 @@ -336,7 +336,7 @@ #ifdef MODULE -static int unit; +static int unit = -1; MODULE_PARM(unit,"i"); static struct net_device dev_ethertap = @@ -349,13 +349,23 @@ int init_module(void) { - dev_ethertap.base_addr=unit+NETLINK_TAPBASE; - sprintf(dev_ethertap.name,"tap%d",unit); - if (dev_get(dev_ethertap.name)) - { - printk(KERN_INFO "%s already loaded.\n", dev_ethertap.name); - return -EBUSY; + if( unit == -1 ){ + /* if unit isnt manually set, alloc it dynamically */ + int err=dev_alloc_name(&dev_ethertap,"tap%d"); + if (err<0) + return err; + unit = err; + }else{ /* for backward compatibility */ + sprintf(dev_ethertap.name,"tap%d",unit); + if (dev_get(dev_ethertap.name)) + { + printk(KERN_INFO "%s already loaded.\n", dev_ethertap.name); + return -EBUSY; + } } + dev_ethertap.base_addr=unit+NETLINK_TAPBASE; + if( dev_ethertap.base_addr > NETLINK_TAPEND ) + return -ENFILE; if (register_netdev(&dev_ethertap) != 0) return -EIO; return 0; --- linux-2.4.0-test1.orig/include/linux/netlink.h Sat Jun 3 15:46:23 2000 +++ linux-2.4.0-test1/include/linux/netlink.h Sat Jun 3 11:17:16 2000 @@ -9,6 +9,7 @@ #define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */ #define NETLINK_IP6_FW 13 #define NETLINK_TAPBASE 16 /* 16 to 31 are ethertap */ +#define NETLINK_TAPEND 31 #define MAX_LINKS 32