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>
30 #include <linux/types.h>
31 #include <linux/string.h>
32 #include <linux/netdevice.h>
33 #include <linux/inetdevice.h>
35 #include <linux/sysfs.h>
36 #include <linux/ctype.h>
37 #include <linux/inet.h>
38 #include <linux/rtnetlink.h>
39 #include <linux/etherdevice.h>
40 #include <net/net_namespace.h>
41 #include <net/netns/generic.h>
42 #include <linux/nsproxy.h>
46 #define to_dev(obj) container_of(obj, struct device, kobj)
47 #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
50 * "show" function for the bond_masters attribute.
51 * The class parameter is ignored.
53 static ssize_t bonding_show_bonds(struct class *cls,
54 struct class_attribute *attr,
58 container_of(attr, struct bond_net, class_attr_bonding_masters);
64 list_for_each_entry(bond, &bn->dev_list, bond_list) {
65 if (res > (PAGE_SIZE - IFNAMSIZ)) {
66 /* not enough space for another interface name */
67 if ((PAGE_SIZE - res) > 10)
69 res += sprintf(buf + res, "++more++ ");
72 res += sprintf(buf + res, "%s ", bond->dev->name);
75 buf[res-1] = '\n'; /* eat the leftover space */
81 static struct net_device *bond_get_by_name(struct bond_net *bn, const char *ifname)
85 list_for_each_entry(bond, &bn->dev_list, bond_list) {
86 if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0)
93 * "store" function for the bond_masters attribute. This is what
94 * creates and deletes entire bonds.
96 * The class parameter is ignored.
100 static ssize_t bonding_store_bonds(struct class *cls,
101 struct class_attribute *attr,
102 const char *buffer, size_t count)
104 struct bond_net *bn =
105 container_of(attr, struct bond_net, class_attr_bonding_masters);
106 char command[IFNAMSIZ + 1] = {0, };
110 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
111 ifname = command + 1;
112 if ((strlen(command) <= 1) ||
113 !dev_valid_name(ifname))
116 if (command[0] == '+') {
117 pr_info("%s is being created...\n", ifname);
118 rv = bond_create(bn->net, ifname);
121 pr_info("%s already exists.\n", ifname);
123 pr_info("%s creation failed.\n", ifname);
126 } else if (command[0] == '-') {
127 struct net_device *bond_dev;
130 bond_dev = bond_get_by_name(bn, ifname);
132 pr_info("%s is being deleted...\n", ifname);
133 unregister_netdevice(bond_dev);
135 pr_err("unable to delete non-existent %s\n", ifname);
142 /* Always return either count or an error. If you return 0, you'll
143 * get called forever, which is bad.
148 pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n");
152 /* class attribute for bond_masters file. This ends up in /sys/class/net */
153 static const struct class_attribute class_attr_bonding_masters = {
155 .name = "bonding_masters",
156 .mode = S_IWUSR | S_IRUGO,
158 .show = bonding_show_bonds,
159 .store = bonding_store_bonds,
162 int bond_create_slave_symlinks(struct net_device *master,
163 struct net_device *slave)
165 char linkname[IFNAMSIZ+7];
168 /* first, create a link from the slave back to the master */
169 ret = sysfs_create_link(&(slave->dev.kobj), &(master->dev.kobj),
173 /* next, create a link from the master to the slave */
174 sprintf(linkname, "slave_%s", slave->name);
175 ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
178 /* free the master link created earlier in case of error */
180 sysfs_remove_link(&(slave->dev.kobj), "master");
186 void bond_destroy_slave_symlinks(struct net_device *master,
187 struct net_device *slave)
189 char linkname[IFNAMSIZ+7];
191 sysfs_remove_link(&(slave->dev.kobj), "master");
192 sprintf(linkname, "slave_%s", slave->name);
193 sysfs_remove_link(&(master->dev.kobj), linkname);
198 * Show the slaves in the current bond.
200 static ssize_t bonding_show_slaves(struct device *d,
201 struct device_attribute *attr, char *buf)
203 struct bonding *bond = to_bond(d);
207 read_lock(&bond->lock);
208 bond_for_each_slave(bond, slave) {
209 if (res > (PAGE_SIZE - IFNAMSIZ)) {
210 /* not enough space for another interface name */
211 if ((PAGE_SIZE - res) > 10)
212 res = PAGE_SIZE - 10;
213 res += sprintf(buf + res, "++more++ ");
216 res += sprintf(buf + res, "%s ", slave->dev->name);
218 read_unlock(&bond->lock);
220 buf[res-1] = '\n'; /* eat the leftover space */
226 * Set the slaves in the current bond.
227 * This is supposed to be only thin wrapper for bond_enslave and bond_release.
228 * All hard work should be done there.
230 static ssize_t bonding_store_slaves(struct device *d,
231 struct device_attribute *attr,
232 const char *buffer, size_t count)
234 char command[IFNAMSIZ + 1] = { 0, };
236 int res, ret = count;
237 struct net_device *dev;
238 struct bonding *bond = to_bond(d);
241 return restart_syscall();
243 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
244 ifname = command + 1;
245 if ((strlen(command) <= 1) ||
246 !dev_valid_name(ifname))
249 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
251 pr_info("%s: Interface %s does not exist!\n",
252 bond->dev->name, ifname);
257 switch (command[0]) {
259 pr_info("%s: Adding slave %s.\n", bond->dev->name, dev->name);
260 res = bond_enslave(bond->dev, dev);
264 pr_info("%s: Removing slave %s.\n", bond->dev->name, dev->name);
265 res = bond_release(bond->dev, dev);
277 pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
286 static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
287 bonding_store_slaves);
290 * Show and set the bonding mode. The bond interface must be down to
293 static ssize_t bonding_show_mode(struct device *d,
294 struct device_attribute *attr, char *buf)
296 struct bonding *bond = to_bond(d);
298 return sprintf(buf, "%s %d\n",
299 bond_mode_tbl[bond->params.mode].modename,
303 static ssize_t bonding_store_mode(struct device *d,
304 struct device_attribute *attr,
305 const char *buf, size_t count)
307 int new_value, ret = count;
308 struct bonding *bond = to_bond(d);
311 return restart_syscall();
313 if (bond->dev->flags & IFF_UP) {
314 pr_err("unable to update mode of %s because interface is up.\n",
320 if (!list_empty(&bond->slave_list)) {
321 pr_err("unable to update mode of %s because it has slaves.\n",
327 new_value = bond_parse_parm(buf, bond_mode_tbl);
329 pr_err("%s: Ignoring invalid mode value %.*s.\n",
330 bond->dev->name, (int)strlen(buf) - 1, buf);
334 if ((new_value == BOND_MODE_ALB ||
335 new_value == BOND_MODE_TLB) &&
336 bond->params.arp_interval) {
337 pr_err("%s: %s mode is incompatible with arp monitoring.\n",
338 bond->dev->name, bond_mode_tbl[new_value].modename);
343 /* don't cache arp_validate between modes */
344 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
345 bond->params.mode = new_value;
346 bond_set_mode_ops(bond, bond->params.mode);
347 pr_info("%s: setting mode to %s (%d).\n",
348 bond->dev->name, bond_mode_tbl[new_value].modename,
354 static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
355 bonding_show_mode, bonding_store_mode);
358 * Show and set the bonding transmit hash method.
360 static ssize_t bonding_show_xmit_hash(struct device *d,
361 struct device_attribute *attr,
364 struct bonding *bond = to_bond(d);
366 return sprintf(buf, "%s %d\n",
367 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
368 bond->params.xmit_policy);
371 static ssize_t bonding_store_xmit_hash(struct device *d,
372 struct device_attribute *attr,
373 const char *buf, size_t count)
375 int new_value, ret = count;
376 struct bonding *bond = to_bond(d);
378 new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
380 pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
382 (int)strlen(buf) - 1, buf);
385 bond->params.xmit_policy = new_value;
386 bond_set_mode_ops(bond, bond->params.mode);
387 pr_info("%s: setting xmit hash policy to %s (%d).\n",
389 xmit_hashtype_tbl[new_value].modename, new_value);
394 static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
395 bonding_show_xmit_hash, bonding_store_xmit_hash);
398 * Show and set arp_validate.
400 static ssize_t bonding_show_arp_validate(struct device *d,
401 struct device_attribute *attr,
404 struct bonding *bond = to_bond(d);
406 return sprintf(buf, "%s %d\n",
407 arp_validate_tbl[bond->params.arp_validate].modename,
408 bond->params.arp_validate);
411 static ssize_t bonding_store_arp_validate(struct device *d,
412 struct device_attribute *attr,
413 const char *buf, size_t count)
415 struct bonding *bond = to_bond(d);
416 int new_value, ret = count;
419 return restart_syscall();
420 new_value = bond_parse_parm(buf, arp_validate_tbl);
422 pr_err("%s: Ignoring invalid arp_validate value %s\n",
423 bond->dev->name, buf);
427 if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
428 pr_err("%s: arp_validate only supported in active-backup mode.\n",
433 pr_info("%s: setting arp_validate to %s (%d).\n",
434 bond->dev->name, arp_validate_tbl[new_value].modename,
437 if (bond->dev->flags & IFF_UP) {
439 bond->recv_probe = NULL;
440 else if (bond->params.arp_interval)
441 bond->recv_probe = bond_arp_rcv;
443 bond->params.arp_validate = new_value;
450 static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
451 bonding_store_arp_validate);
453 * Show and set arp_all_targets.
455 static ssize_t bonding_show_arp_all_targets(struct device *d,
456 struct device_attribute *attr,
459 struct bonding *bond = to_bond(d);
460 int value = bond->params.arp_all_targets;
462 return sprintf(buf, "%s %d\n", arp_all_targets_tbl[value].modename,
466 static ssize_t bonding_store_arp_all_targets(struct device *d,
467 struct device_attribute *attr,
468 const char *buf, size_t count)
470 struct bonding *bond = to_bond(d);
473 new_value = bond_parse_parm(buf, arp_all_targets_tbl);
475 pr_err("%s: Ignoring invalid arp_all_targets value %s\n",
476 bond->dev->name, buf);
479 pr_info("%s: setting arp_all_targets to %s (%d).\n",
480 bond->dev->name, arp_all_targets_tbl[new_value].modename,
483 bond->params.arp_all_targets = new_value;
488 static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,
489 bonding_show_arp_all_targets, bonding_store_arp_all_targets);
492 * Show and store fail_over_mac. User only allowed to change the
493 * value when there are no slaves.
495 static ssize_t bonding_show_fail_over_mac(struct device *d,
496 struct device_attribute *attr,
499 struct bonding *bond = to_bond(d);
501 return sprintf(buf, "%s %d\n",
502 fail_over_mac_tbl[bond->params.fail_over_mac].modename,
503 bond->params.fail_over_mac);
506 static ssize_t bonding_store_fail_over_mac(struct device *d,
507 struct device_attribute *attr,
508 const char *buf, size_t count)
510 int new_value, ret = count;
511 struct bonding *bond = to_bond(d);
514 return restart_syscall();
516 if (!list_empty(&bond->slave_list)) {
517 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
523 new_value = bond_parse_parm(buf, fail_over_mac_tbl);
525 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
526 bond->dev->name, buf);
531 bond->params.fail_over_mac = new_value;
532 pr_info("%s: Setting fail_over_mac to %s (%d).\n",
533 bond->dev->name, fail_over_mac_tbl[new_value].modename,
541 static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR,
542 bonding_show_fail_over_mac, bonding_store_fail_over_mac);
545 * Show and set the arp timer interval. There are two tricky bits
546 * here. First, if ARP monitoring is activated, then we must disable
547 * MII monitoring. Second, if the ARP timer isn't running, we must
550 static ssize_t bonding_show_arp_interval(struct device *d,
551 struct device_attribute *attr,
554 struct bonding *bond = to_bond(d);
556 return sprintf(buf, "%d\n", bond->params.arp_interval);
559 static ssize_t bonding_store_arp_interval(struct device *d,
560 struct device_attribute *attr,
561 const char *buf, size_t count)
563 struct bonding *bond = to_bond(d);
564 int new_value, ret = count;
567 return restart_syscall();
568 if (sscanf(buf, "%d", &new_value) != 1) {
569 pr_err("%s: no arp_interval value specified.\n",
575 pr_err("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n",
576 bond->dev->name, new_value, INT_MAX);
580 if (bond->params.mode == BOND_MODE_ALB ||
581 bond->params.mode == BOND_MODE_TLB) {
582 pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n",
583 bond->dev->name, bond->dev->name);
587 pr_info("%s: Setting ARP monitoring interval to %d.\n",
588 bond->dev->name, new_value);
589 bond->params.arp_interval = new_value;
591 if (bond->params.miimon) {
592 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
593 bond->dev->name, bond->dev->name);
594 bond->params.miimon = 0;
596 if (!bond->params.arp_targets[0])
597 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
600 if (bond->dev->flags & IFF_UP) {
601 /* If the interface is up, we may need to fire off
602 * the ARP timer. If the interface is down, the
603 * timer will get fired off when the open function
607 if (bond->params.arp_validate)
608 bond->recv_probe = NULL;
609 cancel_delayed_work_sync(&bond->arp_work);
611 /* arp_validate can be set only in active-backup mode */
612 if (bond->params.arp_validate)
613 bond->recv_probe = bond_arp_rcv;
614 cancel_delayed_work_sync(&bond->mii_work);
615 queue_delayed_work(bond->wq, &bond->arp_work, 0);
622 static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR,
623 bonding_show_arp_interval, bonding_store_arp_interval);
626 * Show and set the arp targets.
628 static ssize_t bonding_show_arp_targets(struct device *d,
629 struct device_attribute *attr,
633 struct bonding *bond = to_bond(d);
635 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
636 if (bond->params.arp_targets[i])
637 res += sprintf(buf + res, "%pI4 ",
638 &bond->params.arp_targets[i]);
641 buf[res-1] = '\n'; /* eat the leftover space */
645 static ssize_t bonding_store_arp_targets(struct device *d,
646 struct device_attribute *attr,
647 const char *buf, size_t count)
649 struct bonding *bond = to_bond(d);
651 __be32 newtarget, *targets;
652 unsigned long *targets_rx;
653 int ind, i, j, ret = -EINVAL;
655 targets = bond->params.arp_targets;
656 newtarget = in_aton(buf + 1);
659 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
660 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
661 bond->dev->name, &newtarget);
665 if (bond_get_targets_ip(targets, newtarget) != -1) { /* dup */
666 pr_err("%s: ARP target %pI4 is already present\n",
667 bond->dev->name, &newtarget);
671 ind = bond_get_targets_ip(targets, 0); /* first free slot */
673 pr_err("%s: ARP target table is full!\n",
678 pr_info("%s: adding ARP target %pI4.\n", bond->dev->name,
680 /* not to race with bond_arp_rcv */
681 write_lock_bh(&bond->lock);
682 bond_for_each_slave(bond, slave)
683 slave->target_last_arp_rx[ind] = jiffies;
684 targets[ind] = newtarget;
685 write_unlock_bh(&bond->lock);
686 } else if (buf[0] == '-') {
687 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
688 pr_err("%s: invalid ARP target %pI4 specified for removal\n",
689 bond->dev->name, &newtarget);
693 ind = bond_get_targets_ip(targets, newtarget);
695 pr_err("%s: unable to remove nonexistent ARP target %pI4.\n",
696 bond->dev->name, &newtarget);
700 if (ind == 0 && !targets[1] && bond->params.arp_interval)
701 pr_warn("%s: removing last arp target with arp_interval on\n",
704 pr_info("%s: removing ARP target %pI4.\n", bond->dev->name,
707 write_lock_bh(&bond->lock);
708 bond_for_each_slave(bond, slave) {
709 targets_rx = slave->target_last_arp_rx;
711 for (; (j < BOND_MAX_ARP_TARGETS-1) && targets[j+1]; j++)
712 targets_rx[j] = targets_rx[j+1];
715 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
716 targets[i] = targets[i+1];
718 write_unlock_bh(&bond->lock);
720 pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
730 static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets);
733 * Show and set the up and down delays. These must be multiples of the
734 * MII monitoring value, and are stored internally as the multiplier.
735 * Thus, we must translate to MS for the real world.
737 static ssize_t bonding_show_downdelay(struct device *d,
738 struct device_attribute *attr,
741 struct bonding *bond = to_bond(d);
743 return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon);
746 static ssize_t bonding_store_downdelay(struct device *d,
747 struct device_attribute *attr,
748 const char *buf, size_t count)
750 int new_value, ret = count;
751 struct bonding *bond = to_bond(d);
753 if (!(bond->params.miimon)) {
754 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
760 if (sscanf(buf, "%d", &new_value) != 1) {
761 pr_err("%s: no down delay value specified.\n", bond->dev->name);
766 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
767 bond->dev->name, new_value, 0, INT_MAX);
771 if ((new_value % bond->params.miimon) != 0) {
772 pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
773 bond->dev->name, new_value,
775 (new_value / bond->params.miimon) *
776 bond->params.miimon);
778 bond->params.downdelay = new_value / bond->params.miimon;
779 pr_info("%s: Setting down delay to %d.\n",
781 bond->params.downdelay * bond->params.miimon);
788 static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
789 bonding_show_downdelay, bonding_store_downdelay);
791 static ssize_t bonding_show_updelay(struct device *d,
792 struct device_attribute *attr,
795 struct bonding *bond = to_bond(d);
797 return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon);
801 static ssize_t bonding_store_updelay(struct device *d,
802 struct device_attribute *attr,
803 const char *buf, size_t count)
805 int new_value, ret = count;
806 struct bonding *bond = to_bond(d);
808 if (!(bond->params.miimon)) {
809 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
815 if (sscanf(buf, "%d", &new_value) != 1) {
816 pr_err("%s: no up delay value specified.\n",
822 pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n",
823 bond->dev->name, new_value, 0, INT_MAX);
827 if ((new_value % bond->params.miimon) != 0) {
828 pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
829 bond->dev->name, new_value,
831 (new_value / bond->params.miimon) *
832 bond->params.miimon);
834 bond->params.updelay = new_value / bond->params.miimon;
835 pr_info("%s: Setting up delay to %d.\n",
837 bond->params.updelay * bond->params.miimon);
843 static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
844 bonding_show_updelay, bonding_store_updelay);
847 * Show and set the LACP interval. Interface must be down, and the mode
848 * must be set to 802.3ad mode.
850 static ssize_t bonding_show_lacp(struct device *d,
851 struct device_attribute *attr,
854 struct bonding *bond = to_bond(d);
856 return sprintf(buf, "%s %d\n",
857 bond_lacp_tbl[bond->params.lacp_fast].modename,
858 bond->params.lacp_fast);
861 static ssize_t bonding_store_lacp(struct device *d,
862 struct device_attribute *attr,
863 const char *buf, size_t count)
865 struct bonding *bond = to_bond(d);
866 int new_value, ret = count;
869 return restart_syscall();
871 if (bond->dev->flags & IFF_UP) {
872 pr_err("%s: Unable to update LACP rate because interface is up.\n",
878 if (bond->params.mode != BOND_MODE_8023AD) {
879 pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
885 new_value = bond_parse_parm(buf, bond_lacp_tbl);
887 if ((new_value == 1) || (new_value == 0)) {
888 bond->params.lacp_fast = new_value;
889 bond_3ad_update_lacp_rate(bond);
890 pr_info("%s: Setting LACP rate to %s (%d).\n",
891 bond->dev->name, bond_lacp_tbl[new_value].modename,
894 pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
895 bond->dev->name, (int)strlen(buf) - 1, buf);
903 static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR,
904 bonding_show_lacp, bonding_store_lacp);
906 static ssize_t bonding_show_min_links(struct device *d,
907 struct device_attribute *attr,
910 struct bonding *bond = to_bond(d);
912 return sprintf(buf, "%d\n", bond->params.min_links);
915 static ssize_t bonding_store_min_links(struct device *d,
916 struct device_attribute *attr,
917 const char *buf, size_t count)
919 struct bonding *bond = to_bond(d);
921 unsigned int new_value;
923 ret = kstrtouint(buf, 0, &new_value);
925 pr_err("%s: Ignoring invalid min links value %s.\n",
926 bond->dev->name, buf);
930 pr_info("%s: Setting min links value to %u\n",
931 bond->dev->name, new_value);
932 bond->params.min_links = new_value;
935 static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR,
936 bonding_show_min_links, bonding_store_min_links);
938 static ssize_t bonding_show_ad_select(struct device *d,
939 struct device_attribute *attr,
942 struct bonding *bond = to_bond(d);
944 return sprintf(buf, "%s %d\n",
945 ad_select_tbl[bond->params.ad_select].modename,
946 bond->params.ad_select);
950 static ssize_t bonding_store_ad_select(struct device *d,
951 struct device_attribute *attr,
952 const char *buf, size_t count)
954 int new_value, ret = count;
955 struct bonding *bond = to_bond(d);
957 if (bond->dev->flags & IFF_UP) {
958 pr_err("%s: Unable to update ad_select because interface is up.\n",
964 new_value = bond_parse_parm(buf, ad_select_tbl);
966 if (new_value != -1) {
967 bond->params.ad_select = new_value;
968 pr_info("%s: Setting ad_select to %s (%d).\n",
969 bond->dev->name, ad_select_tbl[new_value].modename,
972 pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
973 bond->dev->name, (int)strlen(buf) - 1, buf);
979 static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
980 bonding_show_ad_select, bonding_store_ad_select);
983 * Show and set the number of peer notifications to send after a failover event.
985 static ssize_t bonding_show_num_peer_notif(struct device *d,
986 struct device_attribute *attr,
989 struct bonding *bond = to_bond(d);
990 return sprintf(buf, "%d\n", bond->params.num_peer_notif);
993 static ssize_t bonding_store_num_peer_notif(struct device *d,
994 struct device_attribute *attr,
995 const char *buf, size_t count)
997 struct bonding *bond = to_bond(d);
998 int err = kstrtou8(buf, 10, &bond->params.num_peer_notif);
999 return err ? err : count;
1001 static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
1002 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
1003 static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
1004 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
1007 * Show and set the MII monitor interval. There are two tricky bits
1008 * here. First, if MII monitoring is activated, then we must disable
1009 * ARP monitoring. Second, if the timer isn't running, we must
1012 static ssize_t bonding_show_miimon(struct device *d,
1013 struct device_attribute *attr,
1016 struct bonding *bond = to_bond(d);
1018 return sprintf(buf, "%d\n", bond->params.miimon);
1021 static ssize_t bonding_store_miimon(struct device *d,
1022 struct device_attribute *attr,
1023 const char *buf, size_t count)
1025 int new_value, ret = count;
1026 struct bonding *bond = to_bond(d);
1028 if (!rtnl_trylock())
1029 return restart_syscall();
1030 if (sscanf(buf, "%d", &new_value) != 1) {
1031 pr_err("%s: no miimon value specified.\n",
1036 if (new_value < 0) {
1037 pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
1038 bond->dev->name, new_value, 0, INT_MAX);
1042 pr_info("%s: Setting MII monitoring interval to %d.\n",
1043 bond->dev->name, new_value);
1044 bond->params.miimon = new_value;
1045 if (bond->params.updelay)
1046 pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
1048 bond->params.updelay * bond->params.miimon);
1049 if (bond->params.downdelay)
1050 pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
1052 bond->params.downdelay * bond->params.miimon);
1053 if (new_value && bond->params.arp_interval) {
1054 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
1056 bond->params.arp_interval = 0;
1057 if (bond->params.arp_validate)
1058 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
1060 if (bond->dev->flags & IFF_UP) {
1061 /* If the interface is up, we may need to fire off
1062 * the MII timer. If the interface is down, the
1063 * timer will get fired off when the open function
1067 cancel_delayed_work_sync(&bond->mii_work);
1069 cancel_delayed_work_sync(&bond->arp_work);
1070 queue_delayed_work(bond->wq, &bond->mii_work, 0);
1077 static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR,
1078 bonding_show_miimon, bonding_store_miimon);
1081 * Show and set the primary slave. The store function is much
1082 * simpler than bonding_store_slaves function because it only needs to
1083 * handle one interface name.
1084 * The bond must be a mode that supports a primary for this be
1087 static ssize_t bonding_show_primary(struct device *d,
1088 struct device_attribute *attr,
1092 struct bonding *bond = to_bond(d);
1094 if (bond->primary_slave)
1095 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name);
1100 static ssize_t bonding_store_primary(struct device *d,
1101 struct device_attribute *attr,
1102 const char *buf, size_t count)
1104 struct bonding *bond = to_bond(d);
1105 char ifname[IFNAMSIZ];
1106 struct slave *slave;
1108 if (!rtnl_trylock())
1109 return restart_syscall();
1111 read_lock(&bond->lock);
1112 write_lock_bh(&bond->curr_slave_lock);
1114 if (!USES_PRIMARY(bond->params.mode)) {
1115 pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
1116 bond->dev->name, bond->dev->name, bond->params.mode);
1120 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
1122 /* check to see if we are clearing primary */
1123 if (!strlen(ifname) || buf[0] == '\n') {
1124 pr_info("%s: Setting primary slave to None.\n",
1126 bond->primary_slave = NULL;
1127 memset(bond->params.primary, 0, sizeof(bond->params.primary));
1128 bond_select_active_slave(bond);
1132 bond_for_each_slave(bond, slave) {
1133 if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
1134 pr_info("%s: Setting %s as primary slave.\n",
1135 bond->dev->name, slave->dev->name);
1136 bond->primary_slave = slave;
1137 strcpy(bond->params.primary, slave->dev->name);
1138 bond_select_active_slave(bond);
1143 strncpy(bond->params.primary, ifname, IFNAMSIZ);
1144 bond->params.primary[IFNAMSIZ - 1] = 0;
1146 pr_info("%s: Recording %s as primary, "
1147 "but it has not been enslaved to %s yet.\n",
1148 bond->dev->name, ifname, bond->dev->name);
1150 write_unlock_bh(&bond->curr_slave_lock);
1151 read_unlock(&bond->lock);
1152 unblock_netpoll_tx();
1157 static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR,
1158 bonding_show_primary, bonding_store_primary);
1161 * Show and set the primary_reselect flag.
1163 static ssize_t bonding_show_primary_reselect(struct device *d,
1164 struct device_attribute *attr,
1167 struct bonding *bond = to_bond(d);
1169 return sprintf(buf, "%s %d\n",
1170 pri_reselect_tbl[bond->params.primary_reselect].modename,
1171 bond->params.primary_reselect);
1174 static ssize_t bonding_store_primary_reselect(struct device *d,
1175 struct device_attribute *attr,
1176 const char *buf, size_t count)
1178 int new_value, ret = count;
1179 struct bonding *bond = to_bond(d);
1181 if (!rtnl_trylock())
1182 return restart_syscall();
1184 new_value = bond_parse_parm(buf, pri_reselect_tbl);
1185 if (new_value < 0) {
1186 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
1188 (int) strlen(buf) - 1, buf);
1193 bond->params.primary_reselect = new_value;
1194 pr_info("%s: setting primary_reselect to %s (%d).\n",
1195 bond->dev->name, pri_reselect_tbl[new_value].modename,
1199 read_lock(&bond->lock);
1200 write_lock_bh(&bond->curr_slave_lock);
1201 bond_select_active_slave(bond);
1202 write_unlock_bh(&bond->curr_slave_lock);
1203 read_unlock(&bond->lock);
1204 unblock_netpoll_tx();
1209 static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR,
1210 bonding_show_primary_reselect,
1211 bonding_store_primary_reselect);
1214 * Show and set the use_carrier flag.
1216 static ssize_t bonding_show_carrier(struct device *d,
1217 struct device_attribute *attr,
1220 struct bonding *bond = to_bond(d);
1222 return sprintf(buf, "%d\n", bond->params.use_carrier);
1225 static ssize_t bonding_store_carrier(struct device *d,
1226 struct device_attribute *attr,
1227 const char *buf, size_t count)
1229 int new_value, ret = count;
1230 struct bonding *bond = to_bond(d);
1233 if (sscanf(buf, "%d", &new_value) != 1) {
1234 pr_err("%s: no use_carrier value specified.\n",
1239 if ((new_value == 0) || (new_value == 1)) {
1240 bond->params.use_carrier = new_value;
1241 pr_info("%s: Setting use_carrier to %d.\n",
1242 bond->dev->name, new_value);
1244 pr_info("%s: Ignoring invalid use_carrier value %d.\n",
1245 bond->dev->name, new_value);
1250 static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR,
1251 bonding_show_carrier, bonding_store_carrier);
1255 * Show and set currently active_slave.
1257 static ssize_t bonding_show_active_slave(struct device *d,
1258 struct device_attribute *attr,
1261 struct bonding *bond = to_bond(d);
1266 curr = rcu_dereference(bond->curr_active_slave);
1267 if (USES_PRIMARY(bond->params.mode) && curr)
1268 count = sprintf(buf, "%s\n", curr->dev->name);
1274 static ssize_t bonding_store_active_slave(struct device *d,
1275 struct device_attribute *attr,
1276 const char *buf, size_t count)
1278 struct slave *slave, *old_active, *new_active;
1279 struct bonding *bond = to_bond(d);
1280 char ifname[IFNAMSIZ];
1282 if (!rtnl_trylock())
1283 return restart_syscall();
1285 old_active = new_active = NULL;
1287 read_lock(&bond->lock);
1288 write_lock_bh(&bond->curr_slave_lock);
1290 if (!USES_PRIMARY(bond->params.mode)) {
1291 pr_info("%s: Unable to change active slave; %s is in mode %d\n",
1292 bond->dev->name, bond->dev->name, bond->params.mode);
1296 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
1298 /* check to see if we are clearing active */
1299 if (!strlen(ifname) || buf[0] == '\n') {
1300 pr_info("%s: Clearing current active slave.\n",
1302 rcu_assign_pointer(bond->curr_active_slave, NULL);
1303 bond_select_active_slave(bond);
1307 bond_for_each_slave(bond, slave) {
1308 if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
1309 old_active = bond->curr_active_slave;
1311 if (new_active == old_active) {
1313 pr_info("%s: %s is already the current"
1321 (new_active->link == BOND_LINK_UP) &&
1322 IS_UP(new_active->dev)) {
1323 pr_info("%s: Setting %s as active"
1327 bond_change_active_slave(bond,
1330 pr_info("%s: Could not set %s as"
1331 " active slave; either %s is"
1332 " down or the link is down.\n",
1342 pr_info("%s: Unable to set %.*s as active slave.\n",
1343 bond->dev->name, (int)strlen(buf) - 1, buf);
1345 write_unlock_bh(&bond->curr_slave_lock);
1346 read_unlock(&bond->lock);
1347 unblock_netpoll_tx();
1354 static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR,
1355 bonding_show_active_slave, bonding_store_active_slave);
1359 * Show link status of the bond interface.
1361 static ssize_t bonding_show_mii_status(struct device *d,
1362 struct device_attribute *attr,
1365 struct bonding *bond = to_bond(d);
1367 return sprintf(buf, "%s\n", bond->curr_active_slave ? "up" : "down");
1369 static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
1372 * Show current 802.3ad aggregator ID.
1374 static ssize_t bonding_show_ad_aggregator(struct device *d,
1375 struct device_attribute *attr,
1379 struct bonding *bond = to_bond(d);
1381 if (bond->params.mode == BOND_MODE_8023AD) {
1382 struct ad_info ad_info;
1383 count = sprintf(buf, "%d\n",
1384 bond_3ad_get_active_agg_info(bond, &ad_info)
1385 ? 0 : ad_info.aggregator_id);
1390 static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL);
1394 * Show number of active 802.3ad ports.
1396 static ssize_t bonding_show_ad_num_ports(struct device *d,
1397 struct device_attribute *attr,
1401 struct bonding *bond = to_bond(d);
1403 if (bond->params.mode == BOND_MODE_8023AD) {
1404 struct ad_info ad_info;
1405 count = sprintf(buf, "%d\n",
1406 bond_3ad_get_active_agg_info(bond, &ad_info)
1407 ? 0 : ad_info.ports);
1412 static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL);
1416 * Show current 802.3ad actor key.
1418 static ssize_t bonding_show_ad_actor_key(struct device *d,
1419 struct device_attribute *attr,
1423 struct bonding *bond = to_bond(d);
1425 if (bond->params.mode == BOND_MODE_8023AD) {
1426 struct ad_info ad_info;
1427 count = sprintf(buf, "%d\n",
1428 bond_3ad_get_active_agg_info(bond, &ad_info)
1429 ? 0 : ad_info.actor_key);
1434 static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL);
1438 * Show current 802.3ad partner key.
1440 static ssize_t bonding_show_ad_partner_key(struct device *d,
1441 struct device_attribute *attr,
1445 struct bonding *bond = to_bond(d);
1447 if (bond->params.mode == BOND_MODE_8023AD) {
1448 struct ad_info ad_info;
1449 count = sprintf(buf, "%d\n",
1450 bond_3ad_get_active_agg_info(bond, &ad_info)
1451 ? 0 : ad_info.partner_key);
1456 static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL);
1460 * Show current 802.3ad partner mac.
1462 static ssize_t bonding_show_ad_partner_mac(struct device *d,
1463 struct device_attribute *attr,
1467 struct bonding *bond = to_bond(d);
1469 if (bond->params.mode == BOND_MODE_8023AD) {
1470 struct ad_info ad_info;
1471 if (!bond_3ad_get_active_agg_info(bond, &ad_info))
1472 count = sprintf(buf, "%pM\n", ad_info.partner_system);
1477 static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
1480 * Show the queue_ids of the slaves in the current bond.
1482 static ssize_t bonding_show_queue_id(struct device *d,
1483 struct device_attribute *attr,
1486 struct bonding *bond = to_bond(d);
1487 struct slave *slave;
1490 if (!rtnl_trylock())
1491 return restart_syscall();
1493 read_lock(&bond->lock);
1494 bond_for_each_slave(bond, slave) {
1495 if (res > (PAGE_SIZE - IFNAMSIZ - 6)) {
1496 /* not enough space for another interface_name:queue_id pair */
1497 if ((PAGE_SIZE - res) > 10)
1498 res = PAGE_SIZE - 10;
1499 res += sprintf(buf + res, "++more++ ");
1502 res += sprintf(buf + res, "%s:%d ",
1503 slave->dev->name, slave->queue_id);
1505 read_unlock(&bond->lock);
1507 buf[res-1] = '\n'; /* eat the leftover space */
1514 * Set the queue_ids of the slaves in the current bond. The bond
1515 * interface must be enslaved for this to work.
1517 static ssize_t bonding_store_queue_id(struct device *d,
1518 struct device_attribute *attr,
1519 const char *buffer, size_t count)
1521 struct slave *slave, *update_slave;
1522 struct bonding *bond = to_bond(d);
1526 struct net_device *sdev = NULL;
1528 if (!rtnl_trylock())
1529 return restart_syscall();
1531 /* delim will point to queue id if successful */
1532 delim = strchr(buffer, ':');
1537 * Terminate string that points to device name and bump it
1538 * up one, so we can read the queue id there.
1541 if (sscanf(++delim, "%hd\n", &qid) != 1)
1544 /* Check buffer length, valid ifname and queue id */
1545 if (strlen(buffer) > IFNAMSIZ ||
1546 !dev_valid_name(buffer) ||
1547 qid > bond->dev->real_num_tx_queues)
1550 /* Get the pointer to that interface if it exists */
1551 sdev = __dev_get_by_name(dev_net(bond->dev), buffer);
1555 read_lock(&bond->lock);
1557 /* Search for thes slave and check for duplicate qids */
1558 update_slave = NULL;
1559 bond_for_each_slave(bond, slave) {
1560 if (sdev == slave->dev)
1562 * We don't need to check the matching
1563 * slave for dups, since we're overwriting it
1565 update_slave = slave;
1566 else if (qid && qid == slave->queue_id) {
1567 goto err_no_cmd_unlock;
1572 goto err_no_cmd_unlock;
1574 /* Actually set the qids for the slave */
1575 update_slave->queue_id = qid;
1577 read_unlock(&bond->lock);
1583 read_unlock(&bond->lock);
1585 pr_info("invalid input for queue_id set for %s.\n",
1591 static DEVICE_ATTR(queue_id, S_IRUGO | S_IWUSR, bonding_show_queue_id,
1592 bonding_store_queue_id);
1596 * Show and set the all_slaves_active flag.
1598 static ssize_t bonding_show_slaves_active(struct device *d,
1599 struct device_attribute *attr,
1602 struct bonding *bond = to_bond(d);
1604 return sprintf(buf, "%d\n", bond->params.all_slaves_active);
1607 static ssize_t bonding_store_slaves_active(struct device *d,
1608 struct device_attribute *attr,
1609 const char *buf, size_t count)
1611 struct bonding *bond = to_bond(d);
1612 int new_value, ret = count;
1613 struct slave *slave;
1615 if (sscanf(buf, "%d", &new_value) != 1) {
1616 pr_err("%s: no all_slaves_active value specified.\n",
1622 if (new_value == bond->params.all_slaves_active)
1625 if ((new_value == 0) || (new_value == 1)) {
1626 bond->params.all_slaves_active = new_value;
1628 pr_info("%s: Ignoring invalid all_slaves_active value %d.\n",
1629 bond->dev->name, new_value);
1634 read_lock(&bond->lock);
1635 bond_for_each_slave(bond, slave) {
1636 if (!bond_is_active_slave(slave)) {
1638 slave->inactive = 0;
1640 slave->inactive = 1;
1643 read_unlock(&bond->lock);
1647 static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR,
1648 bonding_show_slaves_active, bonding_store_slaves_active);
1651 * Show and set the number of IGMP membership reports to send on link failure
1653 static ssize_t bonding_show_resend_igmp(struct device *d,
1654 struct device_attribute *attr,
1657 struct bonding *bond = to_bond(d);
1659 return sprintf(buf, "%d\n", bond->params.resend_igmp);
1662 static ssize_t bonding_store_resend_igmp(struct device *d,
1663 struct device_attribute *attr,
1664 const char *buf, size_t count)
1666 int new_value, ret = count;
1667 struct bonding *bond = to_bond(d);
1669 if (sscanf(buf, "%d", &new_value) != 1) {
1670 pr_err("%s: no resend_igmp value specified.\n",
1676 if (new_value < 0 || new_value > 255) {
1677 pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n",
1678 bond->dev->name, new_value);
1683 pr_info("%s: Setting resend_igmp to %d.\n",
1684 bond->dev->name, new_value);
1685 bond->params.resend_igmp = new_value;
1690 static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
1691 bonding_show_resend_igmp, bonding_store_resend_igmp);
1694 static ssize_t bonding_show_lp_interval(struct device *d,
1695 struct device_attribute *attr,
1698 struct bonding *bond = to_bond(d);
1699 return sprintf(buf, "%d\n", bond->params.lp_interval);
1702 static ssize_t bonding_store_lp_interval(struct device *d,
1703 struct device_attribute *attr,
1704 const char *buf, size_t count)
1706 struct bonding *bond = to_bond(d);
1707 int new_value, ret = count;
1709 if (sscanf(buf, "%d", &new_value) != 1) {
1710 pr_err("%s: no lp interval value specified.\n",
1716 if (new_value <= 0) {
1717 pr_err ("%s: lp_interval must be between 1 and %d\n",
1718 bond->dev->name, INT_MAX);
1723 bond->params.lp_interval = new_value;
1728 static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
1729 bonding_show_lp_interval, bonding_store_lp_interval);
1731 static struct attribute *per_bond_attrs[] = {
1732 &dev_attr_slaves.attr,
1733 &dev_attr_mode.attr,
1734 &dev_attr_fail_over_mac.attr,
1735 &dev_attr_arp_validate.attr,
1736 &dev_attr_arp_all_targets.attr,
1737 &dev_attr_arp_interval.attr,
1738 &dev_attr_arp_ip_target.attr,
1739 &dev_attr_downdelay.attr,
1740 &dev_attr_updelay.attr,
1741 &dev_attr_lacp_rate.attr,
1742 &dev_attr_ad_select.attr,
1743 &dev_attr_xmit_hash_policy.attr,
1744 &dev_attr_num_grat_arp.attr,
1745 &dev_attr_num_unsol_na.attr,
1746 &dev_attr_miimon.attr,
1747 &dev_attr_primary.attr,
1748 &dev_attr_primary_reselect.attr,
1749 &dev_attr_use_carrier.attr,
1750 &dev_attr_active_slave.attr,
1751 &dev_attr_mii_status.attr,
1752 &dev_attr_ad_aggregator.attr,
1753 &dev_attr_ad_num_ports.attr,
1754 &dev_attr_ad_actor_key.attr,
1755 &dev_attr_ad_partner_key.attr,
1756 &dev_attr_ad_partner_mac.attr,
1757 &dev_attr_queue_id.attr,
1758 &dev_attr_all_slaves_active.attr,
1759 &dev_attr_resend_igmp.attr,
1760 &dev_attr_min_links.attr,
1761 &dev_attr_lp_interval.attr,
1765 static struct attribute_group bonding_group = {
1767 .attrs = per_bond_attrs,
1771 * Initialize sysfs. This sets up the bonding_masters file in
1774 int bond_create_sysfs(struct bond_net *bn)
1778 bn->class_attr_bonding_masters = class_attr_bonding_masters;
1779 sysfs_attr_init(&bn->class_attr_bonding_masters.attr);
1781 ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters,
1784 * Permit multiple loads of the module by ignoring failures to
1785 * create the bonding_masters sysfs file. Bonding devices
1786 * created by second or subsequent loads of the module will
1787 * not be listed in, or controllable by, bonding_masters, but
1788 * will have the usual "bonding" sysfs directory.
1790 * This is done to preserve backwards compatibility for
1791 * initscripts/sysconfig, which load bonding multiple times to
1792 * configure multiple bonding devices.
1794 if (ret == -EEXIST) {
1795 /* Is someone being kinky and naming a device bonding_master? */
1796 if (__dev_get_by_name(bn->net,
1797 class_attr_bonding_masters.attr.name))
1798 pr_err("network device named %s already exists in sysfs",
1799 class_attr_bonding_masters.attr.name);
1808 * Remove /sys/class/net/bonding_masters.
1810 void bond_destroy_sysfs(struct bond_net *bn)
1812 netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net);
1816 * Initialize sysfs for each bond. This sets up and registers
1817 * the 'bondctl' directory for each individual bond under /sys/class/net.
1819 void bond_prepare_sysfs_group(struct bonding *bond)
1821 bond->dev->sysfs_groups[0] = &bonding_group;