aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJay Vosburgh <fubar@us.ibm.com>2008-06-13 21:12:04 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-06-18 00:00:04 -0400
commitb8a9787eddb0e4665f31dd1d64584732b2b5d051 (patch)
tree08b7537e70b6a96bc04d231d31ccd644e1387e62 /drivers/net
parentb59f9f74c4c0a569398f08c34a877f1b7b457496 (diff)
bonding: Allow setting max_bonds to zero
Permit bonding to function rationally if max_bonds is set to zero. This will load the module, but create no master devices (which can be created via sysfs). Requires some change to bond_create_sysfs; currently, the netdev sysfs directory is determined from the first bonding device created, but this is no longer possible. Instead, an interface from net/core is created to create and destroy files in net_class. Based on a patch submitted by Phil Oester <kernel@linuxaces.com>. Modified by Jay Vosburgh to fix the sysfs issue mentioned above and to update the documentation. Signed-off-by: Phil Oester <kernel@linuxace.com> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_main.c6
-rw-r--r--drivers/net/bonding/bond_sysfs.c22
2 files changed, 6 insertions, 22 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3b6d66a8ab98..d57b65dc2c72 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4750,11 +4750,11 @@ static int bond_check_params(struct bond_params *params)
4750 } 4750 }
4751 } 4751 }
4752 4752
4753 if (max_bonds < 1 || max_bonds > INT_MAX) { 4753 if (max_bonds < 0 || max_bonds > INT_MAX) {
4754 printk(KERN_WARNING DRV_NAME 4754 printk(KERN_WARNING DRV_NAME
4755 ": Warning: max_bonds (%d) not in range %d-%d, so it " 4755 ": Warning: max_bonds (%d) not in range %d-%d, so it "
4756 "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n", 4756 "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
4757 max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); 4757 max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS);
4758 max_bonds = BOND_DEFAULT_MAX_BONDS; 4758 max_bonds = BOND_DEFAULT_MAX_BONDS;
4759 } 4759 }
4760 4760
@@ -4953,7 +4953,7 @@ static int bond_check_params(struct bond_params *params)
4953 4953
4954 printk("\n"); 4954 printk("\n");
4955 4955
4956 } else { 4956 } else if (max_bonds) {
4957 /* miimon and arp_interval not set, we need one so things 4957 /* miimon and arp_interval not set, we need one so things
4958 * work as expected, see bonding.txt for details 4958 * work as expected, see bonding.txt for details
4959 */ 4959 */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index dd265c69b0df..6caac0ffb2f2 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -53,7 +53,6 @@ extern struct bond_parm_tbl arp_validate_tbl[];
53extern struct bond_parm_tbl fail_over_mac_tbl[]; 53extern struct bond_parm_tbl fail_over_mac_tbl[];
54 54
55static int expected_refcount = -1; 55static int expected_refcount = -1;
56static struct class *netdev_class;
57/*--------------------------- Data Structures -----------------------------*/ 56/*--------------------------- Data Structures -----------------------------*/
58 57
59/* Bonding sysfs lock. Why can't we just use the subsystem lock? 58/* Bonding sysfs lock. Why can't we just use the subsystem lock?
@@ -1447,19 +1446,9 @@ static struct attribute_group bonding_group = {
1447 */ 1446 */
1448int bond_create_sysfs(void) 1447int bond_create_sysfs(void)
1449{ 1448{
1450 int ret = 0; 1449 int ret;
1451 struct bonding *firstbond;
1452
1453 /* get the netdev class pointer */
1454 firstbond = container_of(bond_dev_list.next, struct bonding, bond_list);
1455 if (!firstbond)
1456 return -ENODEV;
1457
1458 netdev_class = firstbond->dev->dev.class;
1459 if (!netdev_class)
1460 return -ENODEV;
1461 1450
1462 ret = class_create_file(netdev_class, &class_attr_bonding_masters); 1451 ret = netdev_class_create_file(&class_attr_bonding_masters);
1463 /* 1452 /*
1464 * Permit multiple loads of the module by ignoring failures to 1453 * Permit multiple loads of the module by ignoring failures to
1465 * create the bonding_masters sysfs file. Bonding devices 1454 * create the bonding_masters sysfs file. Bonding devices
@@ -1478,10 +1467,6 @@ int bond_create_sysfs(void)
1478 printk(KERN_ERR 1467 printk(KERN_ERR
1479 "network device named %s already exists in sysfs", 1468 "network device named %s already exists in sysfs",
1480 class_attr_bonding_masters.attr.name); 1469 class_attr_bonding_masters.attr.name);
1481 else {
1482 netdev_class = NULL;
1483 return 0;
1484 }
1485 } 1470 }
1486 1471
1487 return ret; 1472 return ret;
@@ -1493,8 +1478,7 @@ int bond_create_sysfs(void)
1493 */ 1478 */
1494void bond_destroy_sysfs(void) 1479void bond_destroy_sysfs(void)
1495{ 1480{
1496 if (netdev_class) 1481 netdev_class_remove_file(&class_attr_bonding_masters);
1497 class_remove_file(netdev_class, &class_attr_bonding_masters);
1498} 1482}
1499 1483
1500/* 1484/*