blob: a8fde3bc458f6c360252f0a3e0648e533936524e [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Jiri Pirko72be35f2013-10-18 17:43:34 +02002/*
3 * drivers/net/bond/bond_options.c - bonding options
4 * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us>
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -08005 * Copyright (c) 2013 Scott Feldman <sfeldma@cumulusnetworks.com>
Jiri Pirko72be35f2013-10-18 17:43:34 +02006 */
7
Jiri Pirko72be35f2013-10-18 17:43:34 +02008#include <linux/errno.h>
9#include <linux/if.h>
Jiri Pirkod9e32b22013-10-18 17:43:35 +020010#include <linux/netdevice.h>
Mike Galbraitheb2d4c62014-02-14 08:21:04 +010011#include <linux/spinlock.h>
Jiri Pirkod9e32b22013-10-18 17:43:35 +020012#include <linux/rcupdate.h>
Nikolay Aleksandrov09117362014-01-22 14:53:16 +010013#include <linux/ctype.h>
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +010014#include <linux/inet.h>
Ingo Molnar174cd4b2017-02-02 19:15:33 +010015#include <linux/sched/signal.h>
16
David S. Miller1ef80192014-11-10 13:27:49 -050017#include <net/bonding.h>
Jiri Pirko72be35f2013-10-18 17:43:34 +020018
stephen hemmingerf3253332014-03-04 16:36:44 -080019static int bond_option_active_slave_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080020 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080021static int bond_option_miimon_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080022 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080023static int bond_option_updelay_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080024 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080025static int bond_option_downdelay_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080026 const struct bond_opt_value *newval);
Vincent Bernat07a4dde2019-07-02 19:43:54 +020027static int bond_option_peer_notif_delay_set(struct bonding *bond,
28 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080029static int bond_option_use_carrier_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080030 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080031static int bond_option_arp_interval_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080032 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080033static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
34static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
35static int bond_option_arp_ip_targets_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080036 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080037static int bond_option_arp_validate_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080038 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080039static int bond_option_arp_all_targets_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080040 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080041static int bond_option_primary_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080042 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080043static int bond_option_primary_reselect_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080044 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080045static int bond_option_fail_over_mac_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080046 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080047static int bond_option_xmit_hash_policy_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080048 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080049static int bond_option_resend_igmp_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080050 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080051static int bond_option_num_peer_notif_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080052 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080053static int bond_option_all_slaves_active_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080054 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080055static int bond_option_min_links_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080056 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080057static int bond_option_lp_interval_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080058 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080059static int bond_option_pps_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080060 const struct bond_opt_value *newval);
Hangbin Liu3a755cd2021-08-02 11:02:19 +080061static int bond_option_lacp_active_set(struct bonding *bond,
62 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080063static int bond_option_lacp_rate_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080064 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080065static int bond_option_ad_select_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080066 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080067static int bond_option_queue_id_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080068 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080069static int bond_option_mode_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080070 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080071static int bond_option_slaves_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -080072 const struct bond_opt_value *newval);
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -070073static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
74 const struct bond_opt_value *newval);
Mahesh Bandewar6791e462015-05-09 00:01:55 -070075static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
76 const struct bond_opt_value *newval);
Mahesh Bandewar74514952015-05-09 00:01:56 -070077static int bond_option_ad_actor_system_set(struct bonding *bond,
78 const struct bond_opt_value *newval);
Mahesh Bandeward22a5fc2015-05-09 00:01:57 -070079static int bond_option_ad_user_port_key_set(struct bonding *bond,
80 const struct bond_opt_value *newval);
stephen hemmingerf3253332014-03-04 16:36:44 -080081
82
83static const struct bond_opt_value bond_mode_tbl[] = {
Nikolay Aleksandrov2b3798d2014-01-22 14:53:17 +010084 { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT},
85 { "active-backup", BOND_MODE_ACTIVEBACKUP, 0},
86 { "balance-xor", BOND_MODE_XOR, 0},
87 { "broadcast", BOND_MODE_BROADCAST, 0},
88 { "802.3ad", BOND_MODE_8023AD, 0},
89 { "balance-tlb", BOND_MODE_TLB, 0},
90 { "balance-alb", BOND_MODE_ALB, 0},
91 { NULL, -1, 0},
92};
93
stephen hemmingerf3253332014-03-04 16:36:44 -080094static const struct bond_opt_value bond_pps_tbl[] = {
Nikolay Aleksandrovaa59d852014-01-22 14:53:18 +010095 { "default", 1, BOND_VALFLAG_DEFAULT},
96 { "maxval", USHRT_MAX, BOND_VALFLAG_MAX},
97 { NULL, -1, 0},
98};
99
stephen hemmingerf3253332014-03-04 16:36:44 -0800100static const struct bond_opt_value bond_xmit_hashtype_tbl[] = {
Jarod Wilson7b8fc012021-01-18 20:09:27 -0500101 { "layer2", BOND_XMIT_POLICY_LAYER2, BOND_VALFLAG_DEFAULT},
102 { "layer3+4", BOND_XMIT_POLICY_LAYER34, 0},
103 { "layer2+3", BOND_XMIT_POLICY_LAYER23, 0},
104 { "encap2+3", BOND_XMIT_POLICY_ENCAP23, 0},
105 { "encap3+4", BOND_XMIT_POLICY_ENCAP34, 0},
106 { "vlan+srcmac", BOND_XMIT_POLICY_VLAN_SRCMAC, 0},
107 { NULL, -1, 0},
Nikolay Aleksandrova4b32ce2014-01-22 14:53:19 +0100108};
109
stephen hemmingerf3253332014-03-04 16:36:44 -0800110static const struct bond_opt_value bond_arp_validate_tbl[] = {
Veaceslav Falico896149f2014-02-18 07:48:40 +0100111 { "none", BOND_ARP_VALIDATE_NONE, BOND_VALFLAG_DEFAULT},
112 { "active", BOND_ARP_VALIDATE_ACTIVE, 0},
113 { "backup", BOND_ARP_VALIDATE_BACKUP, 0},
114 { "all", BOND_ARP_VALIDATE_ALL, 0},
115 { "filter", BOND_ARP_FILTER, 0},
116 { "filter_active", BOND_ARP_FILTER_ACTIVE, 0},
117 { "filter_backup", BOND_ARP_FILTER_BACKUP, 0},
118 { NULL, -1, 0},
Nikolay Aleksandrov16228882014-01-22 14:53:20 +0100119};
120
stephen hemmingerf3253332014-03-04 16:36:44 -0800121static const struct bond_opt_value bond_arp_all_targets_tbl[] = {
Nikolay Aleksandrovedf36b22014-01-22 14:53:21 +0100122 { "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT},
123 { "all", BOND_ARP_TARGETS_ALL, 0},
124 { NULL, -1, 0},
125};
126
stephen hemmingerf3253332014-03-04 16:36:44 -0800127static const struct bond_opt_value bond_fail_over_mac_tbl[] = {
Nikolay Aleksandrov1df6b6a2014-01-22 14:53:22 +0100128 { "none", BOND_FOM_NONE, BOND_VALFLAG_DEFAULT},
129 { "active", BOND_FOM_ACTIVE, 0},
130 { "follow", BOND_FOM_FOLLOW, 0},
131 { NULL, -1, 0},
132};
133
stephen hemmingerf3253332014-03-04 16:36:44 -0800134static const struct bond_opt_value bond_intmax_tbl[] = {
Nikolay Aleksandrov7bdb04e2014-01-22 14:53:23 +0100135 { "off", 0, BOND_VALFLAG_DEFAULT},
136 { "maxval", INT_MAX, BOND_VALFLAG_MAX},
Nikolay Aleksandrov81c70802014-05-15 13:35:23 +0200137 { NULL, -1, 0}
Nikolay Aleksandrov7bdb04e2014-01-22 14:53:23 +0100138};
139
Hangbin Liu3a755cd2021-08-02 11:02:19 +0800140static const struct bond_opt_value bond_lacp_active[] = {
141 { "off", 0, 0},
142 { "on", 1, BOND_VALFLAG_DEFAULT},
143 { NULL, -1, 0}
144};
145
stephen hemmingerf3253332014-03-04 16:36:44 -0800146static const struct bond_opt_value bond_lacp_rate_tbl[] = {
Nikolay Aleksandrovd3131de2014-01-22 14:53:27 +0100147 { "slow", AD_LACP_SLOW, 0},
148 { "fast", AD_LACP_FAST, 0},
149 { NULL, -1, 0},
150};
151
stephen hemmingerf3253332014-03-04 16:36:44 -0800152static const struct bond_opt_value bond_ad_select_tbl[] = {
Nikolay Aleksandrov9e5f5ee2014-01-22 14:53:29 +0100153 { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT},
154 { "bandwidth", BOND_AD_BANDWIDTH, 0},
155 { "count", BOND_AD_COUNT, 0},
156 { NULL, -1, 0},
157};
158
stephen hemmingerf3253332014-03-04 16:36:44 -0800159static const struct bond_opt_value bond_num_peer_notif_tbl[] = {
Nikolay Aleksandrovef56bec2014-01-22 14:53:30 +0100160 { "off", 0, 0},
161 { "maxval", 255, BOND_VALFLAG_MAX},
162 { "default", 1, BOND_VALFLAG_DEFAULT},
163 { NULL, -1, 0}
164};
165
stephen hemmingerf3253332014-03-04 16:36:44 -0800166static const struct bond_opt_value bond_primary_reselect_tbl[] = {
Nikolay Aleksandrov388d3a62014-01-22 14:53:33 +0100167 { "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT},
168 { "better", BOND_PRI_RESELECT_BETTER, 0},
169 { "failure", BOND_PRI_RESELECT_FAILURE, 0},
170 { NULL, -1},
171};
172
stephen hemmingerf3253332014-03-04 16:36:44 -0800173static const struct bond_opt_value bond_use_carrier_tbl[] = {
Debabrata Banerjeeb3c898e2018-05-16 14:02:13 -0400174 { "off", 0, 0},
175 { "on", 1, BOND_VALFLAG_DEFAULT},
176 { NULL, -1, 0}
Nikolay Aleksandrov0fff06082014-01-22 14:53:34 +0100177};
178
stephen hemmingerf3253332014-03-04 16:36:44 -0800179static const struct bond_opt_value bond_all_slaves_active_tbl[] = {
Nikolay Aleksandrov3df01162014-01-22 14:53:37 +0100180 { "off", 0, BOND_VALFLAG_DEFAULT},
181 { "on", 1, 0},
182 { NULL, -1, 0}
183};
184
stephen hemmingerf3253332014-03-04 16:36:44 -0800185static const struct bond_opt_value bond_resend_igmp_tbl[] = {
Nikolay Aleksandrov105c8fb2014-01-22 14:53:38 +0100186 { "off", 0, 0},
187 { "maxval", 255, BOND_VALFLAG_MAX},
188 { "default", 1, BOND_VALFLAG_DEFAULT},
189 { NULL, -1, 0}
190};
191
stephen hemmingerf3253332014-03-04 16:36:44 -0800192static const struct bond_opt_value bond_lp_interval_tbl[] = {
Nikolay Aleksandrov4325b372014-01-22 14:53:39 +0100193 { "minval", 1, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
194 { "maxval", INT_MAX, BOND_VALFLAG_MAX},
Sasha Levin5bd4e4c2014-03-06 16:53:11 -0500195 { NULL, -1, 0},
Nikolay Aleksandrov4325b372014-01-22 14:53:39 +0100196};
197
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -0700198static const struct bond_opt_value bond_tlb_dynamic_lb_tbl[] = {
199 { "off", 0, 0},
200 { "on", 1, BOND_VALFLAG_DEFAULT},
201 { NULL, -1, 0}
202};
203
Mahesh Bandewar6791e462015-05-09 00:01:55 -0700204static const struct bond_opt_value bond_ad_actor_sys_prio_tbl[] = {
205 { "minval", 1, BOND_VALFLAG_MIN},
206 { "maxval", 65535, BOND_VALFLAG_MAX | BOND_VALFLAG_DEFAULT},
207 { NULL, -1, 0},
208};
209
Mahesh Bandeward22a5fc2015-05-09 00:01:57 -0700210static const struct bond_opt_value bond_ad_user_port_key_tbl[] = {
211 { "minval", 0, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
212 { "maxval", 1023, BOND_VALFLAG_MAX},
213 { NULL, -1, 0},
214};
215
Jonathan Toppins7bfa0142015-01-09 13:31:08 -0500216static const struct bond_option bond_opts[BOND_OPT_LAST] = {
Nikolay Aleksandrov2b3798d2014-01-22 14:53:17 +0100217 [BOND_OPT_MODE] = {
218 .id = BOND_OPT_MODE,
219 .name = "mode",
220 .desc = "bond device mode",
221 .flags = BOND_OPTFLAG_NOSLAVES | BOND_OPTFLAG_IFDOWN,
222 .values = bond_mode_tbl,
223 .set = bond_option_mode_set
224 },
Nikolay Aleksandrovaa59d852014-01-22 14:53:18 +0100225 [BOND_OPT_PACKETS_PER_SLAVE] = {
226 .id = BOND_OPT_PACKETS_PER_SLAVE,
227 .name = "packets_per_slave",
228 .desc = "Packets to send per slave in RR mode",
229 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ROUNDROBIN)),
230 .values = bond_pps_tbl,
231 .set = bond_option_pps_set
232 },
Nikolay Aleksandrova4b32ce2014-01-22 14:53:19 +0100233 [BOND_OPT_XMIT_HASH] = {
234 .id = BOND_OPT_XMIT_HASH,
235 .name = "xmit_hash_policy",
Mahesh Bandewarf05b42e2014-04-22 16:30:20 -0700236 .desc = "balance-xor, 802.3ad, and tlb hashing method",
Nikolay Aleksandrova4b32ce2014-01-22 14:53:19 +0100237 .values = bond_xmit_hashtype_tbl,
238 .set = bond_option_xmit_hash_policy_set
239 },
Nikolay Aleksandrov16228882014-01-22 14:53:20 +0100240 [BOND_OPT_ARP_VALIDATE] = {
241 .id = BOND_OPT_ARP_VALIDATE,
242 .name = "arp_validate",
243 .desc = "validate src/dst of ARP probes",
Veaceslav Falico13ac34a2014-02-18 07:48:37 +0100244 .unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) |
245 BIT(BOND_MODE_ALB),
Nikolay Aleksandrov16228882014-01-22 14:53:20 +0100246 .values = bond_arp_validate_tbl,
247 .set = bond_option_arp_validate_set
248 },
Nikolay Aleksandrovedf36b22014-01-22 14:53:21 +0100249 [BOND_OPT_ARP_ALL_TARGETS] = {
250 .id = BOND_OPT_ARP_ALL_TARGETS,
251 .name = "arp_all_targets",
252 .desc = "fail on any/all arp targets timeout",
253 .values = bond_arp_all_targets_tbl,
254 .set = bond_option_arp_all_targets_set
255 },
Nikolay Aleksandrov1df6b6a2014-01-22 14:53:22 +0100256 [BOND_OPT_FAIL_OVER_MAC] = {
257 .id = BOND_OPT_FAIL_OVER_MAC,
258 .name = "fail_over_mac",
259 .desc = "For active-backup, do not set all slaves to the same MAC",
260 .flags = BOND_OPTFLAG_NOSLAVES,
261 .values = bond_fail_over_mac_tbl,
262 .set = bond_option_fail_over_mac_set
263 },
Nikolay Aleksandrov7bdb04e2014-01-22 14:53:23 +0100264 [BOND_OPT_ARP_INTERVAL] = {
265 .id = BOND_OPT_ARP_INTERVAL,
266 .name = "arp_interval",
267 .desc = "arp interval in milliseconds",
268 .unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) |
269 BIT(BOND_MODE_ALB),
270 .values = bond_intmax_tbl,
271 .set = bond_option_arp_interval_set
272 },
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +0100273 [BOND_OPT_ARP_TARGETS] = {
274 .id = BOND_OPT_ARP_TARGETS,
275 .name = "arp_ip_target",
276 .desc = "arp targets in n.n.n.n form",
277 .flags = BOND_OPTFLAG_RAWVAL,
278 .set = bond_option_arp_ip_targets_set
279 },
Nikolay Aleksandrov25a9b542014-01-22 14:53:25 +0100280 [BOND_OPT_DOWNDELAY] = {
281 .id = BOND_OPT_DOWNDELAY,
282 .name = "downdelay",
283 .desc = "Delay before considering link down, in milliseconds",
284 .values = bond_intmax_tbl,
285 .set = bond_option_downdelay_set
286 },
Nikolay Aleksandrove4994612014-01-22 14:53:26 +0100287 [BOND_OPT_UPDELAY] = {
288 .id = BOND_OPT_UPDELAY,
289 .name = "updelay",
290 .desc = "Delay before considering link up, in milliseconds",
291 .values = bond_intmax_tbl,
292 .set = bond_option_updelay_set
293 },
Hangbin Liu3a755cd2021-08-02 11:02:19 +0800294 [BOND_OPT_LACP_ACTIVE] = {
295 .id = BOND_OPT_LACP_ACTIVE,
296 .name = "lacp_active",
297 .desc = "Send LACPDU frames with configured lacp rate or acts as speak when spoken to",
298 .flags = BOND_OPTFLAG_IFDOWN,
299 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
300 .values = bond_lacp_active,
301 .set = bond_option_lacp_active_set
302 },
Nikolay Aleksandrovd3131de2014-01-22 14:53:27 +0100303 [BOND_OPT_LACP_RATE] = {
304 .id = BOND_OPT_LACP_RATE,
305 .name = "lacp_rate",
306 .desc = "LACPDU tx rate to request from 802.3ad partner",
307 .flags = BOND_OPTFLAG_IFDOWN,
308 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
309 .values = bond_lacp_rate_tbl,
310 .set = bond_option_lacp_rate_set
311 },
Nikolay Aleksandrov633ddc92014-01-22 14:53:28 +0100312 [BOND_OPT_MINLINKS] = {
313 .id = BOND_OPT_MINLINKS,
314 .name = "min_links",
315 .desc = "Minimum number of available links before turning on carrier",
316 .values = bond_intmax_tbl,
317 .set = bond_option_min_links_set
318 },
Nikolay Aleksandrov9e5f5ee2014-01-22 14:53:29 +0100319 [BOND_OPT_AD_SELECT] = {
320 .id = BOND_OPT_AD_SELECT,
321 .name = "ad_select",
322 .desc = "803.ad aggregation selection logic",
323 .flags = BOND_OPTFLAG_IFDOWN,
324 .values = bond_ad_select_tbl,
325 .set = bond_option_ad_select_set
326 },
Nikolay Aleksandrovef56bec2014-01-22 14:53:30 +0100327 [BOND_OPT_NUM_PEER_NOTIF] = {
328 .id = BOND_OPT_NUM_PEER_NOTIF,
329 .name = "num_unsol_na",
330 .desc = "Number of peer notifications to send on failover event",
331 .values = bond_num_peer_notif_tbl,
332 .set = bond_option_num_peer_notif_set
333 },
Nikolay Aleksandrovb98d9c62014-01-22 14:53:31 +0100334 [BOND_OPT_MIIMON] = {
335 .id = BOND_OPT_MIIMON,
336 .name = "miimon",
337 .desc = "Link check interval in milliseconds",
338 .values = bond_intmax_tbl,
339 .set = bond_option_miimon_set
340 },
Nikolay Aleksandrov180222f2014-01-22 14:53:32 +0100341 [BOND_OPT_PRIMARY] = {
342 .id = BOND_OPT_PRIMARY,
343 .name = "primary",
344 .desc = "Primary network device to use",
345 .flags = BOND_OPTFLAG_RAWVAL,
346 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP) |
347 BIT(BOND_MODE_TLB) |
348 BIT(BOND_MODE_ALB)),
349 .set = bond_option_primary_set
350 },
Nikolay Aleksandrov388d3a62014-01-22 14:53:33 +0100351 [BOND_OPT_PRIMARY_RESELECT] = {
352 .id = BOND_OPT_PRIMARY_RESELECT,
353 .name = "primary_reselect",
354 .desc = "Reselect primary slave once it comes up",
355 .values = bond_primary_reselect_tbl,
356 .set = bond_option_primary_reselect_set
357 },
Nikolay Aleksandrov0fff06082014-01-22 14:53:34 +0100358 [BOND_OPT_USE_CARRIER] = {
359 .id = BOND_OPT_USE_CARRIER,
360 .name = "use_carrier",
361 .desc = "Use netif_carrier_ok (vs MII ioctls) in miimon",
362 .values = bond_use_carrier_tbl,
363 .set = bond_option_use_carrier_set
364 },
Nikolay Aleksandrovd1fbd3ed2014-01-22 14:53:35 +0100365 [BOND_OPT_ACTIVE_SLAVE] = {
366 .id = BOND_OPT_ACTIVE_SLAVE,
367 .name = "active_slave",
368 .desc = "Currently active slave",
369 .flags = BOND_OPTFLAG_RAWVAL,
370 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP) |
371 BIT(BOND_MODE_TLB) |
372 BIT(BOND_MODE_ALB)),
373 .set = bond_option_active_slave_set
374 },
Nikolay Aleksandrov24089ba2014-01-22 14:53:36 +0100375 [BOND_OPT_QUEUE_ID] = {
376 .id = BOND_OPT_QUEUE_ID,
377 .name = "queue_id",
378 .desc = "Set queue id of a slave",
379 .flags = BOND_OPTFLAG_RAWVAL,
380 .set = bond_option_queue_id_set
381 },
Nikolay Aleksandrov3df01162014-01-22 14:53:37 +0100382 [BOND_OPT_ALL_SLAVES_ACTIVE] = {
383 .id = BOND_OPT_ALL_SLAVES_ACTIVE,
384 .name = "all_slaves_active",
385 .desc = "Keep all frames received on an interface by setting active flag for all slaves",
386 .values = bond_all_slaves_active_tbl,
387 .set = bond_option_all_slaves_active_set
388 },
Nikolay Aleksandrov105c8fb2014-01-22 14:53:38 +0100389 [BOND_OPT_RESEND_IGMP] = {
390 .id = BOND_OPT_RESEND_IGMP,
391 .name = "resend_igmp",
392 .desc = "Number of IGMP membership reports to send on link failure",
393 .values = bond_resend_igmp_tbl,
394 .set = bond_option_resend_igmp_set
395 },
Nikolay Aleksandrov4325b372014-01-22 14:53:39 +0100396 [BOND_OPT_LP_INTERVAL] = {
397 .id = BOND_OPT_LP_INTERVAL,
398 .name = "lp_interval",
399 .desc = "The number of seconds between instances where the bonding driver sends learning packets to each slave's peer switch",
400 .values = bond_lp_interval_tbl,
401 .set = bond_option_lp_interval_set
402 },
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +0100403 [BOND_OPT_SLAVES] = {
404 .id = BOND_OPT_SLAVES,
405 .name = "slaves",
406 .desc = "Slave membership management",
407 .flags = BOND_OPTFLAG_RAWVAL,
408 .set = bond_option_slaves_set
409 },
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -0700410 [BOND_OPT_TLB_DYNAMIC_LB] = {
411 .id = BOND_OPT_TLB_DYNAMIC_LB,
Nikolay Aleksandrovdc3e5d12014-05-08 14:23:54 +0200412 .name = "tlb_dynamic_lb",
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -0700413 .desc = "Enable dynamic flow shuffling",
Debabrata Banerjeee79c1052018-05-14 14:48:09 -0400414 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_TLB) | BIT(BOND_MODE_ALB)),
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -0700415 .values = bond_tlb_dynamic_lb_tbl,
416 .flags = BOND_OPTFLAG_IFDOWN,
417 .set = bond_option_tlb_dynamic_lb_set,
Mahesh Bandewar6791e462015-05-09 00:01:55 -0700418 },
419 [BOND_OPT_AD_ACTOR_SYS_PRIO] = {
420 .id = BOND_OPT_AD_ACTOR_SYS_PRIO,
421 .name = "ad_actor_sys_prio",
422 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
Mahesh Bandewar6791e462015-05-09 00:01:55 -0700423 .values = bond_ad_actor_sys_prio_tbl,
424 .set = bond_option_ad_actor_sys_prio_set,
425 },
Mahesh Bandewar74514952015-05-09 00:01:56 -0700426 [BOND_OPT_AD_ACTOR_SYSTEM] = {
427 .id = BOND_OPT_AD_ACTOR_SYSTEM,
428 .name = "ad_actor_system",
429 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
Nikolay Aleksandrov7f20cd22016-02-04 17:42:28 +0100430 .flags = BOND_OPTFLAG_RAWVAL,
Mahesh Bandewar74514952015-05-09 00:01:56 -0700431 .set = bond_option_ad_actor_system_set,
432 },
Mahesh Bandeward22a5fc2015-05-09 00:01:57 -0700433 [BOND_OPT_AD_USER_PORT_KEY] = {
434 .id = BOND_OPT_AD_USER_PORT_KEY,
435 .name = "ad_user_port_key",
436 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
437 .flags = BOND_OPTFLAG_IFDOWN,
438 .values = bond_ad_user_port_key_tbl,
439 .set = bond_option_ad_user_port_key_set,
Nikolay Aleksandrov205845a2015-07-24 15:50:31 +0200440 },
441 [BOND_OPT_NUM_PEER_NOTIF_ALIAS] = {
442 .id = BOND_OPT_NUM_PEER_NOTIF_ALIAS,
443 .name = "num_grat_arp",
444 .desc = "Number of peer notifications to send on failover event",
445 .values = bond_num_peer_notif_tbl,
446 .set = bond_option_num_peer_notif_set
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200447 },
448 [BOND_OPT_PEER_NOTIF_DELAY] = {
449 .id = BOND_OPT_PEER_NOTIF_DELAY,
450 .name = "peer_notif_delay",
451 .desc = "Delay between each peer notification on failover event, in milliseconds",
452 .values = bond_intmax_tbl,
453 .set = bond_option_peer_notif_delay_set
Mahesh Bandeward22a5fc2015-05-09 00:01:57 -0700454 }
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100455};
456
Nikolay Aleksandrovdc3e5d12014-05-08 14:23:54 +0200457/* Searches for an option by name */
458const struct bond_option *bond_opt_get_by_name(const char *name)
459{
460 const struct bond_option *opt;
461 int option;
462
463 for (option = 0; option < BOND_OPT_LAST; option++) {
464 opt = bond_opt_get(option);
465 if (opt && !strcmp(opt->name, name))
466 return opt;
467 }
468
469 return NULL;
470}
471
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100472/* Searches for a value in opt's values[] table */
stephen hemmingerf3253332014-03-04 16:36:44 -0800473const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val)
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100474{
stephen hemmingerf3253332014-03-04 16:36:44 -0800475 const struct bond_option *opt;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100476 int i;
477
478 opt = bond_opt_get(option);
479 if (WARN_ON(!opt))
480 return NULL;
481 for (i = 0; opt->values && opt->values[i].string; i++)
482 if (opt->values[i].value == val)
483 return &opt->values[i];
484
485 return NULL;
486}
487
488/* Searches for a value in opt's values[] table which matches the flagmask */
stephen hemmingerf3253332014-03-04 16:36:44 -0800489static const struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt,
Michael Dilmoreeac306b2017-06-26 16:49:46 +0100490 u32 flagmask)
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100491{
492 int i;
493
494 for (i = 0; opt->values && opt->values[i].string; i++)
495 if (opt->values[i].flags & flagmask)
496 return &opt->values[i];
497
498 return NULL;
499}
500
501/* If maxval is missing then there's no range to check. In case minval is
502 * missing then it's considered to be 0.
503 */
504static bool bond_opt_check_range(const struct bond_option *opt, u64 val)
505{
stephen hemmingerf3253332014-03-04 16:36:44 -0800506 const struct bond_opt_value *minval, *maxval;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100507
508 minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
509 maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
510 if (!maxval || (minval && val < minval->value) || val > maxval->value)
511 return false;
512
513 return true;
514}
515
516/**
517 * bond_opt_parse - parse option value
518 * @opt: the option to parse against
519 * @val: value to parse
520 *
521 * This function tries to extract the value from @val and check if it's
522 * a possible match for the option and returns NULL if a match isn't found,
523 * or the struct_opt_value that matched. It also strips the new line from
524 * @val->string if it's present.
525 */
stephen hemmingerf3253332014-03-04 16:36:44 -0800526const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
527 struct bond_opt_value *val)
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100528{
529 char *p, valstr[BOND_OPT_MAX_NAMELEN + 1] = { 0, };
stephen hemmingerf3253332014-03-04 16:36:44 -0800530 const struct bond_opt_value *tbl;
531 const struct bond_opt_value *ret = NULL;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100532 bool checkval;
533 int i, rv;
534
535 /* No parsing if the option wants a raw val */
536 if (opt->flags & BOND_OPTFLAG_RAWVAL)
537 return val;
538
539 tbl = opt->values;
540 if (!tbl)
541 goto out;
542
543 /* ULLONG_MAX is used to bypass string processing */
544 checkval = val->value != ULLONG_MAX;
545 if (!checkval) {
546 if (!val->string)
547 goto out;
548 p = strchr(val->string, '\n');
549 if (p)
550 *p = '\0';
551 for (p = val->string; *p; p++)
552 if (!(isdigit(*p) || isspace(*p)))
553 break;
554 /* The following code extracts the string to match or the value
555 * and sets checkval appropriately
556 */
557 if (*p) {
558 rv = sscanf(val->string, "%32s", valstr);
559 } else {
560 rv = sscanf(val->string, "%llu", &val->value);
561 checkval = true;
562 }
563 if (!rv)
564 goto out;
565 }
566
567 for (i = 0; tbl[i].string; i++) {
568 /* Check for exact match */
569 if (checkval) {
570 if (val->value == tbl[i].value)
571 ret = &tbl[i];
572 } else {
573 if (!strcmp(valstr, "default") &&
574 (tbl[i].flags & BOND_VALFLAG_DEFAULT))
575 ret = &tbl[i];
576
577 if (!strcmp(valstr, tbl[i].string))
578 ret = &tbl[i];
579 }
580 /* Found an exact match */
581 if (ret)
582 goto out;
583 }
584 /* Possible range match */
585 if (checkval && bond_opt_check_range(opt, val->value))
586 ret = val;
587out:
588 return ret;
589}
590
591/* Check opt's dependencies against bond mode and currently set options */
592static int bond_opt_check_deps(struct bonding *bond,
593 const struct bond_option *opt)
594{
595 struct bond_params *params = &bond->params;
596
597 if (test_bit(params->mode, &opt->unsuppmodes))
598 return -EACCES;
599 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond))
600 return -ENOTEMPTY;
601 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP))
602 return -EBUSY;
603
604 return 0;
605}
606
607static void bond_opt_dep_print(struct bonding *bond,
608 const struct bond_option *opt)
609{
stephen hemminger28f084c2014-03-06 14:20:17 -0800610 const struct bond_opt_value *modeval;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100611 struct bond_params *params;
612
613 params = &bond->params;
Nikolay Aleksandrov2b3798d2014-01-22 14:53:17 +0100614 modeval = bond_opt_get_val(BOND_OPT_MODE, params->mode);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100615 if (test_bit(params->mode, &opt->unsuppmodes))
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200616 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n",
617 opt->name, modeval->string, modeval->value);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100618}
619
620static void bond_opt_error_interpret(struct bonding *bond,
621 const struct bond_option *opt,
stephen hemminger28f084c2014-03-06 14:20:17 -0800622 int error, const struct bond_opt_value *val)
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100623{
stephen hemminger28f084c2014-03-06 14:20:17 -0800624 const struct bond_opt_value *minval, *maxval;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100625 char *p;
626
627 switch (error) {
628 case -EINVAL:
629 if (val) {
630 if (val->string) {
631 /* sometimes RAWVAL opts may have new lines */
632 p = strchr(val->string, '\n');
633 if (p)
634 *p = '\0';
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200635 netdev_err(bond->dev, "option %s: invalid value (%s)\n",
636 opt->name, val->string);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100637 } else {
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200638 netdev_err(bond->dev, "option %s: invalid value (%llu)\n",
639 opt->name, val->value);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100640 }
641 }
642 minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
643 maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
644 if (!maxval)
645 break;
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200646 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n",
647 opt->name, minval ? minval->value : 0, maxval->value);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100648 break;
649 case -EACCES:
650 bond_opt_dep_print(bond, opt);
651 break;
652 case -ENOTEMPTY:
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200653 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n",
654 opt->name);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100655 break;
656 case -EBUSY:
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200657 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n",
658 opt->name);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100659 break;
Jianlin Lvacdff0d2021-03-14 22:56:29 +0800660 case -ENODEV:
661 if (val && val->string) {
662 p = strchr(val->string, '\n');
663 if (p)
664 *p = '\0';
665 netdev_err(bond->dev, "option %s: interface %s does not exist!\n",
666 opt->name, val->string);
667 }
668 break;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100669 default:
670 break;
671 }
672}
673
674/**
675 * __bond_opt_set - set a bonding option
676 * @bond: target bond device
677 * @option: option to set
678 * @val: value to set it to
679 *
680 * This function is used to change the bond's option value, it can be
681 * used for both enabling/changing an option and for disabling it. RTNL lock
682 * must be obtained before calling this function.
683 */
684int __bond_opt_set(struct bonding *bond,
685 unsigned int option, struct bond_opt_value *val)
686{
stephen hemminger28f084c2014-03-06 14:20:17 -0800687 const struct bond_opt_value *retval = NULL;
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100688 const struct bond_option *opt;
689 int ret = -ENOENT;
690
691 ASSERT_RTNL();
692
693 opt = bond_opt_get(option);
694 if (WARN_ON(!val) || WARN_ON(!opt))
695 goto out;
696 ret = bond_opt_check_deps(bond, opt);
697 if (ret)
698 goto out;
699 retval = bond_opt_parse(opt, val);
700 if (!retval) {
701 ret = -EINVAL;
702 goto out;
703 }
704 ret = opt->set(bond, retval);
705out:
706 if (ret)
707 bond_opt_error_interpret(bond, opt, ret, val);
Vlad Yasevich7a7e96e2017-05-27 10:14:35 -0400708
709 return ret;
710}
711/**
712 * __bond_opt_set_notify - set a bonding option
713 * @bond: target bond device
714 * @option: option to set
715 * @val: value to set it to
716 *
717 * This function is used to change the bond's option value and trigger
718 * a notification to user sapce. It can be used for both enabling/changing
719 * an option and for disabling it. RTNL lock must be obtained before calling
720 * this function.
721 */
722int __bond_opt_set_notify(struct bonding *bond,
723 unsigned int option, struct bond_opt_value *val)
724{
Colin Ian King92e1b572021-06-03 14:19:04 +0100725 int ret;
Vlad Yasevich7a7e96e2017-05-27 10:14:35 -0400726
727 ASSERT_RTNL();
728
729 ret = __bond_opt_set(bond, option, val);
730
731 if (!ret && (bond->dev->reg_state == NETREG_REGISTERED))
Jiri Pirkod4261e52014-08-19 16:02:12 +0200732 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100733
734 return ret;
735}
736
737/**
738 * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set
739 * @bond: target bond device
740 * @option: option to set
741 * @buf: value to set it to
742 *
743 * This function tries to acquire RTNL without blocking and if successful
744 * calls __bond_opt_set. It is mainly used for sysfs option manipulation.
745 */
746int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
747{
748 struct bond_opt_value optval;
749 int ret;
750
751 if (!rtnl_trylock())
752 return restart_syscall();
753 bond_opt_initstr(&optval, buf);
Vlad Yasevich7a7e96e2017-05-27 10:14:35 -0400754 ret = __bond_opt_set_notify(bond, option, &optval);
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100755 rtnl_unlock();
756
757 return ret;
758}
759
760/**
761 * bond_opt_get - get a pointer to an option
762 * @option: option for which to return a pointer
763 *
764 * This function checks if option is valid and if so returns a pointer
765 * to its entry in the bond_opts[] option array.
766 */
stephen hemmingerf3253332014-03-04 16:36:44 -0800767const struct bond_option *bond_opt_get(unsigned int option)
Nikolay Aleksandrov09117362014-01-22 14:53:16 +0100768{
769 if (!BOND_OPT_VALID(option))
770 return NULL;
771
772 return &bond_opts[option];
773}
774
Tariq Toukanf45583d2021-01-17 16:59:45 +0200775static bool bond_set_xfrm_features(struct bonding *bond)
Jarod Wilson007ab532020-12-05 12:22:29 -0500776{
777 if (!IS_ENABLED(CONFIG_XFRM_OFFLOAD))
Tariq Toukanf45583d2021-01-17 16:59:45 +0200778 return false;
Jarod Wilson007ab532020-12-05 12:22:29 -0500779
Tariq Toukanf45583d2021-01-17 16:59:45 +0200780 if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
781 bond->dev->wanted_features |= BOND_XFRM_FEATURES;
Jarod Wilson007ab532020-12-05 12:22:29 -0500782 else
Tariq Toukanf45583d2021-01-17 16:59:45 +0200783 bond->dev->wanted_features &= ~BOND_XFRM_FEATURES;
Jarod Wilson007ab532020-12-05 12:22:29 -0500784
Tariq Toukanf45583d2021-01-17 16:59:45 +0200785 return true;
Jarod Wilson007ab532020-12-05 12:22:29 -0500786}
787
Tariq Toukan89df6a82021-01-17 16:59:46 +0200788static bool bond_set_tls_features(struct bonding *bond)
789{
790 if (!IS_ENABLED(CONFIG_TLS_DEVICE))
791 return false;
792
793 if (bond_sk_check(bond))
794 bond->dev->wanted_features |= BOND_TLS_FEATURES;
795 else
796 bond->dev->wanted_features &= ~BOND_TLS_FEATURES;
797
798 return true;
799}
800
Nikolay Aleksandrovff11d8b2014-07-15 16:08:57 +0200801static int bond_option_mode_set(struct bonding *bond,
802 const struct bond_opt_value *newval)
Jiri Pirko72be35f2013-10-18 17:43:34 +0200803{
Jarod Wilsonc1f897c2018-07-18 14:49:36 -0400804 if (!bond_mode_uses_arp(newval->value)) {
805 if (bond->params.arp_interval) {
806 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n",
807 newval->string);
808 /* disable arp monitoring */
809 bond->params.arp_interval = 0;
810 }
811
812 if (!bond->params.miimon) {
813 /* set miimon to default value */
814 bond->params.miimon = BOND_DEFAULT_MIIMON;
815 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n",
816 bond->params.miimon);
817 }
Jiri Pirko72be35f2013-10-18 17:43:34 +0200818 }
819
Kosuke Tatsukawac6644d02017-09-06 22:47:59 +0000820 if (newval->value == BOND_MODE_ALB)
821 bond->params.tlb_dynamic_lb = 1;
822
Jiri Pirko72be35f2013-10-18 17:43:34 +0200823 /* don't cache arp_validate between modes */
824 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
Nikolay Aleksandrov2b3798d2014-01-22 14:53:17 +0100825 bond->params.mode = newval->value;
826
Tariq Toukan89df6a82021-01-17 16:59:46 +0200827 if (bond->dev->reg_state == NETREG_REGISTERED) {
828 bool update = false;
829
830 update |= bond_set_xfrm_features(bond);
831 update |= bond_set_tls_features(bond);
832
833 if (update)
Tariq Toukanf45583d2021-01-17 16:59:45 +0200834 netdev_update_features(bond->dev);
Tariq Toukan89df6a82021-01-17 16:59:46 +0200835 }
Tariq Toukanf45583d2021-01-17 16:59:45 +0200836
Jiri Pirko72be35f2013-10-18 17:43:34 +0200837 return 0;
838}
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200839
stephen hemmingerf3253332014-03-04 16:36:44 -0800840static int bond_option_active_slave_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -0800841 const struct bond_opt_value *newval)
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200842{
Nikolay Aleksandrovd1fbd3ed2014-01-22 14:53:35 +0100843 char ifname[IFNAMSIZ] = { 0, };
844 struct net_device *slave_dev;
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200845 int ret = 0;
846
Nikolay Aleksandrovd1fbd3ed2014-01-22 14:53:35 +0100847 sscanf(newval->string, "%15s", ifname); /* IFNAMSIZ */
848 if (!strlen(ifname) || newval->string[0] == '\n') {
849 slave_dev = NULL;
850 } else {
851 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname);
852 if (!slave_dev)
853 return -ENODEV;
854 }
855
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200856 if (slave_dev) {
857 if (!netif_is_bond_slave(slave_dev)) {
Jarod Wilsonf887e542019-06-07 10:59:32 -0400858 slave_err(bond->dev, slave_dev, "Device is not bonding slave\n");
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200859 return -EINVAL;
860 }
861
862 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) {
Jarod Wilsonf887e542019-06-07 10:59:32 -0400863 slave_err(bond->dev, slave_dev, "Device is not our slave\n");
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200864 return -EINVAL;
865 }
866 }
867
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200868 block_netpoll_tx();
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200869 /* check to see if we are clearing active */
870 if (!slave_dev) {
Michael Dilmoreeac306b2017-06-26 16:49:46 +0100871 netdev_dbg(bond->dev, "Clearing current active slave\n");
Monam Agarwal8800a242014-03-24 00:00:17 +0530872 RCU_INIT_POINTER(bond->curr_active_slave, NULL);
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200873 bond_select_active_slave(bond);
874 } else {
Nikolay Aleksandrov1c72cfdc92014-09-11 22:49:24 +0200875 struct slave *old_active = rtnl_dereference(bond->curr_active_slave);
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200876 struct slave *new_active = bond_slave_get_rtnl(slave_dev);
877
878 BUG_ON(!new_active);
879
880 if (new_active == old_active) {
881 /* do nothing */
Jarod Wilsonf887e542019-06-07 10:59:32 -0400882 slave_dbg(bond->dev, new_active->dev, "is already the current active slave\n");
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200883 } else {
884 if (old_active && (new_active->link == BOND_LINK_UP) &&
Veaceslav Falicob6adc612014-05-15 21:39:57 +0200885 bond_slave_is_up(new_active)) {
Jarod Wilsonf887e542019-06-07 10:59:32 -0400886 slave_dbg(bond->dev, new_active->dev, "Setting as active slave\n");
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200887 bond_change_active_slave(bond, new_active);
888 } else {
Jarod Wilsonf887e542019-06-07 10:59:32 -0400889 slave_err(bond->dev, new_active->dev, "Could not set as active slave; either %s is down or the link is down\n",
890 new_active->dev->name);
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200891 ret = -EINVAL;
892 }
893 }
894 }
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200895 unblock_netpoll_tx();
Nikolay Aleksandrovd1fbd3ed2014-01-22 14:53:35 +0100896
Jiri Pirkod9e32b22013-10-18 17:43:35 +0200897 return ret;
898}
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800899
Nikolay Aleksandrovdc3e5d12014-05-08 14:23:54 +0200900/* There are two tricky bits here. First, if MII monitoring is activated, then
901 * we must disable ARP monitoring. Second, if the timer isn't running, we must
902 * start it.
903 */
stephen hemmingerf3253332014-03-04 16:36:44 -0800904static int bond_option_miimon_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -0800905 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800906{
Michael Dilmoreeac306b2017-06-26 16:49:46 +0100907 netdev_dbg(bond->dev, "Setting MII monitoring interval to %llu\n",
908 newval->value);
Nikolay Aleksandrovb98d9c62014-01-22 14:53:31 +0100909 bond->params.miimon = newval->value;
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800910 if (bond->params.updelay)
Michael Dilmoreeac306b2017-06-26 16:49:46 +0100911 netdev_dbg(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n",
912 bond->params.updelay * bond->params.miimon);
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800913 if (bond->params.downdelay)
Michael Dilmoreeac306b2017-06-26 16:49:46 +0100914 netdev_dbg(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value\n",
915 bond->params.downdelay * bond->params.miimon);
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200916 if (bond->params.peer_notif_delay)
917 netdev_dbg(bond->dev, "Note: Updating peer_notif_delay (to %d) since it is a multiple of the miimon value\n",
918 bond->params.peer_notif_delay * bond->params.miimon);
Nikolay Aleksandrovb98d9c62014-01-22 14:53:31 +0100919 if (newval->value && bond->params.arp_interval) {
Michael Dilmoreeac306b2017-06-26 16:49:46 +0100920 netdev_dbg(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitoring...\n");
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800921 bond->params.arp_interval = 0;
922 if (bond->params.arp_validate)
923 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
924 }
925 if (bond->dev->flags & IFF_UP) {
926 /* If the interface is up, we may need to fire off
927 * the MII timer. If the interface is down, the
928 * timer will get fired off when the open function
929 * is called.
930 */
Nikolay Aleksandrovb98d9c62014-01-22 14:53:31 +0100931 if (!newval->value) {
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800932 cancel_delayed_work_sync(&bond->mii_work);
933 } else {
934 cancel_delayed_work_sync(&bond->arp_work);
935 queue_delayed_work(bond->wq, &bond->mii_work, 0);
936 }
937 }
Nikolay Aleksandrovb98d9c62014-01-22 14:53:31 +0100938
sfeldma@cumulusnetworks.comeecdaa62013-12-12 14:09:55 -0800939 return 0;
940}
sfeldma@cumulusnetworks.com25852e22013-12-12 14:10:02 -0800941
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200942/* Set up, down and peer notification delays. These must be multiples
943 * of the MII monitoring value, and are stored internally as the
944 * multiplier. Thus, we must translate to MS for the real world.
Nikolay Aleksandrovdc3e5d12014-05-08 14:23:54 +0200945 */
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200946static int _bond_option_delay_set(struct bonding *bond,
947 const struct bond_opt_value *newval,
948 const char *name,
949 int *target)
sfeldma@cumulusnetworks.com25852e22013-12-12 14:10:02 -0800950{
Nikolay Aleksandrov0681a282014-01-23 23:43:43 +0100951 int value = newval->value;
952
Nikolay Aleksandrove4994612014-01-22 14:53:26 +0100953 if (!bond->params.miimon) {
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200954 netdev_err(bond->dev, "Unable to set %s as MII monitoring is disabled\n",
955 name);
sfeldma@cumulusnetworks.com25852e22013-12-12 14:10:02 -0800956 return -EPERM;
957 }
Nikolay Aleksandrov0681a282014-01-23 23:43:43 +0100958 if ((value % bond->params.miimon) != 0) {
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200959 netdev_warn(bond->dev,
960 "%s (%d) is not a multiple of miimon (%d), value rounded to %d ms\n",
961 name,
Veaceslav Falico2de390b2014-07-15 19:36:08 +0200962 value, bond->params.miimon,
963 (value / bond->params.miimon) *
964 bond->params.miimon);
sfeldma@cumulusnetworks.com25852e22013-12-12 14:10:02 -0800965 }
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200966 *target = value / bond->params.miimon;
967 netdev_dbg(bond->dev, "Setting %s to %d\n",
968 name,
969 *target * bond->params.miimon);
sfeldma@cumulusnetworks.com25852e22013-12-12 14:10:02 -0800970
971 return 0;
972}
sfeldma@cumulusnetworks.comc7461f92013-12-12 14:10:09 -0800973
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200974static int bond_option_updelay_set(struct bonding *bond,
975 const struct bond_opt_value *newval)
976{
977 return _bond_option_delay_set(bond, newval, "up delay",
978 &bond->params.updelay);
979}
980
stephen hemmingerf3253332014-03-04 16:36:44 -0800981static int bond_option_downdelay_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -0800982 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comc7461f92013-12-12 14:10:09 -0800983{
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200984 return _bond_option_delay_set(bond, newval, "down delay",
985 &bond->params.downdelay);
986}
Nikolay Aleksandrov0681a282014-01-23 23:43:43 +0100987
Vincent Bernat07a4dde2019-07-02 19:43:54 +0200988static int bond_option_peer_notif_delay_set(struct bonding *bond,
989 const struct bond_opt_value *newval)
990{
991 int ret = _bond_option_delay_set(bond, newval,
992 "peer notification delay",
993 &bond->params.peer_notif_delay);
994 return ret;
sfeldma@cumulusnetworks.comc7461f92013-12-12 14:10:09 -0800995}
sfeldma@cumulusnetworks.com9f53e142013-12-12 14:10:16 -0800996
stephen hemmingerf3253332014-03-04 16:36:44 -0800997static int bond_option_use_carrier_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -0800998 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com9f53e142013-12-12 14:10:16 -0800999{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001000 netdev_dbg(bond->dev, "Setting use_carrier to %llu\n",
1001 newval->value);
Nikolay Aleksandrov0fff06082014-01-22 14:53:34 +01001002 bond->params.use_carrier = newval->value;
sfeldma@cumulusnetworks.com9f53e142013-12-12 14:10:16 -08001003
1004 return 0;
1005}
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001006
Nikolay Aleksandrovdc3e5d12014-05-08 14:23:54 +02001007/* There are two tricky bits here. First, if ARP monitoring is activated, then
1008 * we must disable MII monitoring. Second, if the ARP timer isn't running,
1009 * we must start it.
1010 */
stephen hemmingerf3253332014-03-04 16:36:44 -08001011static int bond_option_arp_interval_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001012 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001013{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001014 netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n",
1015 newval->value);
Nikolay Aleksandrov7bdb04e2014-01-22 14:53:23 +01001016 bond->params.arp_interval = newval->value;
1017 if (newval->value) {
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001018 if (bond->params.miimon) {
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001019 netdev_dbg(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring\n");
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001020 bond->params.miimon = 0;
1021 }
1022 if (!bond->params.arp_targets[0])
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001023 netdev_dbg(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n");
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001024 }
1025 if (bond->dev->flags & IFF_UP) {
1026 /* If the interface is up, we may need to fire off
1027 * the ARP timer. If the interface is down, the
1028 * timer will get fired off when the open function
1029 * is called.
1030 */
Nikolay Aleksandrov7bdb04e2014-01-22 14:53:23 +01001031 if (!newval->value) {
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001032 if (bond->params.arp_validate)
1033 bond->recv_probe = NULL;
1034 cancel_delayed_work_sync(&bond->arp_work);
1035 } else {
1036 /* arp_validate can be set only in active-backup mode */
Veaceslav Falico3fe68df2014-02-18 07:48:39 +01001037 bond->recv_probe = bond_arp_rcv;
sfeldma@cumulusnetworks.com06151db2013-12-12 14:10:24 -08001038 cancel_delayed_work_sync(&bond->mii_work);
1039 queue_delayed_work(bond->wq, &bond->arp_work, 0);
1040 }
1041 }
1042
1043 return 0;
1044}
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001045
1046static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot,
1047 __be32 target,
1048 unsigned long last_rx)
1049{
1050 __be32 *targets = bond->params.arp_targets;
1051 struct list_head *iter;
1052 struct slave *slave;
1053
1054 if (slot >= 0 && slot < BOND_MAX_ARP_TARGETS) {
1055 bond_for_each_slave(bond, slave, iter)
1056 slave->target_last_arp_rx[slot] = last_rx;
1057 targets[slot] = target;
1058 }
1059}
1060
1061static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
1062{
1063 __be32 *targets = bond->params.arp_targets;
1064 int ind;
1065
Veaceslav Falico2807a9f2014-05-15 21:39:56 +02001066 if (!bond_is_ip_target_ok(target)) {
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001067 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n",
1068 &target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001069 return -EINVAL;
1070 }
1071
1072 if (bond_get_targets_ip(targets, target) != -1) { /* dup */
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001073 netdev_err(bond->dev, "ARP target %pI4 is already present\n",
1074 &target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001075 return -EINVAL;
1076 }
1077
1078 ind = bond_get_targets_ip(targets, 0); /* first free slot */
1079 if (ind == -1) {
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001080 netdev_err(bond->dev, "ARP target table is full!\n");
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001081 return -EINVAL;
1082 }
1083
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001084 netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001085
1086 _bond_options_arp_ip_target_set(bond, ind, target, jiffies);
1087
1088 return 0;
1089}
1090
stephen hemmingerf3253332014-03-04 16:36:44 -08001091static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001092{
Nikolay Aleksandrov246df7b2014-09-09 23:17:02 +02001093 return _bond_option_arp_ip_target_add(bond, target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001094}
1095
stephen hemmingerf3253332014-03-04 16:36:44 -08001096static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001097{
1098 __be32 *targets = bond->params.arp_targets;
1099 struct list_head *iter;
1100 struct slave *slave;
1101 unsigned long *targets_rx;
1102 int ind, i;
1103
Veaceslav Falico2807a9f2014-05-15 21:39:56 +02001104 if (!bond_is_ip_target_ok(target)) {
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001105 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n",
1106 &target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001107 return -EINVAL;
1108 }
1109
1110 ind = bond_get_targets_ip(targets, target);
1111 if (ind == -1) {
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001112 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n",
1113 &target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001114 return -EINVAL;
1115 }
1116
1117 if (ind == 0 && !targets[1] && bond->params.arp_interval)
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001118 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n");
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001119
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001120 netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001121
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001122 bond_for_each_slave(bond, slave, iter) {
1123 targets_rx = slave->target_last_arp_rx;
1124 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
1125 targets_rx[i] = targets_rx[i+1];
1126 targets_rx[i] = 0;
1127 }
1128 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
1129 targets[i] = targets[i+1];
1130 targets[i] = 0;
1131
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001132 return 0;
1133}
1134
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001135void bond_option_arp_ip_targets_clear(struct bonding *bond)
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001136{
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001137 int i;
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001138
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001139 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++)
1140 _bond_options_arp_ip_target_set(bond, i, 0, 0);
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001141}
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001142
stephen hemmingerf3253332014-03-04 16:36:44 -08001143static int bond_option_arp_ip_targets_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001144 const struct bond_opt_value *newval)
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001145{
1146 int ret = -EPERM;
1147 __be32 target;
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001148
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001149 if (newval->string) {
1150 if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) {
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001151 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n",
1152 &target);
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001153 return ret;
1154 }
1155 if (newval->string[0] == '+')
1156 ret = bond_option_arp_ip_target_add(bond, target);
1157 else if (newval->string[0] == '-')
1158 ret = bond_option_arp_ip_target_rem(bond, target);
1159 else
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001160 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n");
Nikolay Aleksandrov4fb0ef582014-01-22 14:53:24 +01001161 } else {
1162 target = newval->value;
1163 ret = bond_option_arp_ip_target_add(bond, target);
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001164 }
1165
sfeldma@cumulusnetworks.com7f28fa12013-12-12 14:10:31 -08001166 return ret;
1167}
sfeldma@cumulusnetworks.com29c49482013-12-12 14:10:38 -08001168
stephen hemmingerf3253332014-03-04 16:36:44 -08001169static int bond_option_arp_validate_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001170 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com29c49482013-12-12 14:10:38 -08001171{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001172 netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n",
1173 newval->string, newval->value);
Nikolay Aleksandrov16228882014-01-22 14:53:20 +01001174 bond->params.arp_validate = newval->value;
sfeldma@cumulusnetworks.com29c49482013-12-12 14:10:38 -08001175
1176 return 0;
1177}
sfeldma@cumulusnetworks.comd5c84252013-12-12 14:10:45 -08001178
stephen hemmingerf3253332014-03-04 16:36:44 -08001179static int bond_option_arp_all_targets_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001180 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comd5c84252013-12-12 14:10:45 -08001181{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001182 netdev_dbg(bond->dev, "Setting arp_all_targets to %s (%llu)\n",
1183 newval->string, newval->value);
Nikolay Aleksandrovedf36b22014-01-22 14:53:21 +01001184 bond->params.arp_all_targets = newval->value;
sfeldma@cumulusnetworks.comd5c84252013-12-12 14:10:45 -08001185
1186 return 0;
1187}
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001188
stephen hemmingerf3253332014-03-04 16:36:44 -08001189static int bond_option_primary_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001190 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001191{
Nikolay Aleksandrov180222f2014-01-22 14:53:32 +01001192 char *p, *primary = newval->string;
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001193 struct list_head *iter;
1194 struct slave *slave;
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001195
1196 block_netpoll_tx();
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001197
Nikolay Aleksandrov180222f2014-01-22 14:53:32 +01001198 p = strchr(primary, '\n');
1199 if (p)
1200 *p = '\0';
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001201 /* check to see if we are clearing primary */
1202 if (!strlen(primary)) {
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001203 netdev_dbg(bond->dev, "Setting primary slave to None\n");
Nikolay Aleksandrov059b47e2014-09-09 23:17:00 +02001204 RCU_INIT_POINTER(bond->primary_slave, NULL);
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001205 memset(bond->params.primary, 0, sizeof(bond->params.primary));
1206 bond_select_active_slave(bond);
1207 goto out;
1208 }
1209
1210 bond_for_each_slave(bond, slave, iter) {
1211 if (strncmp(slave->dev->name, primary, IFNAMSIZ) == 0) {
Jarod Wilsonf887e542019-06-07 10:59:32 -04001212 slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n");
Nikolay Aleksandrov059b47e2014-09-09 23:17:00 +02001213 rcu_assign_pointer(bond->primary_slave, slave);
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001214 strcpy(bond->params.primary, slave->dev->name);
Xiangning Yueb55bbf2018-06-07 13:39:59 +08001215 bond->force_primary = true;
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001216 bond_select_active_slave(bond);
1217 goto out;
1218 }
1219 }
1220
Nikolay Aleksandrov059b47e2014-09-09 23:17:00 +02001221 if (rtnl_dereference(bond->primary_slave)) {
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001222 netdev_dbg(bond->dev, "Setting primary slave to None\n");
Nikolay Aleksandrov059b47e2014-09-09 23:17:00 +02001223 RCU_INIT_POINTER(bond->primary_slave, NULL);
dingtianhongc59ab672014-01-18 16:28:52 +08001224 bond_select_active_slave(bond);
1225 }
Kees Cook43902072021-06-02 13:58:20 -07001226 strscpy_pad(bond->params.primary, primary, IFNAMSIZ);
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001227
Jarod Wilsonf887e542019-06-07 10:59:32 -04001228 netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n",
1229 primary);
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001230
1231out:
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001232 unblock_netpoll_tx();
1233
Nikolay Aleksandrov180222f2014-01-22 14:53:32 +01001234 return 0;
sfeldma@cumulusnetworks.com0a98a0d2013-12-15 16:41:51 -08001235}
sfeldma@cumulusnetworks.com8a41ae42013-12-15 16:41:58 -08001236
stephen hemmingerf3253332014-03-04 16:36:44 -08001237static int bond_option_primary_reselect_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001238 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com8a41ae42013-12-15 16:41:58 -08001239{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001240 netdev_dbg(bond->dev, "Setting primary_reselect to %s (%llu)\n",
1241 newval->string, newval->value);
Nikolay Aleksandrov388d3a62014-01-22 14:53:33 +01001242 bond->params.primary_reselect = newval->value;
sfeldma@cumulusnetworks.com8a41ae42013-12-15 16:41:58 -08001243
1244 block_netpoll_tx();
sfeldma@cumulusnetworks.com8a41ae42013-12-15 16:41:58 -08001245 bond_select_active_slave(bond);
sfeldma@cumulusnetworks.com8a41ae42013-12-15 16:41:58 -08001246 unblock_netpoll_tx();
1247
1248 return 0;
1249}
sfeldma@cumulusnetworks.com89901972013-12-15 16:42:05 -08001250
stephen hemmingerf3253332014-03-04 16:36:44 -08001251static int bond_option_fail_over_mac_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001252 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com89901972013-12-15 16:42:05 -08001253{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001254 netdev_dbg(bond->dev, "Setting fail_over_mac to %s (%llu)\n",
1255 newval->string, newval->value);
Nikolay Aleksandrov1df6b6a2014-01-22 14:53:22 +01001256 bond->params.fail_over_mac = newval->value;
sfeldma@cumulusnetworks.com89901972013-12-15 16:42:05 -08001257
1258 return 0;
1259}
sfeldma@cumulusnetworks.comf70161c2013-12-15 16:42:12 -08001260
stephen hemmingerf3253332014-03-04 16:36:44 -08001261static int bond_option_xmit_hash_policy_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001262 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comf70161c2013-12-15 16:42:12 -08001263{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001264 netdev_dbg(bond->dev, "Setting xmit hash policy to %s (%llu)\n",
1265 newval->string, newval->value);
Nikolay Aleksandrova4b32ce2014-01-22 14:53:19 +01001266 bond->params.xmit_policy = newval->value;
sfeldma@cumulusnetworks.comf70161c2013-12-15 16:42:12 -08001267
Tariq Toukan89df6a82021-01-17 16:59:46 +02001268 if (bond->dev->reg_state == NETREG_REGISTERED)
1269 if (bond_set_tls_features(bond))
1270 netdev_update_features(bond->dev);
1271
sfeldma@cumulusnetworks.comf70161c2013-12-15 16:42:12 -08001272 return 0;
1273}
sfeldma@cumulusnetworks.comd8838de72013-12-15 16:42:19 -08001274
stephen hemmingerf3253332014-03-04 16:36:44 -08001275static int bond_option_resend_igmp_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001276 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comd8838de72013-12-15 16:42:19 -08001277{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001278 netdev_dbg(bond->dev, "Setting resend_igmp to %llu\n",
1279 newval->value);
Nikolay Aleksandrov105c8fb2014-01-22 14:53:38 +01001280 bond->params.resend_igmp = newval->value;
sfeldma@cumulusnetworks.comd8838de72013-12-15 16:42:19 -08001281
1282 return 0;
1283}
sfeldma@cumulusnetworks.com2c9839c2013-12-17 21:30:09 -08001284
stephen hemmingerf3253332014-03-04 16:36:44 -08001285static int bond_option_num_peer_notif_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001286 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com2c9839c2013-12-17 21:30:09 -08001287{
Nikolay Aleksandrovef56bec2014-01-22 14:53:30 +01001288 bond->params.num_peer_notif = newval->value;
1289
sfeldma@cumulusnetworks.com2c9839c2013-12-17 21:30:09 -08001290 return 0;
1291}
sfeldma@cumulusnetworks.com1cc0b1e2013-12-17 21:30:16 -08001292
stephen hemmingerf3253332014-03-04 16:36:44 -08001293static int bond_option_all_slaves_active_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001294 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com1cc0b1e2013-12-17 21:30:16 -08001295{
1296 struct list_head *iter;
1297 struct slave *slave;
1298
Nikolay Aleksandrov3df01162014-01-22 14:53:37 +01001299 if (newval->value == bond->params.all_slaves_active)
sfeldma@cumulusnetworks.com1cc0b1e2013-12-17 21:30:16 -08001300 return 0;
Nikolay Aleksandrov3df01162014-01-22 14:53:37 +01001301 bond->params.all_slaves_active = newval->value;
sfeldma@cumulusnetworks.com1cc0b1e2013-12-17 21:30:16 -08001302 bond_for_each_slave(bond, slave, iter) {
1303 if (!bond_is_active_slave(slave)) {
Nikolay Aleksandrov3df01162014-01-22 14:53:37 +01001304 if (newval->value)
sfeldma@cumulusnetworks.com1cc0b1e2013-12-17 21:30:16 -08001305 slave->inactive = 0;
1306 else
1307 slave->inactive = 1;
1308 }
1309 }
1310
1311 return 0;
1312}
sfeldma@cumulusnetworks.com7d101002013-12-17 21:30:23 -08001313
stephen hemmingerf3253332014-03-04 16:36:44 -08001314static int bond_option_min_links_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001315 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com7d101002013-12-17 21:30:23 -08001316{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001317 netdev_dbg(bond->dev, "Setting min links value to %llu\n",
1318 newval->value);
Nikolay Aleksandrov633ddc92014-01-22 14:53:28 +01001319 bond->params.min_links = newval->value;
Jonathan Toppins2477bc92015-01-26 01:16:57 -05001320 bond_set_carrier(bond);
sfeldma@cumulusnetworks.com7d101002013-12-17 21:30:23 -08001321
1322 return 0;
1323}
sfeldma@cumulusnetworks.com8d836d092013-12-17 21:30:30 -08001324
stephen hemmingerf3253332014-03-04 16:36:44 -08001325static int bond_option_lp_interval_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001326 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com8d836d092013-12-17 21:30:30 -08001327{
Nikolay Aleksandrov4325b372014-01-22 14:53:39 +01001328 bond->params.lp_interval = newval->value;
sfeldma@cumulusnetworks.com8d836d092013-12-17 21:30:30 -08001329
1330 return 0;
1331}
sfeldma@cumulusnetworks.comc13ab3f2013-12-17 21:30:37 -08001332
stephen hemmingerf3253332014-03-04 16:36:44 -08001333static int bond_option_pps_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001334 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comc13ab3f2013-12-17 21:30:37 -08001335{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001336 netdev_dbg(bond->dev, "Setting packets per slave to %llu\n",
1337 newval->value);
Nikolay Aleksandrovaa59d852014-01-22 14:53:18 +01001338 bond->params.packets_per_slave = newval->value;
1339 if (newval->value > 0) {
Hannes Frederic Sowa809fa972014-01-22 02:29:41 +01001340 bond->params.reciprocal_packets_per_slave =
Nikolay Aleksandrovaa59d852014-01-22 14:53:18 +01001341 reciprocal_value(newval->value);
Hannes Frederic Sowa809fa972014-01-22 02:29:41 +01001342 } else {
1343 /* reciprocal_packets_per_slave is unused if
1344 * packets_per_slave is 0 or 1, just initialize it
1345 */
1346 bond->params.reciprocal_packets_per_slave =
1347 (struct reciprocal_value) { 0 };
1348 }
sfeldma@cumulusnetworks.comc13ab3f2013-12-17 21:30:37 -08001349
1350 return 0;
1351}
sfeldma@cumulusnetworks.com998e40bb2014-01-03 14:18:41 -08001352
Hangbin Liu3a755cd2021-08-02 11:02:19 +08001353static int bond_option_lacp_active_set(struct bonding *bond,
1354 const struct bond_opt_value *newval)
1355{
1356 netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n",
1357 newval->string, newval->value);
1358 bond->params.lacp_active = newval->value;
1359
1360 return 0;
1361}
1362
stephen hemmingerf3253332014-03-04 16:36:44 -08001363static int bond_option_lacp_rate_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001364 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.com998e40bb2014-01-03 14:18:41 -08001365{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001366 netdev_dbg(bond->dev, "Setting LACP rate to %s (%llu)\n",
1367 newval->string, newval->value);
Nikolay Aleksandrovd3131de2014-01-22 14:53:27 +01001368 bond->params.lacp_fast = newval->value;
sfeldma@cumulusnetworks.com3243c472014-01-03 14:28:18 -08001369 bond_3ad_update_lacp_rate(bond);
sfeldma@cumulusnetworks.com998e40bb2014-01-03 14:18:41 -08001370
1371 return 0;
1372}
sfeldma@cumulusnetworks.comec029fa2014-01-03 14:18:49 -08001373
stephen hemmingerf3253332014-03-04 16:36:44 -08001374static int bond_option_ad_select_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001375 const struct bond_opt_value *newval)
sfeldma@cumulusnetworks.comec029fa2014-01-03 14:18:49 -08001376{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001377 netdev_dbg(bond->dev, "Setting ad_select to %s (%llu)\n",
1378 newval->string, newval->value);
Nikolay Aleksandrov9e5f5ee2014-01-22 14:53:29 +01001379 bond->params.ad_select = newval->value;
sfeldma@cumulusnetworks.comec029fa2014-01-03 14:18:49 -08001380
1381 return 0;
1382}
Nikolay Aleksandrov24089ba2014-01-22 14:53:36 +01001383
stephen hemmingerf3253332014-03-04 16:36:44 -08001384static int bond_option_queue_id_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001385 const struct bond_opt_value *newval)
Nikolay Aleksandrov24089ba2014-01-22 14:53:36 +01001386{
1387 struct slave *slave, *update_slave;
1388 struct net_device *sdev;
1389 struct list_head *iter;
1390 char *delim;
1391 int ret = 0;
1392 u16 qid;
1393
1394 /* delim will point to queue id if successful */
1395 delim = strchr(newval->string, ':');
1396 if (!delim)
1397 goto err_no_cmd;
1398
1399 /* Terminate string that points to device name and bump it
1400 * up one, so we can read the queue id there.
1401 */
1402 *delim = '\0';
1403 if (sscanf(++delim, "%hd\n", &qid) != 1)
1404 goto err_no_cmd;
1405
1406 /* Check buffer length, valid ifname and queue id */
dingtianhongc313c892014-02-12 14:58:50 +08001407 if (!dev_valid_name(newval->string) ||
Nikolay Aleksandrov24089ba2014-01-22 14:53:36 +01001408 qid > bond->dev->real_num_tx_queues)
1409 goto err_no_cmd;
1410
1411 /* Get the pointer to that interface if it exists */
1412 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string);
1413 if (!sdev)
1414 goto err_no_cmd;
1415
1416 /* Search for thes slave and check for duplicate qids */
1417 update_slave = NULL;
1418 bond_for_each_slave(bond, slave, iter) {
1419 if (sdev == slave->dev)
1420 /* We don't need to check the matching
1421 * slave for dups, since we're overwriting it
1422 */
1423 update_slave = slave;
1424 else if (qid && qid == slave->queue_id) {
1425 goto err_no_cmd;
1426 }
1427 }
1428
1429 if (!update_slave)
1430 goto err_no_cmd;
1431
1432 /* Actually set the qids for the slave */
1433 update_slave->queue_id = qid;
1434
1435out:
1436 return ret;
1437
1438err_no_cmd:
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001439 netdev_dbg(bond->dev, "invalid input for queue_id set\n");
Nikolay Aleksandrov24089ba2014-01-22 14:53:36 +01001440 ret = -EPERM;
1441 goto out;
1442
1443}
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001444
stephen hemmingerf3253332014-03-04 16:36:44 -08001445static int bond_option_slaves_set(struct bonding *bond,
stephen hemminger28f084c2014-03-06 14:20:17 -08001446 const struct bond_opt_value *newval)
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001447{
1448 char command[IFNAMSIZ + 1] = { 0, };
1449 struct net_device *dev;
1450 char *ifname;
1451 int ret;
1452
1453 sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/
1454 ifname = command + 1;
1455 if ((strlen(command) <= 1) ||
Tonghao Zhang415d3942019-02-11 10:49:48 -08001456 (command[0] != '+' && command[0] != '-') ||
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001457 !dev_valid_name(ifname))
1458 goto err_no_cmd;
1459
1460 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
1461 if (!dev) {
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001462 netdev_dbg(bond->dev, "interface %s does not exist!\n",
1463 ifname);
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001464 ret = -ENODEV;
1465 goto out;
1466 }
1467
1468 switch (command[0]) {
1469 case '+':
Jarod Wilsonf887e542019-06-07 10:59:32 -04001470 slave_dbg(bond->dev, dev, "Enslaving interface\n");
David Ahern33eaf2a2017-10-04 17:48:46 -07001471 ret = bond_enslave(bond->dev, dev, NULL);
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001472 break;
1473
1474 case '-':
Jarod Wilsonf887e542019-06-07 10:59:32 -04001475 slave_dbg(bond->dev, dev, "Releasing interface\n");
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001476 ret = bond_release(bond->dev, dev);
1477 break;
1478
1479 default:
Tonghao Zhang415d3942019-02-11 10:49:48 -08001480 /* should not run here. */
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001481 goto err_no_cmd;
1482 }
1483
1484out:
1485 return ret;
1486
1487err_no_cmd:
Veaceslav Falico2de390b2014-07-15 19:36:08 +02001488 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n");
Nikolay Aleksandrov0e2e5b62014-01-22 14:53:40 +01001489 ret = -EPERM;
1490 goto out;
1491}
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -07001492
1493static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
1494 const struct bond_opt_value *newval)
1495{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001496 netdev_dbg(bond->dev, "Setting dynamic-lb to %s (%llu)\n",
1497 newval->string, newval->value);
Mahesh Bandeware9f0fb82014-04-22 16:30:22 -07001498 bond->params.tlb_dynamic_lb = newval->value;
1499
1500 return 0;
1501}
Mahesh Bandewar6791e462015-05-09 00:01:55 -07001502
1503static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
1504 const struct bond_opt_value *newval)
1505{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001506 netdev_dbg(bond->dev, "Setting ad_actor_sys_prio to %llu\n",
1507 newval->value);
Mahesh Bandewar6791e462015-05-09 00:01:55 -07001508
1509 bond->params.ad_actor_sys_prio = newval->value;
Nikolay Aleksandrov5ee14e62016-02-03 13:17:01 +01001510 bond_3ad_update_ad_actor_settings(bond);
1511
Mahesh Bandewar6791e462015-05-09 00:01:55 -07001512 return 0;
1513}
Mahesh Bandewar74514952015-05-09 00:01:56 -07001514
1515static int bond_option_ad_actor_system_set(struct bonding *bond,
1516 const struct bond_opt_value *newval)
1517{
1518 u8 macaddr[ETH_ALEN];
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001519 u8 *mac;
Mahesh Bandewar74514952015-05-09 00:01:56 -07001520
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001521 if (newval->string) {
Andy Shevchenkoce5c1442017-12-19 20:20:44 +02001522 if (!mac_pton(newval->string, macaddr))
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001523 goto err;
1524 mac = macaddr;
1525 } else {
1526 mac = (u8 *)&newval->value;
Mahesh Bandewar74514952015-05-09 00:01:56 -07001527 }
1528
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001529 if (!is_valid_ether_addr(mac))
1530 goto err;
1531
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001532 netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac);
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001533 ether_addr_copy(bond->params.ad_actor_system, mac);
Nikolay Aleksandrov5ee14e62016-02-03 13:17:01 +01001534 bond_3ad_update_ad_actor_settings(bond);
1535
Mahesh Bandewar74514952015-05-09 00:01:56 -07001536 return 0;
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001537
1538err:
Jarod Wilsonf887e542019-06-07 10:59:32 -04001539 netdev_err(bond->dev, "Invalid ad_actor_system MAC address.\n");
Andy Gospodarek171a42c2015-05-09 00:01:58 -07001540 return -EINVAL;
Mahesh Bandewar74514952015-05-09 00:01:56 -07001541}
Mahesh Bandeward22a5fc2015-05-09 00:01:57 -07001542
1543static int bond_option_ad_user_port_key_set(struct bonding *bond,
1544 const struct bond_opt_value *newval)
1545{
Michael Dilmoreeac306b2017-06-26 16:49:46 +01001546 netdev_dbg(bond->dev, "Setting ad_user_port_key to %llu\n",
1547 newval->value);
Mahesh Bandeward22a5fc2015-05-09 00:01:57 -07001548
1549 bond->params.ad_user_port_key = newval->value;
1550 return 0;
1551}