diff options
author | Nikolay Aleksandrov <nikolay@redhat.com> | 2014-01-22 13:53:24 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-22 23:38:42 (GMT) |
commit | 4fb0ef585eb2825ef4e542c2b1d302dc53f36860 (patch) | |
tree | 0979b3f487b2bd52a4d697c0a7d59201d7f1edd1 /drivers/net/bonding/bond_sysfs.c | |
parent | 7bdb04ed0dbf9f0e94110be43db4f8bb7df58de2 (diff) | |
download | linux-4fb0ef585eb2825ef4e542c2b1d302dc53f36860.tar.xz |
bonding: convert arp_ip_target to use the new option API
This patch adds the necessary changes so arp_ip_target would use
the new bonding option API. This option is an exception because of
the way it's currently implemented that's why its netlink code is
a bit different from the other options to keep the functionality as
before and at the same time to have a single set function.
This patch also fixes a few stylistic errors.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 585c38c..5eeb3a2 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -454,8 +454,8 @@ static ssize_t bonding_show_arp_targets(struct device *d, struct device_attribute *attr, char *buf) { - int i, res = 0; struct bonding *bond = to_bond(d); + int i, res = 0; for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { if (bond->params.arp_targets[i]) @@ -464,6 +464,7 @@ static ssize_t bonding_show_arp_targets(struct device *d, } if (res) buf[res-1] = '\n'; /* eat the leftover space */ + return res; } @@ -472,30 +473,12 @@ static ssize_t bonding_store_arp_targets(struct device *d, const char *buf, size_t count) { struct bonding *bond = to_bond(d); - __be32 target; - int ret = -EPERM; - - if (!in4_pton(buf + 1, -1, (u8 *)&target, -1, NULL)) { - pr_err("%s: invalid ARP target %pI4 specified\n", - bond->dev->name, &target); - return -EPERM; - } - - if (!rtnl_trylock()) - return restart_syscall(); - - if (buf[0] == '+') - ret = bond_option_arp_ip_target_add(bond, target); - else if (buf[0] == '-') - ret = bond_option_arp_ip_target_rem(bond, target); - else - pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", - bond->dev->name); + int ret; + ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_TARGETS, (char *)buf); if (!ret) ret = count; - rtnl_unlock(); return ret; } static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); |