bonding: add primary_select attribute netlink support
Add IFLA_BOND_PRIMARY_SELECT to allow get/set of bonding parameter primary_select via netlink. Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
0a98a0d12c
Коммит
8a41ae4496
|
@ -33,6 +33,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
|
|||
[IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 },
|
||||
[IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 },
|
||||
[IFLA_BOND_PRIMARY] = { .type = NLA_U32 },
|
||||
[IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 },
|
||||
};
|
||||
|
||||
static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
|
@ -168,6 +169,14 @@ static int bond_changelink(struct net_device *bond_dev,
|
|||
if (err)
|
||||
return err;
|
||||
}
|
||||
if (data[IFLA_BOND_PRIMARY_RESELECT]) {
|
||||
int primary_reselect =
|
||||
nla_get_u8(data[IFLA_BOND_PRIMARY_RESELECT]);
|
||||
|
||||
err = bond_option_primary_reselect_set(bond, primary_reselect);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -197,6 +206,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
|
|||
nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_VALIDATE */
|
||||
nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */
|
||||
nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */
|
||||
nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */
|
||||
0;
|
||||
}
|
||||
|
||||
|
@ -261,6 +271,10 @@ static int bond_fill_info(struct sk_buff *skb,
|
|||
bond->primary_slave->dev->ifindex))
|
||||
goto nla_put_failure;
|
||||
|
||||
if (nla_put_u8(skb, IFLA_BOND_PRIMARY_RESELECT,
|
||||
bond->params.primary_reselect))
|
||||
goto nla_put_failure;
|
||||
|
||||
return 0;
|
||||
|
||||
nla_put_failure:
|
||||
|
|
|
@ -519,3 +519,19 @@ out:
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bond_option_primary_reselect_set(struct bonding *bond, int primary_reselect)
|
||||
{
|
||||
bond->params.primary_reselect = primary_reselect;
|
||||
pr_info("%s: setting primary_reselect to %s (%d).\n",
|
||||
bond->dev->name, pri_reselect_tbl[primary_reselect].modename,
|
||||
primary_reselect);
|
||||
|
||||
block_netpoll_tx();
|
||||
write_lock_bh(&bond->curr_slave_lock);
|
||||
bond_select_active_slave(bond);
|
||||
write_unlock_bh(&bond->curr_slave_lock);
|
||||
unblock_netpoll_tx();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -909,32 +909,24 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
|
|||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int new_value, ret = count;
|
||||
int new_value, ret;
|
||||
struct bonding *bond = to_bond(d);
|
||||
|
||||
if (!rtnl_trylock())
|
||||
return restart_syscall();
|
||||
|
||||
new_value = bond_parse_parm(buf, pri_reselect_tbl);
|
||||
if (new_value < 0) {
|
||||
pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
|
||||
bond->dev->name,
|
||||
(int) strlen(buf) - 1, buf);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bond->params.primary_reselect = new_value;
|
||||
pr_info("%s: setting primary_reselect to %s (%d).\n",
|
||||
bond->dev->name, pri_reselect_tbl[new_value].modename,
|
||||
new_value);
|
||||
if (!rtnl_trylock())
|
||||
return restart_syscall();
|
||||
|
||||
ret = bond_option_primary_reselect_set(bond, new_value);
|
||||
if (!ret)
|
||||
ret = count;
|
||||
|
||||
block_netpoll_tx();
|
||||
write_lock_bh(&bond->curr_slave_lock);
|
||||
bond_select_active_slave(bond);
|
||||
write_unlock_bh(&bond->curr_slave_lock);
|
||||
unblock_netpoll_tx();
|
||||
out:
|
||||
rtnl_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -455,6 +455,8 @@ int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
|
|||
int bond_option_arp_validate_set(struct bonding *bond, int arp_validate);
|
||||
int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets);
|
||||
int bond_option_primary_set(struct bonding *bond, const char *primary);
|
||||
int bond_option_primary_reselect_set(struct bonding *bond,
|
||||
int primary_reselect);
|
||||
struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
|
||||
struct net_device *bond_option_active_slave_get(struct bonding *bond);
|
||||
|
||||
|
|
|
@ -340,6 +340,7 @@ enum {
|
|||
IFLA_BOND_ARP_VALIDATE,
|
||||
IFLA_BOND_ARP_ALL_TARGETS,
|
||||
IFLA_BOND_PRIMARY,
|
||||
IFLA_BOND_PRIMARY_RESELECT,
|
||||
__IFLA_BOND_MAX,
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче