diff options
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 14 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 10 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 17 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 2 | ||||
-rw-r--r-- | include/uapi/linux/if_link.h | 1 |
5 files changed, 37 insertions, 7 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index dc465ad3fb7c..67acd21a2170 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -35,6 +35,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { | |||
35 | [IFLA_BOND_PRIMARY] = { .type = NLA_U32 }, | 35 | [IFLA_BOND_PRIMARY] = { .type = NLA_U32 }, |
36 | [IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 }, | 36 | [IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 }, |
37 | [IFLA_BOND_FAIL_OVER_MAC] = { .type = NLA_U8 }, | 37 | [IFLA_BOND_FAIL_OVER_MAC] = { .type = NLA_U8 }, |
38 | [IFLA_BOND_XMIT_HASH_POLICY] = { .type = NLA_U8 }, | ||
38 | }; | 39 | }; |
39 | 40 | ||
40 | static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) | 41 | static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) |
@@ -186,6 +187,14 @@ static int bond_changelink(struct net_device *bond_dev, | |||
186 | if (err) | 187 | if (err) |
187 | return err; | 188 | return err; |
188 | } | 189 | } |
190 | if (data[IFLA_BOND_XMIT_HASH_POLICY]) { | ||
191 | int xmit_hash_policy = | ||
192 | nla_get_u8(data[IFLA_BOND_XMIT_HASH_POLICY]); | ||
193 | |||
194 | err = bond_option_xmit_hash_policy_set(bond, xmit_hash_policy); | ||
195 | if (err) | ||
196 | return err; | ||
197 | } | ||
189 | return 0; | 198 | return 0; |
190 | } | 199 | } |
191 | 200 | ||
@@ -217,6 +226,7 @@ static size_t bond_get_size(const struct net_device *bond_dev) | |||
217 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */ | 226 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */ |
218 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */ | 227 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */ |
219 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_FAIL_OVER_MAC */ | 228 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_FAIL_OVER_MAC */ |
229 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_XMIT_HASH_POLICY */ | ||
220 | 0; | 230 | 0; |
221 | } | 231 | } |
222 | 232 | ||
@@ -289,6 +299,10 @@ static int bond_fill_info(struct sk_buff *skb, | |||
289 | bond->params.fail_over_mac)) | 299 | bond->params.fail_over_mac)) |
290 | goto nla_put_failure; | 300 | goto nla_put_failure; |
291 | 301 | ||
302 | if (nla_put_u8(skb, IFLA_BOND_XMIT_HASH_POLICY, | ||
303 | bond->params.xmit_policy)) | ||
304 | goto nla_put_failure; | ||
305 | |||
292 | return 0; | 306 | return 0; |
293 | 307 | ||
294 | nla_put_failure: | 308 | nla_put_failure: |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 86f462008932..8510c6df115b 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -551,3 +551,13 @@ int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac) | |||
551 | 551 | ||
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | |||
555 | int bond_option_xmit_hash_policy_set(struct bonding *bond, int xmit_hash_policy) | ||
556 | { | ||
557 | bond->params.xmit_policy = xmit_hash_policy; | ||
558 | pr_info("%s: setting xmit hash policy to %s (%d).\n", | ||
559 | bond->dev->name, | ||
560 | xmit_hashtype_tbl[xmit_hash_policy].modename, xmit_hash_policy); | ||
561 | |||
562 | return 0; | ||
563 | } | ||
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index c84a90f9a0ac..4c7532289d87 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -318,7 +318,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
318 | struct device_attribute *attr, | 318 | struct device_attribute *attr, |
319 | const char *buf, size_t count) | 319 | const char *buf, size_t count) |
320 | { | 320 | { |
321 | int new_value, ret = count; | 321 | int new_value, ret; |
322 | struct bonding *bond = to_bond(d); | 322 | struct bonding *bond = to_bond(d); |
323 | 323 | ||
324 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); | 324 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); |
@@ -326,14 +326,17 @@ static ssize_t bonding_store_xmit_hash(struct device *d, | |||
326 | pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n", | 326 | pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n", |
327 | bond->dev->name, | 327 | bond->dev->name, |
328 | (int)strlen(buf) - 1, buf); | 328 | (int)strlen(buf) - 1, buf); |
329 | ret = -EINVAL; | 329 | return -EINVAL; |
330 | } else { | ||
331 | bond->params.xmit_policy = new_value; | ||
332 | pr_info("%s: setting xmit hash policy to %s (%d).\n", | ||
333 | bond->dev->name, | ||
334 | xmit_hashtype_tbl[new_value].modename, new_value); | ||
335 | } | 330 | } |
336 | 331 | ||
332 | if (!rtnl_trylock()) | ||
333 | return restart_syscall(); | ||
334 | |||
335 | ret = bond_option_xmit_hash_policy_set(bond, new_value); | ||
336 | if (!ret) | ||
337 | ret = count; | ||
338 | |||
339 | rtnl_unlock(); | ||
337 | return ret; | 340 | return ret; |
338 | } | 341 | } |
339 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, | 342 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index b69059b361a0..4cb603e9c591 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -458,6 +458,8 @@ int bond_option_primary_set(struct bonding *bond, const char *primary); | |||
458 | int bond_option_primary_reselect_set(struct bonding *bond, | 458 | int bond_option_primary_reselect_set(struct bonding *bond, |
459 | int primary_reselect); | 459 | int primary_reselect); |
460 | int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac); | 460 | int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac); |
461 | int bond_option_xmit_hash_policy_set(struct bonding *bond, | ||
462 | int xmit_hash_policy); | ||
461 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); | 463 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); |
462 | struct net_device *bond_option_active_slave_get(struct bonding *bond); | 464 | struct net_device *bond_option_active_slave_get(struct bonding *bond); |
463 | 465 | ||
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index fd181abd19b9..1a5d394894ea 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h | |||
@@ -342,6 +342,7 @@ enum { | |||
342 | IFLA_BOND_PRIMARY, | 342 | IFLA_BOND_PRIMARY, |
343 | IFLA_BOND_PRIMARY_RESELECT, | 343 | IFLA_BOND_PRIMARY_RESELECT, |
344 | IFLA_BOND_FAIL_OVER_MAC, | 344 | IFLA_BOND_FAIL_OVER_MAC, |
345 | IFLA_BOND_XMIT_HASH_POLICY, | ||
345 | __IFLA_BOND_MAX, | 346 | __IFLA_BOND_MAX, |
346 | }; | 347 | }; |
347 | 348 | ||