aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/bonding/bond_main.c15
-rw-r--r--drivers/net/bonding/bond_netlink.c3
-rw-r--r--drivers/net/bonding/bond_options.c44
-rw-r--r--drivers/net/bonding/bond_options.h3
-rw-r--r--drivers/net/bonding/bond_sysfs.c22
-rw-r--r--drivers/net/bonding/bonding.h1
6 files changed, 37 insertions, 51 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6d1515db6ca8..f3bfcafc96a4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -207,12 +207,6 @@ static int bond_mode = BOND_MODE_ROUNDROBIN;
207static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; 207static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
208static int lacp_fast; 208static int lacp_fast;
209 209
210const struct bond_parm_tbl bond_lacp_tbl[] = {
211{ "slow", AD_LACP_SLOW},
212{ "fast", AD_LACP_FAST},
213{ NULL, -1},
214};
215
216const struct bond_parm_tbl pri_reselect_tbl[] = { 210const struct bond_parm_tbl pri_reselect_tbl[] = {
217{ "always", BOND_PRI_RESELECT_ALWAYS}, 211{ "always", BOND_PRI_RESELECT_ALWAYS},
218{ "better", BOND_PRI_RESELECT_BETTER}, 212{ "better", BOND_PRI_RESELECT_BETTER},
@@ -4025,12 +4019,15 @@ static int bond_check_params(struct bond_params *params)
4025 pr_info("lacp_rate param is irrelevant in mode %s\n", 4019 pr_info("lacp_rate param is irrelevant in mode %s\n",
4026 bond_mode_name(bond_mode)); 4020 bond_mode_name(bond_mode));
4027 } else { 4021 } else {
4028 lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl); 4022 bond_opt_initstr(&newval, lacp_rate);
4029 if (lacp_fast == -1) { 4023 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_LACP_RATE),
4024 &newval);
4025 if (!valptr) {
4030 pr_err("Error: Invalid lacp rate \"%s\"\n", 4026 pr_err("Error: Invalid lacp rate \"%s\"\n",
4031 lacp_rate == NULL ? "NULL" : lacp_rate); 4027 lacp_rate);
4032 return -EINVAL; 4028 return -EINVAL;
4033 } 4029 }
4030 lacp_fast = valptr->value;
4034 } 4031 }
4035 } 4032 }
4036 4033
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 9629088cb990..508f2f51adad 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -310,7 +310,8 @@ static int bond_changelink(struct net_device *bond_dev,
310 int lacp_rate = 310 int lacp_rate =
311 nla_get_u8(data[IFLA_BOND_AD_LACP_RATE]); 311 nla_get_u8(data[IFLA_BOND_AD_LACP_RATE]);
312 312
313 err = bond_option_lacp_rate_set(bond, lacp_rate); 313 bond_opt_initval(&newval, lacp_rate);
314 err = __bond_opt_set(bond, BOND_OPT_LACP_RATE, &newval);
314 if (err) 315 if (err)
315 return err; 316 return err;
316 } 317 }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 9cc21628032f..680296c279dc 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -72,6 +72,12 @@ static struct bond_opt_value bond_intmax_tbl[] = {
72 { "maxval", INT_MAX, BOND_VALFLAG_MAX}, 72 { "maxval", INT_MAX, BOND_VALFLAG_MAX},
73}; 73};
74 74
75static struct bond_opt_value bond_lacp_rate_tbl[] = {
76 { "slow", AD_LACP_SLOW, 0},
77 { "fast", AD_LACP_FAST, 0},
78 { NULL, -1, 0},
79};
80
75static struct bond_option bond_opts[] = { 81static struct bond_option bond_opts[] = {
76 [BOND_OPT_MODE] = { 82 [BOND_OPT_MODE] = {
77 .id = BOND_OPT_MODE, 83 .id = BOND_OPT_MODE,
@@ -149,7 +155,15 @@ static struct bond_option bond_opts[] = {
149 .values = bond_intmax_tbl, 155 .values = bond_intmax_tbl,
150 .set = bond_option_updelay_set 156 .set = bond_option_updelay_set
151 }, 157 },
152 158 [BOND_OPT_LACP_RATE] = {
159 .id = BOND_OPT_LACP_RATE,
160 .name = "lacp_rate",
161 .desc = "LACPDU tx rate to request from 802.3ad partner",
162 .flags = BOND_OPTFLAG_IFDOWN,
163 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
164 .values = bond_lacp_rate_tbl,
165 .set = bond_option_lacp_rate_set
166 },
153 { } 167 { }
154}; 168};
155 169
@@ -1015,31 +1029,13 @@ int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval)
1015 return 0; 1029 return 0;
1016} 1030}
1017 1031
1018int bond_option_lacp_rate_set(struct bonding *bond, int lacp_rate) 1032int bond_option_lacp_rate_set(struct bonding *bond,
1033 struct bond_opt_value *newval)
1019{ 1034{
1020 if (bond_parm_tbl_lookup(lacp_rate, bond_lacp_tbl) < 0) { 1035 pr_info("%s: Setting LACP rate to %s (%llu).\n",
1021 pr_err("%s: Ignoring invalid LACP rate value %d.\n", 1036 bond->dev->name, newval->string, newval->value);
1022 bond->dev->name, lacp_rate); 1037 bond->params.lacp_fast = newval->value;
1023 return -EINVAL;
1024 }
1025
1026 if (bond->dev->flags & IFF_UP) {
1027 pr_err("%s: Unable to update LACP rate because interface is up.\n",
1028 bond->dev->name);
1029 return -EPERM;
1030 }
1031
1032 if (bond->params.mode != BOND_MODE_8023AD) {
1033 pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
1034 bond->dev->name);
1035 return -EPERM;
1036 }
1037
1038 bond->params.lacp_fast = lacp_rate;
1039 bond_3ad_update_lacp_rate(bond); 1038 bond_3ad_update_lacp_rate(bond);
1040 pr_info("%s: Setting LACP rate to %s (%d).\n",
1041 bond->dev->name, bond_lacp_tbl[lacp_rate].modename,
1042 lacp_rate);
1043 1039
1044 return 0; 1040 return 0;
1045} 1041}
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h
index 594046c3a608..7ee1a78abd8d 100644
--- a/drivers/net/bonding/bond_options.h
+++ b/drivers/net/bonding/bond_options.h
@@ -48,6 +48,7 @@ enum {
48 BOND_OPT_ARP_TARGETS, 48 BOND_OPT_ARP_TARGETS,
49 BOND_OPT_DOWNDELAY, 49 BOND_OPT_DOWNDELAY,
50 BOND_OPT_UPDELAY, 50 BOND_OPT_UPDELAY,
51 BOND_OPT_LACP_RATE,
51 BOND_OPT_LAST 52 BOND_OPT_LAST
52}; 53};
53 54
@@ -127,4 +128,6 @@ int bond_option_downdelay_set(struct bonding *bond,
127 struct bond_opt_value *newval); 128 struct bond_opt_value *newval);
128int bond_option_updelay_set(struct bonding *bond, 129int bond_option_updelay_set(struct bonding *bond,
129 struct bond_opt_value *newval); 130 struct bond_opt_value *newval);
131int bond_option_lacp_rate_set(struct bonding *bond,
132 struct bond_opt_value *newval);
130#endif /* _BOND_OPTIONS_H */ 133#endif /* _BOND_OPTIONS_H */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index b873a88c3e2e..a0a54d035c52 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -548,10 +548,11 @@ static ssize_t bonding_show_lacp(struct device *d,
548 char *buf) 548 char *buf)
549{ 549{
550 struct bonding *bond = to_bond(d); 550 struct bonding *bond = to_bond(d);
551 struct bond_opt_value *val;
551 552
552 return sprintf(buf, "%s %d\n", 553 val = bond_opt_get_val(BOND_OPT_LACP_RATE, bond->params.lacp_fast);
553 bond_lacp_tbl[bond->params.lacp_fast].modename, 554
554 bond->params.lacp_fast); 555 return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_fast);
555} 556}
556 557
557static ssize_t bonding_store_lacp(struct device *d, 558static ssize_t bonding_store_lacp(struct device *d,
@@ -559,23 +560,12 @@ static ssize_t bonding_store_lacp(struct device *d,
559 const char *buf, size_t count) 560 const char *buf, size_t count)
560{ 561{
561 struct bonding *bond = to_bond(d); 562 struct bonding *bond = to_bond(d);
562 int new_value, ret; 563 int ret;
563
564 new_value = bond_parse_parm(buf, bond_lacp_tbl);
565 if (new_value < 0) {
566 pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
567 bond->dev->name, (int)strlen(buf) - 1, buf);
568 return -EINVAL;
569 }
570
571 if (!rtnl_trylock())
572 return restart_syscall();
573 564
574 ret = bond_option_lacp_rate_set(bond, new_value); 565 ret = bond_opt_tryset_rtnl(bond, BOND_OPT_LACP_RATE, (char *)buf);
575 if (!ret) 566 if (!ret)
576 ret = count; 567 ret = count;
577 568
578 rtnl_unlock();
579 return ret; 569 return ret;
580} 570}
581static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, 571static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index f2b127060c90..da03ede3e0a5 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -466,7 +466,6 @@ int bond_option_all_slaves_active_set(struct bonding *bond,
466 int all_slaves_active); 466 int all_slaves_active);
467int bond_option_min_links_set(struct bonding *bond, int min_links); 467int bond_option_min_links_set(struct bonding *bond, int min_links);
468int bond_option_lp_interval_set(struct bonding *bond, int min_links); 468int bond_option_lp_interval_set(struct bonding *bond, int min_links);
469int bond_option_lacp_rate_set(struct bonding *bond, int lacp_rate);
470int bond_option_ad_select_set(struct bonding *bond, int ad_select); 469int bond_option_ad_select_set(struct bonding *bond, int ad_select);
471struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); 470struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
472struct net_device *bond_option_active_slave_get(struct bonding *bond); 471struct net_device *bond_option_active_slave_get(struct bonding *bond);