Commit | Line | Data |
---|---|---|
72be35fe JP |
1 | /* |
2 | * drivers/net/bond/bond_options.c - bonding options | |
3 | * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us> | |
eecdaa6e | 4 | * Copyright (c) 2013 Scott Feldman <sfeldma@cumulusnetworks.com> |
72be35fe JP |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | */ | |
11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
13 | ||
14 | #include <linux/errno.h> | |
15 | #include <linux/if.h> | |
d9e32b21 JP |
16 | #include <linux/netdevice.h> |
17 | #include <linux/rwlock.h> | |
18 | #include <linux/rcupdate.h> | |
09117362 | 19 | #include <linux/ctype.h> |
4fb0ef58 | 20 | #include <linux/inet.h> |
72be35fe JP |
21 | #include "bonding.h" |
22 | ||
2b3798d5 NA |
23 | static struct bond_opt_value bond_mode_tbl[] = { |
24 | { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT}, | |
25 | { "active-backup", BOND_MODE_ACTIVEBACKUP, 0}, | |
26 | { "balance-xor", BOND_MODE_XOR, 0}, | |
27 | { "broadcast", BOND_MODE_BROADCAST, 0}, | |
28 | { "802.3ad", BOND_MODE_8023AD, 0}, | |
29 | { "balance-tlb", BOND_MODE_TLB, 0}, | |
30 | { "balance-alb", BOND_MODE_ALB, 0}, | |
31 | { NULL, -1, 0}, | |
32 | }; | |
33 | ||
aa59d851 NA |
34 | static struct bond_opt_value bond_pps_tbl[] = { |
35 | { "default", 1, BOND_VALFLAG_DEFAULT}, | |
36 | { "maxval", USHRT_MAX, BOND_VALFLAG_MAX}, | |
37 | { NULL, -1, 0}, | |
38 | }; | |
39 | ||
a4b32ce7 NA |
40 | static struct bond_opt_value bond_xmit_hashtype_tbl[] = { |
41 | { "layer2", BOND_XMIT_POLICY_LAYER2, BOND_VALFLAG_DEFAULT}, | |
42 | { "layer3+4", BOND_XMIT_POLICY_LAYER34, 0}, | |
43 | { "layer2+3", BOND_XMIT_POLICY_LAYER23, 0}, | |
44 | { "encap2+3", BOND_XMIT_POLICY_ENCAP23, 0}, | |
45 | { "encap3+4", BOND_XMIT_POLICY_ENCAP34, 0}, | |
46 | { NULL, -1, 0}, | |
47 | }; | |
48 | ||
16228881 NA |
49 | static struct bond_opt_value bond_arp_validate_tbl[] = { |
50 | { "none", BOND_ARP_VALIDATE_NONE, BOND_VALFLAG_DEFAULT}, | |
51 | { "active", BOND_ARP_VALIDATE_ACTIVE, 0}, | |
52 | { "backup", BOND_ARP_VALIDATE_BACKUP, 0}, | |
53 | { "all", BOND_ARP_VALIDATE_ALL, 0}, | |
54 | { NULL, -1, 0}, | |
55 | }; | |
56 | ||
edf36b24 NA |
57 | static struct bond_opt_value bond_arp_all_targets_tbl[] = { |
58 | { "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT}, | |
59 | { "all", BOND_ARP_TARGETS_ALL, 0}, | |
60 | { NULL, -1, 0}, | |
61 | }; | |
62 | ||
1df6b6aa NA |
63 | static struct bond_opt_value bond_fail_over_mac_tbl[] = { |
64 | { "none", BOND_FOM_NONE, BOND_VALFLAG_DEFAULT}, | |
65 | { "active", BOND_FOM_ACTIVE, 0}, | |
66 | { "follow", BOND_FOM_FOLLOW, 0}, | |
67 | { NULL, -1, 0}, | |
68 | }; | |
69 | ||
7bdb04ed NA |
70 | static struct bond_opt_value bond_intmax_tbl[] = { |
71 | { "off", 0, BOND_VALFLAG_DEFAULT}, | |
72 | { "maxval", INT_MAX, BOND_VALFLAG_MAX}, | |
73 | }; | |
74 | ||
d3131de7 NA |
75 | static 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 | ||
9e5f5eeb NA |
81 | static 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 | ||
09117362 | 88 | static struct bond_option bond_opts[] = { |
2b3798d5 NA |
89 | [BOND_OPT_MODE] = { |
90 | .id = BOND_OPT_MODE, | |
91 | .name = "mode", | |
92 | .desc = "bond device mode", | |
93 | .flags = BOND_OPTFLAG_NOSLAVES | BOND_OPTFLAG_IFDOWN, | |
94 | .values = bond_mode_tbl, | |
95 | .set = bond_option_mode_set | |
96 | }, | |
aa59d851 NA |
97 | [BOND_OPT_PACKETS_PER_SLAVE] = { |
98 | .id = BOND_OPT_PACKETS_PER_SLAVE, | |
99 | .name = "packets_per_slave", | |
100 | .desc = "Packets to send per slave in RR mode", | |
101 | .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ROUNDROBIN)), | |
102 | .values = bond_pps_tbl, | |
103 | .set = bond_option_pps_set | |
104 | }, | |
a4b32ce7 NA |
105 | [BOND_OPT_XMIT_HASH] = { |
106 | .id = BOND_OPT_XMIT_HASH, | |
107 | .name = "xmit_hash_policy", | |
108 | .desc = "balance-xor and 802.3ad hashing method", | |
109 | .values = bond_xmit_hashtype_tbl, | |
110 | .set = bond_option_xmit_hash_policy_set | |
111 | }, | |
16228881 NA |
112 | [BOND_OPT_ARP_VALIDATE] = { |
113 | .id = BOND_OPT_ARP_VALIDATE, | |
114 | .name = "arp_validate", | |
115 | .desc = "validate src/dst of ARP probes", | |
116 | .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP)), | |
117 | .values = bond_arp_validate_tbl, | |
118 | .set = bond_option_arp_validate_set | |
119 | }, | |
edf36b24 NA |
120 | [BOND_OPT_ARP_ALL_TARGETS] = { |
121 | .id = BOND_OPT_ARP_ALL_TARGETS, | |
122 | .name = "arp_all_targets", | |
123 | .desc = "fail on any/all arp targets timeout", | |
124 | .values = bond_arp_all_targets_tbl, | |
125 | .set = bond_option_arp_all_targets_set | |
126 | }, | |
1df6b6aa NA |
127 | [BOND_OPT_FAIL_OVER_MAC] = { |
128 | .id = BOND_OPT_FAIL_OVER_MAC, | |
129 | .name = "fail_over_mac", | |
130 | .desc = "For active-backup, do not set all slaves to the same MAC", | |
131 | .flags = BOND_OPTFLAG_NOSLAVES, | |
132 | .values = bond_fail_over_mac_tbl, | |
133 | .set = bond_option_fail_over_mac_set | |
134 | }, | |
7bdb04ed NA |
135 | [BOND_OPT_ARP_INTERVAL] = { |
136 | .id = BOND_OPT_ARP_INTERVAL, | |
137 | .name = "arp_interval", | |
138 | .desc = "arp interval in milliseconds", | |
139 | .unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) | | |
140 | BIT(BOND_MODE_ALB), | |
141 | .values = bond_intmax_tbl, | |
142 | .set = bond_option_arp_interval_set | |
143 | }, | |
4fb0ef58 NA |
144 | [BOND_OPT_ARP_TARGETS] = { |
145 | .id = BOND_OPT_ARP_TARGETS, | |
146 | .name = "arp_ip_target", | |
147 | .desc = "arp targets in n.n.n.n form", | |
148 | .flags = BOND_OPTFLAG_RAWVAL, | |
149 | .set = bond_option_arp_ip_targets_set | |
150 | }, | |
25a9b54a NA |
151 | [BOND_OPT_DOWNDELAY] = { |
152 | .id = BOND_OPT_DOWNDELAY, | |
153 | .name = "downdelay", | |
154 | .desc = "Delay before considering link down, in milliseconds", | |
155 | .values = bond_intmax_tbl, | |
156 | .set = bond_option_downdelay_set | |
157 | }, | |
e4994612 NA |
158 | [BOND_OPT_UPDELAY] = { |
159 | .id = BOND_OPT_UPDELAY, | |
160 | .name = "updelay", | |
161 | .desc = "Delay before considering link up, in milliseconds", | |
162 | .values = bond_intmax_tbl, | |
163 | .set = bond_option_updelay_set | |
164 | }, | |
d3131de7 NA |
165 | [BOND_OPT_LACP_RATE] = { |
166 | .id = BOND_OPT_LACP_RATE, | |
167 | .name = "lacp_rate", | |
168 | .desc = "LACPDU tx rate to request from 802.3ad partner", | |
169 | .flags = BOND_OPTFLAG_IFDOWN, | |
170 | .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), | |
171 | .values = bond_lacp_rate_tbl, | |
172 | .set = bond_option_lacp_rate_set | |
173 | }, | |
633ddc9e NA |
174 | [BOND_OPT_MINLINKS] = { |
175 | .id = BOND_OPT_MINLINKS, | |
176 | .name = "min_links", | |
177 | .desc = "Minimum number of available links before turning on carrier", | |
178 | .values = bond_intmax_tbl, | |
179 | .set = bond_option_min_links_set | |
180 | }, | |
9e5f5eeb NA |
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 | }, | |
09117362 NA |
189 | { } |
190 | }; | |
191 | ||
192 | /* Searches for a value in opt's values[] table */ | |
193 | struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val) | |
194 | { | |
195 | struct bond_option *opt; | |
196 | int i; | |
197 | ||
198 | opt = bond_opt_get(option); | |
199 | if (WARN_ON(!opt)) | |
200 | return NULL; | |
201 | for (i = 0; opt->values && opt->values[i].string; i++) | |
202 | if (opt->values[i].value == val) | |
203 | return &opt->values[i]; | |
204 | ||
205 | return NULL; | |
206 | } | |
207 | ||
208 | /* Searches for a value in opt's values[] table which matches the flagmask */ | |
209 | static struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt, | |
210 | u32 flagmask) | |
211 | { | |
212 | int i; | |
213 | ||
214 | for (i = 0; opt->values && opt->values[i].string; i++) | |
215 | if (opt->values[i].flags & flagmask) | |
216 | return &opt->values[i]; | |
217 | ||
218 | return NULL; | |
219 | } | |
220 | ||
221 | /* If maxval is missing then there's no range to check. In case minval is | |
222 | * missing then it's considered to be 0. | |
223 | */ | |
224 | static bool bond_opt_check_range(const struct bond_option *opt, u64 val) | |
225 | { | |
226 | struct bond_opt_value *minval, *maxval; | |
227 | ||
228 | minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN); | |
229 | maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX); | |
230 | if (!maxval || (minval && val < minval->value) || val > maxval->value) | |
231 | return false; | |
232 | ||
233 | return true; | |
234 | } | |
235 | ||
236 | /** | |
237 | * bond_opt_parse - parse option value | |
238 | * @opt: the option to parse against | |
239 | * @val: value to parse | |
240 | * | |
241 | * This function tries to extract the value from @val and check if it's | |
242 | * a possible match for the option and returns NULL if a match isn't found, | |
243 | * or the struct_opt_value that matched. It also strips the new line from | |
244 | * @val->string if it's present. | |
245 | */ | |
246 | struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, | |
247 | struct bond_opt_value *val) | |
248 | { | |
249 | char *p, valstr[BOND_OPT_MAX_NAMELEN + 1] = { 0, }; | |
250 | struct bond_opt_value *tbl, *ret = NULL; | |
251 | bool checkval; | |
252 | int i, rv; | |
253 | ||
254 | /* No parsing if the option wants a raw val */ | |
255 | if (opt->flags & BOND_OPTFLAG_RAWVAL) | |
256 | return val; | |
257 | ||
258 | tbl = opt->values; | |
259 | if (!tbl) | |
260 | goto out; | |
261 | ||
262 | /* ULLONG_MAX is used to bypass string processing */ | |
263 | checkval = val->value != ULLONG_MAX; | |
264 | if (!checkval) { | |
265 | if (!val->string) | |
266 | goto out; | |
267 | p = strchr(val->string, '\n'); | |
268 | if (p) | |
269 | *p = '\0'; | |
270 | for (p = val->string; *p; p++) | |
271 | if (!(isdigit(*p) || isspace(*p))) | |
272 | break; | |
273 | /* The following code extracts the string to match or the value | |
274 | * and sets checkval appropriately | |
275 | */ | |
276 | if (*p) { | |
277 | rv = sscanf(val->string, "%32s", valstr); | |
278 | } else { | |
279 | rv = sscanf(val->string, "%llu", &val->value); | |
280 | checkval = true; | |
281 | } | |
282 | if (!rv) | |
283 | goto out; | |
284 | } | |
285 | ||
286 | for (i = 0; tbl[i].string; i++) { | |
287 | /* Check for exact match */ | |
288 | if (checkval) { | |
289 | if (val->value == tbl[i].value) | |
290 | ret = &tbl[i]; | |
291 | } else { | |
292 | if (!strcmp(valstr, "default") && | |
293 | (tbl[i].flags & BOND_VALFLAG_DEFAULT)) | |
294 | ret = &tbl[i]; | |
295 | ||
296 | if (!strcmp(valstr, tbl[i].string)) | |
297 | ret = &tbl[i]; | |
298 | } | |
299 | /* Found an exact match */ | |
300 | if (ret) | |
301 | goto out; | |
302 | } | |
303 | /* Possible range match */ | |
304 | if (checkval && bond_opt_check_range(opt, val->value)) | |
305 | ret = val; | |
306 | out: | |
307 | return ret; | |
308 | } | |
309 | ||
310 | /* Check opt's dependencies against bond mode and currently set options */ | |
311 | static int bond_opt_check_deps(struct bonding *bond, | |
312 | const struct bond_option *opt) | |
313 | { | |
314 | struct bond_params *params = &bond->params; | |
315 | ||
316 | if (test_bit(params->mode, &opt->unsuppmodes)) | |
317 | return -EACCES; | |
318 | if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond)) | |
319 | return -ENOTEMPTY; | |
320 | if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP)) | |
321 | return -EBUSY; | |
322 | ||
323 | return 0; | |
324 | } | |
325 | ||
326 | static void bond_opt_dep_print(struct bonding *bond, | |
327 | const struct bond_option *opt) | |
328 | { | |
2b3798d5 | 329 | struct bond_opt_value *modeval; |
09117362 NA |
330 | struct bond_params *params; |
331 | ||
332 | params = &bond->params; | |
2b3798d5 | 333 | modeval = bond_opt_get_val(BOND_OPT_MODE, params->mode); |
09117362 | 334 | if (test_bit(params->mode, &opt->unsuppmodes)) |
2b3798d5 NA |
335 | pr_err("%s: option %s: mode dependency failed, not supported in mode %s(%llu)\n", |
336 | bond->dev->name, opt->name, | |
337 | modeval->string, modeval->value); | |
09117362 NA |
338 | } |
339 | ||
340 | static void bond_opt_error_interpret(struct bonding *bond, | |
341 | const struct bond_option *opt, | |
342 | int error, struct bond_opt_value *val) | |
343 | { | |
344 | struct bond_opt_value *minval, *maxval; | |
345 | char *p; | |
346 | ||
347 | switch (error) { | |
348 | case -EINVAL: | |
349 | if (val) { | |
350 | if (val->string) { | |
351 | /* sometimes RAWVAL opts may have new lines */ | |
352 | p = strchr(val->string, '\n'); | |
353 | if (p) | |
354 | *p = '\0'; | |
355 | pr_err("%s: option %s: invalid value (%s).\n", | |
356 | bond->dev->name, opt->name, val->string); | |
357 | } else { | |
358 | pr_err("%s: option %s: invalid value (%llu).\n", | |
359 | bond->dev->name, opt->name, val->value); | |
360 | } | |
361 | } | |
362 | minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN); | |
363 | maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX); | |
364 | if (!maxval) | |
365 | break; | |
366 | pr_err("%s: option %s: allowed values %llu - %llu.\n", | |
367 | bond->dev->name, opt->name, minval ? minval->value : 0, | |
368 | maxval->value); | |
369 | break; | |
370 | case -EACCES: | |
371 | bond_opt_dep_print(bond, opt); | |
372 | break; | |
373 | case -ENOTEMPTY: | |
374 | pr_err("%s: option %s: unable to set because the bond device has slaves.\n", | |
375 | bond->dev->name, opt->name); | |
376 | break; | |
377 | case -EBUSY: | |
378 | pr_err("%s: option %s: unable to set because the bond device is up.\n", | |
379 | bond->dev->name, opt->name); | |
380 | break; | |
381 | default: | |
382 | break; | |
383 | } | |
384 | } | |
385 | ||
386 | /** | |
387 | * __bond_opt_set - set a bonding option | |
388 | * @bond: target bond device | |
389 | * @option: option to set | |
390 | * @val: value to set it to | |
391 | * | |
392 | * This function is used to change the bond's option value, it can be | |
393 | * used for both enabling/changing an option and for disabling it. RTNL lock | |
394 | * must be obtained before calling this function. | |
395 | */ | |
396 | int __bond_opt_set(struct bonding *bond, | |
397 | unsigned int option, struct bond_opt_value *val) | |
398 | { | |
399 | struct bond_opt_value *retval = NULL; | |
400 | const struct bond_option *opt; | |
401 | int ret = -ENOENT; | |
402 | ||
403 | ASSERT_RTNL(); | |
404 | ||
405 | opt = bond_opt_get(option); | |
406 | if (WARN_ON(!val) || WARN_ON(!opt)) | |
407 | goto out; | |
408 | ret = bond_opt_check_deps(bond, opt); | |
409 | if (ret) | |
410 | goto out; | |
411 | retval = bond_opt_parse(opt, val); | |
412 | if (!retval) { | |
413 | ret = -EINVAL; | |
414 | goto out; | |
415 | } | |
416 | ret = opt->set(bond, retval); | |
417 | out: | |
418 | if (ret) | |
419 | bond_opt_error_interpret(bond, opt, ret, val); | |
420 | ||
421 | return ret; | |
422 | } | |
423 | ||
424 | /** | |
425 | * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set | |
426 | * @bond: target bond device | |
427 | * @option: option to set | |
428 | * @buf: value to set it to | |
429 | * | |
430 | * This function tries to acquire RTNL without blocking and if successful | |
431 | * calls __bond_opt_set. It is mainly used for sysfs option manipulation. | |
432 | */ | |
433 | int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf) | |
434 | { | |
435 | struct bond_opt_value optval; | |
436 | int ret; | |
437 | ||
438 | if (!rtnl_trylock()) | |
439 | return restart_syscall(); | |
440 | bond_opt_initstr(&optval, buf); | |
441 | ret = __bond_opt_set(bond, option, &optval); | |
442 | rtnl_unlock(); | |
443 | ||
444 | return ret; | |
445 | } | |
446 | ||
447 | /** | |
448 | * bond_opt_get - get a pointer to an option | |
449 | * @option: option for which to return a pointer | |
450 | * | |
451 | * This function checks if option is valid and if so returns a pointer | |
452 | * to its entry in the bond_opts[] option array. | |
453 | */ | |
454 | struct bond_option *bond_opt_get(unsigned int option) | |
455 | { | |
456 | if (!BOND_OPT_VALID(option)) | |
457 | return NULL; | |
458 | ||
459 | return &bond_opts[option]; | |
460 | } | |
461 | ||
2b3798d5 | 462 | int bond_option_mode_set(struct bonding *bond, struct bond_opt_value *newval) |
72be35fe | 463 | { |
2b3798d5 | 464 | if (BOND_NO_USES_ARP(newval->value) && bond->params.arp_interval) { |
fe9d04af | 465 | pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n", |
2b3798d5 | 466 | bond->dev->name, newval->string); |
fe9d04af | 467 | /* disable arp monitoring */ |
468 | bond->params.arp_interval = 0; | |
469 | /* set miimon to default value */ | |
470 | bond->params.miimon = BOND_DEFAULT_MIIMON; | |
471 | pr_info("%s: Setting MII monitoring interval to %d.\n", | |
472 | bond->dev->name, bond->params.miimon); | |
72be35fe JP |
473 | } |
474 | ||
475 | /* don't cache arp_validate between modes */ | |
476 | bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; | |
2b3798d5 NA |
477 | bond->params.mode = newval->value; |
478 | ||
72be35fe JP |
479 | return 0; |
480 | } | |
d9e32b21 | 481 | |
752d48b5 JP |
482 | static struct net_device *__bond_option_active_slave_get(struct bonding *bond, |
483 | struct slave *slave) | |
484 | { | |
485 | return USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL; | |
486 | } | |
487 | ||
488 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) | |
489 | { | |
490 | struct slave *slave = rcu_dereference(bond->curr_active_slave); | |
491 | ||
492 | return __bond_option_active_slave_get(bond, slave); | |
493 | } | |
494 | ||
495 | struct net_device *bond_option_active_slave_get(struct bonding *bond) | |
496 | { | |
497 | return __bond_option_active_slave_get(bond, bond->curr_active_slave); | |
498 | } | |
499 | ||
d9e32b21 JP |
500 | int bond_option_active_slave_set(struct bonding *bond, |
501 | struct net_device *slave_dev) | |
502 | { | |
503 | int ret = 0; | |
504 | ||
505 | if (slave_dev) { | |
506 | if (!netif_is_bond_slave(slave_dev)) { | |
507 | pr_err("Device %s is not bonding slave.\n", | |
508 | slave_dev->name); | |
509 | return -EINVAL; | |
510 | } | |
511 | ||
512 | if (bond->dev != netdev_master_upper_dev_get(slave_dev)) { | |
513 | pr_err("%s: Device %s is not our slave.\n", | |
514 | bond->dev->name, slave_dev->name); | |
515 | return -EINVAL; | |
516 | } | |
517 | } | |
518 | ||
519 | if (!USES_PRIMARY(bond->params.mode)) { | |
520 | pr_err("%s: Unable to change active slave; %s is in mode %d\n", | |
521 | bond->dev->name, bond->dev->name, bond->params.mode); | |
522 | return -EINVAL; | |
523 | } | |
524 | ||
525 | block_netpoll_tx(); | |
d9e32b21 JP |
526 | write_lock_bh(&bond->curr_slave_lock); |
527 | ||
528 | /* check to see if we are clearing active */ | |
529 | if (!slave_dev) { | |
530 | pr_info("%s: Clearing current active slave.\n", | |
531 | bond->dev->name); | |
532 | rcu_assign_pointer(bond->curr_active_slave, NULL); | |
533 | bond_select_active_slave(bond); | |
534 | } else { | |
535 | struct slave *old_active = bond->curr_active_slave; | |
536 | struct slave *new_active = bond_slave_get_rtnl(slave_dev); | |
537 | ||
538 | BUG_ON(!new_active); | |
539 | ||
540 | if (new_active == old_active) { | |
541 | /* do nothing */ | |
542 | pr_info("%s: %s is already the current active slave.\n", | |
543 | bond->dev->name, new_active->dev->name); | |
544 | } else { | |
545 | if (old_active && (new_active->link == BOND_LINK_UP) && | |
546 | IS_UP(new_active->dev)) { | |
547 | pr_info("%s: Setting %s as active slave.\n", | |
548 | bond->dev->name, new_active->dev->name); | |
549 | bond_change_active_slave(bond, new_active); | |
550 | } else { | |
551 | pr_err("%s: Could not set %s as active slave; either %s is down or the link is down.\n", | |
552 | bond->dev->name, new_active->dev->name, | |
553 | new_active->dev->name); | |
554 | ret = -EINVAL; | |
555 | } | |
556 | } | |
557 | } | |
558 | ||
559 | write_unlock_bh(&bond->curr_slave_lock); | |
d9e32b21 JP |
560 | unblock_netpoll_tx(); |
561 | return ret; | |
562 | } | |
eecdaa6e | 563 | |
564 | int bond_option_miimon_set(struct bonding *bond, int miimon) | |
565 | { | |
566 | if (miimon < 0) { | |
567 | pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n", | |
568 | bond->dev->name, miimon, 0, INT_MAX); | |
569 | return -EINVAL; | |
570 | } | |
571 | pr_info("%s: Setting MII monitoring interval to %d.\n", | |
572 | bond->dev->name, miimon); | |
573 | bond->params.miimon = miimon; | |
574 | if (bond->params.updelay) | |
575 | pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n", | |
576 | bond->dev->name, | |
577 | bond->params.updelay * bond->params.miimon); | |
578 | if (bond->params.downdelay) | |
579 | pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n", | |
580 | bond->dev->name, | |
581 | bond->params.downdelay * bond->params.miimon); | |
582 | if (miimon && bond->params.arp_interval) { | |
583 | pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", | |
584 | bond->dev->name); | |
585 | bond->params.arp_interval = 0; | |
586 | if (bond->params.arp_validate) | |
587 | bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; | |
588 | } | |
589 | if (bond->dev->flags & IFF_UP) { | |
590 | /* If the interface is up, we may need to fire off | |
591 | * the MII timer. If the interface is down, the | |
592 | * timer will get fired off when the open function | |
593 | * is called. | |
594 | */ | |
595 | if (!miimon) { | |
596 | cancel_delayed_work_sync(&bond->mii_work); | |
597 | } else { | |
598 | cancel_delayed_work_sync(&bond->arp_work); | |
599 | queue_delayed_work(bond->wq, &bond->mii_work, 0); | |
600 | } | |
601 | } | |
602 | return 0; | |
603 | } | |
25852e29 | 604 | |
e4994612 | 605 | int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval) |
25852e29 | 606 | { |
e4994612 | 607 | if (!bond->params.miimon) { |
25852e29 | 608 | pr_err("%s: Unable to set up delay as MII monitoring is disabled\n", |
609 | bond->dev->name); | |
610 | return -EPERM; | |
611 | } | |
e4994612 NA |
612 | if ((newval->value % bond->params.miimon) != 0) { |
613 | pr_warn("%s: Warning: up delay (%llu) is not a multiple of miimon (%d), updelay rounded to %llu ms\n", | |
614 | bond->dev->name, newval->value, | |
615 | bond->params.miimon, | |
616 | (newval->value / bond->params.miimon) * | |
617 | bond->params.miimon); | |
25852e29 | 618 | } |
e4994612 NA |
619 | bond->params.updelay = newval->value / bond->params.miimon; |
620 | pr_info("%s: Setting up delay to %d.\n", | |
621 | bond->dev->name, | |
622 | bond->params.updelay * bond->params.miimon); | |
25852e29 | 623 | |
624 | return 0; | |
625 | } | |
c7461f9b | 626 | |
25a9b54a NA |
627 | int bond_option_downdelay_set(struct bonding *bond, |
628 | struct bond_opt_value *newval) | |
c7461f9b | 629 | { |
25a9b54a | 630 | if (!bond->params.miimon) { |
c7461f9b | 631 | pr_err("%s: Unable to set down delay as MII monitoring is disabled\n", |
632 | bond->dev->name); | |
633 | return -EPERM; | |
634 | } | |
25a9b54a NA |
635 | if ((newval->value % bond->params.miimon) != 0) { |
636 | pr_warn("%s: Warning: down delay (%llu) is not a multiple of miimon (%d), delay rounded to %llu ms\n", | |
637 | bond->dev->name, newval->value, | |
638 | bond->params.miimon, | |
639 | (newval->value / bond->params.miimon) * | |
640 | bond->params.miimon); | |
c7461f9b | 641 | } |
25a9b54a NA |
642 | bond->params.downdelay = newval->value / bond->params.miimon; |
643 | pr_info("%s: Setting down delay to %d.\n", | |
644 | bond->dev->name, | |
645 | bond->params.downdelay * bond->params.miimon); | |
c7461f9b | 646 | |
647 | return 0; | |
648 | } | |
9f53e14e | 649 | |
650 | int bond_option_use_carrier_set(struct bonding *bond, int use_carrier) | |
651 | { | |
652 | if ((use_carrier == 0) || (use_carrier == 1)) { | |
653 | bond->params.use_carrier = use_carrier; | |
654 | pr_info("%s: Setting use_carrier to %d.\n", | |
655 | bond->dev->name, use_carrier); | |
656 | } else { | |
657 | pr_info("%s: Ignoring invalid use_carrier value %d.\n", | |
658 | bond->dev->name, use_carrier); | |
659 | } | |
660 | ||
661 | return 0; | |
662 | } | |
06151dbc | 663 | |
7bdb04ed NA |
664 | int bond_option_arp_interval_set(struct bonding *bond, |
665 | struct bond_opt_value *newval) | |
06151dbc | 666 | { |
7bdb04ed NA |
667 | pr_info("%s: Setting ARP monitoring interval to %llu.\n", |
668 | bond->dev->name, newval->value); | |
669 | bond->params.arp_interval = newval->value; | |
670 | if (newval->value) { | |
06151dbc | 671 | if (bond->params.miimon) { |
672 | pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", | |
673 | bond->dev->name, bond->dev->name); | |
674 | bond->params.miimon = 0; | |
675 | } | |
676 | if (!bond->params.arp_targets[0]) | |
677 | pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", | |
678 | bond->dev->name); | |
679 | } | |
680 | if (bond->dev->flags & IFF_UP) { | |
681 | /* If the interface is up, we may need to fire off | |
682 | * the ARP timer. If the interface is down, the | |
683 | * timer will get fired off when the open function | |
684 | * is called. | |
685 | */ | |
7bdb04ed | 686 | if (!newval->value) { |
06151dbc | 687 | if (bond->params.arp_validate) |
688 | bond->recv_probe = NULL; | |
689 | cancel_delayed_work_sync(&bond->arp_work); | |
690 | } else { | |
691 | /* arp_validate can be set only in active-backup mode */ | |
692 | if (bond->params.arp_validate) | |
693 | bond->recv_probe = bond_arp_rcv; | |
694 | cancel_delayed_work_sync(&bond->mii_work); | |
695 | queue_delayed_work(bond->wq, &bond->arp_work, 0); | |
696 | } | |
697 | } | |
698 | ||
699 | return 0; | |
700 | } | |
7f28fa10 | 701 | |
702 | static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, | |
703 | __be32 target, | |
704 | unsigned long last_rx) | |
705 | { | |
706 | __be32 *targets = bond->params.arp_targets; | |
707 | struct list_head *iter; | |
708 | struct slave *slave; | |
709 | ||
710 | if (slot >= 0 && slot < BOND_MAX_ARP_TARGETS) { | |
711 | bond_for_each_slave(bond, slave, iter) | |
712 | slave->target_last_arp_rx[slot] = last_rx; | |
713 | targets[slot] = target; | |
714 | } | |
715 | } | |
716 | ||
717 | static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) | |
718 | { | |
719 | __be32 *targets = bond->params.arp_targets; | |
720 | int ind; | |
721 | ||
722 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | |
723 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", | |
724 | bond->dev->name, &target); | |
725 | return -EINVAL; | |
726 | } | |
727 | ||
728 | if (bond_get_targets_ip(targets, target) != -1) { /* dup */ | |
729 | pr_err("%s: ARP target %pI4 is already present\n", | |
730 | bond->dev->name, &target); | |
731 | return -EINVAL; | |
732 | } | |
733 | ||
734 | ind = bond_get_targets_ip(targets, 0); /* first free slot */ | |
735 | if (ind == -1) { | |
736 | pr_err("%s: ARP target table is full!\n", | |
737 | bond->dev->name); | |
738 | return -EINVAL; | |
739 | } | |
740 | ||
741 | pr_info("%s: adding ARP target %pI4.\n", bond->dev->name, &target); | |
742 | ||
743 | _bond_options_arp_ip_target_set(bond, ind, target, jiffies); | |
744 | ||
745 | return 0; | |
746 | } | |
747 | ||
748 | int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) | |
749 | { | |
750 | int ret; | |
751 | ||
752 | /* not to race with bond_arp_rcv */ | |
753 | write_lock_bh(&bond->lock); | |
754 | ret = _bond_option_arp_ip_target_add(bond, target); | |
755 | write_unlock_bh(&bond->lock); | |
756 | ||
757 | return ret; | |
758 | } | |
759 | ||
760 | int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) | |
761 | { | |
762 | __be32 *targets = bond->params.arp_targets; | |
763 | struct list_head *iter; | |
764 | struct slave *slave; | |
765 | unsigned long *targets_rx; | |
766 | int ind, i; | |
767 | ||
768 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | |
769 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", | |
770 | bond->dev->name, &target); | |
771 | return -EINVAL; | |
772 | } | |
773 | ||
774 | ind = bond_get_targets_ip(targets, target); | |
775 | if (ind == -1) { | |
776 | pr_err("%s: unable to remove nonexistent ARP target %pI4.\n", | |
777 | bond->dev->name, &target); | |
778 | return -EINVAL; | |
779 | } | |
780 | ||
781 | if (ind == 0 && !targets[1] && bond->params.arp_interval) | |
782 | pr_warn("%s: removing last arp target with arp_interval on\n", | |
783 | bond->dev->name); | |
784 | ||
785 | pr_info("%s: removing ARP target %pI4.\n", bond->dev->name, | |
786 | &target); | |
787 | ||
788 | /* not to race with bond_arp_rcv */ | |
789 | write_lock_bh(&bond->lock); | |
790 | ||
791 | bond_for_each_slave(bond, slave, iter) { | |
792 | targets_rx = slave->target_last_arp_rx; | |
793 | for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) | |
794 | targets_rx[i] = targets_rx[i+1]; | |
795 | targets_rx[i] = 0; | |
796 | } | |
797 | for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) | |
798 | targets[i] = targets[i+1]; | |
799 | targets[i] = 0; | |
800 | ||
801 | write_unlock_bh(&bond->lock); | |
802 | ||
803 | return 0; | |
804 | } | |
805 | ||
4fb0ef58 | 806 | void bond_option_arp_ip_targets_clear(struct bonding *bond) |
7f28fa10 | 807 | { |
4fb0ef58 | 808 | int i; |
7f28fa10 | 809 | |
810 | /* not to race with bond_arp_rcv */ | |
811 | write_lock_bh(&bond->lock); | |
7f28fa10 | 812 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) |
813 | _bond_options_arp_ip_target_set(bond, i, 0, 0); | |
4fb0ef58 NA |
814 | write_unlock_bh(&bond->lock); |
815 | } | |
7f28fa10 | 816 | |
4fb0ef58 NA |
817 | int bond_option_arp_ip_targets_set(struct bonding *bond, |
818 | struct bond_opt_value *newval) | |
819 | { | |
820 | int ret = -EPERM; | |
821 | __be32 target; | |
822 | ||
823 | if (newval->string) { | |
824 | if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) { | |
825 | pr_err("%s: invalid ARP target %pI4 specified\n", | |
826 | bond->dev->name, &target); | |
827 | return ret; | |
828 | } | |
829 | if (newval->string[0] == '+') | |
830 | ret = bond_option_arp_ip_target_add(bond, target); | |
831 | else if (newval->string[0] == '-') | |
832 | ret = bond_option_arp_ip_target_rem(bond, target); | |
833 | else | |
834 | pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", | |
835 | bond->dev->name); | |
836 | } else { | |
837 | target = newval->value; | |
838 | ret = bond_option_arp_ip_target_add(bond, target); | |
7f28fa10 | 839 | } |
840 | ||
7f28fa10 | 841 | return ret; |
842 | } | |
29c49482 | 843 | |
16228881 NA |
844 | int bond_option_arp_validate_set(struct bonding *bond, |
845 | struct bond_opt_value *newval) | |
29c49482 | 846 | { |
16228881 NA |
847 | pr_info("%s: setting arp_validate to %s (%llu).\n", |
848 | bond->dev->name, newval->string, newval->value); | |
29c49482 | 849 | |
850 | if (bond->dev->flags & IFF_UP) { | |
16228881 | 851 | if (!newval->value) |
29c49482 | 852 | bond->recv_probe = NULL; |
853 | else if (bond->params.arp_interval) | |
854 | bond->recv_probe = bond_arp_rcv; | |
855 | } | |
16228881 | 856 | bond->params.arp_validate = newval->value; |
29c49482 | 857 | |
858 | return 0; | |
859 | } | |
d5c84254 | 860 | |
edf36b24 NA |
861 | int bond_option_arp_all_targets_set(struct bonding *bond, |
862 | struct bond_opt_value *newval) | |
d5c84254 | 863 | { |
edf36b24 NA |
864 | pr_info("%s: setting arp_all_targets to %s (%llu).\n", |
865 | bond->dev->name, newval->string, newval->value); | |
866 | bond->params.arp_all_targets = newval->value; | |
d5c84254 | 867 | |
868 | return 0; | |
869 | } | |
0a98a0d1 | 870 | |
871 | int bond_option_primary_set(struct bonding *bond, const char *primary) | |
872 | { | |
873 | struct list_head *iter; | |
874 | struct slave *slave; | |
875 | int err = 0; | |
876 | ||
877 | block_netpoll_tx(); | |
878 | read_lock(&bond->lock); | |
879 | write_lock_bh(&bond->curr_slave_lock); | |
880 | ||
881 | if (!USES_PRIMARY(bond->params.mode)) { | |
882 | pr_err("%s: Unable to set primary slave; %s is in mode %d\n", | |
883 | bond->dev->name, bond->dev->name, bond->params.mode); | |
884 | err = -EINVAL; | |
885 | goto out; | |
886 | } | |
887 | ||
888 | /* check to see if we are clearing primary */ | |
889 | if (!strlen(primary)) { | |
890 | pr_info("%s: Setting primary slave to None.\n", | |
891 | bond->dev->name); | |
892 | bond->primary_slave = NULL; | |
893 | memset(bond->params.primary, 0, sizeof(bond->params.primary)); | |
894 | bond_select_active_slave(bond); | |
895 | goto out; | |
896 | } | |
897 | ||
898 | bond_for_each_slave(bond, slave, iter) { | |
899 | if (strncmp(slave->dev->name, primary, IFNAMSIZ) == 0) { | |
900 | pr_info("%s: Setting %s as primary slave.\n", | |
901 | bond->dev->name, slave->dev->name); | |
902 | bond->primary_slave = slave; | |
903 | strcpy(bond->params.primary, slave->dev->name); | |
904 | bond_select_active_slave(bond); | |
905 | goto out; | |
906 | } | |
907 | } | |
908 | ||
909 | strncpy(bond->params.primary, primary, IFNAMSIZ); | |
910 | bond->params.primary[IFNAMSIZ - 1] = 0; | |
911 | ||
912 | pr_info("%s: Recording %s as primary, but it has not been enslaved to %s yet.\n", | |
913 | bond->dev->name, primary, bond->dev->name); | |
914 | ||
915 | out: | |
916 | write_unlock_bh(&bond->curr_slave_lock); | |
917 | read_unlock(&bond->lock); | |
918 | unblock_netpoll_tx(); | |
919 | ||
920 | return err; | |
921 | } | |
8a41ae44 | 922 | |
923 | int bond_option_primary_reselect_set(struct bonding *bond, int primary_reselect) | |
924 | { | |
3243c47b | 925 | if (bond_parm_tbl_lookup(primary_reselect, pri_reselect_tbl) < 0) { |
926 | pr_err("%s: Ignoring invalid primary_reselect value %d.\n", | |
927 | bond->dev->name, primary_reselect); | |
928 | return -EINVAL; | |
929 | } | |
930 | ||
8a41ae44 | 931 | bond->params.primary_reselect = primary_reselect; |
932 | pr_info("%s: setting primary_reselect to %s (%d).\n", | |
933 | bond->dev->name, pri_reselect_tbl[primary_reselect].modename, | |
934 | primary_reselect); | |
935 | ||
936 | block_netpoll_tx(); | |
937 | write_lock_bh(&bond->curr_slave_lock); | |
938 | bond_select_active_slave(bond); | |
939 | write_unlock_bh(&bond->curr_slave_lock); | |
940 | unblock_netpoll_tx(); | |
941 | ||
942 | return 0; | |
943 | } | |
89901972 | 944 | |
1df6b6aa NA |
945 | int bond_option_fail_over_mac_set(struct bonding *bond, |
946 | struct bond_opt_value *newval) | |
89901972 | 947 | { |
1df6b6aa NA |
948 | pr_info("%s: Setting fail_over_mac to %s (%llu).\n", |
949 | bond->dev->name, newval->string, newval->value); | |
950 | bond->params.fail_over_mac = newval->value; | |
89901972 | 951 | |
952 | return 0; | |
953 | } | |
f70161c6 | 954 | |
a4b32ce7 NA |
955 | int bond_option_xmit_hash_policy_set(struct bonding *bond, |
956 | struct bond_opt_value *newval) | |
f70161c6 | 957 | { |
a4b32ce7 NA |
958 | pr_info("%s: setting xmit hash policy to %s (%llu).\n", |
959 | bond->dev->name, newval->string, newval->value); | |
960 | bond->params.xmit_policy = newval->value; | |
f70161c6 | 961 | |
962 | return 0; | |
963 | } | |
d8838de7 | 964 | |
965 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp) | |
966 | { | |
967 | if (resend_igmp < 0 || resend_igmp > 255) { | |
968 | pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n", | |
969 | bond->dev->name, resend_igmp); | |
970 | return -EINVAL; | |
971 | } | |
972 | ||
973 | bond->params.resend_igmp = resend_igmp; | |
974 | pr_info("%s: Setting resend_igmp to %d.\n", | |
975 | bond->dev->name, resend_igmp); | |
976 | ||
977 | return 0; | |
978 | } | |
2c9839c1 | 979 | |
980 | int bond_option_num_peer_notif_set(struct bonding *bond, int num_peer_notif) | |
981 | { | |
982 | bond->params.num_peer_notif = num_peer_notif; | |
983 | return 0; | |
984 | } | |
1cc0b1e3 | 985 | |
986 | int bond_option_all_slaves_active_set(struct bonding *bond, | |
987 | int all_slaves_active) | |
988 | { | |
989 | struct list_head *iter; | |
990 | struct slave *slave; | |
991 | ||
992 | if (all_slaves_active == bond->params.all_slaves_active) | |
993 | return 0; | |
994 | ||
995 | if ((all_slaves_active == 0) || (all_slaves_active == 1)) { | |
996 | bond->params.all_slaves_active = all_slaves_active; | |
997 | } else { | |
998 | pr_info("%s: Ignoring invalid all_slaves_active value %d.\n", | |
999 | bond->dev->name, all_slaves_active); | |
1000 | return -EINVAL; | |
1001 | } | |
1002 | ||
1003 | bond_for_each_slave(bond, slave, iter) { | |
1004 | if (!bond_is_active_slave(slave)) { | |
1005 | if (all_slaves_active) | |
1006 | slave->inactive = 0; | |
1007 | else | |
1008 | slave->inactive = 1; | |
1009 | } | |
1010 | } | |
1011 | ||
1012 | return 0; | |
1013 | } | |
7d101008 | 1014 | |
633ddc9e NA |
1015 | int bond_option_min_links_set(struct bonding *bond, |
1016 | struct bond_opt_value *newval) | |
7d101008 | 1017 | { |
633ddc9e NA |
1018 | pr_info("%s: Setting min links value to %llu\n", |
1019 | bond->dev->name, newval->value); | |
1020 | bond->params.min_links = newval->value; | |
7d101008 | 1021 | |
1022 | return 0; | |
1023 | } | |
8d836d09 | 1024 | |
1025 | int bond_option_lp_interval_set(struct bonding *bond, int lp_interval) | |
1026 | { | |
1027 | if (lp_interval <= 0) { | |
1028 | pr_err("%s: lp_interval must be between 1 and %d\n", | |
1029 | bond->dev->name, INT_MAX); | |
1030 | return -EINVAL; | |
1031 | } | |
1032 | ||
1033 | bond->params.lp_interval = lp_interval; | |
1034 | ||
1035 | return 0; | |
1036 | } | |
c13ab3ff | 1037 | |
aa59d851 | 1038 | int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval) |
c13ab3ff | 1039 | { |
aa59d851 NA |
1040 | bond->params.packets_per_slave = newval->value; |
1041 | if (newval->value > 0) { | |
809fa972 | 1042 | bond->params.reciprocal_packets_per_slave = |
aa59d851 | 1043 | reciprocal_value(newval->value); |
809fa972 HFS |
1044 | } else { |
1045 | /* reciprocal_packets_per_slave is unused if | |
1046 | * packets_per_slave is 0 or 1, just initialize it | |
1047 | */ | |
1048 | bond->params.reciprocal_packets_per_slave = | |
1049 | (struct reciprocal_value) { 0 }; | |
1050 | } | |
c13ab3ff | 1051 | |
1052 | return 0; | |
1053 | } | |
998e40bb | 1054 | |
d3131de7 NA |
1055 | int bond_option_lacp_rate_set(struct bonding *bond, |
1056 | struct bond_opt_value *newval) | |
998e40bb | 1057 | { |
d3131de7 NA |
1058 | pr_info("%s: Setting LACP rate to %s (%llu).\n", |
1059 | bond->dev->name, newval->string, newval->value); | |
1060 | bond->params.lacp_fast = newval->value; | |
3243c47b | 1061 | bond_3ad_update_lacp_rate(bond); |
998e40bb | 1062 | |
1063 | return 0; | |
1064 | } | |
ec029fac | 1065 | |
9e5f5eeb NA |
1066 | int bond_option_ad_select_set(struct bonding *bond, |
1067 | struct bond_opt_value *newval) | |
ec029fac | 1068 | { |
9e5f5eeb NA |
1069 | pr_info("%s: Setting ad_select to %s (%llu).\n", |
1070 | bond->dev->name, newval->string, newval->value); | |
1071 | bond->params.ad_select = newval->value; | |
ec029fac | 1072 | |
1073 | return 0; | |
1074 | } |