aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 08:53:29 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-22 18:38:43 -0500
commit9e5f5eebe765b340af0318dba261e5de0f2aaf32 (patch)
tree1a2e1854202ee94bd52f7c83dcdde91f41297e7b /drivers/net/bonding
parent633ddc9e9bafd168861dee1000b2c6ff725e85c5 (diff)
bonding: convert ad_select to use the new option API
This patch adds the necessary changes so ad_select 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.c21
-rw-r--r--drivers/net/bonding/bond_netlink.c3
-rw-r--r--drivers/net/bonding/bond_options.c37
-rw-r--r--drivers/net/bonding/bond_options.h3
-rw-r--r--drivers/net/bonding/bond_procfs.c4
-rw-r--r--drivers/net/bonding/bond_sysfs.c22
-rw-r--r--drivers/net/bonding/bonding.h1
7 files changed, 41 insertions, 50 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f3bfcafc96a4..8f3f9f046f1c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -214,13 +214,6 @@ const struct bond_parm_tbl pri_reselect_tbl[] = {
214{ NULL, -1}, 214{ NULL, -1},
215}; 215};
216 216
217struct bond_parm_tbl ad_select_tbl[] = {
218{ "stable", BOND_AD_STABLE},
219{ "bandwidth", BOND_AD_BANDWIDTH},
220{ "count", BOND_AD_COUNT},
221{ NULL, -1},
222};
223
224/*-------------------------- Forward declarations ---------------------------*/ 217/*-------------------------- Forward declarations ---------------------------*/
225 218
226static int bond_init(struct net_device *bond_dev); 219static int bond_init(struct net_device *bond_dev);
@@ -4032,16 +4025,16 @@ static int bond_check_params(struct bond_params *params)
4032 } 4025 }
4033 4026
4034 if (ad_select) { 4027 if (ad_select) {
4035 params->ad_select = bond_parse_parm(ad_select, ad_select_tbl); 4028 bond_opt_initstr(&newval, lacp_rate);
4036 if (params->ad_select == -1) { 4029 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_AD_SELECT),
4037 pr_err("Error: Invalid ad_select \"%s\"\n", 4030 &newval);
4038 ad_select == NULL ? "NULL" : ad_select); 4031 if (!valptr) {
4032 pr_err("Error: Invalid ad_select \"%s\"\n", ad_select);
4039 return -EINVAL; 4033 return -EINVAL;
4040 } 4034 }
4041 4035 params->ad_select = valptr->value;
4042 if (bond_mode != BOND_MODE_8023AD) { 4036 if (bond_mode != BOND_MODE_8023AD)
4043 pr_warning("ad_select param only affects 802.3ad mode\n"); 4037 pr_warning("ad_select param only affects 802.3ad mode\n");
4044 }
4045 } else { 4038 } else {
4046 params->ad_select = BOND_AD_STABLE; 4039 params->ad_select = BOND_AD_STABLE;
4047 } 4040 }
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index a85466c0b0e3..830203dae20c 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -320,7 +320,8 @@ static int bond_changelink(struct net_device *bond_dev,
320 int ad_select = 320 int ad_select =
321 nla_get_u8(data[IFLA_BOND_AD_SELECT]); 321 nla_get_u8(data[IFLA_BOND_AD_SELECT]);
322 322
323 err = bond_option_ad_select_set(bond, ad_select); 323 bond_opt_initval(&newval, ad_select);
324 err = __bond_opt_set(bond, BOND_OPT_AD_SELECT, &newval);
324 if (err) 325 if (err)
325 return err; 326 return err;
326 } 327 }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index f8821696f823..081ab9b5d48a 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -78,6 +78,13 @@ static struct bond_opt_value bond_lacp_rate_tbl[] = {
78 { NULL, -1, 0}, 78 { NULL, -1, 0},
79}; 79};
80 80
81static struct bond_opt_value bond_ad_select_tbl[] = {
82 { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT},
83 { "bandwidth", BOND_AD_BANDWIDTH, 0},
84 { "count", BOND_AD_COUNT, 0},
85 { NULL, -1, 0},
86};
87
81static struct bond_option bond_opts[] = { 88static struct bond_option bond_opts[] = {
82 [BOND_OPT_MODE] = { 89 [BOND_OPT_MODE] = {
83 .id = BOND_OPT_MODE, 90 .id = BOND_OPT_MODE,
@@ -171,6 +178,14 @@ static struct bond_option bond_opts[] = {
171 .values = bond_intmax_tbl, 178 .values = bond_intmax_tbl,
172 .set = bond_option_min_links_set 179 .set = bond_option_min_links_set
173 }, 180 },
181 [BOND_OPT_AD_SELECT] = {
182 .id = BOND_OPT_AD_SELECT,
183 .name = "ad_select",
184 .desc = "803.ad aggregation selection logic",
185 .flags = BOND_OPTFLAG_IFDOWN,
186 .values = bond_ad_select_tbl,
187 .set = bond_option_ad_select_set
188 },
174 { } 189 { }
175}; 190};
176 191
@@ -1048,24 +1063,12 @@ int bond_option_lacp_rate_set(struct bonding *bond,
1048 return 0; 1063 return 0;
1049} 1064}
1050 1065
1051int bond_option_ad_select_set(struct bonding *bond, int ad_select) 1066int bond_option_ad_select_set(struct bonding *bond,
1067 struct bond_opt_value *newval)
1052{ 1068{
1053 if (bond_parm_tbl_lookup(ad_select, ad_select_tbl) < 0) { 1069 pr_info("%s: Setting ad_select to %s (%llu).\n",
1054 pr_err("%s: Ignoring invalid ad_select value %d.\n", 1070 bond->dev->name, newval->string, newval->value);
1055 bond->dev->name, ad_select); 1071 bond->params.ad_select = newval->value;
1056 return -EINVAL;
1057 }
1058
1059 if (bond->dev->flags & IFF_UP) {
1060 pr_err("%s: Unable to update ad_select because interface is up.\n",
1061 bond->dev->name);
1062 return -EPERM;
1063 }
1064
1065 bond->params.ad_select = ad_select;
1066 pr_info("%s: Setting ad_select to %s (%d).\n",
1067 bond->dev->name, ad_select_tbl[ad_select].modename,
1068 ad_select);
1069 1072
1070 return 0; 1073 return 0;
1071} 1074}
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h
index cc8edef812c4..53df1762d80f 100644
--- a/drivers/net/bonding/bond_options.h
+++ b/drivers/net/bonding/bond_options.h
@@ -50,6 +50,7 @@ enum {
50 BOND_OPT_UPDELAY, 50 BOND_OPT_UPDELAY,
51 BOND_OPT_LACP_RATE, 51 BOND_OPT_LACP_RATE,
52 BOND_OPT_MINLINKS, 52 BOND_OPT_MINLINKS,
53 BOND_OPT_AD_SELECT,
53 BOND_OPT_LAST 54 BOND_OPT_LAST
54}; 55};
55 56
@@ -133,4 +134,6 @@ int bond_option_lacp_rate_set(struct bonding *bond,
133 struct bond_opt_value *newval); 134 struct bond_opt_value *newval);
134int bond_option_min_links_set(struct bonding *bond, 135int bond_option_min_links_set(struct bonding *bond,
135 struct bond_opt_value *newval); 136 struct bond_opt_value *newval);
137int bond_option_ad_select_set(struct bonding *bond,
138 struct bond_opt_value *newval);
136#endif /* _BOND_OPTIONS_H */ 139#endif /* _BOND_OPTIONS_H */
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index 1a6631032f58..d28c3d7ae029 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -140,8 +140,10 @@ static void bond_info_show_master(struct seq_file *seq)
140 seq_printf(seq, "LACP rate: %s\n", 140 seq_printf(seq, "LACP rate: %s\n",
141 (bond->params.lacp_fast) ? "fast" : "slow"); 141 (bond->params.lacp_fast) ? "fast" : "slow");
142 seq_printf(seq, "Min links: %d\n", bond->params.min_links); 142 seq_printf(seq, "Min links: %d\n", bond->params.min_links);
143 optval = bond_opt_get_val(BOND_OPT_AD_SELECT,
144 bond->params.ad_select);
143 seq_printf(seq, "Aggregator selection policy (ad_select): %s\n", 145 seq_printf(seq, "Aggregator selection policy (ad_select): %s\n",
144 ad_select_tbl[bond->params.ad_select].modename); 146 optval->string);
145 147
146 if (__bond_3ad_get_active_agg_info(bond, &ad_info)) { 148 if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
147 seq_printf(seq, "bond %s has no active aggregator\n", 149 seq_printf(seq, "bond %s has no active aggregator\n",
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 3ae9bfd8e65e..02e493ae5173 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -601,10 +601,11 @@ static ssize_t bonding_show_ad_select(struct device *d,
601 char *buf) 601 char *buf)
602{ 602{
603 struct bonding *bond = to_bond(d); 603 struct bonding *bond = to_bond(d);
604 struct bond_opt_value *val;
604 605
605 return sprintf(buf, "%s %d\n", 606 val = bond_opt_get_val(BOND_OPT_AD_SELECT, bond->params.ad_select);
606 ad_select_tbl[bond->params.ad_select].modename, 607
607 bond->params.ad_select); 608 return sprintf(buf, "%s %d\n", val->string, bond->params.ad_select);
608} 609}
609 610
610 611
@@ -612,24 +613,13 @@ static ssize_t bonding_store_ad_select(struct device *d,
612 struct device_attribute *attr, 613 struct device_attribute *attr,
613 const char *buf, size_t count) 614 const char *buf, size_t count)
614{ 615{
615 int new_value, ret;
616 struct bonding *bond = to_bond(d); 616 struct bonding *bond = to_bond(d);
617 int ret;
617 618
618 new_value = bond_parse_parm(buf, ad_select_tbl); 619 ret = bond_opt_tryset_rtnl(bond, BOND_OPT_AD_SELECT, (char *)buf);
619 if (new_value < 0) {
620 pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
621 bond->dev->name, (int)strlen(buf) - 1, buf);
622 return -EINVAL;
623 }
624
625 if (!rtnl_trylock())
626 return restart_syscall();
627
628 ret = bond_option_ad_select_set(bond, new_value);
629 if (!ret) 620 if (!ret)
630 ret = count; 621 ret = count;
631 622
632 rtnl_unlock();
633 return ret; 623 return ret;
634} 624}
635static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, 625static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index df8c5ae44cdc..235fb18b65bf 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -465,7 +465,6 @@ int bond_option_num_peer_notif_set(struct bonding *bond, int num_peer_notif);
465int bond_option_all_slaves_active_set(struct bonding *bond, 465int bond_option_all_slaves_active_set(struct bonding *bond,
466 int all_slaves_active); 466 int all_slaves_active);
467int bond_option_lp_interval_set(struct bonding *bond, int min_links); 467int bond_option_lp_interval_set(struct bonding *bond, int min_links);
468int bond_option_ad_select_set(struct bonding *bond, int ad_select);
469struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); 468struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
470struct net_device *bond_option_active_slave_get(struct bonding *bond); 469struct net_device *bond_option_active_slave_get(struct bonding *bond);
471const char *bond_slave_link_status(s8 link); 470const char *bond_slave_link_status(s8 link);