net: call dev_alloc_name from register_netdevice

Force dev_alloc_name() to be called from register_netdevice() by
dev_get_valid_name(). That allows to remove multiple explicit
dev_alloc_name() calls.

The possibility to call dev_alloc_name in advance remains.

This also fixes veth creation regresion caused by
84c49d8c3e

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko
2011-04-30 01:21:32 +00:00
committed by David S. Miller
parent e892067497
commit 1c5cae815d
20 changed files with 12 additions and 134 deletions

View File

@@ -4917,8 +4917,9 @@ int bond_create(struct net *net, const char *name)
rtnl_lock();
bond_dev = alloc_netdev_mq(sizeof(struct bonding), name ? name : "",
bond_setup, tx_queues);
bond_dev = alloc_netdev_mq(sizeof(struct bonding),
name ? name : "bond%d",
bond_setup, tx_queues);
if (!bond_dev) {
pr_err("%s: eek! can't alloc netdev!\n", name);
rtnl_unlock();
@@ -4928,26 +4929,10 @@ int bond_create(struct net *net, const char *name)
dev_net_set(bond_dev, net);
bond_dev->rtnl_link_ops = &bond_link_ops;
if (!name) {
res = dev_alloc_name(bond_dev, "bond%d");
if (res < 0)
goto out;
} else {
/*
* If we're given a name to register
* we need to ensure that its not already
* registered
*/
res = -EEXIST;
if (__dev_get_by_name(net, name) != NULL)
goto out;
}
res = register_netdevice(bond_dev);
netif_carrier_off(bond_dev);
out:
rtnl_unlock();
if (res < 0)
bond_destructor(bond_dev);