aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com>2013-12-15 19:41:58 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-17 16:08:45 -0500
commit8a41ae4496e534a8b68d9bc3c79113e16d1fcd4c (patch)
tree35d4639e01bd1dc9ba1bbbcc7b4e4720bc651595
parent0a98a0d12c40f9354b942325045cae123d594341 (diff)
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>
-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.c24
-rw-r--r--drivers/net/bonding/bonding.h2
-rw-r--r--include/uapi/linux/if_link.h1
5 files changed, 41 insertions, 16 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 9445243593fc..b361c674dc00 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -33,6 +33,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
33 [IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 }, 33 [IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 },
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}; 37};
37 38
38static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) 39static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -168,6 +169,14 @@ static int bond_changelink(struct net_device *bond_dev,
168 if (err) 169 if (err)
169 return err; 170 return err;
170 } 171 }
172 if (data[IFLA_BOND_PRIMARY_RESELECT]) {
173 int primary_reselect =
174 nla_get_u8(data[IFLA_BOND_PRIMARY_RESELECT]);
175
176 err = bond_option_primary_reselect_set(bond, primary_reselect);
177 if (err)
178 return err;
179 }
171 return 0; 180 return 0;
172} 181}
173 182
@@ -197,6 +206,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
197 nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_VALIDATE */ 206 nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_VALIDATE */
198 nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */ 207 nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */
199 nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */ 208 nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */
209 nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */
200 0; 210 0;
201} 211}
202 212
@@ -261,6 +271,10 @@ static int bond_fill_info(struct sk_buff *skb,
261 bond->primary_slave->dev->ifindex)) 271 bond->primary_slave->dev->ifindex))
262 goto nla_put_failure; 272 goto nla_put_failure;
263 273
274 if (nla_put_u8(skb, IFLA_BOND_PRIMARY_RESELECT,
275 bond->params.primary_reselect))
276 goto nla_put_failure;
277
264 return 0; 278 return 0;
265 279
266nla_put_failure: 280nla_put_failure:
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index c410d2d0dc33..80a9df4e4bf7 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -519,3 +519,19 @@ out:
519 519
520 return err; 520 return err;
521} 521}
522
523int bond_option_primary_reselect_set(struct bonding *bond, int primary_reselect)
524{
525 bond->params.primary_reselect = primary_reselect;
526 pr_info("%s: setting primary_reselect to %s (%d).\n",
527 bond->dev->name, pri_reselect_tbl[primary_reselect].modename,
528 primary_reselect);
529
530 block_netpoll_tx();
531 write_lock_bh(&bond->curr_slave_lock);
532 bond_select_active_slave(bond);
533 write_unlock_bh(&bond->curr_slave_lock);
534 unblock_netpoll_tx();
535
536 return 0;
537}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 7304c2bd2285..324afa5fda93 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -909,32 +909,24 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
909 struct device_attribute *attr, 909 struct device_attribute *attr,
910 const char *buf, size_t count) 910 const char *buf, size_t count)
911{ 911{
912 int new_value, ret = count; 912 int new_value, ret;
913 struct bonding *bond = to_bond(d); 913 struct bonding *bond = to_bond(d);
914 914
915 if (!rtnl_trylock())
916 return restart_syscall();
917
918 new_value = bond_parse_parm(buf, pri_reselect_tbl); 915 new_value = bond_parse_parm(buf, pri_reselect_tbl);
919 if (new_value < 0) { 916 if (new_value < 0) {
920 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n", 917 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
921 bond->dev->name, 918 bond->dev->name,
922 (int) strlen(buf) - 1, buf); 919 (int) strlen(buf) - 1, buf);
923 ret = -EINVAL; 920 return -EINVAL;
924 goto out;
925 } 921 }
926 922
927 bond->params.primary_reselect = new_value; 923 if (!rtnl_trylock())
928 pr_info("%s: setting primary_reselect to %s (%d).\n", 924 return restart_syscall();
929 bond->dev->name, pri_reselect_tbl[new_value].modename, 925
930 new_value); 926 ret = bond_option_primary_reselect_set(bond, new_value);
927 if (!ret)
928 ret = count;
931 929
932 block_netpoll_tx();
933 write_lock_bh(&bond->curr_slave_lock);
934 bond_select_active_slave(bond);
935 write_unlock_bh(&bond->curr_slave_lock);
936 unblock_netpoll_tx();
937out:
938 rtnl_unlock(); 930 rtnl_unlock();
939 return ret; 931 return ret;
940} 932}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index ec35802cd265..4e89d0480a5e 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -455,6 +455,8 @@ int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
455int bond_option_arp_validate_set(struct bonding *bond, int arp_validate); 455int bond_option_arp_validate_set(struct bonding *bond, int arp_validate);
456int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets); 456int 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,
459 int primary_reselect);
458struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); 460struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
459struct net_device *bond_option_active_slave_get(struct bonding *bond); 461struct net_device *bond_option_active_slave_get(struct bonding *bond);
460 462
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index fb3cfe2b176a..cf59d54a199d 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -340,6 +340,7 @@ enum {
340 IFLA_BOND_ARP_VALIDATE, 340 IFLA_BOND_ARP_VALIDATE,
341 IFLA_BOND_ARP_ALL_TARGETS, 341 IFLA_BOND_ARP_ALL_TARGETS,
342 IFLA_BOND_PRIMARY, 342 IFLA_BOND_PRIMARY,
343 IFLA_BOND_PRIMARY_RESELECT,
343 __IFLA_BOND_MAX, 344 __IFLA_BOND_MAX,
344}; 345};
345 346