diff options
author | nikolay@redhat.com <nikolay@redhat.com> | 2013-09-06 18:00:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-09-11 15:55:17 -0400 |
commit | 5c5038dc26bdc609022a897e15f9ccdd28402ad9 (patch) | |
tree | acbde7eac54c53a2303c8d7dfab6fdc34f45e8ef /drivers/net/bonding | |
parent | 8112b1fe071be01a28a774ed55909e6f4b29712d (diff) |
bonding: fix store_arp_validate race with mode change
We need to protect store_arp_validate via rtnl because it can race with
mode changing and we can end up having arp_validate set in a mode
different from active-backup.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Acked-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index ce4677668e2c..4e386836d34f 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -419,27 +419,33 @@ static ssize_t bonding_store_arp_validate(struct device *d, | |||
419 | struct device_attribute *attr, | 419 | struct device_attribute *attr, |
420 | const char *buf, size_t count) | 420 | const char *buf, size_t count) |
421 | { | 421 | { |
422 | int new_value; | 422 | int new_value, ret = count; |
423 | struct bonding *bond = to_bond(d); | 423 | struct bonding *bond = to_bond(d); |
424 | 424 | ||
425 | if (!rtnl_trylock()) | ||
426 | return restart_syscall(); | ||
425 | new_value = bond_parse_parm(buf, arp_validate_tbl); | 427 | new_value = bond_parse_parm(buf, arp_validate_tbl); |
426 | if (new_value < 0) { | 428 | if (new_value < 0) { |
427 | pr_err("%s: Ignoring invalid arp_validate value %s\n", | 429 | pr_err("%s: Ignoring invalid arp_validate value %s\n", |
428 | bond->dev->name, buf); | 430 | bond->dev->name, buf); |
429 | return -EINVAL; | 431 | ret = -EINVAL; |
432 | goto out; | ||
430 | } | 433 | } |
431 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { | 434 | if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { |
432 | pr_err("%s: arp_validate only supported in active-backup mode.\n", | 435 | pr_err("%s: arp_validate only supported in active-backup mode.\n", |
433 | bond->dev->name); | 436 | bond->dev->name); |
434 | return -EINVAL; | 437 | ret = -EINVAL; |
438 | goto out; | ||
435 | } | 439 | } |
436 | pr_info("%s: setting arp_validate to %s (%d).\n", | 440 | pr_info("%s: setting arp_validate to %s (%d).\n", |
437 | bond->dev->name, arp_validate_tbl[new_value].modename, | 441 | bond->dev->name, arp_validate_tbl[new_value].modename, |
438 | new_value); | 442 | new_value); |
439 | 443 | ||
440 | bond->params.arp_validate = new_value; | 444 | bond->params.arp_validate = new_value; |
445 | out: | ||
446 | rtnl_unlock(); | ||
441 | 447 | ||
442 | return count; | 448 | return ret; |
443 | } | 449 | } |
444 | 450 | ||
445 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, | 451 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, |