From: Veaceslav Falico Date: Tue, 15 Nov 2011 06:44:42 +0000 (+0000) Subject: bonding: Don't allow mode change via sysfs with slaves present X-Git-Tag: v3.2-rc3~25^2~4 X-Git-Url: http://git.cascardo.info/?a=commitdiff_plain;h=4a8bb7e27fbb68da888b55f26defd2855225b2d5;p=cascardo%2Flinux.git bonding: Don't allow mode change via sysfs with slaves present When changing mode via bonding's sysfs, the slaves are not initialized correctly. Forbid to change modes with slaves present to ensure that every slave is initialized correctly via bond_enslave(). Signed-off-by: Veaceslav Falico Signed-off-by: Andy Gospodarek Acked-by: Nicolas de Pesloüan Signed-off-by: David S. Miller --- diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 5a20804fdece..4ef7e2fd9fe6 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -319,6 +319,13 @@ static ssize_t bonding_store_mode(struct device *d, goto out; } + if (bond->slave_cnt > 0) { + pr_err("unable to update mode of %s because it has slaves.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + new_value = bond_parse_parm(buf, bond_mode_tbl); if (new_value < 0) { pr_err("%s: Ignoring invalid mode value %.*s.\n",