aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@aristanetworks.com>2009-10-29 10:18:23 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-30 15:41:19 -0400
commit30c15ba9936a17d743f90eb3e2f6fa82acddc5f3 (patch)
treed9a9c6cf0df8ae3ab04111977a824c92ab634384 /drivers/net/bonding
parent6151b3d435feeeae7487032fcd5c8c7f281ba05c (diff)
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: Eric W. Biederman <ebiederm@aristanetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_main.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a58a60859da9..17c9580068b2 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -5089,14 +5089,6 @@ int bond_create(const char *name)
5089 int res; 5089 int res;
5090 5090
5091 rtnl_lock(); 5091 rtnl_lock();
5092 /* Check to see if the bond already exists. */
5093 /* FIXME: pass netns from caller */
5094 if (name && __dev_get_by_name(&init_net, name)) {
5095 pr_err(DRV_NAME ": cannot add bond %s; already exists\n",
5096 name);
5097 res = -EEXIST;
5098 goto out_rtnl;
5099 }
5100 5092
5101 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", 5093 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
5102 bond_setup); 5094 bond_setup);
@@ -5104,7 +5096,7 @@ int bond_create(const char *name)
5104 pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n", 5096 pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n",
5105 name); 5097 name);
5106 res = -ENOMEM; 5098 res = -ENOMEM;
5107 goto out_rtnl; 5099 goto out;
5108 } 5100 }
5109 5101
5110 if (!name) { 5102 if (!name) {
@@ -5114,19 +5106,13 @@ int bond_create(const char *name)
5114 } 5106 }
5115 5107
5116 res = register_netdevice(bond_dev); 5108 res = register_netdevice(bond_dev);
5117 if (res < 0)
5118 goto out_bond;
5119 5109
5110out:
5120 rtnl_unlock(); 5111 rtnl_unlock();
5121 return 0; 5112 return res;
5122
5123out_bond:
5124 bond_deinit(bond_dev);
5125out_netdev: 5113out_netdev:
5126 free_netdev(bond_dev); 5114 free_netdev(bond_dev);
5127out_rtnl: 5115 goto out;
5128 rtnl_unlock();
5129 return res;
5130} 5116}
5131 5117
5132static int __init bonding_init(void) 5118static int __init bonding_init(void)