aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_options.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_options.c')
-rw-r--r--drivers/net/bonding/bond_options.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 18b1cc0d8b80..2315104de8c0 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -244,6 +244,16 @@ static struct bond_option bond_opts[] = {
244 .values = bond_use_carrier_tbl, 244 .values = bond_use_carrier_tbl,
245 .set = bond_option_use_carrier_set 245 .set = bond_option_use_carrier_set
246 }, 246 },
247 [BOND_OPT_ACTIVE_SLAVE] = {
248 .id = BOND_OPT_ACTIVE_SLAVE,
249 .name = "active_slave",
250 .desc = "Currently active slave",
251 .flags = BOND_OPTFLAG_RAWVAL,
252 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP) |
253 BIT(BOND_MODE_TLB) |
254 BIT(BOND_MODE_ALB)),
255 .set = bond_option_active_slave_set
256 },
247 { } 257 { }
248}; 258};
249 259
@@ -556,10 +566,21 @@ struct net_device *bond_option_active_slave_get(struct bonding *bond)
556} 566}
557 567
558int bond_option_active_slave_set(struct bonding *bond, 568int bond_option_active_slave_set(struct bonding *bond,
559 struct net_device *slave_dev) 569 struct bond_opt_value *newval)
560{ 570{
571 char ifname[IFNAMSIZ] = { 0, };
572 struct net_device *slave_dev;
561 int ret = 0; 573 int ret = 0;
562 574
575 sscanf(newval->string, "%15s", ifname); /* IFNAMSIZ */
576 if (!strlen(ifname) || newval->string[0] == '\n') {
577 slave_dev = NULL;
578 } else {
579 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname);
580 if (!slave_dev)
581 return -ENODEV;
582 }
583
563 if (slave_dev) { 584 if (slave_dev) {
564 if (!netif_is_bond_slave(slave_dev)) { 585 if (!netif_is_bond_slave(slave_dev)) {
565 pr_err("Device %s is not bonding slave.\n", 586 pr_err("Device %s is not bonding slave.\n",
@@ -574,12 +595,6 @@ int bond_option_active_slave_set(struct bonding *bond,
574 } 595 }
575 } 596 }
576 597
577 if (!USES_PRIMARY(bond->params.mode)) {
578 pr_err("%s: Unable to change active slave; %s is in mode %d\n",
579 bond->dev->name, bond->dev->name, bond->params.mode);
580 return -EINVAL;
581 }
582
583 block_netpoll_tx(); 598 block_netpoll_tx();
584 write_lock_bh(&bond->curr_slave_lock); 599 write_lock_bh(&bond->curr_slave_lock);
585 600
@@ -616,6 +631,7 @@ int bond_option_active_slave_set(struct bonding *bond,
616 631
617 write_unlock_bh(&bond->curr_slave_lock); 632 write_unlock_bh(&bond->curr_slave_lock);
618 unblock_netpoll_tx(); 633 unblock_netpoll_tx();
634
619 return ret; 635 return ret;
620} 636}
621 637