1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/net/bond/bond_options.c - bonding options
4 * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us>
5 * Copyright (c) 2013 Scott Feldman <sfeldma@cumulusnetworks.com>
8 #include <linux/errno.h>
10 #include <linux/netdevice.h>
11 #include <linux/spinlock.h>
12 #include <linux/rcupdate.h>
13 #include <linux/ctype.h>
14 #include <linux/inet.h>
15 #include <linux/sched/signal.h>
17 #include <net/bonding.h>
19 static int bond_option_active_slave_set(struct bonding
*bond
,
20 const struct bond_opt_value
*newval
);
21 static int bond_option_miimon_set(struct bonding
*bond
,
22 const struct bond_opt_value
*newval
);
23 static int bond_option_updelay_set(struct bonding
*bond
,
24 const struct bond_opt_value
*newval
);
25 static int bond_option_downdelay_set(struct bonding
*bond
,
26 const struct bond_opt_value
*newval
);
27 static int bond_option_use_carrier_set(struct bonding
*bond
,
28 const struct bond_opt_value
*newval
);
29 static int bond_option_arp_interval_set(struct bonding
*bond
,
30 const struct bond_opt_value
*newval
);
31 static int bond_option_arp_ip_target_add(struct bonding
*bond
, __be32 target
);
32 static int bond_option_arp_ip_target_rem(struct bonding
*bond
, __be32 target
);
33 static int bond_option_arp_ip_targets_set(struct bonding
*bond
,
34 const struct bond_opt_value
*newval
);
35 static int bond_option_arp_validate_set(struct bonding
*bond
,
36 const struct bond_opt_value
*newval
);
37 static int bond_option_arp_all_targets_set(struct bonding
*bond
,
38 const struct bond_opt_value
*newval
);
39 static int bond_option_primary_set(struct bonding
*bond
,
40 const struct bond_opt_value
*newval
);
41 static int bond_option_primary_reselect_set(struct bonding
*bond
,
42 const struct bond_opt_value
*newval
);
43 static int bond_option_fail_over_mac_set(struct bonding
*bond
,
44 const struct bond_opt_value
*newval
);
45 static int bond_option_xmit_hash_policy_set(struct bonding
*bond
,
46 const struct bond_opt_value
*newval
);
47 static int bond_option_resend_igmp_set(struct bonding
*bond
,
48 const struct bond_opt_value
*newval
);
49 static int bond_option_num_peer_notif_set(struct bonding
*bond
,
50 const struct bond_opt_value
*newval
);
51 static int bond_option_all_slaves_active_set(struct bonding
*bond
,
52 const struct bond_opt_value
*newval
);
53 static int bond_option_min_links_set(struct bonding
*bond
,
54 const struct bond_opt_value
*newval
);
55 static int bond_option_lp_interval_set(struct bonding
*bond
,
56 const struct bond_opt_value
*newval
);
57 static int bond_option_pps_set(struct bonding
*bond
,
58 const struct bond_opt_value
*newval
);
59 static int bond_option_lacp_rate_set(struct bonding
*bond
,
60 const struct bond_opt_value
*newval
);
61 static int bond_option_ad_select_set(struct bonding
*bond
,
62 const struct bond_opt_value
*newval
);
63 static int bond_option_queue_id_set(struct bonding
*bond
,
64 const struct bond_opt_value
*newval
);
65 static int bond_option_mode_set(struct bonding
*bond
,
66 const struct bond_opt_value
*newval
);
67 static int bond_option_slaves_set(struct bonding
*bond
,
68 const struct bond_opt_value
*newval
);
69 static int bond_option_tlb_dynamic_lb_set(struct bonding
*bond
,
70 const struct bond_opt_value
*newval
);
71 static int bond_option_ad_actor_sys_prio_set(struct bonding
*bond
,
72 const struct bond_opt_value
*newval
);
73 static int bond_option_ad_actor_system_set(struct bonding
*bond
,
74 const struct bond_opt_value
*newval
);
75 static int bond_option_ad_user_port_key_set(struct bonding
*bond
,
76 const struct bond_opt_value
*newval
);
79 static const struct bond_opt_value bond_mode_tbl
[] = {
80 { "balance-rr", BOND_MODE_ROUNDROBIN
, BOND_VALFLAG_DEFAULT
},
81 { "active-backup", BOND_MODE_ACTIVEBACKUP
, 0},
82 { "balance-xor", BOND_MODE_XOR
, 0},
83 { "broadcast", BOND_MODE_BROADCAST
, 0},
84 { "802.3ad", BOND_MODE_8023AD
, 0},
85 { "balance-tlb", BOND_MODE_TLB
, 0},
86 { "balance-alb", BOND_MODE_ALB
, 0},
90 static const struct bond_opt_value bond_pps_tbl
[] = {
91 { "default", 1, BOND_VALFLAG_DEFAULT
},
92 { "maxval", USHRT_MAX
, BOND_VALFLAG_MAX
},
96 static const struct bond_opt_value bond_xmit_hashtype_tbl
[] = {
97 { "layer2", BOND_XMIT_POLICY_LAYER2
, BOND_VALFLAG_DEFAULT
},
98 { "layer3+4", BOND_XMIT_POLICY_LAYER34
, 0},
99 { "layer2+3", BOND_XMIT_POLICY_LAYER23
, 0},
100 { "encap2+3", BOND_XMIT_POLICY_ENCAP23
, 0},
101 { "encap3+4", BOND_XMIT_POLICY_ENCAP34
, 0},
105 static const struct bond_opt_value bond_arp_validate_tbl
[] = {
106 { "none", BOND_ARP_VALIDATE_NONE
, BOND_VALFLAG_DEFAULT
},
107 { "active", BOND_ARP_VALIDATE_ACTIVE
, 0},
108 { "backup", BOND_ARP_VALIDATE_BACKUP
, 0},
109 { "all", BOND_ARP_VALIDATE_ALL
, 0},
110 { "filter", BOND_ARP_FILTER
, 0},
111 { "filter_active", BOND_ARP_FILTER_ACTIVE
, 0},
112 { "filter_backup", BOND_ARP_FILTER_BACKUP
, 0},
116 static const struct bond_opt_value bond_arp_all_targets_tbl
[] = {
117 { "any", BOND_ARP_TARGETS_ANY
, BOND_VALFLAG_DEFAULT
},
118 { "all", BOND_ARP_TARGETS_ALL
, 0},
122 static const struct bond_opt_value bond_fail_over_mac_tbl
[] = {
123 { "none", BOND_FOM_NONE
, BOND_VALFLAG_DEFAULT
},
124 { "active", BOND_FOM_ACTIVE
, 0},
125 { "follow", BOND_FOM_FOLLOW
, 0},
129 static const struct bond_opt_value bond_intmax_tbl
[] = {
130 { "off", 0, BOND_VALFLAG_DEFAULT
},
131 { "maxval", INT_MAX
, BOND_VALFLAG_MAX
},
135 static const struct bond_opt_value bond_lacp_rate_tbl
[] = {
136 { "slow", AD_LACP_SLOW
, 0},
137 { "fast", AD_LACP_FAST
, 0},
141 static const struct bond_opt_value bond_ad_select_tbl
[] = {
142 { "stable", BOND_AD_STABLE
, BOND_VALFLAG_DEFAULT
},
143 { "bandwidth", BOND_AD_BANDWIDTH
, 0},
144 { "count", BOND_AD_COUNT
, 0},
148 static const struct bond_opt_value bond_num_peer_notif_tbl
[] = {
150 { "maxval", 255, BOND_VALFLAG_MAX
},
151 { "default", 1, BOND_VALFLAG_DEFAULT
},
155 static const struct bond_opt_value bond_primary_reselect_tbl
[] = {
156 { "always", BOND_PRI_RESELECT_ALWAYS
, BOND_VALFLAG_DEFAULT
},
157 { "better", BOND_PRI_RESELECT_BETTER
, 0},
158 { "failure", BOND_PRI_RESELECT_FAILURE
, 0},
162 static const struct bond_opt_value bond_use_carrier_tbl
[] = {
164 { "on", 1, BOND_VALFLAG_DEFAULT
},
168 static const struct bond_opt_value bond_all_slaves_active_tbl
[] = {
169 { "off", 0, BOND_VALFLAG_DEFAULT
},
174 static const struct bond_opt_value bond_resend_igmp_tbl
[] = {
176 { "maxval", 255, BOND_VALFLAG_MAX
},
177 { "default", 1, BOND_VALFLAG_DEFAULT
},
181 static const struct bond_opt_value bond_lp_interval_tbl
[] = {
182 { "minval", 1, BOND_VALFLAG_MIN
| BOND_VALFLAG_DEFAULT
},
183 { "maxval", INT_MAX
, BOND_VALFLAG_MAX
},
187 static const struct bond_opt_value bond_tlb_dynamic_lb_tbl
[] = {
189 { "on", 1, BOND_VALFLAG_DEFAULT
},
193 static const struct bond_opt_value bond_ad_actor_sys_prio_tbl
[] = {
194 { "minval", 1, BOND_VALFLAG_MIN
},
195 { "maxval", 65535, BOND_VALFLAG_MAX
| BOND_VALFLAG_DEFAULT
},
199 static const struct bond_opt_value bond_ad_user_port_key_tbl
[] = {
200 { "minval", 0, BOND_VALFLAG_MIN
| BOND_VALFLAG_DEFAULT
},
201 { "maxval", 1023, BOND_VALFLAG_MAX
},
205 static const struct bond_option bond_opts
[BOND_OPT_LAST
] = {
209 .desc
= "bond device mode",
210 .flags
= BOND_OPTFLAG_NOSLAVES
| BOND_OPTFLAG_IFDOWN
,
211 .values
= bond_mode_tbl
,
212 .set
= bond_option_mode_set
214 [BOND_OPT_PACKETS_PER_SLAVE
] = {
215 .id
= BOND_OPT_PACKETS_PER_SLAVE
,
216 .name
= "packets_per_slave",
217 .desc
= "Packets to send per slave in RR mode",
218 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_ROUNDROBIN
)),
219 .values
= bond_pps_tbl
,
220 .set
= bond_option_pps_set
222 [BOND_OPT_XMIT_HASH
] = {
223 .id
= BOND_OPT_XMIT_HASH
,
224 .name
= "xmit_hash_policy",
225 .desc
= "balance-xor, 802.3ad, and tlb hashing method",
226 .values
= bond_xmit_hashtype_tbl
,
227 .set
= bond_option_xmit_hash_policy_set
229 [BOND_OPT_ARP_VALIDATE
] = {
230 .id
= BOND_OPT_ARP_VALIDATE
,
231 .name
= "arp_validate",
232 .desc
= "validate src/dst of ARP probes",
233 .unsuppmodes
= BIT(BOND_MODE_8023AD
) | BIT(BOND_MODE_TLB
) |
235 .values
= bond_arp_validate_tbl
,
236 .set
= bond_option_arp_validate_set
238 [BOND_OPT_ARP_ALL_TARGETS
] = {
239 .id
= BOND_OPT_ARP_ALL_TARGETS
,
240 .name
= "arp_all_targets",
241 .desc
= "fail on any/all arp targets timeout",
242 .values
= bond_arp_all_targets_tbl
,
243 .set
= bond_option_arp_all_targets_set
245 [BOND_OPT_FAIL_OVER_MAC
] = {
246 .id
= BOND_OPT_FAIL_OVER_MAC
,
247 .name
= "fail_over_mac",
248 .desc
= "For active-backup, do not set all slaves to the same MAC",
249 .flags
= BOND_OPTFLAG_NOSLAVES
,
250 .values
= bond_fail_over_mac_tbl
,
251 .set
= bond_option_fail_over_mac_set
253 [BOND_OPT_ARP_INTERVAL
] = {
254 .id
= BOND_OPT_ARP_INTERVAL
,
255 .name
= "arp_interval",
256 .desc
= "arp interval in milliseconds",
257 .unsuppmodes
= BIT(BOND_MODE_8023AD
) | BIT(BOND_MODE_TLB
) |
259 .values
= bond_intmax_tbl
,
260 .set
= bond_option_arp_interval_set
262 [BOND_OPT_ARP_TARGETS
] = {
263 .id
= BOND_OPT_ARP_TARGETS
,
264 .name
= "arp_ip_target",
265 .desc
= "arp targets in n.n.n.n form",
266 .flags
= BOND_OPTFLAG_RAWVAL
,
267 .set
= bond_option_arp_ip_targets_set
269 [BOND_OPT_DOWNDELAY
] = {
270 .id
= BOND_OPT_DOWNDELAY
,
272 .desc
= "Delay before considering link down, in milliseconds",
273 .values
= bond_intmax_tbl
,
274 .set
= bond_option_downdelay_set
276 [BOND_OPT_UPDELAY
] = {
277 .id
= BOND_OPT_UPDELAY
,
279 .desc
= "Delay before considering link up, in milliseconds",
280 .values
= bond_intmax_tbl
,
281 .set
= bond_option_updelay_set
283 [BOND_OPT_LACP_RATE
] = {
284 .id
= BOND_OPT_LACP_RATE
,
286 .desc
= "LACPDU tx rate to request from 802.3ad partner",
287 .flags
= BOND_OPTFLAG_IFDOWN
,
288 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD
)),
289 .values
= bond_lacp_rate_tbl
,
290 .set
= bond_option_lacp_rate_set
292 [BOND_OPT_MINLINKS
] = {
293 .id
= BOND_OPT_MINLINKS
,
295 .desc
= "Minimum number of available links before turning on carrier",
296 .values
= bond_intmax_tbl
,
297 .set
= bond_option_min_links_set
299 [BOND_OPT_AD_SELECT
] = {
300 .id
= BOND_OPT_AD_SELECT
,
302 .desc
= "803.ad aggregation selection logic",
303 .flags
= BOND_OPTFLAG_IFDOWN
,
304 .values
= bond_ad_select_tbl
,
305 .set
= bond_option_ad_select_set
307 [BOND_OPT_NUM_PEER_NOTIF
] = {
308 .id
= BOND_OPT_NUM_PEER_NOTIF
,
309 .name
= "num_unsol_na",
310 .desc
= "Number of peer notifications to send on failover event",
311 .values
= bond_num_peer_notif_tbl
,
312 .set
= bond_option_num_peer_notif_set
314 [BOND_OPT_MIIMON
] = {
315 .id
= BOND_OPT_MIIMON
,
317 .desc
= "Link check interval in milliseconds",
318 .values
= bond_intmax_tbl
,
319 .set
= bond_option_miimon_set
321 [BOND_OPT_PRIMARY
] = {
322 .id
= BOND_OPT_PRIMARY
,
324 .desc
= "Primary network device to use",
325 .flags
= BOND_OPTFLAG_RAWVAL
,
326 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP
) |
329 .set
= bond_option_primary_set
331 [BOND_OPT_PRIMARY_RESELECT
] = {
332 .id
= BOND_OPT_PRIMARY_RESELECT
,
333 .name
= "primary_reselect",
334 .desc
= "Reselect primary slave once it comes up",
335 .values
= bond_primary_reselect_tbl
,
336 .set
= bond_option_primary_reselect_set
338 [BOND_OPT_USE_CARRIER
] = {
339 .id
= BOND_OPT_USE_CARRIER
,
340 .name
= "use_carrier",
341 .desc
= "Use netif_carrier_ok (vs MII ioctls) in miimon",
342 .values
= bond_use_carrier_tbl
,
343 .set
= bond_option_use_carrier_set
345 [BOND_OPT_ACTIVE_SLAVE
] = {
346 .id
= BOND_OPT_ACTIVE_SLAVE
,
347 .name
= "active_slave",
348 .desc
= "Currently active slave",
349 .flags
= BOND_OPTFLAG_RAWVAL
,
350 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP
) |
353 .set
= bond_option_active_slave_set
355 [BOND_OPT_QUEUE_ID
] = {
356 .id
= BOND_OPT_QUEUE_ID
,
358 .desc
= "Set queue id of a slave",
359 .flags
= BOND_OPTFLAG_RAWVAL
,
360 .set
= bond_option_queue_id_set
362 [BOND_OPT_ALL_SLAVES_ACTIVE
] = {
363 .id
= BOND_OPT_ALL_SLAVES_ACTIVE
,
364 .name
= "all_slaves_active",
365 .desc
= "Keep all frames received on an interface by setting active flag for all slaves",
366 .values
= bond_all_slaves_active_tbl
,
367 .set
= bond_option_all_slaves_active_set
369 [BOND_OPT_RESEND_IGMP
] = {
370 .id
= BOND_OPT_RESEND_IGMP
,
371 .name
= "resend_igmp",
372 .desc
= "Number of IGMP membership reports to send on link failure",
373 .values
= bond_resend_igmp_tbl
,
374 .set
= bond_option_resend_igmp_set
376 [BOND_OPT_LP_INTERVAL
] = {
377 .id
= BOND_OPT_LP_INTERVAL
,
378 .name
= "lp_interval",
379 .desc
= "The number of seconds between instances where the bonding driver sends learning packets to each slave's peer switch",
380 .values
= bond_lp_interval_tbl
,
381 .set
= bond_option_lp_interval_set
383 [BOND_OPT_SLAVES
] = {
384 .id
= BOND_OPT_SLAVES
,
386 .desc
= "Slave membership management",
387 .flags
= BOND_OPTFLAG_RAWVAL
,
388 .set
= bond_option_slaves_set
390 [BOND_OPT_TLB_DYNAMIC_LB
] = {
391 .id
= BOND_OPT_TLB_DYNAMIC_LB
,
392 .name
= "tlb_dynamic_lb",
393 .desc
= "Enable dynamic flow shuffling",
394 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_TLB
) | BIT(BOND_MODE_ALB
)),
395 .values
= bond_tlb_dynamic_lb_tbl
,
396 .flags
= BOND_OPTFLAG_IFDOWN
,
397 .set
= bond_option_tlb_dynamic_lb_set
,
399 [BOND_OPT_AD_ACTOR_SYS_PRIO
] = {
400 .id
= BOND_OPT_AD_ACTOR_SYS_PRIO
,
401 .name
= "ad_actor_sys_prio",
402 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD
)),
403 .values
= bond_ad_actor_sys_prio_tbl
,
404 .set
= bond_option_ad_actor_sys_prio_set
,
406 [BOND_OPT_AD_ACTOR_SYSTEM
] = {
407 .id
= BOND_OPT_AD_ACTOR_SYSTEM
,
408 .name
= "ad_actor_system",
409 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD
)),
410 .flags
= BOND_OPTFLAG_RAWVAL
,
411 .set
= bond_option_ad_actor_system_set
,
413 [BOND_OPT_AD_USER_PORT_KEY
] = {
414 .id
= BOND_OPT_AD_USER_PORT_KEY
,
415 .name
= "ad_user_port_key",
416 .unsuppmodes
= BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD
)),
417 .flags
= BOND_OPTFLAG_IFDOWN
,
418 .values
= bond_ad_user_port_key_tbl
,
419 .set
= bond_option_ad_user_port_key_set
,
421 [BOND_OPT_NUM_PEER_NOTIF_ALIAS
] = {
422 .id
= BOND_OPT_NUM_PEER_NOTIF_ALIAS
,
423 .name
= "num_grat_arp",
424 .desc
= "Number of peer notifications to send on failover event",
425 .values
= bond_num_peer_notif_tbl
,
426 .set
= bond_option_num_peer_notif_set
430 /* Searches for an option by name */
431 const struct bond_option
*bond_opt_get_by_name(const char *name
)
433 const struct bond_option
*opt
;
436 for (option
= 0; option
< BOND_OPT_LAST
; option
++) {
437 opt
= bond_opt_get(option
);
438 if (opt
&& !strcmp(opt
->name
, name
))
445 /* Searches for a value in opt's values[] table */
446 const struct bond_opt_value
*bond_opt_get_val(unsigned int option
, u64 val
)
448 const struct bond_option
*opt
;
451 opt
= bond_opt_get(option
);
454 for (i
= 0; opt
->values
&& opt
->values
[i
].string
; i
++)
455 if (opt
->values
[i
].value
== val
)
456 return &opt
->values
[i
];
461 /* Searches for a value in opt's values[] table which matches the flagmask */
462 static const struct bond_opt_value
*bond_opt_get_flags(const struct bond_option
*opt
,
467 for (i
= 0; opt
->values
&& opt
->values
[i
].string
; i
++)
468 if (opt
->values
[i
].flags
& flagmask
)
469 return &opt
->values
[i
];
474 /* If maxval is missing then there's no range to check. In case minval is
475 * missing then it's considered to be 0.
477 static bool bond_opt_check_range(const struct bond_option
*opt
, u64 val
)
479 const struct bond_opt_value
*minval
, *maxval
;
481 minval
= bond_opt_get_flags(opt
, BOND_VALFLAG_MIN
);
482 maxval
= bond_opt_get_flags(opt
, BOND_VALFLAG_MAX
);
483 if (!maxval
|| (minval
&& val
< minval
->value
) || val
> maxval
->value
)
490 * bond_opt_parse - parse option value
491 * @opt: the option to parse against
492 * @val: value to parse
494 * This function tries to extract the value from @val and check if it's
495 * a possible match for the option and returns NULL if a match isn't found,
496 * or the struct_opt_value that matched. It also strips the new line from
497 * @val->string if it's present.
499 const struct bond_opt_value
*bond_opt_parse(const struct bond_option
*opt
,
500 struct bond_opt_value
*val
)
502 char *p
, valstr
[BOND_OPT_MAX_NAMELEN
+ 1] = { 0, };
503 const struct bond_opt_value
*tbl
;
504 const struct bond_opt_value
*ret
= NULL
;
508 /* No parsing if the option wants a raw val */
509 if (opt
->flags
& BOND_OPTFLAG_RAWVAL
)
516 /* ULLONG_MAX is used to bypass string processing */
517 checkval
= val
->value
!= ULLONG_MAX
;
521 p
= strchr(val
->string
, '\n');
524 for (p
= val
->string
; *p
; p
++)
525 if (!(isdigit(*p
) || isspace(*p
)))
527 /* The following code extracts the string to match or the value
528 * and sets checkval appropriately
531 rv
= sscanf(val
->string
, "%32s", valstr
);
533 rv
= sscanf(val
->string
, "%llu", &val
->value
);
540 for (i
= 0; tbl
[i
].string
; i
++) {
541 /* Check for exact match */
543 if (val
->value
== tbl
[i
].value
)
546 if (!strcmp(valstr
, "default") &&
547 (tbl
[i
].flags
& BOND_VALFLAG_DEFAULT
))
550 if (!strcmp(valstr
, tbl
[i
].string
))
553 /* Found an exact match */
557 /* Possible range match */
558 if (checkval
&& bond_opt_check_range(opt
, val
->value
))
564 /* Check opt's dependencies against bond mode and currently set options */
565 static int bond_opt_check_deps(struct bonding
*bond
,
566 const struct bond_option
*opt
)
568 struct bond_params
*params
= &bond
->params
;
570 if (test_bit(params
->mode
, &opt
->unsuppmodes
))
572 if ((opt
->flags
& BOND_OPTFLAG_NOSLAVES
) && bond_has_slaves(bond
))
574 if ((opt
->flags
& BOND_OPTFLAG_IFDOWN
) && (bond
->dev
->flags
& IFF_UP
))
580 static void bond_opt_dep_print(struct bonding
*bond
,
581 const struct bond_option
*opt
)
583 const struct bond_opt_value
*modeval
;
584 struct bond_params
*params
;
586 params
= &bond
->params
;
587 modeval
= bond_opt_get_val(BOND_OPT_MODE
, params
->mode
);
588 if (test_bit(params
->mode
, &opt
->unsuppmodes
))
589 netdev_err(bond
->dev
, "option %s: mode dependency failed, not supported in mode %s(%llu)\n",
590 opt
->name
, modeval
->string
, modeval
->value
);
593 static void bond_opt_error_interpret(struct bonding
*bond
,
594 const struct bond_option
*opt
,
595 int error
, const struct bond_opt_value
*val
)
597 const struct bond_opt_value
*minval
, *maxval
;
604 /* sometimes RAWVAL opts may have new lines */
605 p
= strchr(val
->string
, '\n');
608 netdev_err(bond
->dev
, "option %s: invalid value (%s)\n",
609 opt
->name
, val
->string
);
611 netdev_err(bond
->dev
, "option %s: invalid value (%llu)\n",
612 opt
->name
, val
->value
);
615 minval
= bond_opt_get_flags(opt
, BOND_VALFLAG_MIN
);
616 maxval
= bond_opt_get_flags(opt
, BOND_VALFLAG_MAX
);
619 netdev_err(bond
->dev
, "option %s: allowed values %llu - %llu\n",
620 opt
->name
, minval
? minval
->value
: 0, maxval
->value
);
623 bond_opt_dep_print(bond
, opt
);
626 netdev_err(bond
->dev
, "option %s: unable to set because the bond device has slaves\n",
630 netdev_err(bond
->dev
, "option %s: unable to set because the bond device is up\n",
639 * __bond_opt_set - set a bonding option
640 * @bond: target bond device
641 * @option: option to set
642 * @val: value to set it to
644 * This function is used to change the bond's option value, it can be
645 * used for both enabling/changing an option and for disabling it. RTNL lock
646 * must be obtained before calling this function.
648 int __bond_opt_set(struct bonding
*bond
,
649 unsigned int option
, struct bond_opt_value
*val
)
651 const struct bond_opt_value
*retval
= NULL
;
652 const struct bond_option
*opt
;
657 opt
= bond_opt_get(option
);
658 if (WARN_ON(!val
) || WARN_ON(!opt
))
660 ret
= bond_opt_check_deps(bond
, opt
);
663 retval
= bond_opt_parse(opt
, val
);
668 ret
= opt
->set(bond
, retval
);
671 bond_opt_error_interpret(bond
, opt
, ret
, val
);
676 * __bond_opt_set_notify - set a bonding option
677 * @bond: target bond device
678 * @option: option to set
679 * @val: value to set it to
681 * This function is used to change the bond's option value and trigger
682 * a notification to user sapce. It can be used for both enabling/changing
683 * an option and for disabling it. RTNL lock must be obtained before calling
686 int __bond_opt_set_notify(struct bonding
*bond
,
687 unsigned int option
, struct bond_opt_value
*val
)
693 ret
= __bond_opt_set(bond
, option
, val
);
695 if (!ret
&& (bond
->dev
->reg_state
== NETREG_REGISTERED
))
696 call_netdevice_notifiers(NETDEV_CHANGEINFODATA
, bond
->dev
);
702 * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set
703 * @bond: target bond device
704 * @option: option to set
705 * @buf: value to set it to
707 * This function tries to acquire RTNL without blocking and if successful
708 * calls __bond_opt_set. It is mainly used for sysfs option manipulation.
710 int bond_opt_tryset_rtnl(struct bonding
*bond
, unsigned int option
, char *buf
)
712 struct bond_opt_value optval
;
716 return restart_syscall();
717 bond_opt_initstr(&optval
, buf
);
718 ret
= __bond_opt_set_notify(bond
, option
, &optval
);
725 * bond_opt_get - get a pointer to an option
726 * @option: option for which to return a pointer
728 * This function checks if option is valid and if so returns a pointer
729 * to its entry in the bond_opts[] option array.
731 const struct bond_option
*bond_opt_get(unsigned int option
)
733 if (!BOND_OPT_VALID(option
))
736 return &bond_opts
[option
];
739 static int bond_option_mode_set(struct bonding
*bond
,
740 const struct bond_opt_value
*newval
)
742 if (!bond_mode_uses_arp(newval
->value
)) {
743 if (bond
->params
.arp_interval
) {
744 netdev_dbg(bond
->dev
, "%s mode is incompatible with arp monitoring, start mii monitoring\n",
746 /* disable arp monitoring */
747 bond
->params
.arp_interval
= 0;
750 if (!bond
->params
.miimon
) {
751 /* set miimon to default value */
752 bond
->params
.miimon
= BOND_DEFAULT_MIIMON
;
753 netdev_dbg(bond
->dev
, "Setting MII monitoring interval to %d\n",
754 bond
->params
.miimon
);
758 if (newval
->value
== BOND_MODE_ALB
)
759 bond
->params
.tlb_dynamic_lb
= 1;
761 /* don't cache arp_validate between modes */
762 bond
->params
.arp_validate
= BOND_ARP_VALIDATE_NONE
;
763 bond
->params
.mode
= newval
->value
;
768 static int bond_option_active_slave_set(struct bonding
*bond
,
769 const struct bond_opt_value
*newval
)
771 char ifname
[IFNAMSIZ
] = { 0, };
772 struct net_device
*slave_dev
;
775 sscanf(newval
->string
, "%15s", ifname
); /* IFNAMSIZ */
776 if (!strlen(ifname
) || newval
->string
[0] == '\n') {
779 slave_dev
= __dev_get_by_name(dev_net(bond
->dev
), ifname
);
785 if (!netif_is_bond_slave(slave_dev
)) {
786 netdev_err(bond
->dev
, "Device %s is not bonding slave\n",
791 if (bond
->dev
!= netdev_master_upper_dev_get(slave_dev
)) {
792 netdev_err(bond
->dev
, "Device %s is not our slave\n",
799 /* check to see if we are clearing active */
801 netdev_dbg(bond
->dev
, "Clearing current active slave\n");
802 RCU_INIT_POINTER(bond
->curr_active_slave
, NULL
);
803 bond_select_active_slave(bond
);
805 struct slave
*old_active
= rtnl_dereference(bond
->curr_active_slave
);
806 struct slave
*new_active
= bond_slave_get_rtnl(slave_dev
);
810 if (new_active
== old_active
) {
812 netdev_dbg(bond
->dev
, "%s is already the current active slave\n",
813 new_active
->dev
->name
);
815 if (old_active
&& (new_active
->link
== BOND_LINK_UP
) &&
816 bond_slave_is_up(new_active
)) {
817 netdev_dbg(bond
->dev
, "Setting %s as active slave\n",
818 new_active
->dev
->name
);
819 bond_change_active_slave(bond
, new_active
);
821 netdev_err(bond
->dev
, "Could not set %s as active slave; either %s is down or the link is down\n",
822 new_active
->dev
->name
,
823 new_active
->dev
->name
);
828 unblock_netpoll_tx();
833 /* There are two tricky bits here. First, if MII monitoring is activated, then
834 * we must disable ARP monitoring. Second, if the timer isn't running, we must
837 static int bond_option_miimon_set(struct bonding
*bond
,
838 const struct bond_opt_value
*newval
)
840 netdev_dbg(bond
->dev
, "Setting MII monitoring interval to %llu\n",
842 bond
->params
.miimon
= newval
->value
;
843 if (bond
->params
.updelay
)
844 netdev_dbg(bond
->dev
, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n",
845 bond
->params
.updelay
* bond
->params
.miimon
);
846 if (bond
->params
.downdelay
)
847 netdev_dbg(bond
->dev
, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value\n",
848 bond
->params
.downdelay
* bond
->params
.miimon
);
849 if (newval
->value
&& bond
->params
.arp_interval
) {
850 netdev_dbg(bond
->dev
, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitoring...\n");
851 bond
->params
.arp_interval
= 0;
852 if (bond
->params
.arp_validate
)
853 bond
->params
.arp_validate
= BOND_ARP_VALIDATE_NONE
;
855 if (bond
->dev
->flags
& IFF_UP
) {
856 /* If the interface is up, we may need to fire off
857 * the MII timer. If the interface is down, the
858 * timer will get fired off when the open function
861 if (!newval
->value
) {
862 cancel_delayed_work_sync(&bond
->mii_work
);
864 cancel_delayed_work_sync(&bond
->arp_work
);
865 queue_delayed_work(bond
->wq
, &bond
->mii_work
, 0);
872 /* Set up and down delays. These must be multiples of the
873 * MII monitoring value, and are stored internally as the multiplier.
874 * Thus, we must translate to MS for the real world.
876 static int bond_option_updelay_set(struct bonding
*bond
,
877 const struct bond_opt_value
*newval
)
879 int value
= newval
->value
;
881 if (!bond
->params
.miimon
) {
882 netdev_err(bond
->dev
, "Unable to set up delay as MII monitoring is disabled\n");
885 if ((value
% bond
->params
.miimon
) != 0) {
886 netdev_warn(bond
->dev
, "up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
887 value
, bond
->params
.miimon
,
888 (value
/ bond
->params
.miimon
) *
889 bond
->params
.miimon
);
891 bond
->params
.updelay
= value
/ bond
->params
.miimon
;
892 netdev_dbg(bond
->dev
, "Setting up delay to %d\n",
893 bond
->params
.updelay
* bond
->params
.miimon
);
898 static int bond_option_downdelay_set(struct bonding
*bond
,
899 const struct bond_opt_value
*newval
)
901 int value
= newval
->value
;
903 if (!bond
->params
.miimon
) {
904 netdev_err(bond
->dev
, "Unable to set down delay as MII monitoring is disabled\n");
907 if ((value
% bond
->params
.miimon
) != 0) {
908 netdev_warn(bond
->dev
, "down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
909 value
, bond
->params
.miimon
,
910 (value
/ bond
->params
.miimon
) *
911 bond
->params
.miimon
);
913 bond
->params
.downdelay
= value
/ bond
->params
.miimon
;
914 netdev_dbg(bond
->dev
, "Setting down delay to %d\n",
915 bond
->params
.downdelay
* bond
->params
.miimon
);
920 static int bond_option_use_carrier_set(struct bonding
*bond
,
921 const struct bond_opt_value
*newval
)
923 netdev_dbg(bond
->dev
, "Setting use_carrier to %llu\n",
925 bond
->params
.use_carrier
= newval
->value
;
930 /* There are two tricky bits here. First, if ARP monitoring is activated, then
931 * we must disable MII monitoring. Second, if the ARP timer isn't running,
934 static int bond_option_arp_interval_set(struct bonding
*bond
,
935 const struct bond_opt_value
*newval
)
937 netdev_dbg(bond
->dev
, "Setting ARP monitoring interval to %llu\n",
939 bond
->params
.arp_interval
= newval
->value
;
941 if (bond
->params
.miimon
) {
942 netdev_dbg(bond
->dev
, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring\n");
943 bond
->params
.miimon
= 0;
945 if (!bond
->params
.arp_targets
[0])
946 netdev_dbg(bond
->dev
, "ARP monitoring has been set up, but no ARP targets have been specified\n");
948 if (bond
->dev
->flags
& IFF_UP
) {
949 /* If the interface is up, we may need to fire off
950 * the ARP timer. If the interface is down, the
951 * timer will get fired off when the open function
954 if (!newval
->value
) {
955 if (bond
->params
.arp_validate
)
956 bond
->recv_probe
= NULL
;
957 cancel_delayed_work_sync(&bond
->arp_work
);
959 /* arp_validate can be set only in active-backup mode */
960 bond
->recv_probe
= bond_arp_rcv
;
961 cancel_delayed_work_sync(&bond
->mii_work
);
962 queue_delayed_work(bond
->wq
, &bond
->arp_work
, 0);
969 static void _bond_options_arp_ip_target_set(struct bonding
*bond
, int slot
,
971 unsigned long last_rx
)
973 __be32
*targets
= bond
->params
.arp_targets
;
974 struct list_head
*iter
;
977 if (slot
>= 0 && slot
< BOND_MAX_ARP_TARGETS
) {
978 bond_for_each_slave(bond
, slave
, iter
)
979 slave
->target_last_arp_rx
[slot
] = last_rx
;
980 targets
[slot
] = target
;
984 static int _bond_option_arp_ip_target_add(struct bonding
*bond
, __be32 target
)
986 __be32
*targets
= bond
->params
.arp_targets
;
989 if (!bond_is_ip_target_ok(target
)) {
990 netdev_err(bond
->dev
, "invalid ARP target %pI4 specified for addition\n",
995 if (bond_get_targets_ip(targets
, target
) != -1) { /* dup */
996 netdev_err(bond
->dev
, "ARP target %pI4 is already present\n",
1001 ind
= bond_get_targets_ip(targets
, 0); /* first free slot */
1003 netdev_err(bond
->dev
, "ARP target table is full!\n");
1007 netdev_dbg(bond
->dev
, "Adding ARP target %pI4\n", &target
);
1009 _bond_options_arp_ip_target_set(bond
, ind
, target
, jiffies
);
1014 static int bond_option_arp_ip_target_add(struct bonding
*bond
, __be32 target
)
1016 return _bond_option_arp_ip_target_add(bond
, target
);
1019 static int bond_option_arp_ip_target_rem(struct bonding
*bond
, __be32 target
)
1021 __be32
*targets
= bond
->params
.arp_targets
;
1022 struct list_head
*iter
;
1023 struct slave
*slave
;
1024 unsigned long *targets_rx
;
1027 if (!bond_is_ip_target_ok(target
)) {
1028 netdev_err(bond
->dev
, "invalid ARP target %pI4 specified for removal\n",
1033 ind
= bond_get_targets_ip(targets
, target
);
1035 netdev_err(bond
->dev
, "unable to remove nonexistent ARP target %pI4\n",
1040 if (ind
== 0 && !targets
[1] && bond
->params
.arp_interval
)
1041 netdev_warn(bond
->dev
, "Removing last arp target with arp_interval on\n");
1043 netdev_dbg(bond
->dev
, "Removing ARP target %pI4\n", &target
);
1045 bond_for_each_slave(bond
, slave
, iter
) {
1046 targets_rx
= slave
->target_last_arp_rx
;
1047 for (i
= ind
; (i
< BOND_MAX_ARP_TARGETS
-1) && targets
[i
+1]; i
++)
1048 targets_rx
[i
] = targets_rx
[i
+1];
1051 for (i
= ind
; (i
< BOND_MAX_ARP_TARGETS
-1) && targets
[i
+1]; i
++)
1052 targets
[i
] = targets
[i
+1];
1058 void bond_option_arp_ip_targets_clear(struct bonding
*bond
)
1062 for (i
= 0; i
< BOND_MAX_ARP_TARGETS
; i
++)
1063 _bond_options_arp_ip_target_set(bond
, i
, 0, 0);
1066 static int bond_option_arp_ip_targets_set(struct bonding
*bond
,
1067 const struct bond_opt_value
*newval
)
1072 if (newval
->string
) {
1073 if (!in4_pton(newval
->string
+1, -1, (u8
*)&target
, -1, NULL
)) {
1074 netdev_err(bond
->dev
, "invalid ARP target %pI4 specified\n",
1078 if (newval
->string
[0] == '+')
1079 ret
= bond_option_arp_ip_target_add(bond
, target
);
1080 else if (newval
->string
[0] == '-')
1081 ret
= bond_option_arp_ip_target_rem(bond
, target
);
1083 netdev_err(bond
->dev
, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n");
1085 target
= newval
->value
;
1086 ret
= bond_option_arp_ip_target_add(bond
, target
);
1092 static int bond_option_arp_validate_set(struct bonding
*bond
,
1093 const struct bond_opt_value
*newval
)
1095 netdev_dbg(bond
->dev
, "Setting arp_validate to %s (%llu)\n",
1096 newval
->string
, newval
->value
);
1097 bond
->params
.arp_validate
= newval
->value
;
1102 static int bond_option_arp_all_targets_set(struct bonding
*bond
,
1103 const struct bond_opt_value
*newval
)
1105 netdev_dbg(bond
->dev
, "Setting arp_all_targets to %s (%llu)\n",
1106 newval
->string
, newval
->value
);
1107 bond
->params
.arp_all_targets
= newval
->value
;
1112 static int bond_option_primary_set(struct bonding
*bond
,
1113 const struct bond_opt_value
*newval
)
1115 char *p
, *primary
= newval
->string
;
1116 struct list_head
*iter
;
1117 struct slave
*slave
;
1121 p
= strchr(primary
, '\n');
1124 /* check to see if we are clearing primary */
1125 if (!strlen(primary
)) {
1126 netdev_dbg(bond
->dev
, "Setting primary slave to None\n");
1127 RCU_INIT_POINTER(bond
->primary_slave
, NULL
);
1128 memset(bond
->params
.primary
, 0, sizeof(bond
->params
.primary
));
1129 bond_select_active_slave(bond
);
1133 bond_for_each_slave(bond
, slave
, iter
) {
1134 if (strncmp(slave
->dev
->name
, primary
, IFNAMSIZ
) == 0) {
1135 netdev_dbg(bond
->dev
, "Setting %s as primary slave\n",
1137 rcu_assign_pointer(bond
->primary_slave
, slave
);
1138 strcpy(bond
->params
.primary
, slave
->dev
->name
);
1139 bond
->force_primary
= true;
1140 bond_select_active_slave(bond
);
1145 if (rtnl_dereference(bond
->primary_slave
)) {
1146 netdev_dbg(bond
->dev
, "Setting primary slave to None\n");
1147 RCU_INIT_POINTER(bond
->primary_slave
, NULL
);
1148 bond_select_active_slave(bond
);
1150 strncpy(bond
->params
.primary
, primary
, IFNAMSIZ
);
1151 bond
->params
.primary
[IFNAMSIZ
- 1] = 0;
1153 netdev_dbg(bond
->dev
, "Recording %s as primary, but it has not been enslaved to %s yet\n",
1154 primary
, bond
->dev
->name
);
1157 unblock_netpoll_tx();
1162 static int bond_option_primary_reselect_set(struct bonding
*bond
,
1163 const struct bond_opt_value
*newval
)
1165 netdev_dbg(bond
->dev
, "Setting primary_reselect to %s (%llu)\n",
1166 newval
->string
, newval
->value
);
1167 bond
->params
.primary_reselect
= newval
->value
;
1170 bond_select_active_slave(bond
);
1171 unblock_netpoll_tx();
1176 static int bond_option_fail_over_mac_set(struct bonding
*bond
,
1177 const struct bond_opt_value
*newval
)
1179 netdev_dbg(bond
->dev
, "Setting fail_over_mac to %s (%llu)\n",
1180 newval
->string
, newval
->value
);
1181 bond
->params
.fail_over_mac
= newval
->value
;
1186 static int bond_option_xmit_hash_policy_set(struct bonding
*bond
,
1187 const struct bond_opt_value
*newval
)
1189 netdev_dbg(bond
->dev
, "Setting xmit hash policy to %s (%llu)\n",
1190 newval
->string
, newval
->value
);
1191 bond
->params
.xmit_policy
= newval
->value
;
1196 static int bond_option_resend_igmp_set(struct bonding
*bond
,
1197 const struct bond_opt_value
*newval
)
1199 netdev_dbg(bond
->dev
, "Setting resend_igmp to %llu\n",
1201 bond
->params
.resend_igmp
= newval
->value
;
1206 static int bond_option_num_peer_notif_set(struct bonding
*bond
,
1207 const struct bond_opt_value
*newval
)
1209 bond
->params
.num_peer_notif
= newval
->value
;
1214 static int bond_option_all_slaves_active_set(struct bonding
*bond
,
1215 const struct bond_opt_value
*newval
)
1217 struct list_head
*iter
;
1218 struct slave
*slave
;
1220 if (newval
->value
== bond
->params
.all_slaves_active
)
1222 bond
->params
.all_slaves_active
= newval
->value
;
1223 bond_for_each_slave(bond
, slave
, iter
) {
1224 if (!bond_is_active_slave(slave
)) {
1226 slave
->inactive
= 0;
1228 slave
->inactive
= 1;
1235 static int bond_option_min_links_set(struct bonding
*bond
,
1236 const struct bond_opt_value
*newval
)
1238 netdev_dbg(bond
->dev
, "Setting min links value to %llu\n",
1240 bond
->params
.min_links
= newval
->value
;
1241 bond_set_carrier(bond
);
1246 static int bond_option_lp_interval_set(struct bonding
*bond
,
1247 const struct bond_opt_value
*newval
)
1249 bond
->params
.lp_interval
= newval
->value
;
1254 static int bond_option_pps_set(struct bonding
*bond
,
1255 const struct bond_opt_value
*newval
)
1257 netdev_dbg(bond
->dev
, "Setting packets per slave to %llu\n",
1259 bond
->params
.packets_per_slave
= newval
->value
;
1260 if (newval
->value
> 0) {
1261 bond
->params
.reciprocal_packets_per_slave
=
1262 reciprocal_value(newval
->value
);
1264 /* reciprocal_packets_per_slave is unused if
1265 * packets_per_slave is 0 or 1, just initialize it
1267 bond
->params
.reciprocal_packets_per_slave
=
1268 (struct reciprocal_value
) { 0 };
1274 static int bond_option_lacp_rate_set(struct bonding
*bond
,
1275 const struct bond_opt_value
*newval
)
1277 netdev_dbg(bond
->dev
, "Setting LACP rate to %s (%llu)\n",
1278 newval
->string
, newval
->value
);
1279 bond
->params
.lacp_fast
= newval
->value
;
1280 bond_3ad_update_lacp_rate(bond
);
1285 static int bond_option_ad_select_set(struct bonding
*bond
,
1286 const struct bond_opt_value
*newval
)
1288 netdev_dbg(bond
->dev
, "Setting ad_select to %s (%llu)\n",
1289 newval
->string
, newval
->value
);
1290 bond
->params
.ad_select
= newval
->value
;
1295 static int bond_option_queue_id_set(struct bonding
*bond
,
1296 const struct bond_opt_value
*newval
)
1298 struct slave
*slave
, *update_slave
;
1299 struct net_device
*sdev
;
1300 struct list_head
*iter
;
1305 /* delim will point to queue id if successful */
1306 delim
= strchr(newval
->string
, ':');
1310 /* Terminate string that points to device name and bump it
1311 * up one, so we can read the queue id there.
1314 if (sscanf(++delim
, "%hd\n", &qid
) != 1)
1317 /* Check buffer length, valid ifname and queue id */
1318 if (!dev_valid_name(newval
->string
) ||
1319 qid
> bond
->dev
->real_num_tx_queues
)
1322 /* Get the pointer to that interface if it exists */
1323 sdev
= __dev_get_by_name(dev_net(bond
->dev
), newval
->string
);
1327 /* Search for thes slave and check for duplicate qids */
1328 update_slave
= NULL
;
1329 bond_for_each_slave(bond
, slave
, iter
) {
1330 if (sdev
== slave
->dev
)
1331 /* We don't need to check the matching
1332 * slave for dups, since we're overwriting it
1334 update_slave
= slave
;
1335 else if (qid
&& qid
== slave
->queue_id
) {
1343 /* Actually set the qids for the slave */
1344 update_slave
->queue_id
= qid
;
1350 netdev_dbg(bond
->dev
, "invalid input for queue_id set\n");
1356 static int bond_option_slaves_set(struct bonding
*bond
,
1357 const struct bond_opt_value
*newval
)
1359 char command
[IFNAMSIZ
+ 1] = { 0, };
1360 struct net_device
*dev
;
1364 sscanf(newval
->string
, "%16s", command
); /* IFNAMSIZ*/
1365 ifname
= command
+ 1;
1366 if ((strlen(command
) <= 1) ||
1367 (command
[0] != '+' && command
[0] != '-') ||
1368 !dev_valid_name(ifname
))
1371 dev
= __dev_get_by_name(dev_net(bond
->dev
), ifname
);
1373 netdev_dbg(bond
->dev
, "interface %s does not exist!\n",
1379 switch (command
[0]) {
1381 netdev_dbg(bond
->dev
, "Adding slave %s\n", dev
->name
);
1382 ret
= bond_enslave(bond
->dev
, dev
, NULL
);
1386 netdev_dbg(bond
->dev
, "Removing slave %s\n", dev
->name
);
1387 ret
= bond_release(bond
->dev
, dev
);
1391 /* should not run here. */
1399 netdev_err(bond
->dev
, "no command found in slaves file - use +ifname or -ifname\n");
1404 static int bond_option_tlb_dynamic_lb_set(struct bonding
*bond
,
1405 const struct bond_opt_value
*newval
)
1407 netdev_dbg(bond
->dev
, "Setting dynamic-lb to %s (%llu)\n",
1408 newval
->string
, newval
->value
);
1409 bond
->params
.tlb_dynamic_lb
= newval
->value
;
1414 static int bond_option_ad_actor_sys_prio_set(struct bonding
*bond
,
1415 const struct bond_opt_value
*newval
)
1417 netdev_dbg(bond
->dev
, "Setting ad_actor_sys_prio to %llu\n",
1420 bond
->params
.ad_actor_sys_prio
= newval
->value
;
1421 bond_3ad_update_ad_actor_settings(bond
);
1426 static int bond_option_ad_actor_system_set(struct bonding
*bond
,
1427 const struct bond_opt_value
*newval
)
1429 u8 macaddr
[ETH_ALEN
];
1432 if (newval
->string
) {
1433 if (!mac_pton(newval
->string
, macaddr
))
1437 mac
= (u8
*)&newval
->value
;
1440 if (!is_valid_ether_addr(mac
))
1443 netdev_dbg(bond
->dev
, "Setting ad_actor_system to %pM\n", mac
);
1444 ether_addr_copy(bond
->params
.ad_actor_system
, mac
);
1445 bond_3ad_update_ad_actor_settings(bond
);
1450 netdev_err(bond
->dev
, "Invalid MAC address.\n");
1454 static int bond_option_ad_user_port_key_set(struct bonding
*bond
,
1455 const struct bond_opt_value
*newval
)
1457 netdev_dbg(bond
->dev
, "Setting ad_user_port_key to %llu\n",
1460 bond
->params
.ad_user_port_key
= newval
->value
;