提交 f70161c6 编写于 作者: S sfeldma@cumulusnetworks.com 提交者: David S. Miller

bonding: add xmit_hash_policy attribute netlink support

Add IFLA_BOND_XMIT_HASH_POLICY to allow get/set of bonding parameter
xmit_hash_policy via netlink.
Signed-off-by: NScott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 89901972
...@@ -35,6 +35,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { ...@@ -35,6 +35,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
[IFLA_BOND_PRIMARY] = { .type = NLA_U32 }, [IFLA_BOND_PRIMARY] = { .type = NLA_U32 },
[IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 }, [IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 },
[IFLA_BOND_FAIL_OVER_MAC] = { .type = NLA_U8 }, [IFLA_BOND_FAIL_OVER_MAC] = { .type = NLA_U8 },
[IFLA_BOND_XMIT_HASH_POLICY] = { .type = NLA_U8 },
}; };
static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
...@@ -186,6 +187,14 @@ static int bond_changelink(struct net_device *bond_dev, ...@@ -186,6 +187,14 @@ static int bond_changelink(struct net_device *bond_dev,
if (err) if (err)
return err; return err;
} }
if (data[IFLA_BOND_XMIT_HASH_POLICY]) {
int xmit_hash_policy =
nla_get_u8(data[IFLA_BOND_XMIT_HASH_POLICY]);
err = bond_option_xmit_hash_policy_set(bond, xmit_hash_policy);
if (err)
return err;
}
return 0; return 0;
} }
...@@ -217,6 +226,7 @@ static size_t bond_get_size(const struct net_device *bond_dev) ...@@ -217,6 +226,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */ nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */
nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */ nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */
nla_total_size(sizeof(u8)) + /* IFLA_BOND_FAIL_OVER_MAC */ nla_total_size(sizeof(u8)) + /* IFLA_BOND_FAIL_OVER_MAC */
nla_total_size(sizeof(u8)) + /* IFLA_BOND_XMIT_HASH_POLICY */
0; 0;
} }
...@@ -289,6 +299,10 @@ static int bond_fill_info(struct sk_buff *skb, ...@@ -289,6 +299,10 @@ static int bond_fill_info(struct sk_buff *skb,
bond->params.fail_over_mac)) bond->params.fail_over_mac))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u8(skb, IFLA_BOND_XMIT_HASH_POLICY,
bond->params.xmit_policy))
goto nla_put_failure;
return 0; return 0;
nla_put_failure: nla_put_failure:
......
...@@ -551,3 +551,13 @@ int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac) ...@@ -551,3 +551,13 @@ int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac)
return 0; return 0;
} }
int bond_option_xmit_hash_policy_set(struct bonding *bond, int xmit_hash_policy)
{
bond->params.xmit_policy = xmit_hash_policy;
pr_info("%s: setting xmit hash policy to %s (%d).\n",
bond->dev->name,
xmit_hashtype_tbl[xmit_hash_policy].modename, xmit_hash_policy);
return 0;
}
...@@ -318,7 +318,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, ...@@ -318,7 +318,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int new_value, ret = count; int new_value, ret;
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
new_value = bond_parse_parm(buf, xmit_hashtype_tbl); new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
...@@ -326,14 +326,17 @@ static ssize_t bonding_store_xmit_hash(struct device *d, ...@@ -326,14 +326,17 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n", pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
bond->dev->name, bond->dev->name,
(int)strlen(buf) - 1, buf); (int)strlen(buf) - 1, buf);
ret = -EINVAL; return -EINVAL;
} else {
bond->params.xmit_policy = new_value;
pr_info("%s: setting xmit hash policy to %s (%d).\n",
bond->dev->name,
xmit_hashtype_tbl[new_value].modename, new_value);
} }
if (!rtnl_trylock())
return restart_syscall();
ret = bond_option_xmit_hash_policy_set(bond, new_value);
if (!ret)
ret = count;
rtnl_unlock();
return ret; return ret;
} }
static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
......
...@@ -458,6 +458,8 @@ int bond_option_primary_set(struct bonding *bond, const char *primary); ...@@ -458,6 +458,8 @@ int bond_option_primary_set(struct bonding *bond, const char *primary);
int bond_option_primary_reselect_set(struct bonding *bond, int bond_option_primary_reselect_set(struct bonding *bond,
int primary_reselect); int primary_reselect);
int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac); int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac);
int bond_option_xmit_hash_policy_set(struct bonding *bond,
int xmit_hash_policy);
struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
struct net_device *bond_option_active_slave_get(struct bonding *bond); struct net_device *bond_option_active_slave_get(struct bonding *bond);
......
...@@ -342,6 +342,7 @@ enum { ...@@ -342,6 +342,7 @@ enum {
IFLA_BOND_PRIMARY, IFLA_BOND_PRIMARY,
IFLA_BOND_PRIMARY_RESELECT, IFLA_BOND_PRIMARY_RESELECT,
IFLA_BOND_FAIL_OVER_MAC, IFLA_BOND_FAIL_OVER_MAC,
IFLA_BOND_XMIT_HASH_POLICY,
__IFLA_BOND_MAX, __IFLA_BOND_MAX,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册