diff options
author | Jason Wang <jasowang@redhat.com> | 2012-12-02 12:19:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-03 13:47:57 -0500 |
commit | eb0fb363f920e4d8c70d30b712f9dd433271218c (patch) | |
tree | 947aa526a29af66a659f7e995b77167bd09d658f | |
parent | 092a5fc9636268bc2c0fef4d9b99845699cf19f9 (diff) |
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 <jslaby@suse.cz>
Tested-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/tun.c | 11 |
1 files changed, 5 insertions, 6 deletions
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) | |||
493 | 493 | ||
494 | tun_set_real_num_queues(tun); | 494 | tun_set_real_num_queues(tun); |
495 | 495 | ||
496 | if (tun->numqueues == 1) | ||
497 | netif_carrier_on(tun->dev); | ||
498 | |||
499 | /* device is allowed to go away first, so no need to hold extra | 496 | /* device is allowed to go away first, so no need to hold extra |
500 | * refcnt. | 497 | * refcnt. |
501 | */ | 498 | */ |
@@ -1612,6 +1609,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
1612 | TUN_USER_FEATURES; | 1609 | TUN_USER_FEATURES; |
1613 | dev->features = dev->hw_features; | 1610 | dev->features = dev->hw_features; |
1614 | 1611 | ||
1612 | err = tun_attach(tun, file); | ||
1613 | if (err < 0) | ||
1614 | goto err_free_dev; | ||
1615 | |||
1615 | err = register_netdevice(tun->dev); | 1616 | err = register_netdevice(tun->dev); |
1616 | if (err < 0) | 1617 | if (err < 0) |
1617 | goto err_free_dev; | 1618 | goto err_free_dev; |
@@ -1621,9 +1622,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
1621 | device_create_file(&tun->dev->dev, &dev_attr_group)) | 1622 | device_create_file(&tun->dev->dev, &dev_attr_group)) |
1622 | pr_err("Failed to create tun sysfs files\n"); | 1623 | pr_err("Failed to create tun sysfs files\n"); |
1623 | 1624 | ||
1624 | err = tun_attach(tun, file); | 1625 | netif_carrier_on(tun->dev); |
1625 | if (err < 0) | ||
1626 | goto err_free_dev; | ||
1627 | } | 1626 | } |
1628 | 1627 | ||
1629 | tun_debug(KERN_INFO, tun, "tun_set_iff\n"); | 1628 | tun_debug(KERN_INFO, tun, "tun_set_iff\n"); |