2 * Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
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.
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
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.
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/device.h>
28 #include <linux/sched.h>
29 #include <linux/sysdev.h>
31 #include <linux/types.h>
32 #include <linux/string.h>
33 #include <linux/netdevice.h>
34 #include <linux/inetdevice.h>
36 #include <linux/sysfs.h>
37 #include <linux/ctype.h>
38 #include <linux/inet.h>
39 #include <linux/rtnetlink.h>
40 #include <linux/etherdevice.h>
41 #include <net/net_namespace.h>
42 #include <net/netns/generic.h>
43 #include <linux/nsproxy.h>
47 #define to_dev(obj) container_of(obj, struct device, kobj)
48 #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
51 * "show" function for the bond_masters attribute.
52 * The class parameter is ignored.
54 static ssize_t
bonding_show_bonds(struct class *cls
,
55 struct class_attribute
*attr
,
58 struct net
*net
= current
->nsproxy
->net_ns
;
59 struct bond_net
*bn
= net_generic(net
, bond_net_id
);
65 list_for_each_entry(bond
, &bn
->dev_list
, bond_list
) {
66 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
67 /* not enough space for another interface name */
68 if ((PAGE_SIZE
- res
) > 10)
70 res
+= sprintf(buf
+ res
, "++more++ ");
73 res
+= sprintf(buf
+ res
, "%s ", bond
->dev
->name
);
76 buf
[res
-1] = '\n'; /* eat the leftover space */
82 static struct net_device
*bond_get_by_name(struct net
*net
, const char *ifname
)
84 struct bond_net
*bn
= net_generic(net
, bond_net_id
);
87 list_for_each_entry(bond
, &bn
->dev_list
, bond_list
) {
88 if (strncmp(bond
->dev
->name
, ifname
, IFNAMSIZ
) == 0)
95 * "store" function for the bond_masters attribute. This is what
96 * creates and deletes entire bonds.
98 * The class parameter is ignored.
102 static ssize_t
bonding_store_bonds(struct class *cls
,
103 struct class_attribute
*attr
,
104 const char *buffer
, size_t count
)
106 struct net
*net
= current
->nsproxy
->net_ns
;
107 char command
[IFNAMSIZ
+ 1] = {0, };
111 sscanf(buffer
, "%16s", command
); /* IFNAMSIZ*/
112 ifname
= command
+ 1;
113 if ((strlen(command
) <= 1) ||
114 !dev_valid_name(ifname
))
117 if (command
[0] == '+') {
118 pr_info("%s is being created...\n", ifname
);
119 rv
= bond_create(net
, ifname
);
121 pr_info("Bond creation failed.\n");
124 } else if (command
[0] == '-') {
125 struct net_device
*bond_dev
;
128 bond_dev
= bond_get_by_name(net
, ifname
);
130 pr_info("%s is being deleted...\n", ifname
);
131 unregister_netdevice(bond_dev
);
133 pr_err("unable to delete non-existent %s\n", ifname
);
140 /* Always return either count or an error. If you return 0, you'll
141 * get called forever, which is bad.
146 pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n");
150 /* class attribute for bond_masters file. This ends up in /sys/class/net */
151 static CLASS_ATTR(bonding_masters
, S_IWUSR
| S_IRUGO
,
152 bonding_show_bonds
, bonding_store_bonds
);
154 int bond_create_slave_symlinks(struct net_device
*master
,
155 struct net_device
*slave
)
157 char linkname
[IFNAMSIZ
+7];
160 /* first, create a link from the slave back to the master */
161 ret
= sysfs_create_link(&(slave
->dev
.kobj
), &(master
->dev
.kobj
),
165 /* next, create a link from the master to the slave */
166 sprintf(linkname
, "slave_%s", slave
->name
);
167 ret
= sysfs_create_link(&(master
->dev
.kobj
), &(slave
->dev
.kobj
),
173 void bond_destroy_slave_symlinks(struct net_device
*master
,
174 struct net_device
*slave
)
176 char linkname
[IFNAMSIZ
+7];
178 sysfs_remove_link(&(slave
->dev
.kobj
), "master");
179 sprintf(linkname
, "slave_%s", slave
->name
);
180 sysfs_remove_link(&(master
->dev
.kobj
), linkname
);
185 * Show the slaves in the current bond.
187 static ssize_t
bonding_show_slaves(struct device
*d
,
188 struct device_attribute
*attr
, char *buf
)
192 struct bonding
*bond
= to_bond(d
);
194 read_lock(&bond
->lock
);
195 bond_for_each_slave(bond
, slave
, i
) {
196 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
197 /* not enough space for another interface name */
198 if ((PAGE_SIZE
- res
) > 10)
199 res
= PAGE_SIZE
- 10;
200 res
+= sprintf(buf
+ res
, "++more++ ");
203 res
+= sprintf(buf
+ res
, "%s ", slave
->dev
->name
);
205 read_unlock(&bond
->lock
);
207 buf
[res
-1] = '\n'; /* eat the leftover space */
212 * Set the slaves in the current bond. The bond interface must be
213 * up for this to succeed.
214 * This is supposed to be only thin wrapper for bond_enslave and bond_release.
215 * All hard work should be done there.
217 static ssize_t
bonding_store_slaves(struct device
*d
,
218 struct device_attribute
*attr
,
219 const char *buffer
, size_t count
)
221 char command
[IFNAMSIZ
+ 1] = { 0, };
223 int res
, ret
= count
;
224 struct net_device
*dev
;
225 struct bonding
*bond
= to_bond(d
);
228 return restart_syscall();
230 sscanf(buffer
, "%16s", command
); /* IFNAMSIZ*/
231 ifname
= command
+ 1;
232 if ((strlen(command
) <= 1) ||
233 !dev_valid_name(ifname
))
236 dev
= __dev_get_by_name(dev_net(bond
->dev
), ifname
);
238 pr_info("%s: Interface %s does not exist!\n",
239 bond
->dev
->name
, ifname
);
244 switch (command
[0]) {
246 pr_info("%s: Adding slave %s.\n", bond
->dev
->name
, dev
->name
);
247 res
= bond_enslave(bond
->dev
, dev
);
251 pr_info("%s: Removing slave %s.\n", bond
->dev
->name
, dev
->name
);
252 res
= bond_release(bond
->dev
, dev
);
264 pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
273 static DEVICE_ATTR(slaves
, S_IRUGO
| S_IWUSR
, bonding_show_slaves
,
274 bonding_store_slaves
);
277 * Show and set the bonding mode. The bond interface must be down to
280 static ssize_t
bonding_show_mode(struct device
*d
,
281 struct device_attribute
*attr
, char *buf
)
283 struct bonding
*bond
= to_bond(d
);
285 return sprintf(buf
, "%s %d\n",
286 bond_mode_tbl
[bond
->params
.mode
].modename
,
290 static ssize_t
bonding_store_mode(struct device
*d
,
291 struct device_attribute
*attr
,
292 const char *buf
, size_t count
)
294 int new_value
, ret
= count
;
295 struct bonding
*bond
= to_bond(d
);
297 if (bond
->dev
->flags
& IFF_UP
) {
298 pr_err("unable to update mode of %s because interface is up.\n",
304 new_value
= bond_parse_parm(buf
, bond_mode_tbl
);
306 pr_err("%s: Ignoring invalid mode value %.*s.\n",
307 bond
->dev
->name
, (int)strlen(buf
) - 1, buf
);
311 if ((new_value
== BOND_MODE_ALB
||
312 new_value
== BOND_MODE_TLB
) &&
313 bond
->params
.arp_interval
) {
314 pr_err("%s: %s mode is incompatible with arp monitoring.\n",
315 bond
->dev
->name
, bond_mode_tbl
[new_value
].modename
);
319 if (bond
->params
.mode
== BOND_MODE_8023AD
)
320 bond_unset_master_3ad_flags(bond
);
322 if (bond
->params
.mode
== BOND_MODE_ALB
)
323 bond_unset_master_alb_flags(bond
);
325 bond
->params
.mode
= new_value
;
326 bond_set_mode_ops(bond
, bond
->params
.mode
);
327 pr_info("%s: setting mode to %s (%d).\n",
328 bond
->dev
->name
, bond_mode_tbl
[new_value
].modename
,
333 static DEVICE_ATTR(mode
, S_IRUGO
| S_IWUSR
,
334 bonding_show_mode
, bonding_store_mode
);
337 * Show and set the bonding transmit hash method.
338 * The bond interface must be down to change the xmit hash policy.
340 static ssize_t
bonding_show_xmit_hash(struct device
*d
,
341 struct device_attribute
*attr
,
344 struct bonding
*bond
= to_bond(d
);
346 return sprintf(buf
, "%s %d\n",
347 xmit_hashtype_tbl
[bond
->params
.xmit_policy
].modename
,
348 bond
->params
.xmit_policy
);
351 static ssize_t
bonding_store_xmit_hash(struct device
*d
,
352 struct device_attribute
*attr
,
353 const char *buf
, size_t count
)
355 int new_value
, ret
= count
;
356 struct bonding
*bond
= to_bond(d
);
358 if (bond
->dev
->flags
& IFF_UP
) {
359 pr_err("%s: Interface is up. Unable to update xmit policy.\n",
365 new_value
= bond_parse_parm(buf
, xmit_hashtype_tbl
);
367 pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
369 (int)strlen(buf
) - 1, buf
);
373 bond
->params
.xmit_policy
= new_value
;
374 bond_set_mode_ops(bond
, bond
->params
.mode
);
375 pr_info("%s: setting xmit hash policy to %s (%d).\n",
377 xmit_hashtype_tbl
[new_value
].modename
, new_value
);
382 static DEVICE_ATTR(xmit_hash_policy
, S_IRUGO
| S_IWUSR
,
383 bonding_show_xmit_hash
, bonding_store_xmit_hash
);
386 * Show and set arp_validate.
388 static ssize_t
bonding_show_arp_validate(struct device
*d
,
389 struct device_attribute
*attr
,
392 struct bonding
*bond
= to_bond(d
);
394 return sprintf(buf
, "%s %d\n",
395 arp_validate_tbl
[bond
->params
.arp_validate
].modename
,
396 bond
->params
.arp_validate
);
399 static ssize_t
bonding_store_arp_validate(struct device
*d
,
400 struct device_attribute
*attr
,
401 const char *buf
, size_t count
)
404 struct bonding
*bond
= to_bond(d
);
406 new_value
= bond_parse_parm(buf
, arp_validate_tbl
);
408 pr_err("%s: Ignoring invalid arp_validate value %s\n",
409 bond
->dev
->name
, buf
);
412 if (new_value
&& (bond
->params
.mode
!= BOND_MODE_ACTIVEBACKUP
)) {
413 pr_err("%s: arp_validate only supported in active-backup mode.\n",
417 pr_info("%s: setting arp_validate to %s (%d).\n",
418 bond
->dev
->name
, arp_validate_tbl
[new_value
].modename
,
421 if (!bond
->params
.arp_validate
&& new_value
)
422 bond_register_arp(bond
);
423 else if (bond
->params
.arp_validate
&& !new_value
)
424 bond_unregister_arp(bond
);
426 bond
->params
.arp_validate
= new_value
;
431 static DEVICE_ATTR(arp_validate
, S_IRUGO
| S_IWUSR
, bonding_show_arp_validate
,
432 bonding_store_arp_validate
);
435 * Show and store fail_over_mac. User only allowed to change the
436 * value when there are no slaves.
438 static ssize_t
bonding_show_fail_over_mac(struct device
*d
,
439 struct device_attribute
*attr
,
442 struct bonding
*bond
= to_bond(d
);
444 return sprintf(buf
, "%s %d\n",
445 fail_over_mac_tbl
[bond
->params
.fail_over_mac
].modename
,
446 bond
->params
.fail_over_mac
);
449 static ssize_t
bonding_store_fail_over_mac(struct device
*d
,
450 struct device_attribute
*attr
,
451 const char *buf
, size_t count
)
454 struct bonding
*bond
= to_bond(d
);
456 if (bond
->slave_cnt
!= 0) {
457 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
462 new_value
= bond_parse_parm(buf
, fail_over_mac_tbl
);
464 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
465 bond
->dev
->name
, buf
);
469 bond
->params
.fail_over_mac
= new_value
;
470 pr_info("%s: Setting fail_over_mac to %s (%d).\n",
471 bond
->dev
->name
, fail_over_mac_tbl
[new_value
].modename
,
477 static DEVICE_ATTR(fail_over_mac
, S_IRUGO
| S_IWUSR
,
478 bonding_show_fail_over_mac
, bonding_store_fail_over_mac
);
481 * Show and set the arp timer interval. There are two tricky bits
482 * here. First, if ARP monitoring is activated, then we must disable
483 * MII monitoring. Second, if the ARP timer isn't running, we must
486 static ssize_t
bonding_show_arp_interval(struct device
*d
,
487 struct device_attribute
*attr
,
490 struct bonding
*bond
= to_bond(d
);
492 return sprintf(buf
, "%d\n", bond
->params
.arp_interval
);
495 static ssize_t
bonding_store_arp_interval(struct device
*d
,
496 struct device_attribute
*attr
,
497 const char *buf
, size_t count
)
499 int new_value
, ret
= count
;
500 struct bonding
*bond
= to_bond(d
);
502 if (sscanf(buf
, "%d", &new_value
) != 1) {
503 pr_err("%s: no arp_interval value specified.\n",
509 pr_err("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
510 bond
->dev
->name
, new_value
, INT_MAX
);
514 if (bond
->params
.mode
== BOND_MODE_ALB
||
515 bond
->params
.mode
== BOND_MODE_TLB
) {
516 pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n",
517 bond
->dev
->name
, bond
->dev
->name
);
521 pr_info("%s: Setting ARP monitoring interval to %d.\n",
522 bond
->dev
->name
, new_value
);
523 bond
->params
.arp_interval
= new_value
;
524 if (bond
->params
.arp_interval
)
525 bond
->dev
->priv_flags
|= IFF_MASTER_ARPMON
;
526 if (bond
->params
.miimon
) {
527 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
528 bond
->dev
->name
, bond
->dev
->name
);
529 bond
->params
.miimon
= 0;
530 if (delayed_work_pending(&bond
->mii_work
)) {
531 cancel_delayed_work(&bond
->mii_work
);
532 flush_workqueue(bond
->wq
);
535 if (!bond
->params
.arp_targets
[0]) {
536 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
539 if (bond
->dev
->flags
& IFF_UP
) {
540 /* If the interface is up, we may need to fire off
541 * the ARP timer. If the interface is down, the
542 * timer will get fired off when the open function
545 if (!delayed_work_pending(&bond
->arp_work
)) {
546 if (bond
->params
.mode
== BOND_MODE_ACTIVEBACKUP
)
547 INIT_DELAYED_WORK(&bond
->arp_work
,
548 bond_activebackup_arp_mon
);
550 INIT_DELAYED_WORK(&bond
->arp_work
,
551 bond_loadbalance_arp_mon
);
553 queue_delayed_work(bond
->wq
, &bond
->arp_work
, 0);
560 static DEVICE_ATTR(arp_interval
, S_IRUGO
| S_IWUSR
,
561 bonding_show_arp_interval
, bonding_store_arp_interval
);
564 * Show and set the arp targets.
566 static ssize_t
bonding_show_arp_targets(struct device
*d
,
567 struct device_attribute
*attr
,
571 struct bonding
*bond
= to_bond(d
);
573 for (i
= 0; i
< BOND_MAX_ARP_TARGETS
; i
++) {
574 if (bond
->params
.arp_targets
[i
])
575 res
+= sprintf(buf
+ res
, "%pI4 ",
576 &bond
->params
.arp_targets
[i
]);
579 buf
[res
-1] = '\n'; /* eat the leftover space */
583 static ssize_t
bonding_store_arp_targets(struct device
*d
,
584 struct device_attribute
*attr
,
585 const char *buf
, size_t count
)
588 int i
= 0, done
= 0, ret
= count
;
589 struct bonding
*bond
= to_bond(d
);
592 targets
= bond
->params
.arp_targets
;
593 newtarget
= in_aton(buf
+ 1);
596 if ((newtarget
== 0) || (newtarget
== htonl(INADDR_BROADCAST
))) {
597 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
598 bond
->dev
->name
, &newtarget
);
602 /* look for an empty slot to put the target in, and check for dupes */
603 for (i
= 0; (i
< BOND_MAX_ARP_TARGETS
) && !done
; i
++) {
604 if (targets
[i
] == newtarget
) { /* duplicate */
605 pr_err("%s: ARP target %pI4 is already present\n",
606 bond
->dev
->name
, &newtarget
);
610 if (targets
[i
] == 0) {
611 pr_info("%s: adding ARP target %pI4.\n",
612 bond
->dev
->name
, &newtarget
);
614 targets
[i
] = newtarget
;
618 pr_err("%s: ARP target table is full!\n",
624 } else if (buf
[0] == '-') {
625 if ((newtarget
== 0) || (newtarget
== htonl(INADDR_BROADCAST
))) {
626 pr_err("%s: invalid ARP target %pI4 specified for removal\n",
627 bond
->dev
->name
, &newtarget
);
632 for (i
= 0; (i
< BOND_MAX_ARP_TARGETS
) && !done
; i
++) {
633 if (targets
[i
] == newtarget
) {
635 pr_info("%s: removing ARP target %pI4.\n",
636 bond
->dev
->name
, &newtarget
);
637 for (j
= i
; (j
< (BOND_MAX_ARP_TARGETS
-1)) && targets
[j
+1]; j
++)
638 targets
[j
] = targets
[j
+1];
645 pr_info("%s: unable to remove nonexistent ARP target %pI4.\n",
646 bond
->dev
->name
, &newtarget
);
651 pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
660 static DEVICE_ATTR(arp_ip_target
, S_IRUGO
| S_IWUSR
, bonding_show_arp_targets
, bonding_store_arp_targets
);
663 * Show and set the up and down delays. These must be multiples of the
664 * MII monitoring value, and are stored internally as the multiplier.
665 * Thus, we must translate to MS for the real world.
667 static ssize_t
bonding_show_downdelay(struct device
*d
,
668 struct device_attribute
*attr
,
671 struct bonding
*bond
= to_bond(d
);
673 return sprintf(buf
, "%d\n", bond
->params
.downdelay
* bond
->params
.miimon
);
676 static ssize_t
bonding_store_downdelay(struct device
*d
,
677 struct device_attribute
*attr
,
678 const char *buf
, size_t count
)
680 int new_value
, ret
= count
;
681 struct bonding
*bond
= to_bond(d
);
683 if (!(bond
->params
.miimon
)) {
684 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
690 if (sscanf(buf
, "%d", &new_value
) != 1) {
691 pr_err("%s: no down delay value specified.\n", bond
->dev
->name
);
696 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
697 bond
->dev
->name
, new_value
, 1, INT_MAX
);
701 if ((new_value
% bond
->params
.miimon
) != 0) {
702 pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
703 bond
->dev
->name
, new_value
,
705 (new_value
/ bond
->params
.miimon
) *
706 bond
->params
.miimon
);
708 bond
->params
.downdelay
= new_value
/ bond
->params
.miimon
;
709 pr_info("%s: Setting down delay to %d.\n",
711 bond
->params
.downdelay
* bond
->params
.miimon
);
718 static DEVICE_ATTR(downdelay
, S_IRUGO
| S_IWUSR
,
719 bonding_show_downdelay
, bonding_store_downdelay
);
721 static ssize_t
bonding_show_updelay(struct device
*d
,
722 struct device_attribute
*attr
,
725 struct bonding
*bond
= to_bond(d
);
727 return sprintf(buf
, "%d\n", bond
->params
.updelay
* bond
->params
.miimon
);
731 static ssize_t
bonding_store_updelay(struct device
*d
,
732 struct device_attribute
*attr
,
733 const char *buf
, size_t count
)
735 int new_value
, ret
= count
;
736 struct bonding
*bond
= to_bond(d
);
738 if (!(bond
->params
.miimon
)) {
739 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
745 if (sscanf(buf
, "%d", &new_value
) != 1) {
746 pr_err("%s: no up delay value specified.\n",
752 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
753 bond
->dev
->name
, new_value
, 1, INT_MAX
);
757 if ((new_value
% bond
->params
.miimon
) != 0) {
758 pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
759 bond
->dev
->name
, new_value
,
761 (new_value
/ bond
->params
.miimon
) *
762 bond
->params
.miimon
);
764 bond
->params
.updelay
= new_value
/ bond
->params
.miimon
;
765 pr_info("%s: Setting up delay to %d.\n",
767 bond
->params
.updelay
* bond
->params
.miimon
);
773 static DEVICE_ATTR(updelay
, S_IRUGO
| S_IWUSR
,
774 bonding_show_updelay
, bonding_store_updelay
);
777 * Show and set the LACP interval. Interface must be down, and the mode
778 * must be set to 802.3ad mode.
780 static ssize_t
bonding_show_lacp(struct device
*d
,
781 struct device_attribute
*attr
,
784 struct bonding
*bond
= to_bond(d
);
786 return sprintf(buf
, "%s %d\n",
787 bond_lacp_tbl
[bond
->params
.lacp_fast
].modename
,
788 bond
->params
.lacp_fast
);
791 static ssize_t
bonding_store_lacp(struct device
*d
,
792 struct device_attribute
*attr
,
793 const char *buf
, size_t count
)
795 int new_value
, ret
= count
;
796 struct bonding
*bond
= to_bond(d
);
798 if (bond
->dev
->flags
& IFF_UP
) {
799 pr_err("%s: Unable to update LACP rate because interface is up.\n",
805 if (bond
->params
.mode
!= BOND_MODE_8023AD
) {
806 pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
812 new_value
= bond_parse_parm(buf
, bond_lacp_tbl
);
814 if ((new_value
== 1) || (new_value
== 0)) {
815 bond
->params
.lacp_fast
= new_value
;
816 pr_info("%s: Setting LACP rate to %s (%d).\n",
817 bond
->dev
->name
, bond_lacp_tbl
[new_value
].modename
,
820 pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
821 bond
->dev
->name
, (int)strlen(buf
) - 1, buf
);
827 static DEVICE_ATTR(lacp_rate
, S_IRUGO
| S_IWUSR
,
828 bonding_show_lacp
, bonding_store_lacp
);
830 static ssize_t
bonding_show_ad_select(struct device
*d
,
831 struct device_attribute
*attr
,
834 struct bonding
*bond
= to_bond(d
);
836 return sprintf(buf
, "%s %d\n",
837 ad_select_tbl
[bond
->params
.ad_select
].modename
,
838 bond
->params
.ad_select
);
842 static ssize_t
bonding_store_ad_select(struct device
*d
,
843 struct device_attribute
*attr
,
844 const char *buf
, size_t count
)
846 int new_value
, ret
= count
;
847 struct bonding
*bond
= to_bond(d
);
849 if (bond
->dev
->flags
& IFF_UP
) {
850 pr_err("%s: Unable to update ad_select because interface is up.\n",
856 new_value
= bond_parse_parm(buf
, ad_select_tbl
);
858 if (new_value
!= -1) {
859 bond
->params
.ad_select
= new_value
;
860 pr_info("%s: Setting ad_select to %s (%d).\n",
861 bond
->dev
->name
, ad_select_tbl
[new_value
].modename
,
864 pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
865 bond
->dev
->name
, (int)strlen(buf
) - 1, buf
);
871 static DEVICE_ATTR(ad_select
, S_IRUGO
| S_IWUSR
,
872 bonding_show_ad_select
, bonding_store_ad_select
);
875 * Show and set the number of grat ARP to send after a failover event.
877 static ssize_t
bonding_show_n_grat_arp(struct device
*d
,
878 struct device_attribute
*attr
,
881 struct bonding
*bond
= to_bond(d
);
883 return sprintf(buf
, "%d\n", bond
->params
.num_grat_arp
);
886 static ssize_t
bonding_store_n_grat_arp(struct device
*d
,
887 struct device_attribute
*attr
,
888 const char *buf
, size_t count
)
890 int new_value
, ret
= count
;
891 struct bonding
*bond
= to_bond(d
);
893 if (sscanf(buf
, "%d", &new_value
) != 1) {
894 pr_err("%s: no num_grat_arp value specified.\n",
899 if (new_value
< 0 || new_value
> 255) {
900 pr_err("%s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
901 bond
->dev
->name
, new_value
);
905 bond
->params
.num_grat_arp
= new_value
;
910 static DEVICE_ATTR(num_grat_arp
, S_IRUGO
| S_IWUSR
,
911 bonding_show_n_grat_arp
, bonding_store_n_grat_arp
);
914 * Show and set the number of unsolicited NA's to send after a failover event.
916 static ssize_t
bonding_show_n_unsol_na(struct device
*d
,
917 struct device_attribute
*attr
,
920 struct bonding
*bond
= to_bond(d
);
922 return sprintf(buf
, "%d\n", bond
->params
.num_unsol_na
);
925 static ssize_t
bonding_store_n_unsol_na(struct device
*d
,
926 struct device_attribute
*attr
,
927 const char *buf
, size_t count
)
929 int new_value
, ret
= count
;
930 struct bonding
*bond
= to_bond(d
);
932 if (sscanf(buf
, "%d", &new_value
) != 1) {
933 pr_err("%s: no num_unsol_na value specified.\n",
939 if (new_value
< 0 || new_value
> 255) {
940 pr_err("%s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
941 bond
->dev
->name
, new_value
);
945 bond
->params
.num_unsol_na
= new_value
;
949 static DEVICE_ATTR(num_unsol_na
, S_IRUGO
| S_IWUSR
,
950 bonding_show_n_unsol_na
, bonding_store_n_unsol_na
);
953 * Show and set the MII monitor interval. There are two tricky bits
954 * here. First, if MII monitoring is activated, then we must disable
955 * ARP monitoring. Second, if the timer isn't running, we must
958 static ssize_t
bonding_show_miimon(struct device
*d
,
959 struct device_attribute
*attr
,
962 struct bonding
*bond
= to_bond(d
);
964 return sprintf(buf
, "%d\n", bond
->params
.miimon
);
967 static ssize_t
bonding_store_miimon(struct device
*d
,
968 struct device_attribute
*attr
,
969 const char *buf
, size_t count
)
971 int new_value
, ret
= count
;
972 struct bonding
*bond
= to_bond(d
);
974 if (sscanf(buf
, "%d", &new_value
) != 1) {
975 pr_err("%s: no miimon value specified.\n",
981 pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
982 bond
->dev
->name
, new_value
, 1, INT_MAX
);
986 pr_info("%s: Setting MII monitoring interval to %d.\n",
987 bond
->dev
->name
, new_value
);
988 bond
->params
.miimon
= new_value
;
989 if (bond
->params
.updelay
)
990 pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
992 bond
->params
.updelay
* bond
->params
.miimon
);
993 if (bond
->params
.downdelay
)
994 pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
996 bond
->params
.downdelay
* bond
->params
.miimon
);
997 if (bond
->params
.arp_interval
) {
998 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
1000 bond
->params
.arp_interval
= 0;
1001 bond
->dev
->priv_flags
&= ~IFF_MASTER_ARPMON
;
1002 if (bond
->params
.arp_validate
) {
1003 bond_unregister_arp(bond
);
1004 bond
->params
.arp_validate
=
1005 BOND_ARP_VALIDATE_NONE
;
1007 if (delayed_work_pending(&bond
->arp_work
)) {
1008 cancel_delayed_work(&bond
->arp_work
);
1009 flush_workqueue(bond
->wq
);
1013 if (bond
->dev
->flags
& IFF_UP
) {
1014 /* If the interface is up, we may need to fire off
1015 * the MII timer. If the interface is down, the
1016 * timer will get fired off when the open function
1019 if (!delayed_work_pending(&bond
->mii_work
)) {
1020 INIT_DELAYED_WORK(&bond
->mii_work
,
1022 queue_delayed_work(bond
->wq
,
1023 &bond
->mii_work
, 0);
1030 static DEVICE_ATTR(miimon
, S_IRUGO
| S_IWUSR
,
1031 bonding_show_miimon
, bonding_store_miimon
);
1034 * Show and set the primary slave. The store function is much
1035 * simpler than bonding_store_slaves function because it only needs to
1036 * handle one interface name.
1037 * The bond must be a mode that supports a primary for this be
1040 static ssize_t
bonding_show_primary(struct device
*d
,
1041 struct device_attribute
*attr
,
1045 struct bonding
*bond
= to_bond(d
);
1047 if (bond
->primary_slave
)
1048 count
= sprintf(buf
, "%s\n", bond
->primary_slave
->dev
->name
);
1053 static ssize_t
bonding_store_primary(struct device
*d
,
1054 struct device_attribute
*attr
,
1055 const char *buf
, size_t count
)
1058 struct slave
*slave
;
1059 struct bonding
*bond
= to_bond(d
);
1061 if (!rtnl_trylock())
1062 return restart_syscall();
1064 read_lock(&bond
->lock
);
1065 write_lock_bh(&bond
->curr_slave_lock
);
1067 if (!USES_PRIMARY(bond
->params
.mode
)) {
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
);
1071 bond_for_each_slave(bond
, slave
, i
) {
1073 (slave
->dev
->name
, buf
,
1074 strlen(slave
->dev
->name
)) == 0) {
1075 pr_info("%s: Setting %s as primary slave.\n",
1076 bond
->dev
->name
, slave
->dev
->name
);
1077 bond
->primary_slave
= slave
;
1078 strcpy(bond
->params
.primary
, slave
->dev
->name
);
1079 bond_select_active_slave(bond
);
1084 /* if we got here, then we didn't match the name of any slave */
1086 if (strlen(buf
) == 0 || buf
[0] == '\n') {
1087 pr_info("%s: Setting primary slave to None.\n",
1089 bond
->primary_slave
= NULL
;
1090 bond_select_active_slave(bond
);
1092 pr_info("%s: Unable to set %.*s as primary slave as it is not a slave.\n",
1093 bond
->dev
->name
, (int)strlen(buf
) - 1, buf
);
1097 write_unlock_bh(&bond
->curr_slave_lock
);
1098 read_unlock(&bond
->lock
);
1099 unblock_netpoll_tx();
1104 static DEVICE_ATTR(primary
, S_IRUGO
| S_IWUSR
,
1105 bonding_show_primary
, bonding_store_primary
);
1108 * Show and set the primary_reselect flag.
1110 static ssize_t
bonding_show_primary_reselect(struct device
*d
,
1111 struct device_attribute
*attr
,
1114 struct bonding
*bond
= to_bond(d
);
1116 return sprintf(buf
, "%s %d\n",
1117 pri_reselect_tbl
[bond
->params
.primary_reselect
].modename
,
1118 bond
->params
.primary_reselect
);
1121 static ssize_t
bonding_store_primary_reselect(struct device
*d
,
1122 struct device_attribute
*attr
,
1123 const char *buf
, size_t count
)
1125 int new_value
, ret
= count
;
1126 struct bonding
*bond
= to_bond(d
);
1128 if (!rtnl_trylock())
1129 return restart_syscall();
1131 new_value
= bond_parse_parm(buf
, pri_reselect_tbl
);
1132 if (new_value
< 0) {
1133 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
1135 (int) strlen(buf
) - 1, buf
);
1140 bond
->params
.primary_reselect
= new_value
;
1141 pr_info("%s: setting primary_reselect to %s (%d).\n",
1142 bond
->dev
->name
, pri_reselect_tbl
[new_value
].modename
,
1146 read_lock(&bond
->lock
);
1147 write_lock_bh(&bond
->curr_slave_lock
);
1148 bond_select_active_slave(bond
);
1149 write_unlock_bh(&bond
->curr_slave_lock
);
1150 read_unlock(&bond
->lock
);
1151 unblock_netpoll_tx();
1156 static DEVICE_ATTR(primary_reselect
, S_IRUGO
| S_IWUSR
,
1157 bonding_show_primary_reselect
,
1158 bonding_store_primary_reselect
);
1161 * Show and set the use_carrier flag.
1163 static ssize_t
bonding_show_carrier(struct device
*d
,
1164 struct device_attribute
*attr
,
1167 struct bonding
*bond
= to_bond(d
);
1169 return sprintf(buf
, "%d\n", bond
->params
.use_carrier
);
1172 static ssize_t
bonding_store_carrier(struct device
*d
,
1173 struct device_attribute
*attr
,
1174 const char *buf
, size_t count
)
1176 int new_value
, ret
= count
;
1177 struct bonding
*bond
= to_bond(d
);
1180 if (sscanf(buf
, "%d", &new_value
) != 1) {
1181 pr_err("%s: no use_carrier value specified.\n",
1186 if ((new_value
== 0) || (new_value
== 1)) {
1187 bond
->params
.use_carrier
= new_value
;
1188 pr_info("%s: Setting use_carrier to %d.\n",
1189 bond
->dev
->name
, new_value
);
1191 pr_info("%s: Ignoring invalid use_carrier value %d.\n",
1192 bond
->dev
->name
, new_value
);
1197 static DEVICE_ATTR(use_carrier
, S_IRUGO
| S_IWUSR
,
1198 bonding_show_carrier
, bonding_store_carrier
);
1202 * Show and set currently active_slave.
1204 static ssize_t
bonding_show_active_slave(struct device
*d
,
1205 struct device_attribute
*attr
,
1209 struct bonding
*bond
= to_bond(d
);
1212 read_lock(&bond
->curr_slave_lock
);
1213 curr
= bond
->curr_active_slave
;
1214 read_unlock(&bond
->curr_slave_lock
);
1216 if (USES_PRIMARY(bond
->params
.mode
) && curr
)
1217 count
= sprintf(buf
, "%s\n", curr
->dev
->name
);
1221 static ssize_t
bonding_store_active_slave(struct device
*d
,
1222 struct device_attribute
*attr
,
1223 const char *buf
, size_t count
)
1226 struct slave
*slave
;
1227 struct slave
*old_active
= NULL
;
1228 struct slave
*new_active
= NULL
;
1229 struct bonding
*bond
= to_bond(d
);
1231 if (!rtnl_trylock())
1232 return restart_syscall();
1235 read_lock(&bond
->lock
);
1236 write_lock_bh(&bond
->curr_slave_lock
);
1238 if (!USES_PRIMARY(bond
->params
.mode
))
1239 pr_info("%s: Unable to change active slave; %s is in mode %d\n",
1240 bond
->dev
->name
, bond
->dev
->name
, bond
->params
.mode
);
1242 bond_for_each_slave(bond
, slave
, i
) {
1244 (slave
->dev
->name
, buf
,
1245 strlen(slave
->dev
->name
)) == 0) {
1246 old_active
= bond
->curr_active_slave
;
1248 if (new_active
== old_active
) {
1250 pr_info("%s: %s is already the current active slave.\n",
1258 (new_active
->link
== BOND_LINK_UP
) &&
1259 IS_UP(new_active
->dev
)) {
1260 pr_info("%s: Setting %s as active slave.\n",
1263 bond_change_active_slave(bond
, new_active
);
1266 pr_info("%s: Could not set %s as active slave; either %s is down or the link is down.\n",
1276 /* if we got here, then we didn't match the name of any slave */
1278 if (strlen(buf
) == 0 || buf
[0] == '\n') {
1279 pr_info("%s: Setting active slave to None.\n",
1281 bond
->primary_slave
= NULL
;
1282 bond_select_active_slave(bond
);
1284 pr_info("%s: Unable to set %.*s as active slave as it is not a slave.\n",
1285 bond
->dev
->name
, (int)strlen(buf
) - 1, buf
);
1289 write_unlock_bh(&bond
->curr_slave_lock
);
1290 read_unlock(&bond
->lock
);
1291 unblock_netpoll_tx();
1298 static DEVICE_ATTR(active_slave
, S_IRUGO
| S_IWUSR
,
1299 bonding_show_active_slave
, bonding_store_active_slave
);
1303 * Show link status of the bond interface.
1305 static ssize_t
bonding_show_mii_status(struct device
*d
,
1306 struct device_attribute
*attr
,
1310 struct bonding
*bond
= to_bond(d
);
1312 read_lock(&bond
->curr_slave_lock
);
1313 curr
= bond
->curr_active_slave
;
1314 read_unlock(&bond
->curr_slave_lock
);
1316 return sprintf(buf
, "%s\n", curr
? "up" : "down");
1318 static DEVICE_ATTR(mii_status
, S_IRUGO
, bonding_show_mii_status
, NULL
);
1322 * Show current 802.3ad aggregator ID.
1324 static ssize_t
bonding_show_ad_aggregator(struct device
*d
,
1325 struct device_attribute
*attr
,
1329 struct bonding
*bond
= to_bond(d
);
1331 if (bond
->params
.mode
== BOND_MODE_8023AD
) {
1332 struct ad_info ad_info
;
1333 count
= sprintf(buf
, "%d\n",
1334 (bond_3ad_get_active_agg_info(bond
, &ad_info
))
1335 ? 0 : ad_info
.aggregator_id
);
1340 static DEVICE_ATTR(ad_aggregator
, S_IRUGO
, bonding_show_ad_aggregator
, NULL
);
1344 * Show number of active 802.3ad ports.
1346 static ssize_t
bonding_show_ad_num_ports(struct device
*d
,
1347 struct device_attribute
*attr
,
1351 struct bonding
*bond
= to_bond(d
);
1353 if (bond
->params
.mode
== BOND_MODE_8023AD
) {
1354 struct ad_info ad_info
;
1355 count
= sprintf(buf
, "%d\n",
1356 (bond_3ad_get_active_agg_info(bond
, &ad_info
))
1357 ? 0 : ad_info
.ports
);
1362 static DEVICE_ATTR(ad_num_ports
, S_IRUGO
, bonding_show_ad_num_ports
, NULL
);
1366 * Show current 802.3ad actor key.
1368 static ssize_t
bonding_show_ad_actor_key(struct device
*d
,
1369 struct device_attribute
*attr
,
1373 struct bonding
*bond
= to_bond(d
);
1375 if (bond
->params
.mode
== BOND_MODE_8023AD
) {
1376 struct ad_info ad_info
;
1377 count
= sprintf(buf
, "%d\n",
1378 (bond_3ad_get_active_agg_info(bond
, &ad_info
))
1379 ? 0 : ad_info
.actor_key
);
1384 static DEVICE_ATTR(ad_actor_key
, S_IRUGO
, bonding_show_ad_actor_key
, NULL
);
1388 * Show current 802.3ad partner key.
1390 static ssize_t
bonding_show_ad_partner_key(struct device
*d
,
1391 struct device_attribute
*attr
,
1395 struct bonding
*bond
= to_bond(d
);
1397 if (bond
->params
.mode
== BOND_MODE_8023AD
) {
1398 struct ad_info ad_info
;
1399 count
= sprintf(buf
, "%d\n",
1400 (bond_3ad_get_active_agg_info(bond
, &ad_info
))
1401 ? 0 : ad_info
.partner_key
);
1406 static DEVICE_ATTR(ad_partner_key
, S_IRUGO
, bonding_show_ad_partner_key
, NULL
);
1410 * Show current 802.3ad partner mac.
1412 static ssize_t
bonding_show_ad_partner_mac(struct device
*d
,
1413 struct device_attribute
*attr
,
1417 struct bonding
*bond
= to_bond(d
);
1419 if (bond
->params
.mode
== BOND_MODE_8023AD
) {
1420 struct ad_info ad_info
;
1421 if (!bond_3ad_get_active_agg_info(bond
, &ad_info
))
1422 count
= sprintf(buf
, "%pM\n", ad_info
.partner_system
);
1427 static DEVICE_ATTR(ad_partner_mac
, S_IRUGO
, bonding_show_ad_partner_mac
, NULL
);
1430 * Show the queue_ids of the slaves in the current bond.
1432 static ssize_t
bonding_show_queue_id(struct device
*d
,
1433 struct device_attribute
*attr
,
1436 struct slave
*slave
;
1438 struct bonding
*bond
= to_bond(d
);
1440 if (!rtnl_trylock())
1441 return restart_syscall();
1443 read_lock(&bond
->lock
);
1444 bond_for_each_slave(bond
, slave
, i
) {
1445 if (res
> (PAGE_SIZE
- IFNAMSIZ
- 6)) {
1446 /* not enough space for another interface_name:queue_id pair */
1447 if ((PAGE_SIZE
- res
) > 10)
1448 res
= PAGE_SIZE
- 10;
1449 res
+= sprintf(buf
+ res
, "++more++ ");
1452 res
+= sprintf(buf
+ res
, "%s:%d ",
1453 slave
->dev
->name
, slave
->queue_id
);
1455 read_unlock(&bond
->lock
);
1457 buf
[res
-1] = '\n'; /* eat the leftover space */
1463 * Set the queue_ids of the slaves in the current bond. The bond
1464 * interface must be enslaved for this to work.
1466 static ssize_t
bonding_store_queue_id(struct device
*d
,
1467 struct device_attribute
*attr
,
1468 const char *buffer
, size_t count
)
1470 struct slave
*slave
, *update_slave
;
1471 struct bonding
*bond
= to_bond(d
);
1475 struct net_device
*sdev
= NULL
;
1477 if (!rtnl_trylock())
1478 return restart_syscall();
1480 /* delim will point to queue id if successful */
1481 delim
= strchr(buffer
, ':');
1486 * Terminate string that points to device name and bump it
1487 * up one, so we can read the queue id there.
1490 if (sscanf(++delim
, "%hd\n", &qid
) != 1)
1493 /* Check buffer length, valid ifname and queue id */
1494 if (strlen(buffer
) > IFNAMSIZ
||
1495 !dev_valid_name(buffer
) ||
1496 qid
> bond
->params
.tx_queues
)
1499 /* Get the pointer to that interface if it exists */
1500 sdev
= __dev_get_by_name(dev_net(bond
->dev
), buffer
);
1504 read_lock(&bond
->lock
);
1506 /* Search for thes slave and check for duplicate qids */
1507 update_slave
= NULL
;
1508 bond_for_each_slave(bond
, slave
, i
) {
1509 if (sdev
== slave
->dev
)
1511 * We don't need to check the matching
1512 * slave for dups, since we're overwriting it
1514 update_slave
= slave
;
1515 else if (qid
&& qid
== slave
->queue_id
) {
1516 goto err_no_cmd_unlock
;
1521 goto err_no_cmd_unlock
;
1523 /* Actually set the qids for the slave */
1524 update_slave
->queue_id
= qid
;
1526 read_unlock(&bond
->lock
);
1532 read_unlock(&bond
->lock
);
1534 pr_info("invalid input for queue_id set for %s.\n",
1540 static DEVICE_ATTR(queue_id
, S_IRUGO
| S_IWUSR
, bonding_show_queue_id
,
1541 bonding_store_queue_id
);
1545 * Show and set the all_slaves_active flag.
1547 static ssize_t
bonding_show_slaves_active(struct device
*d
,
1548 struct device_attribute
*attr
,
1551 struct bonding
*bond
= to_bond(d
);
1553 return sprintf(buf
, "%d\n", bond
->params
.all_slaves_active
);
1556 static ssize_t
bonding_store_slaves_active(struct device
*d
,
1557 struct device_attribute
*attr
,
1558 const char *buf
, size_t count
)
1560 int i
, new_value
, ret
= count
;
1561 struct bonding
*bond
= to_bond(d
);
1562 struct slave
*slave
;
1564 if (sscanf(buf
, "%d", &new_value
) != 1) {
1565 pr_err("%s: no all_slaves_active value specified.\n",
1571 if (new_value
== bond
->params
.all_slaves_active
)
1574 if ((new_value
== 0) || (new_value
== 1)) {
1575 bond
->params
.all_slaves_active
= new_value
;
1577 pr_info("%s: Ignoring invalid all_slaves_active value %d.\n",
1578 bond
->dev
->name
, new_value
);
1583 bond_for_each_slave(bond
, slave
, i
) {
1584 if (slave
->state
== BOND_STATE_BACKUP
) {
1586 slave
->dev
->priv_flags
&= ~IFF_SLAVE_INACTIVE
;
1588 slave
->dev
->priv_flags
|= IFF_SLAVE_INACTIVE
;
1594 static DEVICE_ATTR(all_slaves_active
, S_IRUGO
| S_IWUSR
,
1595 bonding_show_slaves_active
, bonding_store_slaves_active
);
1598 * Show and set the number of IGMP membership reports to send on link failure
1600 static ssize_t
bonding_show_resend_igmp(struct device
*d
,
1601 struct device_attribute
*attr
,
1604 struct bonding
*bond
= to_bond(d
);
1606 return sprintf(buf
, "%d\n", bond
->params
.resend_igmp
);
1609 static ssize_t
bonding_store_resend_igmp(struct device
*d
,
1610 struct device_attribute
*attr
,
1611 const char *buf
, size_t count
)
1613 int new_value
, ret
= count
;
1614 struct bonding
*bond
= to_bond(d
);
1616 if (sscanf(buf
, "%d", &new_value
) != 1) {
1617 pr_err("%s: no resend_igmp value specified.\n",
1623 if (new_value
< 0) {
1624 pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n",
1625 bond
->dev
->name
, new_value
);
1630 pr_info("%s: Setting resend_igmp to %d.\n",
1631 bond
->dev
->name
, new_value
);
1632 bond
->params
.resend_igmp
= new_value
;
1637 static DEVICE_ATTR(resend_igmp
, S_IRUGO
| S_IWUSR
,
1638 bonding_show_resend_igmp
, bonding_store_resend_igmp
);
1640 static struct attribute
*per_bond_attrs
[] = {
1641 &dev_attr_slaves
.attr
,
1642 &dev_attr_mode
.attr
,
1643 &dev_attr_fail_over_mac
.attr
,
1644 &dev_attr_arp_validate
.attr
,
1645 &dev_attr_arp_interval
.attr
,
1646 &dev_attr_arp_ip_target
.attr
,
1647 &dev_attr_downdelay
.attr
,
1648 &dev_attr_updelay
.attr
,
1649 &dev_attr_lacp_rate
.attr
,
1650 &dev_attr_ad_select
.attr
,
1651 &dev_attr_xmit_hash_policy
.attr
,
1652 &dev_attr_num_grat_arp
.attr
,
1653 &dev_attr_num_unsol_na
.attr
,
1654 &dev_attr_miimon
.attr
,
1655 &dev_attr_primary
.attr
,
1656 &dev_attr_primary_reselect
.attr
,
1657 &dev_attr_use_carrier
.attr
,
1658 &dev_attr_active_slave
.attr
,
1659 &dev_attr_mii_status
.attr
,
1660 &dev_attr_ad_aggregator
.attr
,
1661 &dev_attr_ad_num_ports
.attr
,
1662 &dev_attr_ad_actor_key
.attr
,
1663 &dev_attr_ad_partner_key
.attr
,
1664 &dev_attr_ad_partner_mac
.attr
,
1665 &dev_attr_queue_id
.attr
,
1666 &dev_attr_all_slaves_active
.attr
,
1667 &dev_attr_resend_igmp
.attr
,
1671 static struct attribute_group bonding_group
= {
1673 .attrs
= per_bond_attrs
,
1677 * Initialize sysfs. This sets up the bonding_masters file in
1680 int bond_create_sysfs(void)
1684 ret
= netdev_class_create_file(&class_attr_bonding_masters
);
1686 * Permit multiple loads of the module by ignoring failures to
1687 * create the bonding_masters sysfs file. Bonding devices
1688 * created by second or subsequent loads of the module will
1689 * not be listed in, or controllable by, bonding_masters, but
1690 * will have the usual "bonding" sysfs directory.
1692 * This is done to preserve backwards compatibility for
1693 * initscripts/sysconfig, which load bonding multiple times to
1694 * configure multiple bonding devices.
1696 if (ret
== -EEXIST
) {
1697 /* Is someone being kinky and naming a device bonding_master? */
1698 if (__dev_get_by_name(&init_net
,
1699 class_attr_bonding_masters
.attr
.name
))
1700 pr_err("network device named %s already exists in sysfs",
1701 class_attr_bonding_masters
.attr
.name
);
1710 * Remove /sys/class/net/bonding_masters.
1712 void bond_destroy_sysfs(void)
1714 netdev_class_remove_file(&class_attr_bonding_masters
);
1718 * Initialize sysfs for each bond. This sets up and registers
1719 * the 'bondctl' directory for each individual bond under /sys/class/net.
1721 void bond_prepare_sysfs_group(struct bonding
*bond
)
1723 bond
->dev
->sysfs_groups
[0] = &bonding_group
;