diff options
author | sfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com> | 2013-12-15 16:41:51 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-17 16:08:45 -0500 |
commit | 0a98a0d12c40f9354b942325045cae123d594341 (patch) | |
tree | 7b23f578d9c833e28dfa6ecd6d3aab086d008d8d /drivers/net/bonding/bond_sysfs.c | |
parent | c3bd85495aef69e9df2e03a450a3a1f195c3867c (diff) | |
download | op-kernel-dev-0a98a0d12c40f9354b942325045cae123d594341.zip op-kernel-dev-0a98a0d12c40f9354b942325045cae123d594341.tar.gz |
bonding: add primary attribute netlink support
Add IFLA_BOND_PRIMARY to allow get/set of bonding parameter
primary via netlink.
Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.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 | 52 |
1 files changed, 9 insertions, 43 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 6368d29..7304c2b 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -871,56 +871,22 @@ static ssize_t bonding_store_primary(struct device *d, const char *buf, size_t count) { struct bonding *bond = to_bond(d); - struct list_head *iter; char ifname[IFNAMSIZ]; - struct slave *slave; - - if (!rtnl_trylock()) - return restart_syscall(); - block_netpoll_tx(); - write_lock_bh(&bond->curr_slave_lock); - - if (!USES_PRIMARY(bond->params.mode)) { - pr_info("%s: Unable to set primary slave; %s is in mode %d\n", - bond->dev->name, bond->dev->name, bond->params.mode); - goto out; - } + int ret; sscanf(buf, "%15s", ifname); /* IFNAMSIZ */ + if (ifname[0] == '\n') + ifname[0] = '\0'; - /* check to see if we are clearing primary */ - if (!strlen(ifname) || buf[0] == '\n') { - pr_info("%s: Setting primary slave to None.\n", - bond->dev->name); - bond->primary_slave = NULL; - memset(bond->params.primary, 0, sizeof(bond->params.primary)); - bond_select_active_slave(bond); - goto out; - } - - bond_for_each_slave(bond, slave, iter) { - if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { - pr_info("%s: Setting %s as primary slave.\n", - bond->dev->name, slave->dev->name); - bond->primary_slave = slave; - strcpy(bond->params.primary, slave->dev->name); - bond_select_active_slave(bond); - goto out; - } - } + if (!rtnl_trylock()) + return restart_syscall(); - strncpy(bond->params.primary, ifname, IFNAMSIZ); - bond->params.primary[IFNAMSIZ - 1] = 0; + ret = bond_option_primary_set(bond, ifname); + if (!ret) + ret = count; - pr_info("%s: Recording %s as primary, " - "but it has not been enslaved to %s yet.\n", - bond->dev->name, ifname, bond->dev->name); -out: - write_unlock_bh(&bond->curr_slave_lock); - unblock_netpoll_tx(); rtnl_unlock(); - - return count; + return ret; } static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); |