Commit 30c15ba9 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

bond: Simplify bond_create.

Stop calling dev_get_by_name to see if the bond device already
exists.  register_netdevice already does that.

Stop calling bond_deinit if register_netdevice fails as bond_uninit
is guaranteed to be called if bond_init succeeds.
Signed-off-by: default avatarEric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6151b3d4
...@@ -5089,14 +5089,6 @@ int bond_create(const char *name) ...@@ -5089,14 +5089,6 @@ int bond_create(const char *name)
int res; int res;
rtnl_lock(); rtnl_lock();
/* Check to see if the bond already exists. */
/* FIXME: pass netns from caller */
if (name && __dev_get_by_name(&init_net, name)) {
pr_err(DRV_NAME ": cannot add bond %s; already exists\n",
name);
res = -EEXIST;
goto out_rtnl;
}
bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
bond_setup); bond_setup);
...@@ -5104,7 +5096,7 @@ int bond_create(const char *name) ...@@ -5104,7 +5096,7 @@ int bond_create(const char *name)
pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n", pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n",
name); name);
res = -ENOMEM; res = -ENOMEM;
goto out_rtnl; goto out;
} }
if (!name) { if (!name) {
...@@ -5114,19 +5106,13 @@ int bond_create(const char *name) ...@@ -5114,19 +5106,13 @@ int bond_create(const char *name)
} }
res = register_netdevice(bond_dev); res = register_netdevice(bond_dev);
if (res < 0)
goto out_bond;
out:
rtnl_unlock(); rtnl_unlock();
return 0; return res;
out_bond:
bond_deinit(bond_dev);
out_netdev: out_netdev:
free_netdev(bond_dev); free_netdev(bond_dev);
out_rtnl: goto out;
rtnl_unlock();
return res;
} }
static int __init bonding_init(void) static int __init bonding_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment