aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 08:53:21 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-22 18:38:42 -0500
commitedf36b24c58dbbd5f2e708096537bf0a88ffa477 (patch)
tree0eb18f5930e6e524124df2fc0ac1dd99236fb3cd /drivers/net/bonding
parent162288810c9ebd2efb79ee6dc364e266044cac9e (diff)
bonding: convert arp_all_targets to use the new option API
This patch adds the necessary changes so arp_all_targets would use the new bonding option API. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_main.c16
-rw-r--r--drivers/net/bonding/bond_netlink.c3
-rw-r--r--drivers/net/bonding/bond_options.c30
-rw-r--r--drivers/net/bonding/bond_options.h3
-rw-r--r--drivers/net/bonding/bond_sysfs.c24
-rw-r--r--drivers/net/bonding/bonding.h1
6 files changed, 36 insertions, 41 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3903c87c8b8c..103b6af30474 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -214,12 +214,6 @@ const struct bond_parm_tbl bond_lacp_tbl[] = {
214{ NULL, -1}, 214{ NULL, -1},
215}; 215};
216 216
217const struct bond_parm_tbl arp_all_targets_tbl[] = {
218{ "any", BOND_ARP_TARGETS_ANY},
219{ "all", BOND_ARP_TARGETS_ALL},
220{ NULL, -1},
221};
222
223const struct bond_parm_tbl fail_over_mac_tbl[] = { 217const struct bond_parm_tbl fail_over_mac_tbl[] = {
224{ "none", BOND_FOM_NONE}, 218{ "none", BOND_FOM_NONE},
225{ "active", BOND_FOM_ACTIVE}, 219{ "active", BOND_FOM_ACTIVE},
@@ -4231,13 +4225,15 @@ static int bond_check_params(struct bond_params *params)
4231 4225
4232 arp_all_targets_value = 0; 4226 arp_all_targets_value = 0;
4233 if (arp_all_targets) { 4227 if (arp_all_targets) {
4234 arp_all_targets_value = bond_parse_parm(arp_all_targets, 4228 bond_opt_initstr(&newval, arp_all_targets);
4235 arp_all_targets_tbl); 4229 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_ARP_ALL_TARGETS),
4236 4230 &newval);
4237 if (arp_all_targets_value == -1) { 4231 if (!valptr) {
4238 pr_err("Error: invalid arp_all_targets_value \"%s\"\n", 4232 pr_err("Error: invalid arp_all_targets_value \"%s\"\n",
4239 arp_all_targets); 4233 arp_all_targets);
4240 arp_all_targets_value = 0; 4234 arp_all_targets_value = 0;
4235 } else {
4236 arp_all_targets_value = valptr->value;
4241 } 4237 }
4242 } 4238 }
4243 4239
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 588730c39748..ff1e3d3282e3 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -202,7 +202,8 @@ static int bond_changelink(struct net_device *bond_dev,
202 int arp_all_targets = 202 int arp_all_targets =
203 nla_get_u32(data[IFLA_BOND_ARP_ALL_TARGETS]); 203 nla_get_u32(data[IFLA_BOND_ARP_ALL_TARGETS]);
204 204
205 err = bond_option_arp_all_targets_set(bond, arp_all_targets); 205 bond_opt_initval(&newval, arp_all_targets);
206 err = __bond_opt_set(bond, BOND_OPT_ARP_ALL_TARGETS, &newval);
206 if (err) 207 if (err)
207 return err; 208 return err;
208 } 209 }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index eff68a0f71f0..e136e7525a02 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -53,6 +53,12 @@ static struct bond_opt_value bond_arp_validate_tbl[] = {
53 { NULL, -1, 0}, 53 { NULL, -1, 0},
54}; 54};
55 55
56static struct bond_opt_value bond_arp_all_targets_tbl[] = {
57 { "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT},
58 { "all", BOND_ARP_TARGETS_ALL, 0},
59 { NULL, -1, 0},
60};
61
56static struct bond_option bond_opts[] = { 62static struct bond_option bond_opts[] = {
57 [BOND_OPT_MODE] = { 63 [BOND_OPT_MODE] = {
58 .id = BOND_OPT_MODE, 64 .id = BOND_OPT_MODE,
@@ -85,6 +91,13 @@ static struct bond_option bond_opts[] = {
85 .values = bond_arp_validate_tbl, 91 .values = bond_arp_validate_tbl,
86 .set = bond_option_arp_validate_set 92 .set = bond_option_arp_validate_set
87 }, 93 },
94 [BOND_OPT_ARP_ALL_TARGETS] = {
95 .id = BOND_OPT_ARP_ALL_TARGETS,
96 .name = "arp_all_targets",
97 .desc = "fail on any/all arp targets timeout",
98 .values = bond_arp_all_targets_tbl,
99 .set = bond_option_arp_all_targets_set
100 },
88 { } 101 { }
89}; 102};
90 103
@@ -767,19 +780,12 @@ int bond_option_arp_validate_set(struct bonding *bond,
767 return 0; 780 return 0;
768} 781}
769 782
770int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets) 783int bond_option_arp_all_targets_set(struct bonding *bond,
784 struct bond_opt_value *newval)
771{ 785{
772 if (bond_parm_tbl_lookup(arp_all_targets, arp_all_targets_tbl) < 0) { 786 pr_info("%s: setting arp_all_targets to %s (%llu).\n",
773 pr_err("%s: Ignoring invalid arp_all_targets value %d.\n", 787 bond->dev->name, newval->string, newval->value);
774 bond->dev->name, arp_all_targets); 788 bond->params.arp_all_targets = newval->value;
775 return -EINVAL;
776 }
777
778 pr_info("%s: setting arp_all_targets to %s (%d).\n",
779 bond->dev->name, arp_all_targets_tbl[arp_all_targets].modename,
780 arp_all_targets);
781
782 bond->params.arp_all_targets = arp_all_targets;
783 789
784 return 0; 790 return 0;
785} 791}
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h
index 15c6c0185b2e..88f8c178b233 100644
--- a/drivers/net/bonding/bond_options.h
+++ b/drivers/net/bonding/bond_options.h
@@ -42,6 +42,7 @@ enum {
42 BOND_OPT_PACKETS_PER_SLAVE, 42 BOND_OPT_PACKETS_PER_SLAVE,
43 BOND_OPT_XMIT_HASH, 43 BOND_OPT_XMIT_HASH,
44 BOND_OPT_ARP_VALIDATE, 44 BOND_OPT_ARP_VALIDATE,
45 BOND_OPT_ARP_ALL_TARGETS,
45 BOND_OPT_LAST 46 BOND_OPT_LAST
46}; 47};
47 48
@@ -108,4 +109,6 @@ int bond_option_xmit_hash_policy_set(struct bonding *bond,
108 struct bond_opt_value *newval); 109 struct bond_opt_value *newval);
109int bond_option_arp_validate_set(struct bonding *bond, 110int bond_option_arp_validate_set(struct bonding *bond,
110 struct bond_opt_value *newval); 111 struct bond_opt_value *newval);
112int bond_option_arp_all_targets_set(struct bonding *bond,
113 struct bond_opt_value *newval);
111#endif /* _BOND_OPTIONS_H */ 114#endif /* _BOND_OPTIONS_H */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index e1a4b633013f..83463fc7622b 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -357,10 +357,12 @@ static ssize_t bonding_show_arp_all_targets(struct device *d,
357 char *buf) 357 char *buf)
358{ 358{
359 struct bonding *bond = to_bond(d); 359 struct bonding *bond = to_bond(d);
360 int value = bond->params.arp_all_targets; 360 struct bond_opt_value *val;
361 361
362 return sprintf(buf, "%s %d\n", arp_all_targets_tbl[value].modename, 362 val = bond_opt_get_val(BOND_OPT_ARP_ALL_TARGETS,
363 value); 363 bond->params.arp_all_targets);
364 return sprintf(buf, "%s %d\n",
365 val->string, bond->params.arp_all_targets);
364} 366}
365 367
366static ssize_t bonding_store_arp_all_targets(struct device *d, 368static ssize_t bonding_store_arp_all_targets(struct device *d,
@@ -368,24 +370,12 @@ static ssize_t bonding_store_arp_all_targets(struct device *d,
368 const char *buf, size_t count) 370 const char *buf, size_t count)
369{ 371{
370 struct bonding *bond = to_bond(d); 372 struct bonding *bond = to_bond(d);
371 int new_value, ret; 373 int ret;
372
373 new_value = bond_parse_parm(buf, arp_all_targets_tbl);
374 if (new_value < 0) {
375 pr_err("%s: Ignoring invalid arp_all_targets value %s\n",
376 bond->dev->name, buf);
377 return -EINVAL;
378 }
379
380 if (!rtnl_trylock())
381 return restart_syscall();
382 374
383 ret = bond_option_arp_all_targets_set(bond, new_value); 375 ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_ALL_TARGETS, (char *)buf);
384 if (!ret) 376 if (!ret)
385 ret = count; 377 ret = count;
386 378
387 rtnl_unlock();
388
389 return ret; 379 return ret;
390} 380}
391 381
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 9af61716d78a..18b948ad28d3 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -462,7 +462,6 @@ int bond_option_arp_ip_targets_set(struct bonding *bond, __be32 *targets,
462 int count); 462 int count);
463int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); 463int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
464int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); 464int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
465int bond_option_arp_all_targets_set(struct bonding *bond, int arp_all_targets);
466int bond_option_primary_set(struct bonding *bond, const char *primary); 465int bond_option_primary_set(struct bonding *bond, const char *primary);
467int bond_option_primary_reselect_set(struct bonding *bond, 466int bond_option_primary_reselect_set(struct bonding *bond,
468 int primary_reselect); 467 int primary_reselect);