tcp: tsq: restore minimal amount of queueing
[deliverable/linux.git] / drivers / net / bonding / bond_sysfs.c
CommitLineData
b76cdba9
MW
1/*
2 * Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
b76cdba9 21 */
a4aee5c8
JP
22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
b76cdba9
MW
25#include <linux/kernel.h>
26#include <linux/module.h>
b76cdba9 27#include <linux/device.h>
d43c36dc 28#include <linux/sched.h>
b76cdba9
MW
29#include <linux/fs.h>
30#include <linux/types.h>
31#include <linux/string.h>
32#include <linux/netdevice.h>
33#include <linux/inetdevice.h>
34#include <linux/in.h>
35#include <linux/sysfs.h>
b76cdba9
MW
36#include <linux/ctype.h>
37#include <linux/inet.h>
38#include <linux/rtnetlink.h>
5c5129b5 39#include <linux/etherdevice.h>
881d966b 40#include <net/net_namespace.h>
ec87fd3b
EB
41#include <net/netns/generic.h>
42#include <linux/nsproxy.h>
73958329 43#include <linux/reciprocal_div.h>
b76cdba9 44
b76cdba9 45#include "bonding.h"
5a03cdb7 46
3d632c3f 47#define to_dev(obj) container_of(obj, struct device, kobj)
454d7c9b 48#define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
b76cdba9 49
b76cdba9
MW
50/*
51 * "show" function for the bond_masters attribute.
52 * The class parameter is ignored.
53 */
28812fe1
AK
54static ssize_t bonding_show_bonds(struct class *cls,
55 struct class_attribute *attr,
56 char *buf)
b76cdba9 57{
4c22400a
EB
58 struct bond_net *bn =
59 container_of(attr, struct bond_net, class_attr_bonding_masters);
b76cdba9
MW
60 int res = 0;
61 struct bonding *bond;
62
7e083840 63 rtnl_lock();
b76cdba9 64
ec87fd3b 65 list_for_each_entry(bond, &bn->dev_list, bond_list) {
b76cdba9
MW
66 if (res > (PAGE_SIZE - IFNAMSIZ)) {
67 /* not enough space for another interface name */
68 if ((PAGE_SIZE - res) > 10)
69 res = PAGE_SIZE - 10;
b8843665 70 res += sprintf(buf + res, "++more++ ");
b76cdba9
MW
71 break;
72 }
b8843665 73 res += sprintf(buf + res, "%s ", bond->dev->name);
b76cdba9 74 }
1dcdcd69
WF
75 if (res)
76 buf[res-1] = '\n'; /* eat the leftover space */
7e083840
SH
77
78 rtnl_unlock();
b76cdba9
MW
79 return res;
80}
81
4c22400a 82static struct net_device *bond_get_by_name(struct bond_net *bn, const char *ifname)
373500db
SH
83{
84 struct bonding *bond;
85
ec87fd3b 86 list_for_each_entry(bond, &bn->dev_list, bond_list) {
373500db
SH
87 if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0)
88 return bond->dev;
89 }
90 return NULL;
91}
92
b76cdba9
MW
93/*
94 * "store" function for the bond_masters attribute. This is what
95 * creates and deletes entire bonds.
96 *
97 * The class parameter is ignored.
98 *
99 */
100
3d632c3f 101static ssize_t bonding_store_bonds(struct class *cls,
28812fe1 102 struct class_attribute *attr,
3d632c3f 103 const char *buffer, size_t count)
b76cdba9 104{
4c22400a
EB
105 struct bond_net *bn =
106 container_of(attr, struct bond_net, class_attr_bonding_masters);
b76cdba9
MW
107 char command[IFNAMSIZ + 1] = {0, };
108 char *ifname;
027ea041 109 int rv, res = count;
b76cdba9 110
b76cdba9
MW
111 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
112 ifname = command + 1;
113 if ((strlen(command) <= 1) ||
114 !dev_valid_name(ifname))
115 goto err_no_cmd;
116
117 if (command[0] == '+') {
a4aee5c8 118 pr_info("%s is being created...\n", ifname);
4c22400a 119 rv = bond_create(bn->net, ifname);
027ea041 120 if (rv) {
5f86cad1
PO
121 if (rv == -EEXIST)
122 pr_info("%s already exists.\n", ifname);
123 else
124 pr_info("%s creation failed.\n", ifname);
027ea041 125 res = rv;
b76cdba9 126 }
373500db
SH
127 } else if (command[0] == '-') {
128 struct net_device *bond_dev;
b76cdba9 129
027ea041 130 rtnl_lock();
4c22400a 131 bond_dev = bond_get_by_name(bn, ifname);
373500db 132 if (bond_dev) {
a4aee5c8 133 pr_info("%s is being deleted...\n", ifname);
373500db
SH
134 unregister_netdevice(bond_dev);
135 } else {
a4aee5c8 136 pr_err("unable to delete non-existent %s\n", ifname);
373500db
SH
137 res = -ENODEV;
138 }
139 rtnl_unlock();
140 } else
141 goto err_no_cmd;
027ea041 142
373500db
SH
143 /* Always return either count or an error. If you return 0, you'll
144 * get called forever, which is bad.
145 */
146 return res;
b76cdba9
MW
147
148err_no_cmd:
a4aee5c8 149 pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n");
c4ebc66a 150 return -EPERM;
b76cdba9 151}
373500db 152
b76cdba9 153/* class attribute for bond_masters file. This ends up in /sys/class/net */
4c22400a
EB
154static const struct class_attribute class_attr_bonding_masters = {
155 .attr = {
156 .name = "bonding_masters",
157 .mode = S_IWUSR | S_IRUGO,
158 },
159 .show = bonding_show_bonds,
160 .store = bonding_store_bonds,
4c22400a 161};
b76cdba9 162
b76cdba9
MW
163/*
164 * Show the slaves in the current bond.
165 */
43cb76d9
GKH
166static ssize_t bonding_show_slaves(struct device *d,
167 struct device_attribute *attr, char *buf)
b76cdba9 168{
43cb76d9 169 struct bonding *bond = to_bond(d);
9caff1e7 170 struct list_head *iter;
dec1e90e 171 struct slave *slave;
172 int res = 0;
b76cdba9 173
4d1ae5fb 174 if (!rtnl_trylock())
175 return restart_syscall();
176
9caff1e7 177 bond_for_each_slave(bond, slave, iter) {
b76cdba9
MW
178 if (res > (PAGE_SIZE - IFNAMSIZ)) {
179 /* not enough space for another interface name */
180 if ((PAGE_SIZE - res) > 10)
181 res = PAGE_SIZE - 10;
7bd46508 182 res += sprintf(buf + res, "++more++ ");
b76cdba9
MW
183 break;
184 }
185 res += sprintf(buf + res, "%s ", slave->dev->name);
186 }
4d1ae5fb 187
188 rtnl_unlock();
189
1dcdcd69
WF
190 if (res)
191 buf[res-1] = '\n'; /* eat the leftover space */
dec1e90e 192
b76cdba9
MW
193 return res;
194}
195
196/*
d6641ccf 197 * Set the slaves in the current bond.
f9f3545e
JP
198 * This is supposed to be only thin wrapper for bond_enslave and bond_release.
199 * All hard work should be done there.
b76cdba9 200 */
43cb76d9
GKH
201static ssize_t bonding_store_slaves(struct device *d,
202 struct device_attribute *attr,
203 const char *buffer, size_t count)
b76cdba9
MW
204{
205 char command[IFNAMSIZ + 1] = { 0, };
206 char *ifname;
f9f3545e
JP
207 int res, ret = count;
208 struct net_device *dev;
43cb76d9 209 struct bonding *bond = to_bond(d);
b76cdba9 210
496a60cd
EB
211 if (!rtnl_trylock())
212 return restart_syscall();
027ea041 213
b76cdba9
MW
214 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
215 ifname = command + 1;
216 if ((strlen(command) <= 1) ||
217 !dev_valid_name(ifname))
218 goto err_no_cmd;
219
f9f3545e
JP
220 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
221 if (!dev) {
222 pr_info("%s: Interface %s does not exist!\n",
223 bond->dev->name, ifname);
224 ret = -ENODEV;
225 goto out;
226 }
b76cdba9 227
f9f3545e
JP
228 switch (command[0]) {
229 case '+':
230 pr_info("%s: Adding slave %s.\n", bond->dev->name, dev->name);
b76cdba9 231 res = bond_enslave(bond->dev, dev);
f9f3545e 232 break;
3d632c3f 233
f9f3545e
JP
234 case '-':
235 pr_info("%s: Removing slave %s.\n", bond->dev->name, dev->name);
236 res = bond_release(bond->dev, dev);
237 break;
b76cdba9 238
f9f3545e
JP
239 default:
240 goto err_no_cmd;
b76cdba9
MW
241 }
242
f9f3545e
JP
243 if (res)
244 ret = res;
245 goto out;
246
b76cdba9 247err_no_cmd:
a4aee5c8
JP
248 pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
249 bond->dev->name);
b76cdba9
MW
250 ret = -EPERM;
251
252out:
027ea041 253 rtnl_unlock();
b76cdba9
MW
254 return ret;
255}
256
3d632c3f
SH
257static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
258 bonding_store_slaves);
b76cdba9
MW
259
260/*
261 * Show and set the bonding mode. The bond interface must be down to
262 * change the mode.
263 */
43cb76d9
GKH
264static ssize_t bonding_show_mode(struct device *d,
265 struct device_attribute *attr, char *buf)
b76cdba9 266{
43cb76d9 267 struct bonding *bond = to_bond(d);
b76cdba9
MW
268
269 return sprintf(buf, "%s %d\n",
270 bond_mode_tbl[bond->params.mode].modename,
7bd46508 271 bond->params.mode);
b76cdba9
MW
272}
273
43cb76d9
GKH
274static ssize_t bonding_store_mode(struct device *d,
275 struct device_attribute *attr,
276 const char *buf, size_t count)
b76cdba9 277{
72be35fe 278 int new_value, ret;
43cb76d9 279 struct bonding *bond = to_bond(d);
b76cdba9 280
ece95f7f 281 new_value = bond_parse_parm(buf, bond_mode_tbl);
b76cdba9 282 if (new_value < 0) {
a4aee5c8
JP
283 pr_err("%s: Ignoring invalid mode value %.*s.\n",
284 bond->dev->name, (int)strlen(buf) - 1, buf);
72be35fe 285 return -EINVAL;
c5cb002f 286 }
72be35fe
JP
287 if (!rtnl_trylock())
288 return restart_syscall();
289
290 ret = bond_option_mode_set(bond, new_value);
291 if (!ret) {
292 pr_info("%s: setting mode to %s (%d).\n",
293 bond->dev->name, bond_mode_tbl[new_value].modename,
294 new_value);
295 ret = count;
c5cb002f 296 }
8f903c70 297
ea6836dd 298 rtnl_unlock();
b76cdba9
MW
299 return ret;
300}
3d632c3f
SH
301static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
302 bonding_show_mode, bonding_store_mode);
b76cdba9
MW
303
304/*
3d632c3f 305 * Show and set the bonding transmit hash method.
b76cdba9 306 */
43cb76d9
GKH
307static ssize_t bonding_show_xmit_hash(struct device *d,
308 struct device_attribute *attr,
309 char *buf)
b76cdba9 310{
43cb76d9 311 struct bonding *bond = to_bond(d);
b76cdba9 312
8e4b9329
WF
313 return sprintf(buf, "%s %d\n",
314 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
315 bond->params.xmit_policy);
b76cdba9
MW
316}
317
43cb76d9
GKH
318static ssize_t bonding_store_xmit_hash(struct device *d,
319 struct device_attribute *attr,
320 const char *buf, size_t count)
b76cdba9
MW
321{
322 int new_value, ret = count;
43cb76d9 323 struct bonding *bond = to_bond(d);
b76cdba9 324
ece95f7f 325 new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
b76cdba9 326 if (new_value < 0) {
a4aee5c8 327 pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
b76cdba9
MW
328 bond->dev->name,
329 (int)strlen(buf) - 1, buf);
330 ret = -EINVAL;
b76cdba9
MW
331 } else {
332 bond->params.xmit_policy = new_value;
a4aee5c8 333 pr_info("%s: setting xmit hash policy to %s (%d).\n",
3d632c3f
SH
334 bond->dev->name,
335 xmit_hashtype_tbl[new_value].modename, new_value);
b76cdba9 336 }
53edee2c 337
b76cdba9
MW
338 return ret;
339}
3d632c3f
SH
340static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
341 bonding_show_xmit_hash, bonding_store_xmit_hash);
b76cdba9 342
f5b2b966
JV
343/*
344 * Show and set arp_validate.
345 */
43cb76d9
GKH
346static ssize_t bonding_show_arp_validate(struct device *d,
347 struct device_attribute *attr,
348 char *buf)
f5b2b966 349{
43cb76d9 350 struct bonding *bond = to_bond(d);
f5b2b966
JV
351
352 return sprintf(buf, "%s %d\n",
353 arp_validate_tbl[bond->params.arp_validate].modename,
7bd46508 354 bond->params.arp_validate);
f5b2b966
JV
355}
356
43cb76d9
GKH
357static ssize_t bonding_store_arp_validate(struct device *d,
358 struct device_attribute *attr,
359 const char *buf, size_t count)
f5b2b966 360{
43cb76d9 361 struct bonding *bond = to_bond(d);
5bb9e0b5 362 int new_value, ret = count;
f5b2b966 363
5c5038dc 364 if (!rtnl_trylock())
365 return restart_syscall();
ece95f7f 366 new_value = bond_parse_parm(buf, arp_validate_tbl);
f5b2b966 367 if (new_value < 0) {
a4aee5c8 368 pr_err("%s: Ignoring invalid arp_validate value %s\n",
f5b2b966 369 bond->dev->name, buf);
5c5038dc 370 ret = -EINVAL;
371 goto out;
f5b2b966 372 }
5bb9e0b5 373 if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
a4aee5c8 374 pr_err("%s: arp_validate only supported in active-backup mode.\n",
f5b2b966 375 bond->dev->name);
5c5038dc 376 ret = -EINVAL;
377 goto out;
f5b2b966 378 }
a4aee5c8
JP
379 pr_info("%s: setting arp_validate to %s (%d).\n",
380 bond->dev->name, arp_validate_tbl[new_value].modename,
381 new_value);
f5b2b966 382
5bb9e0b5 383 if (bond->dev->flags & IFF_UP) {
384 if (!new_value)
385 bond->recv_probe = NULL;
386 else if (bond->params.arp_interval)
387 bond->recv_probe = bond_arp_rcv;
388 }
f5b2b966 389 bond->params.arp_validate = new_value;
5c5038dc 390out:
391 rtnl_unlock();
f5b2b966 392
5c5038dc 393 return ret;
f5b2b966
JV
394}
395
3d632c3f
SH
396static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
397 bonding_store_arp_validate);
8599b52e
VF
398/*
399 * Show and set arp_all_targets.
400 */
401static ssize_t bonding_show_arp_all_targets(struct device *d,
402 struct device_attribute *attr,
403 char *buf)
404{
405 struct bonding *bond = to_bond(d);
406 int value = bond->params.arp_all_targets;
407
408 return sprintf(buf, "%s %d\n", arp_all_targets_tbl[value].modename,
409 value);
410}
411
412static ssize_t bonding_store_arp_all_targets(struct device *d,
413 struct device_attribute *attr,
414 const char *buf, size_t count)
415{
416 struct bonding *bond = to_bond(d);
417 int new_value;
418
419 new_value = bond_parse_parm(buf, arp_all_targets_tbl);
420 if (new_value < 0) {
421 pr_err("%s: Ignoring invalid arp_all_targets value %s\n",
422 bond->dev->name, buf);
423 return -EINVAL;
424 }
425 pr_info("%s: setting arp_all_targets to %s (%d).\n",
426 bond->dev->name, arp_all_targets_tbl[new_value].modename,
427 new_value);
428
429 bond->params.arp_all_targets = new_value;
430
431 return count;
432}
433
434static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,
435 bonding_show_arp_all_targets, bonding_store_arp_all_targets);
f5b2b966 436
dd957c57
JV
437/*
438 * Show and store fail_over_mac. User only allowed to change the
439 * value when there are no slaves.
440 */
3d632c3f
SH
441static ssize_t bonding_show_fail_over_mac(struct device *d,
442 struct device_attribute *attr,
443 char *buf)
dd957c57
JV
444{
445 struct bonding *bond = to_bond(d);
446
3915c1e8
JV
447 return sprintf(buf, "%s %d\n",
448 fail_over_mac_tbl[bond->params.fail_over_mac].modename,
449 bond->params.fail_over_mac);
dd957c57
JV
450}
451
3d632c3f
SH
452static ssize_t bonding_store_fail_over_mac(struct device *d,
453 struct device_attribute *attr,
454 const char *buf, size_t count)
dd957c57 455{
9402b746 456 int new_value, ret = count;
dd957c57
JV
457 struct bonding *bond = to_bond(d);
458
9402b746 459 if (!rtnl_trylock())
460 return restart_syscall();
461
0965a1f3 462 if (bond_has_slaves(bond)) {
a4aee5c8 463 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
dd957c57 464 bond->dev->name);
9402b746 465 ret = -EPERM;
466 goto out;
dd957c57
JV
467 }
468
3915c1e8
JV
469 new_value = bond_parse_parm(buf, fail_over_mac_tbl);
470 if (new_value < 0) {
a4aee5c8 471 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
3915c1e8 472 bond->dev->name, buf);
9402b746 473 ret = -EINVAL;
474 goto out;
dd957c57
JV
475 }
476
3915c1e8 477 bond->params.fail_over_mac = new_value;
a4aee5c8
JP
478 pr_info("%s: Setting fail_over_mac to %s (%d).\n",
479 bond->dev->name, fail_over_mac_tbl[new_value].modename,
480 new_value);
3915c1e8 481
9402b746 482out:
483 rtnl_unlock();
484 return ret;
dd957c57
JV
485}
486
3d632c3f
SH
487static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR,
488 bonding_show_fail_over_mac, bonding_store_fail_over_mac);
dd957c57 489
b76cdba9
MW
490/*
491 * Show and set the arp timer interval. There are two tricky bits
492 * here. First, if ARP monitoring is activated, then we must disable
493 * MII monitoring. Second, if the ARP timer isn't running, we must
494 * start it.
495 */
43cb76d9
GKH
496static ssize_t bonding_show_arp_interval(struct device *d,
497 struct device_attribute *attr,
498 char *buf)
b76cdba9 499{
43cb76d9 500 struct bonding *bond = to_bond(d);
b76cdba9 501
7bd46508 502 return sprintf(buf, "%d\n", bond->params.arp_interval);
b76cdba9
MW
503}
504
43cb76d9
GKH
505static ssize_t bonding_store_arp_interval(struct device *d,
506 struct device_attribute *attr,
507 const char *buf, size_t count)
b76cdba9 508{
43cb76d9 509 struct bonding *bond = to_bond(d);
5bb9e0b5 510 int new_value, ret = count;
b76cdba9 511
fbb0c41b 512 if (!rtnl_trylock())
513 return restart_syscall();
b76cdba9 514 if (sscanf(buf, "%d", &new_value) != 1) {
a4aee5c8 515 pr_err("%s: no arp_interval value specified.\n",
b76cdba9
MW
516 bond->dev->name);
517 ret = -EINVAL;
518 goto out;
519 }
520 if (new_value < 0) {
1bc7db16 521 pr_err("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n",
b76cdba9
MW
522 bond->dev->name, new_value, INT_MAX);
523 ret = -EINVAL;
524 goto out;
525 }
c5cb002f 526 if (bond->params.mode == BOND_MODE_ALB ||
ec9f1d15
VF
527 bond->params.mode == BOND_MODE_TLB ||
528 bond->params.mode == BOND_MODE_8023AD) {
529 pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n",
c5cb002f
AG
530 bond->dev->name, bond->dev->name);
531 ret = -EINVAL;
532 goto out;
533 }
a4aee5c8
JP
534 pr_info("%s: Setting ARP monitoring interval to %d.\n",
535 bond->dev->name, new_value);
b76cdba9 536 bond->params.arp_interval = new_value;
1bc7db16 537 if (new_value) {
538 if (bond->params.miimon) {
539 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
540 bond->dev->name, bond->dev->name);
541 bond->params.miimon = 0;
542 }
543 if (!bond->params.arp_targets[0])
544 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
545 bond->dev->name);
b76cdba9
MW
546 }
547 if (bond->dev->flags & IFF_UP) {
548 /* If the interface is up, we may need to fire off
549 * the ARP timer. If the interface is down, the
550 * timer will get fired off when the open function
551 * is called.
552 */
1bc7db16 553 if (!new_value) {
5bb9e0b5 554 if (bond->params.arp_validate)
555 bond->recv_probe = NULL;
1bc7db16 556 cancel_delayed_work_sync(&bond->arp_work);
557 } else {
5bb9e0b5 558 /* arp_validate can be set only in active-backup mode */
559 if (bond->params.arp_validate)
560 bond->recv_probe = bond_arp_rcv;
1bc7db16 561 cancel_delayed_work_sync(&bond->mii_work);
562 queue_delayed_work(bond->wq, &bond->arp_work, 0);
563 }
b76cdba9 564 }
b76cdba9 565out:
fbb0c41b 566 rtnl_unlock();
b76cdba9
MW
567 return ret;
568}
3d632c3f
SH
569static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR,
570 bonding_show_arp_interval, bonding_store_arp_interval);
b76cdba9
MW
571
572/*
573 * Show and set the arp targets.
574 */
43cb76d9
GKH
575static ssize_t bonding_show_arp_targets(struct device *d,
576 struct device_attribute *attr,
577 char *buf)
b76cdba9
MW
578{
579 int i, res = 0;
43cb76d9 580 struct bonding *bond = to_bond(d);
b76cdba9
MW
581
582 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
583 if (bond->params.arp_targets[i])
63779436
HH
584 res += sprintf(buf + res, "%pI4 ",
585 &bond->params.arp_targets[i]);
b76cdba9 586 }
1dcdcd69
WF
587 if (res)
588 buf[res-1] = '\n'; /* eat the leftover space */
b76cdba9
MW
589 return res;
590}
591
43cb76d9
GKH
592static ssize_t bonding_store_arp_targets(struct device *d,
593 struct device_attribute *attr,
594 const char *buf, size_t count)
b76cdba9 595{
43cb76d9 596 struct bonding *bond = to_bond(d);
9caff1e7 597 struct list_head *iter;
8599b52e
VF
598 struct slave *slave;
599 __be32 newtarget, *targets;
600 unsigned long *targets_rx;
601 int ind, i, j, ret = -EINVAL;
b76cdba9 602
4d1ae5fb 603 if (!rtnl_trylock())
604 return restart_syscall();
605
b76cdba9
MW
606 targets = bond->params.arp_targets;
607 newtarget = in_aton(buf + 1);
608 /* look for adds */
609 if (buf[0] == '+') {
d3bb52b0 610 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
a4aee5c8 611 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
63779436 612 bond->dev->name, &newtarget);
b76cdba9
MW
613 goto out;
614 }
87a7b84b
VF
615
616 if (bond_get_targets_ip(targets, newtarget) != -1) { /* dup */
617 pr_err("%s: ARP target %pI4 is already present\n",
618 bond->dev->name, &newtarget);
619 goto out;
b76cdba9 620 }
87a7b84b 621
8599b52e
VF
622 ind = bond_get_targets_ip(targets, 0); /* first free slot */
623 if (ind == -1) {
a4aee5c8 624 pr_err("%s: ARP target table is full!\n",
b76cdba9 625 bond->dev->name);
b76cdba9
MW
626 goto out;
627 }
628
87a7b84b
VF
629 pr_info("%s: adding ARP target %pI4.\n", bond->dev->name,
630 &newtarget);
8599b52e
VF
631 /* not to race with bond_arp_rcv */
632 write_lock_bh(&bond->lock);
9caff1e7 633 bond_for_each_slave(bond, slave, iter)
8599b52e
VF
634 slave->target_last_arp_rx[ind] = jiffies;
635 targets[ind] = newtarget;
636 write_unlock_bh(&bond->lock);
3d632c3f 637 } else if (buf[0] == '-') {
d3bb52b0 638 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
a4aee5c8 639 pr_err("%s: invalid ARP target %pI4 specified for removal\n",
63779436 640 bond->dev->name, &newtarget);
b76cdba9
MW
641 goto out;
642 }
643
8599b52e
VF
644 ind = bond_get_targets_ip(targets, newtarget);
645 if (ind == -1) {
646 pr_err("%s: unable to remove nonexistent ARP target %pI4.\n",
a4aee5c8 647 bond->dev->name, &newtarget);
b76cdba9
MW
648 goto out;
649 }
87a7b84b 650
8599b52e
VF
651 if (ind == 0 && !targets[1] && bond->params.arp_interval)
652 pr_warn("%s: removing last arp target with arp_interval on\n",
653 bond->dev->name);
654
87a7b84b
VF
655 pr_info("%s: removing ARP target %pI4.\n", bond->dev->name,
656 &newtarget);
8599b52e
VF
657
658 write_lock_bh(&bond->lock);
9caff1e7 659 bond_for_each_slave(bond, slave, iter) {
8599b52e
VF
660 targets_rx = slave->target_last_arp_rx;
661 j = ind;
662 for (; (j < BOND_MAX_ARP_TARGETS-1) && targets[j+1]; j++)
663 targets_rx[j] = targets_rx[j+1];
664 targets_rx[j] = 0;
665 }
666 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
87a7b84b
VF
667 targets[i] = targets[i+1];
668 targets[i] = 0;
8599b52e 669 write_unlock_bh(&bond->lock);
3d632c3f 670 } else {
a4aee5c8
JP
671 pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
672 bond->dev->name);
b76cdba9
MW
673 ret = -EPERM;
674 goto out;
675 }
676
87a7b84b 677 ret = count;
b76cdba9 678out:
4d1ae5fb 679 rtnl_unlock();
b76cdba9
MW
680 return ret;
681}
43cb76d9 682static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets);
b76cdba9
MW
683
684/*
685 * Show and set the up and down delays. These must be multiples of the
686 * MII monitoring value, and are stored internally as the multiplier.
687 * Thus, we must translate to MS for the real world.
688 */
43cb76d9
GKH
689static ssize_t bonding_show_downdelay(struct device *d,
690 struct device_attribute *attr,
691 char *buf)
b76cdba9 692{
43cb76d9 693 struct bonding *bond = to_bond(d);
b76cdba9 694
7bd46508 695 return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon);
b76cdba9
MW
696}
697
43cb76d9
GKH
698static ssize_t bonding_store_downdelay(struct device *d,
699 struct device_attribute *attr,
700 const char *buf, size_t count)
b76cdba9
MW
701{
702 int new_value, ret = count;
43cb76d9 703 struct bonding *bond = to_bond(d);
b76cdba9
MW
704
705 if (!(bond->params.miimon)) {
a4aee5c8 706 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
b76cdba9
MW
707 bond->dev->name);
708 ret = -EPERM;
709 goto out;
710 }
711
712 if (sscanf(buf, "%d", &new_value) != 1) {
a4aee5c8 713 pr_err("%s: no down delay value specified.\n", bond->dev->name);
b76cdba9
MW
714 ret = -EINVAL;
715 goto out;
716 }
717 if (new_value < 0) {
a4aee5c8 718 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
1bc7db16 719 bond->dev->name, new_value, 0, INT_MAX);
b76cdba9
MW
720 ret = -EINVAL;
721 goto out;
722 } else {
723 if ((new_value % bond->params.miimon) != 0) {
a4aee5c8 724 pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
e5e2a8fd
JP
725 bond->dev->name, new_value,
726 bond->params.miimon,
727 (new_value / bond->params.miimon) *
728 bond->params.miimon);
b76cdba9
MW
729 }
730 bond->params.downdelay = new_value / bond->params.miimon;
a4aee5c8
JP
731 pr_info("%s: Setting down delay to %d.\n",
732 bond->dev->name,
733 bond->params.downdelay * bond->params.miimon);
b76cdba9
MW
734
735 }
736
737out:
738 return ret;
739}
3d632c3f
SH
740static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
741 bonding_show_downdelay, bonding_store_downdelay);
b76cdba9 742
43cb76d9
GKH
743static ssize_t bonding_show_updelay(struct device *d,
744 struct device_attribute *attr,
745 char *buf)
b76cdba9 746{
43cb76d9 747 struct bonding *bond = to_bond(d);
b76cdba9 748
7bd46508 749 return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon);
b76cdba9
MW
750
751}
752
43cb76d9
GKH
753static ssize_t bonding_store_updelay(struct device *d,
754 struct device_attribute *attr,
755 const char *buf, size_t count)
b76cdba9
MW
756{
757 int new_value, ret = count;
43cb76d9 758 struct bonding *bond = to_bond(d);
b76cdba9
MW
759
760 if (!(bond->params.miimon)) {
a4aee5c8 761 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
b76cdba9
MW
762 bond->dev->name);
763 ret = -EPERM;
764 goto out;
765 }
766
767 if (sscanf(buf, "%d", &new_value) != 1) {
a4aee5c8 768 pr_err("%s: no up delay value specified.\n",
b76cdba9
MW
769 bond->dev->name);
770 ret = -EINVAL;
771 goto out;
772 }
773 if (new_value < 0) {
1bc7db16 774 pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n",
775 bond->dev->name, new_value, 0, INT_MAX);
b76cdba9
MW
776 ret = -EINVAL;
777 goto out;
778 } else {
779 if ((new_value % bond->params.miimon) != 0) {
a4aee5c8 780 pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
e5e2a8fd
JP
781 bond->dev->name, new_value,
782 bond->params.miimon,
783 (new_value / bond->params.miimon) *
784 bond->params.miimon);
b76cdba9
MW
785 }
786 bond->params.updelay = new_value / bond->params.miimon;
a4aee5c8
JP
787 pr_info("%s: Setting up delay to %d.\n",
788 bond->dev->name,
789 bond->params.updelay * bond->params.miimon);
b76cdba9
MW
790 }
791
792out:
793 return ret;
794}
3d632c3f
SH
795static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
796 bonding_show_updelay, bonding_store_updelay);
b76cdba9
MW
797
798/*
799 * Show and set the LACP interval. Interface must be down, and the mode
800 * must be set to 802.3ad mode.
801 */
43cb76d9
GKH
802static ssize_t bonding_show_lacp(struct device *d,
803 struct device_attribute *attr,
804 char *buf)
b76cdba9 805{
43cb76d9 806 struct bonding *bond = to_bond(d);
b76cdba9
MW
807
808 return sprintf(buf, "%s %d\n",
809 bond_lacp_tbl[bond->params.lacp_fast].modename,
7bd46508 810 bond->params.lacp_fast);
b76cdba9
MW
811}
812
43cb76d9
GKH
813static ssize_t bonding_store_lacp(struct device *d,
814 struct device_attribute *attr,
815 const char *buf, size_t count)
b76cdba9 816{
43cb76d9 817 struct bonding *bond = to_bond(d);
c509316b 818 int new_value, ret = count;
819
820 if (!rtnl_trylock())
821 return restart_syscall();
b76cdba9
MW
822
823 if (bond->dev->flags & IFF_UP) {
a4aee5c8 824 pr_err("%s: Unable to update LACP rate because interface is up.\n",
b76cdba9
MW
825 bond->dev->name);
826 ret = -EPERM;
827 goto out;
828 }
829
830 if (bond->params.mode != BOND_MODE_8023AD) {
a4aee5c8 831 pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
b76cdba9
MW
832 bond->dev->name);
833 ret = -EPERM;
834 goto out;
835 }
836
ece95f7f 837 new_value = bond_parse_parm(buf, bond_lacp_tbl);
b76cdba9
MW
838
839 if ((new_value == 1) || (new_value == 0)) {
840 bond->params.lacp_fast = new_value;
ba824a8b 841 bond_3ad_update_lacp_rate(bond);
a4aee5c8 842 pr_info("%s: Setting LACP rate to %s (%d).\n",
3d632c3f
SH
843 bond->dev->name, bond_lacp_tbl[new_value].modename,
844 new_value);
b76cdba9 845 } else {
a4aee5c8 846 pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
3d632c3f 847 bond->dev->name, (int)strlen(buf) - 1, buf);
b76cdba9
MW
848 ret = -EINVAL;
849 }
850out:
c509316b 851 rtnl_unlock();
852
b76cdba9
MW
853 return ret;
854}
3d632c3f
SH
855static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR,
856 bonding_show_lacp, bonding_store_lacp);
b76cdba9 857
655f8919 858static ssize_t bonding_show_min_links(struct device *d,
859 struct device_attribute *attr,
860 char *buf)
861{
862 struct bonding *bond = to_bond(d);
863
864 return sprintf(buf, "%d\n", bond->params.min_links);
865}
866
867static ssize_t bonding_store_min_links(struct device *d,
868 struct device_attribute *attr,
869 const char *buf, size_t count)
870{
871 struct bonding *bond = to_bond(d);
872 int ret;
873 unsigned int new_value;
874
875 ret = kstrtouint(buf, 0, &new_value);
876 if (ret < 0) {
877 pr_err("%s: Ignoring invalid min links value %s.\n",
878 bond->dev->name, buf);
879 return ret;
880 }
881
882 pr_info("%s: Setting min links value to %u\n",
883 bond->dev->name, new_value);
884 bond->params.min_links = new_value;
885 return count;
886}
887static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR,
888 bonding_show_min_links, bonding_store_min_links);
889
fd989c83
JV
890static ssize_t bonding_show_ad_select(struct device *d,
891 struct device_attribute *attr,
892 char *buf)
893{
894 struct bonding *bond = to_bond(d);
895
896 return sprintf(buf, "%s %d\n",
897 ad_select_tbl[bond->params.ad_select].modename,
898 bond->params.ad_select);
899}
900
901
902static ssize_t bonding_store_ad_select(struct device *d,
903 struct device_attribute *attr,
904 const char *buf, size_t count)
905{
906 int new_value, ret = count;
907 struct bonding *bond = to_bond(d);
908
909 if (bond->dev->flags & IFF_UP) {
a4aee5c8
JP
910 pr_err("%s: Unable to update ad_select because interface is up.\n",
911 bond->dev->name);
fd989c83
JV
912 ret = -EPERM;
913 goto out;
914 }
915
916 new_value = bond_parse_parm(buf, ad_select_tbl);
917
918 if (new_value != -1) {
919 bond->params.ad_select = new_value;
a4aee5c8
JP
920 pr_info("%s: Setting ad_select to %s (%d).\n",
921 bond->dev->name, ad_select_tbl[new_value].modename,
922 new_value);
fd989c83 923 } else {
a4aee5c8 924 pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
fd989c83
JV
925 bond->dev->name, (int)strlen(buf) - 1, buf);
926 ret = -EINVAL;
927 }
928out:
929 return ret;
930}
3d632c3f
SH
931static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
932 bonding_show_ad_select, bonding_store_ad_select);
fd989c83 933
ad246c99
BH
934/*
935 * Show and set the number of peer notifications to send after a failover event.
936 */
937static ssize_t bonding_show_num_peer_notif(struct device *d,
938 struct device_attribute *attr,
939 char *buf)
940{
941 struct bonding *bond = to_bond(d);
942 return sprintf(buf, "%d\n", bond->params.num_peer_notif);
943}
944
945static ssize_t bonding_store_num_peer_notif(struct device *d,
946 struct device_attribute *attr,
947 const char *buf, size_t count)
948{
949 struct bonding *bond = to_bond(d);
950 int err = kstrtou8(buf, 10, &bond->params.num_peer_notif);
951 return err ? err : count;
952}
953static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
954 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
955static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
956 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
957
b76cdba9
MW
958/*
959 * Show and set the MII monitor interval. There are two tricky bits
960 * here. First, if MII monitoring is activated, then we must disable
961 * ARP monitoring. Second, if the timer isn't running, we must
962 * start it.
963 */
43cb76d9
GKH
964static ssize_t bonding_show_miimon(struct device *d,
965 struct device_attribute *attr,
966 char *buf)
b76cdba9 967{
43cb76d9 968 struct bonding *bond = to_bond(d);
b76cdba9 969
7bd46508 970 return sprintf(buf, "%d\n", bond->params.miimon);
b76cdba9
MW
971}
972
43cb76d9
GKH
973static ssize_t bonding_store_miimon(struct device *d,
974 struct device_attribute *attr,
975 const char *buf, size_t count)
b76cdba9
MW
976{
977 int new_value, ret = count;
43cb76d9 978 struct bonding *bond = to_bond(d);
b76cdba9 979
fbb0c41b 980 if (!rtnl_trylock())
981 return restart_syscall();
b76cdba9 982 if (sscanf(buf, "%d", &new_value) != 1) {
a4aee5c8 983 pr_err("%s: no miimon value specified.\n",
b76cdba9
MW
984 bond->dev->name);
985 ret = -EINVAL;
986 goto out;
987 }
988 if (new_value < 0) {
a4aee5c8 989 pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
1bc7db16 990 bond->dev->name, new_value, 0, INT_MAX);
b76cdba9
MW
991 ret = -EINVAL;
992 goto out;
1bc7db16 993 }
994 pr_info("%s: Setting MII monitoring interval to %d.\n",
995 bond->dev->name, new_value);
996 bond->params.miimon = new_value;
997 if (bond->params.updelay)
998 pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
999 bond->dev->name,
1000 bond->params.updelay * bond->params.miimon);
1001 if (bond->params.downdelay)
1002 pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
1003 bond->dev->name,
1004 bond->params.downdelay * bond->params.miimon);
1005 if (new_value && bond->params.arp_interval) {
1006 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
1007 bond->dev->name);
1008 bond->params.arp_interval = 0;
1009 if (bond->params.arp_validate)
1010 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
1011 }
1012 if (bond->dev->flags & IFF_UP) {
1013 /* If the interface is up, we may need to fire off
1014 * the MII timer. If the interface is down, the
1015 * timer will get fired off when the open function
1016 * is called.
1017 */
1018 if (!new_value) {
1019 cancel_delayed_work_sync(&bond->mii_work);
1020 } else {
fbb0c41b 1021 cancel_delayed_work_sync(&bond->arp_work);
1022 queue_delayed_work(bond->wq, &bond->mii_work, 0);
b76cdba9
MW
1023 }
1024 }
1025out:
fbb0c41b 1026 rtnl_unlock();
b76cdba9
MW
1027 return ret;
1028}
3d632c3f
SH
1029static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR,
1030 bonding_show_miimon, bonding_store_miimon);
b76cdba9
MW
1031
1032/*
1033 * Show and set the primary slave. The store function is much
1034 * simpler than bonding_store_slaves function because it only needs to
1035 * handle one interface name.
1036 * The bond must be a mode that supports a primary for this be
1037 * set.
1038 */
43cb76d9
GKH
1039static ssize_t bonding_show_primary(struct device *d,
1040 struct device_attribute *attr,
1041 char *buf)
b76cdba9
MW
1042{
1043 int count = 0;
43cb76d9 1044 struct bonding *bond = to_bond(d);
b76cdba9
MW
1045
1046 if (bond->primary_slave)
7bd46508 1047 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name);
b76cdba9
MW
1048
1049 return count;
1050}
1051
43cb76d9
GKH
1052static ssize_t bonding_store_primary(struct device *d,
1053 struct device_attribute *attr,
1054 const char *buf, size_t count)
b76cdba9 1055{
43cb76d9 1056 struct bonding *bond = to_bond(d);
9caff1e7 1057 struct list_head *iter;
f4bb2e9c 1058 char ifname[IFNAMSIZ];
dec1e90e 1059 struct slave *slave;
b76cdba9 1060
496a60cd
EB
1061 if (!rtnl_trylock())
1062 return restart_syscall();
e843fa50 1063 block_netpoll_tx();
e934dd78
JV
1064 read_lock(&bond->lock);
1065 write_lock_bh(&bond->curr_slave_lock);
1066
b76cdba9 1067 if (!USES_PRIMARY(bond->params.mode)) {
a4aee5c8
JP
1068 pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
1069 bond->dev->name, bond->dev->name, bond->params.mode);
f4bb2e9c
AG
1070 goto out;
1071 }
b76cdba9 1072
eb6e98a1 1073 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
b76cdba9 1074
f4bb2e9c
AG
1075 /* check to see if we are clearing primary */
1076 if (!strlen(ifname) || buf[0] == '\n') {
1077 pr_info("%s: Setting primary slave to None.\n",
1078 bond->dev->name);
1079 bond->primary_slave = NULL;
eb492f74 1080 memset(bond->params.primary, 0, sizeof(bond->params.primary));
f4bb2e9c
AG
1081 bond_select_active_slave(bond);
1082 goto out;
1083 }
1084
9caff1e7 1085 bond_for_each_slave(bond, slave, iter) {
f4bb2e9c
AG
1086 if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
1087 pr_info("%s: Setting %s as primary slave.\n",
1088 bond->dev->name, slave->dev->name);
1089 bond->primary_slave = slave;
1090 strcpy(bond->params.primary, slave->dev->name);
1091 bond_select_active_slave(bond);
1092 goto out;
b76cdba9
MW
1093 }
1094 }
f4bb2e9c 1095
8a93664d
WP
1096 strncpy(bond->params.primary, ifname, IFNAMSIZ);
1097 bond->params.primary[IFNAMSIZ - 1] = 0;
1098
1099 pr_info("%s: Recording %s as primary, "
1100 "but it has not been enslaved to %s yet.\n",
1101 bond->dev->name, ifname, bond->dev->name);
b76cdba9 1102out:
e934dd78
JV
1103 write_unlock_bh(&bond->curr_slave_lock);
1104 read_unlock(&bond->lock);
e843fa50 1105 unblock_netpoll_tx();
6603a6f2
JV
1106 rtnl_unlock();
1107
b76cdba9
MW
1108 return count;
1109}
3d632c3f
SH
1110static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR,
1111 bonding_show_primary, bonding_store_primary);
b76cdba9 1112
a549952a
JP
1113/*
1114 * Show and set the primary_reselect flag.
1115 */
1116static ssize_t bonding_show_primary_reselect(struct device *d,
1117 struct device_attribute *attr,
1118 char *buf)
1119{
1120 struct bonding *bond = to_bond(d);
1121
1122 return sprintf(buf, "%s %d\n",
1123 pri_reselect_tbl[bond->params.primary_reselect].modename,
1124 bond->params.primary_reselect);
1125}
1126
1127static ssize_t bonding_store_primary_reselect(struct device *d,
1128 struct device_attribute *attr,
1129 const char *buf, size_t count)
1130{
1131 int new_value, ret = count;
1132 struct bonding *bond = to_bond(d);
1133
1134 if (!rtnl_trylock())
1135 return restart_syscall();
1136
1137 new_value = bond_parse_parm(buf, pri_reselect_tbl);
1138 if (new_value < 0) {
a4aee5c8 1139 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
a549952a
JP
1140 bond->dev->name,
1141 (int) strlen(buf) - 1, buf);
1142 ret = -EINVAL;
1143 goto out;
1144 }
1145
1146 bond->params.primary_reselect = new_value;
a4aee5c8 1147 pr_info("%s: setting primary_reselect to %s (%d).\n",
a549952a
JP
1148 bond->dev->name, pri_reselect_tbl[new_value].modename,
1149 new_value);
1150
e843fa50 1151 block_netpoll_tx();
a549952a
JP
1152 read_lock(&bond->lock);
1153 write_lock_bh(&bond->curr_slave_lock);
1154 bond_select_active_slave(bond);
1155 write_unlock_bh(&bond->curr_slave_lock);
1156 read_unlock(&bond->lock);
e843fa50 1157 unblock_netpoll_tx();
a549952a
JP
1158out:
1159 rtnl_unlock();
1160 return ret;
1161}
1162static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR,
1163 bonding_show_primary_reselect,
1164 bonding_store_primary_reselect);
1165
b76cdba9
MW
1166/*
1167 * Show and set the use_carrier flag.
1168 */
43cb76d9
GKH
1169static ssize_t bonding_show_carrier(struct device *d,
1170 struct device_attribute *attr,
1171 char *buf)
b76cdba9 1172{
43cb76d9 1173 struct bonding *bond = to_bond(d);
b76cdba9 1174
7bd46508 1175 return sprintf(buf, "%d\n", bond->params.use_carrier);
b76cdba9
MW
1176}
1177
43cb76d9
GKH
1178static ssize_t bonding_store_carrier(struct device *d,
1179 struct device_attribute *attr,
1180 const char *buf, size_t count)
b76cdba9
MW
1181{
1182 int new_value, ret = count;
43cb76d9 1183 struct bonding *bond = to_bond(d);
b76cdba9
MW
1184
1185
1186 if (sscanf(buf, "%d", &new_value) != 1) {
a4aee5c8 1187 pr_err("%s: no use_carrier value specified.\n",
b76cdba9
MW
1188 bond->dev->name);
1189 ret = -EINVAL;
1190 goto out;
1191 }
1192 if ((new_value == 0) || (new_value == 1)) {
1193 bond->params.use_carrier = new_value;
a4aee5c8
JP
1194 pr_info("%s: Setting use_carrier to %d.\n",
1195 bond->dev->name, new_value);
b76cdba9 1196 } else {
a4aee5c8
JP
1197 pr_info("%s: Ignoring invalid use_carrier value %d.\n",
1198 bond->dev->name, new_value);
b76cdba9
MW
1199 }
1200out:
672bda33 1201 return ret;
b76cdba9 1202}
3d632c3f
SH
1203static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR,
1204 bonding_show_carrier, bonding_store_carrier);
b76cdba9
MW
1205
1206
1207/*
1208 * Show and set currently active_slave.
1209 */
43cb76d9
GKH
1210static ssize_t bonding_show_active_slave(struct device *d,
1211 struct device_attribute *attr,
1212 char *buf)
b76cdba9 1213{
43cb76d9 1214 struct bonding *bond = to_bond(d);
752d48b5 1215 struct net_device *slave_dev;
16cd0160 1216 int count = 0;
b76cdba9 1217
278b2083 1218 rcu_read_lock();
752d48b5
JP
1219 slave_dev = bond_option_active_slave_get_rcu(bond);
1220 if (slave_dev)
1221 count = sprintf(buf, "%s\n", slave_dev->name);
278b2083 1222 rcu_read_unlock();
1223
b76cdba9
MW
1224 return count;
1225}
1226
43cb76d9
GKH
1227static ssize_t bonding_store_active_slave(struct device *d,
1228 struct device_attribute *attr,
1229 const char *buf, size_t count)
b76cdba9 1230{
d9e32b21 1231 int ret;
43cb76d9 1232 struct bonding *bond = to_bond(d);
f4bb2e9c 1233 char ifname[IFNAMSIZ];
d9e32b21 1234 struct net_device *dev;
b76cdba9 1235
496a60cd
EB
1236 if (!rtnl_trylock())
1237 return restart_syscall();
e843fa50 1238
c84e1590 1239 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
f4bb2e9c 1240 if (!strlen(ifname) || buf[0] == '\n') {
d9e32b21
JP
1241 dev = NULL;
1242 } else {
1243 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
1244 if (!dev) {
1245 ret = -ENODEV;
1246 goto out;
b76cdba9 1247 }
b76cdba9 1248 }
f4bb2e9c 1249
d9e32b21
JP
1250 ret = bond_option_active_slave_set(bond, dev);
1251 if (!ret)
1252 ret = count;
e843fa50 1253
d9e32b21 1254 out:
6603a6f2
JV
1255 rtnl_unlock();
1256
d9e32b21 1257 return ret;
b76cdba9
MW
1258
1259}
3d632c3f
SH
1260static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR,
1261 bonding_show_active_slave, bonding_store_active_slave);
b76cdba9
MW
1262
1263
1264/*
1265 * Show link status of the bond interface.
1266 */
43cb76d9
GKH
1267static ssize_t bonding_show_mii_status(struct device *d,
1268 struct device_attribute *attr,
1269 char *buf)
b76cdba9 1270{
43cb76d9 1271 struct bonding *bond = to_bond(d);
b76cdba9 1272
278b2083 1273 return sprintf(buf, "%s\n", bond->curr_active_slave ? "up" : "down");
b76cdba9 1274}
43cb76d9 1275static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
b76cdba9 1276
b76cdba9
MW
1277/*
1278 * Show current 802.3ad aggregator ID.
1279 */
43cb76d9
GKH
1280static ssize_t bonding_show_ad_aggregator(struct device *d,
1281 struct device_attribute *attr,
1282 char *buf)
b76cdba9
MW
1283{
1284 int count = 0;
43cb76d9 1285 struct bonding *bond = to_bond(d);
b76cdba9
MW
1286
1287 if (bond->params.mode == BOND_MODE_8023AD) {
1288 struct ad_info ad_info;
3d632c3f 1289 count = sprintf(buf, "%d\n",
318debd8 1290 bond_3ad_get_active_agg_info(bond, &ad_info)
3d632c3f 1291 ? 0 : ad_info.aggregator_id);
b76cdba9 1292 }
b76cdba9
MW
1293
1294 return count;
1295}
43cb76d9 1296static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL);
b76cdba9
MW
1297
1298
1299/*
1300 * Show number of active 802.3ad ports.
1301 */
43cb76d9
GKH
1302static ssize_t bonding_show_ad_num_ports(struct device *d,
1303 struct device_attribute *attr,
1304 char *buf)
b76cdba9
MW
1305{
1306 int count = 0;
43cb76d9 1307 struct bonding *bond = to_bond(d);
b76cdba9
MW
1308
1309 if (bond->params.mode == BOND_MODE_8023AD) {
1310 struct ad_info ad_info;
3d632c3f 1311 count = sprintf(buf, "%d\n",
318debd8 1312 bond_3ad_get_active_agg_info(bond, &ad_info)
3d632c3f 1313 ? 0 : ad_info.ports);
b76cdba9 1314 }
b76cdba9
MW
1315
1316 return count;
1317}
43cb76d9 1318static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL);
b76cdba9
MW
1319
1320
1321/*
1322 * Show current 802.3ad actor key.
1323 */
43cb76d9
GKH
1324static ssize_t bonding_show_ad_actor_key(struct device *d,
1325 struct device_attribute *attr,
1326 char *buf)
b76cdba9
MW
1327{
1328 int count = 0;
43cb76d9 1329 struct bonding *bond = to_bond(d);
b76cdba9
MW
1330
1331 if (bond->params.mode == BOND_MODE_8023AD) {
1332 struct ad_info ad_info;
3d632c3f 1333 count = sprintf(buf, "%d\n",
318debd8 1334 bond_3ad_get_active_agg_info(bond, &ad_info)
3d632c3f 1335 ? 0 : ad_info.actor_key);
b76cdba9 1336 }
b76cdba9
MW
1337
1338 return count;
1339}
43cb76d9 1340static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL);
b76cdba9
MW
1341
1342
1343/*
1344 * Show current 802.3ad partner key.
1345 */
43cb76d9
GKH
1346static ssize_t bonding_show_ad_partner_key(struct device *d,
1347 struct device_attribute *attr,
1348 char *buf)
b76cdba9
MW
1349{
1350 int count = 0;
43cb76d9 1351 struct bonding *bond = to_bond(d);
b76cdba9
MW
1352
1353 if (bond->params.mode == BOND_MODE_8023AD) {
1354 struct ad_info ad_info;
3d632c3f 1355 count = sprintf(buf, "%d\n",
318debd8 1356 bond_3ad_get_active_agg_info(bond, &ad_info)
3d632c3f 1357 ? 0 : ad_info.partner_key);
b76cdba9 1358 }
b76cdba9
MW
1359
1360 return count;
1361}
43cb76d9 1362static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL);
b76cdba9
MW
1363
1364
1365/*
1366 * Show current 802.3ad partner mac.
1367 */
43cb76d9
GKH
1368static ssize_t bonding_show_ad_partner_mac(struct device *d,
1369 struct device_attribute *attr,
1370 char *buf)
b76cdba9
MW
1371{
1372 int count = 0;
43cb76d9 1373 struct bonding *bond = to_bond(d);
b76cdba9
MW
1374
1375 if (bond->params.mode == BOND_MODE_8023AD) {
1376 struct ad_info ad_info;
3d632c3f 1377 if (!bond_3ad_get_active_agg_info(bond, &ad_info))
e174961c 1378 count = sprintf(buf, "%pM\n", ad_info.partner_system);
b76cdba9 1379 }
b76cdba9
MW
1380
1381 return count;
1382}
43cb76d9 1383static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
b76cdba9 1384
bb1d9123
AG
1385/*
1386 * Show the queue_ids of the slaves in the current bond.
1387 */
1388static ssize_t bonding_show_queue_id(struct device *d,
1389 struct device_attribute *attr,
1390 char *buf)
1391{
bb1d9123 1392 struct bonding *bond = to_bond(d);
9caff1e7 1393 struct list_head *iter;
dec1e90e 1394 struct slave *slave;
1395 int res = 0;
bb1d9123
AG
1396
1397 if (!rtnl_trylock())
1398 return restart_syscall();
1399
9caff1e7 1400 bond_for_each_slave(bond, slave, iter) {
79236680
NP
1401 if (res > (PAGE_SIZE - IFNAMSIZ - 6)) {
1402 /* not enough space for another interface_name:queue_id pair */
bb1d9123
AG
1403 if ((PAGE_SIZE - res) > 10)
1404 res = PAGE_SIZE - 10;
1405 res += sprintf(buf + res, "++more++ ");
1406 break;
1407 }
1408 res += sprintf(buf + res, "%s:%d ",
1409 slave->dev->name, slave->queue_id);
1410 }
bb1d9123
AG
1411 if (res)
1412 buf[res-1] = '\n'; /* eat the leftover space */
4d1ae5fb 1413
bb1d9123 1414 rtnl_unlock();
dec1e90e 1415
bb1d9123
AG
1416 return res;
1417}
1418
1419/*
1420 * Set the queue_ids of the slaves in the current bond. The bond
1421 * interface must be enslaved for this to work.
1422 */
1423static ssize_t bonding_store_queue_id(struct device *d,
1424 struct device_attribute *attr,
1425 const char *buffer, size_t count)
1426{
1427 struct slave *slave, *update_slave;
1428 struct bonding *bond = to_bond(d);
9caff1e7 1429 struct list_head *iter;
bb1d9123 1430 u16 qid;
dec1e90e 1431 int ret = count;
bb1d9123
AG
1432 char *delim;
1433 struct net_device *sdev = NULL;
1434
1435 if (!rtnl_trylock())
1436 return restart_syscall();
1437
1438 /* delim will point to queue id if successful */
1439 delim = strchr(buffer, ':');
1440 if (!delim)
1441 goto err_no_cmd;
1442
1443 /*
1444 * Terminate string that points to device name and bump it
1445 * up one, so we can read the queue id there.
1446 */
1447 *delim = '\0';
1448 if (sscanf(++delim, "%hd\n", &qid) != 1)
1449 goto err_no_cmd;
1450
1451 /* Check buffer length, valid ifname and queue id */
1452 if (strlen(buffer) > IFNAMSIZ ||
1453 !dev_valid_name(buffer) ||
8a540ff9 1454 qid > bond->dev->real_num_tx_queues)
bb1d9123
AG
1455 goto err_no_cmd;
1456
1457 /* Get the pointer to that interface if it exists */
1458 sdev = __dev_get_by_name(dev_net(bond->dev), buffer);
1459 if (!sdev)
1460 goto err_no_cmd;
1461
bb1d9123
AG
1462 /* Search for thes slave and check for duplicate qids */
1463 update_slave = NULL;
9caff1e7 1464 bond_for_each_slave(bond, slave, iter) {
bb1d9123
AG
1465 if (sdev == slave->dev)
1466 /*
1467 * We don't need to check the matching
1468 * slave for dups, since we're overwriting it
1469 */
1470 update_slave = slave;
1471 else if (qid && qid == slave->queue_id) {
4d1ae5fb 1472 goto err_no_cmd;
bb1d9123
AG
1473 }
1474 }
1475
1476 if (!update_slave)
4d1ae5fb 1477 goto err_no_cmd;
bb1d9123
AG
1478
1479 /* Actually set the qids for the slave */
1480 update_slave->queue_id = qid;
1481
bb1d9123
AG
1482out:
1483 rtnl_unlock();
1484 return ret;
1485
bb1d9123
AG
1486err_no_cmd:
1487 pr_info("invalid input for queue_id set for %s.\n",
1488 bond->dev->name);
1489 ret = -EPERM;
1490 goto out;
1491}
1492
1493static DEVICE_ATTR(queue_id, S_IRUGO | S_IWUSR, bonding_show_queue_id,
1494 bonding_store_queue_id);
1495
1496
ebd8e497
AG
1497/*
1498 * Show and set the all_slaves_active flag.
1499 */
1500static ssize_t bonding_show_slaves_active(struct device *d,
1501 struct device_attribute *attr,
1502 char *buf)
1503{
1504 struct bonding *bond = to_bond(d);
1505
1506 return sprintf(buf, "%d\n", bond->params.all_slaves_active);
1507}
1508
1509static ssize_t bonding_store_slaves_active(struct device *d,
1510 struct device_attribute *attr,
1511 const char *buf, size_t count)
1512{
ebd8e497 1513 struct bonding *bond = to_bond(d);
dec1e90e 1514 int new_value, ret = count;
9caff1e7 1515 struct list_head *iter;
ebd8e497
AG
1516 struct slave *slave;
1517
4d1ae5fb 1518 if (!rtnl_trylock())
1519 return restart_syscall();
1520
ebd8e497
AG
1521 if (sscanf(buf, "%d", &new_value) != 1) {
1522 pr_err("%s: no all_slaves_active value specified.\n",
1523 bond->dev->name);
1524 ret = -EINVAL;
1525 goto out;
1526 }
1527
1528 if (new_value == bond->params.all_slaves_active)
1529 goto out;
1530
1531 if ((new_value == 0) || (new_value == 1)) {
1532 bond->params.all_slaves_active = new_value;
1533 } else {
1534 pr_info("%s: Ignoring invalid all_slaves_active value %d.\n",
1535 bond->dev->name, new_value);
1536 ret = -EINVAL;
1537 goto out;
1538 }
b76cdba9 1539
9caff1e7 1540 bond_for_each_slave(bond, slave, iter) {
e30bc066 1541 if (!bond_is_active_slave(slave)) {
ebd8e497 1542 if (new_value)
2d7011ca 1543 slave->inactive = 0;
ebd8e497 1544 else
2d7011ca 1545 slave->inactive = 1;
ebd8e497
AG
1546 }
1547 }
1548out:
4d1ae5fb 1549 rtnl_unlock();
672bda33 1550 return ret;
ebd8e497
AG
1551}
1552static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR,
1553 bonding_show_slaves_active, bonding_store_slaves_active);
b76cdba9 1554
c2952c31
FL
1555/*
1556 * Show and set the number of IGMP membership reports to send on link failure
1557 */
1558static ssize_t bonding_show_resend_igmp(struct device *d,
94265cf5
FL
1559 struct device_attribute *attr,
1560 char *buf)
c2952c31
FL
1561{
1562 struct bonding *bond = to_bond(d);
1563
1564 return sprintf(buf, "%d\n", bond->params.resend_igmp);
1565}
1566
1567static ssize_t bonding_store_resend_igmp(struct device *d,
94265cf5
FL
1568 struct device_attribute *attr,
1569 const char *buf, size_t count)
c2952c31
FL
1570{
1571 int new_value, ret = count;
1572 struct bonding *bond = to_bond(d);
1573
1574 if (sscanf(buf, "%d", &new_value) != 1) {
1575 pr_err("%s: no resend_igmp value specified.\n",
1576 bond->dev->name);
1577 ret = -EINVAL;
1578 goto out;
1579 }
1580
94265cf5 1581 if (new_value < 0 || new_value > 255) {
c2952c31
FL
1582 pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n",
1583 bond->dev->name, new_value);
1584 ret = -EINVAL;
1585 goto out;
1586 }
1587
1588 pr_info("%s: Setting resend_igmp to %d.\n",
1589 bond->dev->name, new_value);
1590 bond->params.resend_igmp = new_value;
1591out:
1592 return ret;
1593}
1594
1595static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
1596 bonding_show_resend_igmp, bonding_store_resend_igmp);
1597
7eacd038
NH
1598
1599static ssize_t bonding_show_lp_interval(struct device *d,
1600 struct device_attribute *attr,
1601 char *buf)
1602{
1603 struct bonding *bond = to_bond(d);
1604 return sprintf(buf, "%d\n", bond->params.lp_interval);
1605}
1606
1607static ssize_t bonding_store_lp_interval(struct device *d,
1608 struct device_attribute *attr,
1609 const char *buf, size_t count)
1610{
1611 struct bonding *bond = to_bond(d);
1612 int new_value, ret = count;
1613
1614 if (sscanf(buf, "%d", &new_value) != 1) {
1615 pr_err("%s: no lp interval value specified.\n",
1616 bond->dev->name);
1617 ret = -EINVAL;
1618 goto out;
1619 }
1620
1621 if (new_value <= 0) {
1622 pr_err ("%s: lp_interval must be between 1 and %d\n",
1623 bond->dev->name, INT_MAX);
1624 ret = -EINVAL;
1625 goto out;
1626 }
1627
1628 bond->params.lp_interval = new_value;
1629out:
1630 return ret;
1631}
1632
1633static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
1634 bonding_show_lp_interval, bonding_store_lp_interval);
1635
73958329
NA
1636static ssize_t bonding_show_packets_per_slave(struct device *d,
1637 struct device_attribute *attr,
1638 char *buf)
1639{
1640 struct bonding *bond = to_bond(d);
1641 int packets_per_slave = bond->params.packets_per_slave;
1642
1643 if (packets_per_slave > 1)
1644 packets_per_slave = reciprocal_value(packets_per_slave);
1645
1646 return sprintf(buf, "%d\n", packets_per_slave);
1647}
1648
1649static ssize_t bonding_store_packets_per_slave(struct device *d,
1650 struct device_attribute *attr,
1651 const char *buf, size_t count)
1652{
1653 struct bonding *bond = to_bond(d);
1654 int new_value, ret = count;
1655
1656 if (sscanf(buf, "%d", &new_value) != 1) {
1657 pr_err("%s: no packets_per_slave value specified.\n",
1658 bond->dev->name);
1659 ret = -EINVAL;
1660 goto out;
1661 }
1662 if (new_value < 0 || new_value > USHRT_MAX) {
1663 pr_err("%s: packets_per_slave must be between 0 and %u\n",
1664 bond->dev->name, USHRT_MAX);
1665 ret = -EINVAL;
1666 goto out;
1667 }
1668 if (bond->params.mode != BOND_MODE_ROUNDROBIN)
1669 pr_warn("%s: Warning: packets_per_slave has effect only in balance-rr mode\n",
1670 bond->dev->name);
1671 if (new_value > 1)
1672 bond->params.packets_per_slave = reciprocal_value(new_value);
1673 else
1674 bond->params.packets_per_slave = new_value;
1675out:
1676 return ret;
1677}
1678
1679static DEVICE_ATTR(packets_per_slave, S_IRUGO | S_IWUSR,
1680 bonding_show_packets_per_slave,
1681 bonding_store_packets_per_slave);
1682
b76cdba9 1683static struct attribute *per_bond_attrs[] = {
43cb76d9
GKH
1684 &dev_attr_slaves.attr,
1685 &dev_attr_mode.attr,
dd957c57 1686 &dev_attr_fail_over_mac.attr,
43cb76d9 1687 &dev_attr_arp_validate.attr,
8599b52e 1688 &dev_attr_arp_all_targets.attr,
43cb76d9
GKH
1689 &dev_attr_arp_interval.attr,
1690 &dev_attr_arp_ip_target.attr,
1691 &dev_attr_downdelay.attr,
1692 &dev_attr_updelay.attr,
1693 &dev_attr_lacp_rate.attr,
fd989c83 1694 &dev_attr_ad_select.attr,
43cb76d9 1695 &dev_attr_xmit_hash_policy.attr,
ad246c99
BH
1696 &dev_attr_num_grat_arp.attr,
1697 &dev_attr_num_unsol_na.attr,
43cb76d9
GKH
1698 &dev_attr_miimon.attr,
1699 &dev_attr_primary.attr,
a549952a 1700 &dev_attr_primary_reselect.attr,
43cb76d9
GKH
1701 &dev_attr_use_carrier.attr,
1702 &dev_attr_active_slave.attr,
1703 &dev_attr_mii_status.attr,
1704 &dev_attr_ad_aggregator.attr,
1705 &dev_attr_ad_num_ports.attr,
1706 &dev_attr_ad_actor_key.attr,
1707 &dev_attr_ad_partner_key.attr,
1708 &dev_attr_ad_partner_mac.attr,
bb1d9123 1709 &dev_attr_queue_id.attr,
ebd8e497 1710 &dev_attr_all_slaves_active.attr,
c2952c31 1711 &dev_attr_resend_igmp.attr,
655f8919 1712 &dev_attr_min_links.attr,
7eacd038 1713 &dev_attr_lp_interval.attr,
73958329 1714 &dev_attr_packets_per_slave.attr,
b76cdba9
MW
1715 NULL,
1716};
1717
1718static struct attribute_group bonding_group = {
1719 .name = "bonding",
1720 .attrs = per_bond_attrs,
1721};
1722
1723/*
1724 * Initialize sysfs. This sets up the bonding_masters file in
1725 * /sys/class/net.
1726 */
4c22400a 1727int bond_create_sysfs(struct bond_net *bn)
b76cdba9 1728{
b8a9787e 1729 int ret;
b76cdba9 1730
4c22400a 1731 bn->class_attr_bonding_masters = class_attr_bonding_masters;
01718e36 1732 sysfs_attr_init(&bn->class_attr_bonding_masters.attr);
4c22400a 1733
58292cbe
TH
1734 ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters,
1735 bn->net);
877cbd36
JV
1736 /*
1737 * Permit multiple loads of the module by ignoring failures to
1738 * create the bonding_masters sysfs file. Bonding devices
1739 * created by second or subsequent loads of the module will
1740 * not be listed in, or controllable by, bonding_masters, but
1741 * will have the usual "bonding" sysfs directory.
1742 *
1743 * This is done to preserve backwards compatibility for
1744 * initscripts/sysconfig, which load bonding multiple times to
1745 * configure multiple bonding devices.
1746 */
1747 if (ret == -EEXIST) {
38d2f38b 1748 /* Is someone being kinky and naming a device bonding_master? */
4c22400a 1749 if (__dev_get_by_name(bn->net,
38d2f38b 1750 class_attr_bonding_masters.attr.name))
a4aee5c8 1751 pr_err("network device named %s already exists in sysfs",
38d2f38b 1752 class_attr_bonding_masters.attr.name);
130aa61a 1753 ret = 0;
877cbd36 1754 }
b76cdba9
MW
1755
1756 return ret;
1757
1758}
1759
1760/*
1761 * Remove /sys/class/net/bonding_masters.
1762 */
4c22400a 1763void bond_destroy_sysfs(struct bond_net *bn)
b76cdba9 1764{
58292cbe 1765 netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net);
b76cdba9
MW
1766}
1767
1768/*
1769 * Initialize sysfs for each bond. This sets up and registers
1770 * the 'bondctl' directory for each individual bond under /sys/class/net.
1771 */
6151b3d4 1772void bond_prepare_sysfs_group(struct bonding *bond)
b76cdba9 1773{
6151b3d4 1774 bond->dev->sysfs_groups[0] = &bonding_group;
b76cdba9
MW
1775}
1776
This page took 0.89764 seconds and 5 git commands to generate.