aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorJay Vosburgh <fubar@us.ibm.com>2007-01-19 21:15:47 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-05 16:58:47 -0500
commit877cbd36b27e073eb78fe7073a433fbe0da7d5f8 (patch)
tree2509195023739015f75711f5358db2209ae03e8a /drivers/net/bonding
parent09c892797688312dc8a3c4d8b37dcb7207c1d48a (diff)
bonding: modify sysfs support to permit multiple loads
The existing code would blindly attempt to create the bonding_masters file (in /sys/class/net) every time the module was loaded. When the module is loaded multiple times (which is the historical method used by initscripts and sysconfig to create multiple bonding interfaces), this caused load failure of the second module load attempt, as the creation request would fail. This changes the code to note the failure, arrange to not remove the bonding_masters file upon module exit, and then return success. Bonding interfaces created by the second or subsequent loads of the module will not exist in bonding_masters. This is not a significant change, as previously only the interfaces from the most recent load of the module would be listed. Both situations are less than optimal, but this case permits compatibility with existing distro configuration scripts, and is consistent. Note that previously, the sysfs create request would overwrite the exsting bonding_masters file and succeed, allowing multiple loads of the module. The sysfs code has recently changed to return an error if the file being created already exists. Patrick McHardy <kaber@trash.net>, who reported this problem, observed crashes on the old kernel (before sysfs checked for duplicates). I did not experience such crashes, but this change should resolve them. Signed-off-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_sysfs.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ced9ed8f995a..8e317e115532 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1372,6 +1372,21 @@ int bond_create_sysfs(void)
1372 return -ENODEV; 1372 return -ENODEV;
1373 1373
1374 ret = class_create_file(netdev_class, &class_attr_bonding_masters); 1374 ret = class_create_file(netdev_class, &class_attr_bonding_masters);
1375 /*
1376 * Permit multiple loads of the module by ignoring failures to
1377 * create the bonding_masters sysfs file. Bonding devices
1378 * created by second or subsequent loads of the module will
1379 * not be listed in, or controllable by, bonding_masters, but
1380 * will have the usual "bonding" sysfs directory.
1381 *
1382 * This is done to preserve backwards compatibility for
1383 * initscripts/sysconfig, which load bonding multiple times to
1384 * configure multiple bonding devices.
1385 */
1386 if (ret == -EEXIST) {
1387 netdev_class = NULL;
1388 return 0;
1389 }
1375 1390
1376 return ret; 1391 return ret;
1377 1392