From: Jason Wang Date: Sun, 2 Dec 2012 17:19:45 +0000 (+0000) Subject: tuntap: attach queue 0 before registering netdevice X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=eb0fb363f920e4d8c70d30b712f9dd433271218c;p=openwrt%2Fstaging%2Fblogic.git tuntap: attach queue 0 before registering netdevice We attach queue 0 after registering netdevice currently. This leads to call netif_set_real_num_{tx|rx}_queues() after registering the netdevice. Since we allow tun/tap has a maximum of 1024 queues, this may lead a huge number of uevents to be injected to userspace since we create 2048 kobjects and then remove 2046. Solve this problem by attaching queue 0 and set the real number of queues before registering netdevice. Reported-by: Jiri Slaby Tested-by: Jiri Slaby Signed-off-by: Jason Wang Signed-off-by: David S. Miller --- diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 607a3a5981c6..71f6874d8048 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -493,9 +493,6 @@ static int tun_attach(struct tun_struct *tun, struct file *file) tun_set_real_num_queues(tun); - if (tun->numqueues == 1) - netif_carrier_on(tun->dev); - /* device is allowed to go away first, so no need to hold extra * refcnt. */ @@ -1612,6 +1609,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) TUN_USER_FEATURES; dev->features = dev->hw_features; + err = tun_attach(tun, file); + if (err < 0) + goto err_free_dev; + err = register_netdevice(tun->dev); if (err < 0) goto err_free_dev; @@ -1621,9 +1622,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) device_create_file(&tun->dev->dev, &dev_attr_group)) pr_err("Failed to create tun sysfs files\n"); - err = tun_attach(tun, file); - if (err < 0) - goto err_free_dev; + netif_carrier_on(tun->dev); } tun_debug(KERN_INFO, tun, "tun_set_iff\n");