aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorsfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com>2013-12-15 19:42:05 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-17 16:08:45 -0500
commit89901972de4c00e74e56529804493734d77ee3d3 (patch)
tree1ca8eb5d436b00fb9b5c921efdd74ed5bd64dfaa /drivers/net
parent8a41ae4496e534a8b68d9bc3c79113e16d1fcd4c (diff)
bonding: add fail_over_mac attribute netlink support
Add IFLA_BOND_FAIL_OVER_MAC to allow get/set of bonding parameter fail_over_mac via netlink. Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_netlink.c14
-rw-r--r--drivers/net/bonding/bond_options.c16
-rw-r--r--drivers/net/bonding/bond_sysfs.c26
-rw-r--r--drivers/net/bonding/bonding.h1
4 files changed, 39 insertions, 18 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index b361c674dc00..dc465ad3fb7c 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -34,6 +34,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
34 [IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 }, 34 [IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 },
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}; 38};
38 39
39static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) 40static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -177,6 +178,14 @@ static int bond_changelink(struct net_device *bond_dev,
177 if (err) 178 if (err)
178 return err; 179 return err;
179 } 180 }
181 if (data[IFLA_BOND_FAIL_OVER_MAC]) {
182 int fail_over_mac =
183 nla_get_u8(data[IFLA_BOND_FAIL_OVER_MAC]);
184
185 err = bond_option_fail_over_mac_set(bond, fail_over_mac);
186 if (err)
187 return err;
188 }
180 return 0; 189 return 0;
181} 190}
182 191
@@ -207,6 +216,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
207 nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */ 216 nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */
208 nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */ 217 nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */
209 nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */ 218 nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */
219 nla_total_size(sizeof(u8)) + /* IFLA_BOND_FAIL_OVER_MAC */
210 0; 220 0;
211} 221}
212 222
@@ -275,6 +285,10 @@ static int bond_fill_info(struct sk_buff *skb,
275 bond->params.primary_reselect)) 285 bond->params.primary_reselect))
276 goto nla_put_failure; 286 goto nla_put_failure;
277 287
288 if (nla_put_u8(skb, IFLA_BOND_FAIL_OVER_MAC,
289 bond->params.fail_over_mac))
290 goto nla_put_failure;
291
278 return 0; 292 return 0;
279 293
280nla_put_failure: 294nla_put_failure:
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 80a9df4e4bf7..86f462008932 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -535,3 +535,19 @@ int bond_option_primary_reselect_set(struct bonding *bond, int primary_reselect)
535 535
536 return 0; 536 return 0;
537} 537}
538
539int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac)
540{
541 if (bond_has_slaves(bond)) {
542 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
543 bond->dev->name);
544 return -EPERM;
545 }
546
547 bond->params.fail_over_mac = fail_over_mac;
548 pr_info("%s: Setting fail_over_mac to %s (%d).\n",
549 bond->dev->name, fail_over_mac_tbl[fail_over_mac].modename,
550 fail_over_mac);
551
552 return 0;
553}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 324afa5fda93..c84a90f9a0ac 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -442,33 +442,23 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
442 struct device_attribute *attr, 442 struct device_attribute *attr,
443 const char *buf, size_t count) 443 const char *buf, size_t count)
444{ 444{
445 int new_value, ret = count; 445 int new_value, ret;
446 struct bonding *bond = to_bond(d); 446 struct bonding *bond = to_bond(d);
447 447
448 if (!rtnl_trylock())
449 return restart_syscall();
450
451 if (bond_has_slaves(bond)) {
452 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
453 bond->dev->name);
454 ret = -EPERM;
455 goto out;
456 }
457
458 new_value = bond_parse_parm(buf, fail_over_mac_tbl); 448 new_value = bond_parse_parm(buf, fail_over_mac_tbl);
459 if (new_value < 0) { 449 if (new_value < 0) {
460 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n", 450 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
461 bond->dev->name, buf); 451 bond->dev->name, buf);
462 ret = -EINVAL; 452 return -EINVAL;
463 goto out;
464 } 453 }
465 454
466 bond->params.fail_over_mac = new_value; 455 if (!rtnl_trylock())
467 pr_info("%s: Setting fail_over_mac to %s (%d).\n", 456 return restart_syscall();
468 bond->dev->name, fail_over_mac_tbl[new_value].modename, 457
469 new_value); 458 ret = bond_option_fail_over_mac_set(bond, new_value);
459 if (!ret)
460 ret = count;
470 461
471out:
472 rtnl_unlock(); 462 rtnl_unlock();
473 return ret; 463 return ret;
474} 464}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 4e89d0480a5e..b69059b361a0 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -457,6 +457,7 @@ int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets);
457int bond_option_primary_set(struct bonding *bond, const char *primary); 457int bond_option_primary_set(struct bonding *bond, const char *primary);
458int bond_option_primary_reselect_set(struct bonding *bond, 458int bond_option_primary_reselect_set(struct bonding *bond,
459 int primary_reselect); 459 int primary_reselect);
460int bond_option_fail_over_mac_set(struct bonding *bond, int fail_over_mac);
460struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); 461struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
461struct net_device *bond_option_active_slave_get(struct bonding *bond); 462struct net_device *bond_option_active_slave_get(struct bonding *bond);
462 463