diff options
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 6482aed4bb7c..07b9d1f65b66 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4704,6 +4704,7 @@ static int bond_check_params(struct bond_params *params) | |||
4704 | static struct lock_class_key bonding_netdev_xmit_lock_key; | 4704 | static struct lock_class_key bonding_netdev_xmit_lock_key; |
4705 | 4705 | ||
4706 | /* Create a new bond based on the specified name and bonding parameters. | 4706 | /* Create a new bond based on the specified name and bonding parameters. |
4707 | * If name is NULL, obtain a suitable "bond%d" name for us. | ||
4707 | * Caller must NOT hold rtnl_lock; we need to release it here before we | 4708 | * Caller must NOT hold rtnl_lock; we need to release it here before we |
4708 | * set up our sysfs entries. | 4709 | * set up our sysfs entries. |
4709 | */ | 4710 | */ |
@@ -4713,7 +4714,8 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond | |||
4713 | int res; | 4714 | int res; |
4714 | 4715 | ||
4715 | rtnl_lock(); | 4716 | rtnl_lock(); |
4716 | bond_dev = alloc_netdev(sizeof(struct bonding), name, ether_setup); | 4717 | bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", |
4718 | ether_setup); | ||
4717 | if (!bond_dev) { | 4719 | if (!bond_dev) { |
4718 | printk(KERN_ERR DRV_NAME | 4720 | printk(KERN_ERR DRV_NAME |
4719 | ": %s: eek! can't alloc netdev!\n", | 4721 | ": %s: eek! can't alloc netdev!\n", |
@@ -4722,6 +4724,12 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond | |||
4722 | goto out_rtnl; | 4724 | goto out_rtnl; |
4723 | } | 4725 | } |
4724 | 4726 | ||
4727 | if (!name) { | ||
4728 | res = dev_alloc_name(bond_dev, "bond%d"); | ||
4729 | if (res < 0) | ||
4730 | goto out_netdev; | ||
4731 | } | ||
4732 | |||
4725 | /* bond_init() must be called after dev_alloc_name() (for the | 4733 | /* bond_init() must be called after dev_alloc_name() (for the |
4726 | * /proc files), but before register_netdevice(), because we | 4734 | * /proc files), but before register_netdevice(), because we |
4727 | * need to set function pointers. | 4735 | * need to set function pointers. |
@@ -4763,7 +4771,6 @@ static int __init bonding_init(void) | |||
4763 | { | 4771 | { |
4764 | int i; | 4772 | int i; |
4765 | int res; | 4773 | int res; |
4766 | char new_bond_name[8]; /* Enough room for 999 bonds at init. */ | ||
4767 | 4774 | ||
4768 | printk(KERN_INFO "%s", version); | 4775 | printk(KERN_INFO "%s", version); |
4769 | 4776 | ||
@@ -4776,8 +4783,7 @@ static int __init bonding_init(void) | |||
4776 | bond_create_proc_dir(); | 4783 | bond_create_proc_dir(); |
4777 | #endif | 4784 | #endif |
4778 | for (i = 0; i < max_bonds; i++) { | 4785 | for (i = 0; i < max_bonds; i++) { |
4779 | sprintf(new_bond_name, "bond%d",i); | 4786 | res = bond_create(NULL, &bonding_defaults, NULL); |
4780 | res = bond_create(new_bond_name,&bonding_defaults, NULL); | ||
4781 | if (res) | 4787 | if (res) |
4782 | goto err; | 4788 | goto err; |
4783 | } | 4789 | } |