netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] bonding: fix device name allocation error
@ 2007-01-20  2:15 Jay Vosburgh
  2007-01-23  5:49 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Jay Vosburgh @ 2007-01-20  2:15 UTC (permalink / raw)
  To: netdev, bonding-devel; +Cc: Jeff Garzik, Patrick McHardy, mitch.a.williams


	The code to select names for the bonding interfaces was, for the
non-sysfs creation case, always using a hard-coded set of bond0, bond1,
etc, up to max_bonds.  This caused conflicts for the second or
subsequent loads of the module.

	Changed the code to obtain device names from dev_alloc_name().

Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>


diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6482aed..07b9d1f 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
 static struct lock_class_key bonding_netdev_xmit_lock_key;
 
 /* Create a new bond based on the specified name and bonding parameters.
+ * If name is NULL, obtain a suitable "bond%d" name for us.
  * Caller must NOT hold rtnl_lock; we need to release it here before we
  * set up our sysfs entries.
  */
@@ -4713,7 +4714,8 @@ int bond_create(char *name, struct bond_
 	int res;
 
 	rtnl_lock();
-	bond_dev = alloc_netdev(sizeof(struct bonding), name, ether_setup);
+	bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
+				ether_setup);
 	if (!bond_dev) {
 		printk(KERN_ERR DRV_NAME
 		       ": %s: eek! can't alloc netdev!\n",
@@ -4722,6 +4724,12 @@ int bond_create(char *name, struct bond_
 		goto out_rtnl;
 	}
 
+	if (!name) {
+		res = dev_alloc_name(bond_dev, "bond%d");
+		if (res < 0)
+			goto out_netdev;
+	}
+
 	/* bond_init() must be called after dev_alloc_name() (for the
 	 * /proc files), but before register_netdevice(), because we
 	 * need to set function pointers.
@@ -4763,7 +4771,6 @@ static int __init bonding_init(void)
 {
 	int i;
 	int res;
-	char new_bond_name[8];  /* Enough room for 999 bonds at init. */
 
 	printk(KERN_INFO "%s", version);
 
@@ -4776,8 +4783,7 @@ #ifdef CONFIG_PROC_FS
 	bond_create_proc_dir();
 #endif
 	for (i = 0; i < max_bonds; i++) {
-		sprintf(new_bond_name, "bond%d",i);
-		res = bond_create(new_bond_name,&bonding_defaults, NULL);
+		res = bond_create(NULL, &bonding_defaults, NULL);
 		if (res)
 			goto err;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/4] bonding: fix device name allocation error
  2007-01-20  2:15 [PATCH 1/4] bonding: fix device name allocation error Jay Vosburgh
@ 2007-01-23  5:49 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-01-23  5:49 UTC (permalink / raw)
  To: Jay Vosburgh; +Cc: netdev, bonding-devel, Patrick McHardy, mitch.a.williams

Jay Vosburgh wrote:
> 	The code to select names for the bonding interfaces was, for the
> non-sysfs creation case, always using a hard-coded set of bond0, bond1,
> etc, up to max_bonds.  This caused conflicts for the second or
> subsequent loads of the module.
> 
> 	Changed the code to obtain device names from dev_alloc_name().
> 
> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>

applied 1-4 to #upstream



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-23  5:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-20  2:15 [PATCH 1/4] bonding: fix device name allocation error Jay Vosburgh
2007-01-23  5:49 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).