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 static const void *bonding_namespace(struct class *cls,
153 const struct class_attribute *attr)
155 const struct bond_net *bn =
156 container_of(attr, struct bond_net, class_attr_bonding_masters);
160 /* class attribute for bond_masters file. This ends up in /sys/class/net */
161 static const struct class_attribute class_attr_bonding_masters = {
163 .name = "bonding_masters",
164 .mode = S_IWUSR | S_IRUGO,
166 .show = bonding_show_bonds,
167 .store = bonding_store_bonds,
168 .namespace = bonding_namespace,
171 int bond_create_slave_symlinks(struct net_device *master,
172 struct net_device *slave)
174 char linkname[IFNAMSIZ+7];
177 /* first, create a link from the slave back to the master */
178 ret = sysfs_create_link(&(slave->dev.kobj), &(master->dev.kobj),
182 /* next, create a link from the master to the slave */
183 sprintf(linkname, "slave_%s", slave->name);
184 ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj),
187 /* free the master link created earlier in case of error */
189 sysfs_remove_link(&(slave->dev.kobj), "master");
195 void bond_destroy_slave_symlinks(struct net_device *master,
196 struct net_device *slave)
198 char linkname[IFNAMSIZ+7];
200 sysfs_remove_link(&(slave->dev.kobj), "master");
201 sprintf(linkname, "slave_%s", slave->name);
202 sysfs_remove_link(&(master->dev.kobj), linkname);
207 * Show the slaves in the current bond.
209 static ssize_t bonding_show_slaves(struct device *d,
210 struct device_attribute *attr, char *buf)
212 struct bonding *bond = to_bond(d);
216 read_lock(&bond->lock);
217 bond_for_each_slave(bond, slave) {
218 if (res > (PAGE_SIZE - IFNAMSIZ)) {
219 /* not enough space for another interface name */
220 if ((PAGE_SIZE - res) > 10)
221 res = PAGE_SIZE - 10;
222 res += sprintf(buf + res, "++more++ ");
225 res += sprintf(buf + res, "%s ", slave->dev->name);
227 read_unlock(&bond->lock);
229 buf[res-1] = '\n'; /* eat the leftover space */
235 * Set the slaves in the current bond.
236 * This is supposed to be only thin wrapper for bond_enslave and bond_release.
237 * All hard work should be done there.
239 static ssize_t bonding_store_slaves(struct device *d,
240 struct device_attribute *attr,
241 const char *buffer, size_t count)
243 char command[IFNAMSIZ + 1] = { 0, };
245 int res, ret = count;
246 struct net_device *dev;
247 struct bonding *bond = to_bond(d);
250 return restart_syscall();
252 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
253 ifname = command + 1;
254 if ((strlen(command) <= 1) ||
255 !dev_valid_name(ifname))
258 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
260 pr_info("%s: Interface %s does not exist!\n",
261 bond->dev->name, ifname);
266 switch (command[0]) {
268 pr_info("%s: Adding slave %s.\n", bond->dev->name, dev->name);
269 res = bond_enslave(bond->dev, dev);
273 pr_info("%s: Removing slave %s.\n", bond->dev->name, dev->name);
274 res = bond_release(bond->dev, dev);
286 pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
295 static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
296 bonding_store_slaves);
299 * Show and set the bonding mode. The bond interface must be down to
302 static ssize_t bonding_show_mode(struct device *d,
303 struct device_attribute *attr, char *buf)
305 struct bonding *bond = to_bond(d);
307 return sprintf(buf, "%s %d\n",
308 bond_mode_tbl[bond->params.mode].modename,
312 static ssize_t bonding_store_mode(struct device *d,
313 struct device_attribute *attr,
314 const char *buf, size_t count)
316 int new_value, ret = count;
317 struct bonding *bond = to_bond(d);
320 return restart_syscall();
322 if (bond->dev->flags & IFF_UP) {
323 pr_err("unable to update mode of %s because interface is up.\n",
329 if (!list_empty(&bond->slave_list)) {
330 pr_err("unable to update mode of %s because it has slaves.\n",
336 new_value = bond_parse_parm(buf, bond_mode_tbl);
338 pr_err("%s: Ignoring invalid mode value %.*s.\n",
339 bond->dev->name, (int)strlen(buf) - 1, buf);
343 if ((new_value == BOND_MODE_ALB ||
344 new_value == BOND_MODE_TLB) &&
345 bond->params.arp_interval) {
346 pr_err("%s: %s mode is incompatible with arp monitoring.\n",
347 bond->dev->name, bond_mode_tbl[new_value].modename);
352 /* don't cache arp_validate between modes */
353 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
354 bond->params.mode = new_value;
355 bond_set_mode_ops(bond, bond->params.mode);
356 pr_info("%s: setting mode to %s (%d).\n",
357 bond->dev->name, bond_mode_tbl[new_value].modename,
363 static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
364 bonding_show_mode, bonding_store_mode);
367 * Show and set the bonding transmit hash method.
369 static ssize_t bonding_show_xmit_hash(struct device *d,
370 struct device_attribute *attr,
373 struct bonding *bond = to_bond(d);
375 return sprintf(buf, "%s %d\n",
376 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
377 bond->params.xmit_policy);
380 static ssize_t bonding_store_xmit_hash(struct device *d,
381 struct device_attribute *attr,
382 const char *buf, size_t count)
384 int new_value, ret = count;
385 struct bonding *bond = to_bond(d);
387 new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
389 pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
391 (int)strlen(buf) - 1, buf);
394 bond->params.xmit_policy = new_value;
395 bond_set_mode_ops(bond, bond->params.mode);
396 pr_info("%s: setting xmit hash policy to %s (%d).\n",
398 xmit_hashtype_tbl[new_value].modename, new_value);
403 static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
404 bonding_show_xmit_hash, bonding_store_xmit_hash);
407 * Show and set arp_validate.
409 static ssize_t bonding_show_arp_validate(struct device *d,
410 struct device_attribute *attr,
413 struct bonding *bond = to_bond(d);
415 return sprintf(buf, "%s %d\n",
416 arp_validate_tbl[bond->params.arp_validate].modename,
417 bond->params.arp_validate);
420 static ssize_t bonding_store_arp_validate(struct device *d,
421 struct device_attribute *attr,
422 const char *buf, size_t count)
424 struct bonding *bond = to_bond(d);
425 int new_value, ret = count;
428 return restart_syscall();
429 new_value = bond_parse_parm(buf, arp_validate_tbl);
431 pr_err("%s: Ignoring invalid arp_validate value %s\n",
432 bond->dev->name, buf);
436 if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
437 pr_err("%s: arp_validate only supported in active-backup mode.\n",
442 pr_info("%s: setting arp_validate to %s (%d).\n",
443 bond->dev->name, arp_validate_tbl[new_value].modename,
446 if (bond->dev->flags & IFF_UP) {
448 bond->recv_probe = NULL;
449 else if (bond->params.arp_interval)
450 bond->recv_probe = bond_arp_rcv;
452 bond->params.arp_validate = new_value;
459 static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
460 bonding_store_arp_validate);
462 * Show and set arp_all_targets.
464 static ssize_t bonding_show_arp_all_targets(struct device *d,
465 struct device_attribute *attr,
468 struct bonding *bond = to_bond(d);
469 int value = bond->params.arp_all_targets;
471 return sprintf(buf, "%s %d\n", arp_all_targets_tbl[value].modename,
475 static ssize_t bonding_store_arp_all_targets(struct device *d,
476 struct device_attribute *attr,
477 const char *buf, size_t count)
479 struct bonding *bond = to_bond(d);
482 new_value = bond_parse_parm(buf, arp_all_targets_tbl);
484 pr_err("%s: Ignoring invalid arp_all_targets value %s\n",
485 bond->dev->name, buf);
488 pr_info("%s: setting arp_all_targets to %s (%d).\n",
489 bond->dev->name, arp_all_targets_tbl[new_value].modename,
492 bond->params.arp_all_targets = new_value;
497 static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,
498 bonding_show_arp_all_targets, bonding_store_arp_all_targets);
501 * Show and store fail_over_mac. User only allowed to change the
502 * value when there are no slaves.
504 static ssize_t bonding_show_fail_over_mac(struct device *d,
505 struct device_attribute *attr,
508 struct bonding *bond = to_bond(d);
510 return sprintf(buf, "%s %d\n",
511 fail_over_mac_tbl[bond->params.fail_over_mac].modename,
512 bond->params.fail_over_mac);
515 static ssize_t bonding_store_fail_over_mac(struct device *d,
516 struct device_attribute *attr,
517 const char *buf, size_t count)
519 int new_value, ret = count;
520 struct bonding *bond = to_bond(d);
523 return restart_syscall();
525 if (!list_empty(&bond->slave_list)) {
526 pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
532 new_value = bond_parse_parm(buf, fail_over_mac_tbl);
534 pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
535 bond->dev->name, buf);
540 bond->params.fail_over_mac = new_value;
541 pr_info("%s: Setting fail_over_mac to %s (%d).\n",
542 bond->dev->name, fail_over_mac_tbl[new_value].modename,
550 static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR,
551 bonding_show_fail_over_mac, bonding_store_fail_over_mac);
554 * Show and set the arp timer interval. There are two tricky bits
555 * here. First, if ARP monitoring is activated, then we must disable
556 * MII monitoring. Second, if the ARP timer isn't running, we must
559 static ssize_t bonding_show_arp_interval(struct device *d,
560 struct device_attribute *attr,
563 struct bonding *bond = to_bond(d);
565 return sprintf(buf, "%d\n", bond->params.arp_interval);
568 static ssize_t bonding_store_arp_interval(struct device *d,
569 struct device_attribute *attr,
570 const char *buf, size_t count)
572 struct bonding *bond = to_bond(d);
573 int new_value, ret = count;
576 return restart_syscall();
577 if (sscanf(buf, "%d", &new_value) != 1) {
578 pr_err("%s: no arp_interval value specified.\n",
584 pr_err("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n",
585 bond->dev->name, new_value, INT_MAX);
589 if (bond->params.mode == BOND_MODE_ALB ||
590 bond->params.mode == BOND_MODE_TLB) {
591 pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n",
592 bond->dev->name, bond->dev->name);
596 pr_info("%s: Setting ARP monitoring interval to %d.\n",
597 bond->dev->name, new_value);
598 bond->params.arp_interval = new_value;
600 if (bond->params.miimon) {
601 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
602 bond->dev->name, bond->dev->name);
603 bond->params.miimon = 0;
605 if (!bond->params.arp_targets[0])
606 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
609 if (bond->dev->flags & IFF_UP) {
610 /* If the interface is up, we may need to fire off
611 * the ARP timer. If the interface is down, the
612 * timer will get fired off when the open function
616 if (bond->params.arp_validate)
617 bond->recv_probe = NULL;
618 cancel_delayed_work_sync(&bond->arp_work);
620 /* arp_validate can be set only in active-backup mode */
621 if (bond->params.arp_validate)
622 bond->recv_probe = bond_arp_rcv;
623 cancel_delayed_work_sync(&bond->mii_work);
624 queue_delayed_work(bond->wq, &bond->arp_work, 0);
631 static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR,
632 bonding_show_arp_interval, bonding_store_arp_interval);
635 * Show and set the arp targets.
637 static ssize_t bonding_show_arp_targets(struct device *d,
638 struct device_attribute *attr,
642 struct bonding *bond = to_bond(d);
644 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
645 if (bond->params.arp_targets[i])
646 res += sprintf(buf + res, "%pI4 ",
647 &bond->params.arp_targets[i]);
650 buf[res-1] = '\n'; /* eat the leftover space */
654 static ssize_t bonding_store_arp_targets(struct device *d,
655 struct device_attribute *attr,
656 const char *buf, size_t count)
658 struct bonding *bond = to_bond(d);
660 __be32 newtarget, *targets;
661 unsigned long *targets_rx;
662 int ind, i, j, ret = -EINVAL;
664 targets = bond->params.arp_targets;
665 newtarget = in_aton(buf + 1);
668 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
669 pr_err("%s: invalid ARP target %pI4 specified for addition\n",
670 bond->dev->name, &newtarget);
674 if (bond_get_targets_ip(targets, newtarget) != -1) { /* dup */
675 pr_err("%s: ARP target %pI4 is already present\n",
676 bond->dev->name, &newtarget);
680 ind = bond_get_targets_ip(targets, 0); /* first free slot */
682 pr_err("%s: ARP target table is full!\n",
687 pr_info("%s: adding ARP target %pI4.\n", bond->dev->name,
689 /* not to race with bond_arp_rcv */
690 write_lock_bh(&bond->lock);
691 bond_for_each_slave(bond, slave)
692 slave->target_last_arp_rx[ind] = jiffies;
693 targets[ind] = newtarget;
694 write_unlock_bh(&bond->lock);
695 } else if (buf[0] == '-') {
696 if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
697 pr_err("%s: invalid ARP target %pI4 specified for removal\n",
698 bond->dev->name, &newtarget);
702 ind = bond_get_targets_ip(targets, newtarget);
704 pr_err("%s: unable to remove nonexistent ARP target %pI4.\n",
705 bond->dev->name, &newtarget);
709 if (ind == 0 && !targets[1] && bond->params.arp_interval)
710 pr_warn("%s: removing last arp target with arp_interval on\n",
713 pr_info("%s: removing ARP target %pI4.\n", bond->dev->name,
716 write_lock_bh(&bond->lock);
717 bond_for_each_slave(bond, slave) {
718 targets_rx = slave->target_last_arp_rx;
720 for (; (j < BOND_MAX_ARP_TARGETS-1) && targets[j+1]; j++)
721 targets_rx[j] = targets_rx[j+1];
724 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
725 targets[i] = targets[i+1];
727 write_unlock_bh(&bond->lock);
729 pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
739 static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets);
742 * Show and set the up and down delays. These must be multiples of the
743 * MII monitoring value, and are stored internally as the multiplier.
744 * Thus, we must translate to MS for the real world.
746 static ssize_t bonding_show_downdelay(struct device *d,
747 struct device_attribute *attr,
750 struct bonding *bond = to_bond(d);
752 return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon);
755 static ssize_t bonding_store_downdelay(struct device *d,
756 struct device_attribute *attr,
757 const char *buf, size_t count)
759 int new_value, ret = count;
760 struct bonding *bond = to_bond(d);
762 if (!(bond->params.miimon)) {
763 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
769 if (sscanf(buf, "%d", &new_value) != 1) {
770 pr_err("%s: no down delay value specified.\n", bond->dev->name);
775 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
776 bond->dev->name, new_value, 0, INT_MAX);
780 if ((new_value % bond->params.miimon) != 0) {
781 pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
782 bond->dev->name, new_value,
784 (new_value / bond->params.miimon) *
785 bond->params.miimon);
787 bond->params.downdelay = new_value / bond->params.miimon;
788 pr_info("%s: Setting down delay to %d.\n",
790 bond->params.downdelay * bond->params.miimon);
797 static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
798 bonding_show_downdelay, bonding_store_downdelay);
800 static ssize_t bonding_show_updelay(struct device *d,
801 struct device_attribute *attr,
804 struct bonding *bond = to_bond(d);
806 return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon);
810 static ssize_t bonding_store_updelay(struct device *d,
811 struct device_attribute *attr,
812 const char *buf, size_t count)
814 int new_value, ret = count;
815 struct bonding *bond = to_bond(d);
817 if (!(bond->params.miimon)) {
818 pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
824 if (sscanf(buf, "%d", &new_value) != 1) {
825 pr_err("%s: no up delay value specified.\n",
831 pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n",
832 bond->dev->name, new_value, 0, INT_MAX);
836 if ((new_value % bond->params.miimon) != 0) {
837 pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
838 bond->dev->name, new_value,
840 (new_value / bond->params.miimon) *
841 bond->params.miimon);
843 bond->params.updelay = new_value / bond->params.miimon;
844 pr_info("%s: Setting up delay to %d.\n",
846 bond->params.updelay * bond->params.miimon);
852 static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
853 bonding_show_updelay, bonding_store_updelay);
856 * Show and set the LACP interval. Interface must be down, and the mode
857 * must be set to 802.3ad mode.
859 static ssize_t bonding_show_lacp(struct device *d,
860 struct device_attribute *attr,
863 struct bonding *bond = to_bond(d);
865 return sprintf(buf, "%s %d\n",
866 bond_lacp_tbl[bond->params.lacp_fast].modename,
867 bond->params.lacp_fast);
870 static ssize_t bonding_store_lacp(struct device *d,
871 struct device_attribute *attr,
872 const char *buf, size_t count)
874 struct bonding *bond = to_bond(d);
875 int new_value, ret = count;
878 return restart_syscall();
880 if (bond->dev->flags & IFF_UP) {
881 pr_err("%s: Unable to update LACP rate because interface is up.\n",
887 if (bond->params.mode != BOND_MODE_8023AD) {
888 pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
894 new_value = bond_parse_parm(buf, bond_lacp_tbl);
896 if ((new_value == 1) || (new_value == 0)) {
897 bond->params.lacp_fast = new_value;
898 bond_3ad_update_lacp_rate(bond);
899 pr_info("%s: Setting LACP rate to %s (%d).\n",
900 bond->dev->name, bond_lacp_tbl[new_value].modename,
903 pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
904 bond->dev->name, (int)strlen(buf) - 1, buf);
912 static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR,
913 bonding_show_lacp, bonding_store_lacp);
915 static ssize_t bonding_show_min_links(struct device *d,
916 struct device_attribute *attr,
919 struct bonding *bond = to_bond(d);
921 return sprintf(buf, "%d\n", bond->params.min_links);
924 static ssize_t bonding_store_min_links(struct device *d,
925 struct device_attribute *attr,
926 const char *buf, size_t count)
928 struct bonding *bond = to_bond(d);
930 unsigned int new_value;
932 ret = kstrtouint(buf, 0, &new_value);
934 pr_err("%s: Ignoring invalid min links value %s.\n",
935 bond->dev->name, buf);
939 pr_info("%s: Setting min links value to %u\n",
940 bond->dev->name, new_value);
941 bond->params.min_links = new_value;
944 static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR,
945 bonding_show_min_links, bonding_store_min_links);
947 static ssize_t bonding_show_ad_select(struct device *d,
948 struct device_attribute *attr,
951 struct bonding *bond = to_bond(d);
953 return sprintf(buf, "%s %d\n",
954 ad_select_tbl[bond->params.ad_select].modename,
955 bond->params.ad_select);
959 static ssize_t bonding_store_ad_select(struct device *d,
960 struct device_attribute *attr,
961 const char *buf, size_t count)
963 int new_value, ret = count;
964 struct bonding *bond = to_bond(d);
966 if (bond->dev->flags & IFF_UP) {
967 pr_err("%s: Unable to update ad_select because interface is up.\n",
973 new_value = bond_parse_parm(buf, ad_select_tbl);
975 if (new_value != -1) {
976 bond->params.ad_select = new_value;
977 pr_info("%s: Setting ad_select to %s (%d).\n",
978 bond->dev->name, ad_select_tbl[new_value].modename,
981 pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
982 bond->dev->name, (int)strlen(buf) - 1, buf);
988 static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR,
989 bonding_show_ad_select, bonding_store_ad_select);
992 * Show and set the number of peer notifications to send after a failover event.
994 static ssize_t bonding_show_num_peer_notif(struct device *d,
995 struct device_attribute *attr,
998 struct bonding *bond = to_bond(d);
999 return sprintf(buf, "%d\n", bond->params.num_peer_notif);
1002 static ssize_t bonding_store_num_peer_notif(struct device *d,
1003 struct device_attribute *attr,
1004 const char *buf, size_t count)
1006 struct bonding *bond = to_bond(d);
1007 int err = kstrtou8(buf, 10, &bond->params.num_peer_notif);
1008 return err ? err : count;
1010 static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
1011 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
1012 static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
1013 bonding_show_num_peer_notif, bonding_store_num_peer_notif);
1016 * Show and set the MII monitor interval. There are two tricky bits
1017 * here. First, if MII monitoring is activated, then we must disable
1018 * ARP monitoring. Second, if the timer isn't running, we must
1021 static ssize_t bonding_show_miimon(struct device *d,
1022 struct device_attribute *attr,
1025 struct bonding *bond = to_bond(d);
1027 return sprintf(buf, "%d\n", bond->params.miimon);
1030 static ssize_t bonding_store_miimon(struct device *d,
1031 struct device_attribute *attr,
1032 const char *buf, size_t count)
1034 int new_value, ret = count;
1035 struct bonding *bond = to_bond(d);
1037 if (!rtnl_trylock())
1038 return restart_syscall();
1039 if (sscanf(buf, "%d", &new_value) != 1) {
1040 pr_err("%s: no miimon value specified.\n",
1045 if (new_value < 0) {
1046 pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
1047 bond->dev->name, new_value, 0, INT_MAX);
1051 pr_info("%s: Setting MII monitoring interval to %d.\n",
1052 bond->dev->name, new_value);
1053 bond->params.miimon = new_value;
1054 if (bond->params.updelay)
1055 pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
1057 bond->params.updelay * bond->params.miimon);
1058 if (bond->params.downdelay)
1059 pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
1061 bond->params.downdelay * bond->params.miimon);
1062 if (new_value && bond->params.arp_interval) {
1063 pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
1065 bond->params.arp_interval = 0;
1066 if (bond->params.arp_validate)
1067 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
1069 if (bond->dev->flags & IFF_UP) {
1070 /* If the interface is up, we may need to fire off
1071 * the MII timer. If the interface is down, the
1072 * timer will get fired off when the open function
1076 cancel_delayed_work_sync(&bond->mii_work);
1078 cancel_delayed_work_sync(&bond->arp_work);
1079 queue_delayed_work(bond->wq, &bond->mii_work, 0);
1086 static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR,
1087 bonding_show_miimon, bonding_store_miimon);
1090 * Show and set the primary slave. The store function is much
1091 * simpler than bonding_store_slaves function because it only needs to
1092 * handle one interface name.
1093 * The bond must be a mode that supports a primary for this be
1096 static ssize_t bonding_show_primary(struct device *d,
1097 struct device_attribute *attr,
1101 struct bonding *bond = to_bond(d);
1103 if (bond->primary_slave)
1104 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name);
1109 static ssize_t bonding_store_primary(struct device *d,
1110 struct device_attribute *attr,
1111 const char *buf, size_t count)
1113 struct bonding *bond = to_bond(d);
1114 char ifname[IFNAMSIZ];
1115 struct slave *slave;
1117 if (!rtnl_trylock())
1118 return restart_syscall();
1120 read_lock(&bond->lock);
1121 write_lock_bh(&bond->curr_slave_lock);
1123 if (!USES_PRIMARY(bond->params.mode)) {
1124 pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
1125 bond->dev->name, bond->dev->name, bond->params.mode);
1129 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
1131 /* check to see if we are clearing primary */
1132 if (!strlen(ifname) || buf[0] == '\n') {
1133 pr_info("%s: Setting primary slave to None.\n",
1135 bond->primary_slave = NULL;
1136 memset(bond->params.primary, 0, sizeof(bond->params.primary));
1137 bond_select_active_slave(bond);
1141 bond_for_each_slave(bond, slave) {
1142 if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
1143 pr_info("%s: Setting %s as primary slave.\n",
1144 bond->dev->name, slave->dev->name);
1145 bond->primary_slave = slave;
1146 strcpy(bond->params.primary, slave->dev->name);
1147 bond_select_active_slave(bond);
1152 strncpy(bond->params.primary, ifname, IFNAMSIZ);
1153 bond->params.primary[IFNAMSIZ - 1] = 0;
1155 pr_info("%s: Recording %s as primary, "
1156 "but it has not been enslaved to %s yet.\n",
1157 bond->dev->name, ifname, bond->dev->name);
1159 write_unlock_bh(&bond->curr_slave_lock);
1160 read_unlock(&bond->lock);
1161 unblock_netpoll_tx();
1166 static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR,
1167 bonding_show_primary, bonding_store_primary);
1170 * Show and set the primary_reselect flag.
1172 static ssize_t bonding_show_primary_reselect(struct device *d,
1173 struct device_attribute *attr,
1176 struct bonding *bond = to_bond(d);
1178 return sprintf(buf, "%s %d\n",
1179 pri_reselect_tbl[bond->params.primary_reselect].modename,
1180 bond->params.primary_reselect);
1183 static ssize_t bonding_store_primary_reselect(struct device *d,
1184 struct device_attribute *attr,
1185 const char *buf, size_t count)
1187 int new_value, ret = count;
1188 struct bonding *bond = to_bond(d);
1190 if (!rtnl_trylock())
1191 return restart_syscall();
1193 new_value = bond_parse_parm(buf, pri_reselect_tbl);
1194 if (new_value < 0) {
1195 pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
1197 (int) strlen(buf) - 1, buf);
1202 bond->params.primary_reselect = new_value;
1203 pr_info("%s: setting primary_reselect to %s (%d).\n",
1204 bond->dev->name, pri_reselect_tbl[new_value].modename,
1208 read_lock(&bond->lock);
1209 write_lock_bh(&bond->curr_slave_lock);
1210 bond_select_active_slave(bond);
1211 write_unlock_bh(&bond->curr_slave_lock);
1212 read_unlock(&bond->lock);
1213 unblock_netpoll_tx();
1218 static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR,
1219 bonding_show_primary_reselect,
1220 bonding_store_primary_reselect);
1223 * Show and set the use_carrier flag.
1225 static ssize_t bonding_show_carrier(struct device *d,
1226 struct device_attribute *attr,
1229 struct bonding *bond = to_bond(d);
1231 return sprintf(buf, "%d\n", bond->params.use_carrier);
1234 static ssize_t bonding_store_carrier(struct device *d,
1235 struct device_attribute *attr,
1236 const char *buf, size_t count)
1238 int new_value, ret = count;
1239 struct bonding *bond = to_bond(d);
1242 if (sscanf(buf, "%d", &new_value) != 1) {
1243 pr_err("%s: no use_carrier value specified.\n",
1248 if ((new_value == 0) || (new_value == 1)) {
1249 bond->params.use_carrier = new_value;
1250 pr_info("%s: Setting use_carrier to %d.\n",
1251 bond->dev->name, new_value);
1253 pr_info("%s: Ignoring invalid use_carrier value %d.\n",
1254 bond->dev->name, new_value);
1259 static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR,
1260 bonding_show_carrier, bonding_store_carrier);
1264 * Show and set currently active_slave.
1266 static ssize_t bonding_show_active_slave(struct device *d,
1267 struct device_attribute *attr,
1270 struct bonding *bond = to_bond(d);
1275 curr = rcu_dereference(bond->curr_active_slave);
1276 if (USES_PRIMARY(bond->params.mode) && curr)
1277 count = sprintf(buf, "%s\n", curr->dev->name);
1283 static ssize_t bonding_store_active_slave(struct device *d,
1284 struct device_attribute *attr,
1285 const char *buf, size_t count)
1287 struct slave *slave, *old_active, *new_active;
1288 struct bonding *bond = to_bond(d);
1289 char ifname[IFNAMSIZ];
1291 if (!rtnl_trylock())
1292 return restart_syscall();
1294 old_active = new_active = NULL;
1296 read_lock(&bond->lock);
1297 write_lock_bh(&bond->curr_slave_lock);
1299 if (!USES_PRIMARY(bond->params.mode)) {
1300 pr_info("%s: Unable to change active slave; %s is in mode %d\n",
1301 bond->dev->name, bond->dev->name, bond->params.mode);
1305 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
1307 /* check to see if we are clearing active */
1308 if (!strlen(ifname) || buf[0] == '\n') {
1309 pr_info("%s: Clearing current active slave.\n",
1311 rcu_assign_pointer(bond->curr_active_slave, NULL);
1312 bond_select_active_slave(bond);
1316 bond_for_each_slave(bond, slave) {
1317 if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
1318 old_active = bond->curr_active_slave;
1320 if (new_active == old_active) {
1322 pr_info("%s: %s is already the current"
1330 (new_active->link == BOND_LINK_UP) &&
1331 IS_UP(new_active->dev)) {
1332 pr_info("%s: Setting %s as active"
1336 bond_change_active_slave(bond,
1339 pr_info("%s: Could not set %s as"
1340 " active slave; either %s is"
1341 " down or the link is down.\n",
1351 pr_info("%s: Unable to set %.*s as active slave.\n",
1352 bond->dev->name, (int)strlen(buf) - 1, buf);
1354 write_unlock_bh(&bond->curr_slave_lock);
1355 read_unlock(&bond->lock);
1356 unblock_netpoll_tx();
1363 static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR,
1364 bonding_show_active_slave, bonding_store_active_slave);
1368 * Show link status of the bond interface.
1370 static ssize_t bonding_show_mii_status(struct device *d,
1371 struct device_attribute *attr,
1374 struct bonding *bond = to_bond(d);
1376 return sprintf(buf, "%s\n", bond->curr_active_slave ? "up" : "down");
1378 static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
1381 * Show current 802.3ad aggregator ID.
1383 static ssize_t bonding_show_ad_aggregator(struct device *d,
1384 struct device_attribute *attr,
1388 struct bonding *bond = to_bond(d);
1390 if (bond->params.mode == BOND_MODE_8023AD) {
1391 struct ad_info ad_info;
1392 count = sprintf(buf, "%d\n",
1393 bond_3ad_get_active_agg_info(bond, &ad_info)
1394 ? 0 : ad_info.aggregator_id);
1399 static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL);
1403 * Show number of active 802.3ad ports.
1405 static ssize_t bonding_show_ad_num_ports(struct device *d,
1406 struct device_attribute *attr,
1410 struct bonding *bond = to_bond(d);
1412 if (bond->params.mode == BOND_MODE_8023AD) {
1413 struct ad_info ad_info;
1414 count = sprintf(buf, "%d\n",
1415 bond_3ad_get_active_agg_info(bond, &ad_info)
1416 ? 0 : ad_info.ports);
1421 static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL);
1425 * Show current 802.3ad actor key.
1427 static ssize_t bonding_show_ad_actor_key(struct device *d,
1428 struct device_attribute *attr,
1432 struct bonding *bond = to_bond(d);
1434 if (bond->params.mode == BOND_MODE_8023AD) {
1435 struct ad_info ad_info;
1436 count = sprintf(buf, "%d\n",
1437 bond_3ad_get_active_agg_info(bond, &ad_info)
1438 ? 0 : ad_info.actor_key);
1443 static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL);
1447 * Show current 802.3ad partner key.
1449 static ssize_t bonding_show_ad_partner_key(struct device *d,
1450 struct device_attribute *attr,
1454 struct bonding *bond = to_bond(d);
1456 if (bond->params.mode == BOND_MODE_8023AD) {
1457 struct ad_info ad_info;
1458 count = sprintf(buf, "%d\n",
1459 bond_3ad_get_active_agg_info(bond, &ad_info)
1460 ? 0 : ad_info.partner_key);
1465 static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL);
1469 * Show current 802.3ad partner mac.
1471 static ssize_t bonding_show_ad_partner_mac(struct device *d,
1472 struct device_attribute *attr,
1476 struct bonding *bond = to_bond(d);
1478 if (bond->params.mode == BOND_MODE_8023AD) {
1479 struct ad_info ad_info;
1480 if (!bond_3ad_get_active_agg_info(bond, &ad_info))
1481 count = sprintf(buf, "%pM\n", ad_info.partner_system);
1486 static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
1489 * Show the queue_ids of the slaves in the current bond.
1491 static ssize_t bonding_show_queue_id(struct device *d,
1492 struct device_attribute *attr,
1495 struct bonding *bond = to_bond(d);
1496 struct slave *slave;
1499 if (!rtnl_trylock())
1500 return restart_syscall();
1502 read_lock(&bond->lock);
1503 bond_for_each_slave(bond, slave) {
1504 if (res > (PAGE_SIZE - IFNAMSIZ - 6)) {
1505 /* not enough space for another interface_name:queue_id pair */
1506 if ((PAGE_SIZE - res) > 10)
1507 res = PAGE_SIZE - 10;
1508 res += sprintf(buf + res, "++more++ ");
1511 res += sprintf(buf + res, "%s:%d ",
1512 slave->dev->name, slave->queue_id);
1514 read_unlock(&bond->lock);
1516 buf[res-1] = '\n'; /* eat the leftover space */
1523 * Set the queue_ids of the slaves in the current bond. The bond
1524 * interface must be enslaved for this to work.
1526 static ssize_t bonding_store_queue_id(struct device *d,
1527 struct device_attribute *attr,
1528 const char *buffer, size_t count)
1530 struct slave *slave, *update_slave;
1531 struct bonding *bond = to_bond(d);
1535 struct net_device *sdev = NULL;
1537 if (!rtnl_trylock())
1538 return restart_syscall();
1540 /* delim will point to queue id if successful */
1541 delim = strchr(buffer, ':');
1546 * Terminate string that points to device name and bump it
1547 * up one, so we can read the queue id there.
1550 if (sscanf(++delim, "%hd\n", &qid) != 1)
1553 /* Check buffer length, valid ifname and queue id */
1554 if (strlen(buffer) > IFNAMSIZ ||
1555 !dev_valid_name(buffer) ||
1556 qid > bond->dev->real_num_tx_queues)
1559 /* Get the pointer to that interface if it exists */
1560 sdev = __dev_get_by_name(dev_net(bond->dev), buffer);
1564 read_lock(&bond->lock);
1566 /* Search for thes slave and check for duplicate qids */
1567 update_slave = NULL;
1568 bond_for_each_slave(bond, slave) {
1569 if (sdev == slave->dev)
1571 * We don't need to check the matching
1572 * slave for dups, since we're overwriting it
1574 update_slave = slave;
1575 else if (qid && qid == slave->queue_id) {
1576 goto err_no_cmd_unlock;
1581 goto err_no_cmd_unlock;
1583 /* Actually set the qids for the slave */
1584 update_slave->queue_id = qid;
1586 read_unlock(&bond->lock);
1592 read_unlock(&bond->lock);
1594 pr_info("invalid input for queue_id set for %s.\n",
1600 static DEVICE_ATTR(queue_id, S_IRUGO | S_IWUSR, bonding_show_queue_id,
1601 bonding_store_queue_id);
1605 * Show and set the all_slaves_active flag.
1607 static ssize_t bonding_show_slaves_active(struct device *d,
1608 struct device_attribute *attr,
1611 struct bonding *bond = to_bond(d);
1613 return sprintf(buf, "%d\n", bond->params.all_slaves_active);
1616 static ssize_t bonding_store_slaves_active(struct device *d,
1617 struct device_attribute *attr,
1618 const char *buf, size_t count)
1620 struct bonding *bond = to_bond(d);
1621 int new_value, ret = count;
1622 struct slave *slave;
1624 if (sscanf(buf, "%d", &new_value) != 1) {
1625 pr_err("%s: no all_slaves_active value specified.\n",
1631 if (new_value == bond->params.all_slaves_active)
1634 if ((new_value == 0) || (new_value == 1)) {
1635 bond->params.all_slaves_active = new_value;
1637 pr_info("%s: Ignoring invalid all_slaves_active value %d.\n",
1638 bond->dev->name, new_value);
1643 read_lock(&bond->lock);
1644 bond_for_each_slave(bond, slave) {
1645 if (!bond_is_active_slave(slave)) {
1647 slave->inactive = 0;
1649 slave->inactive = 1;
1652 read_unlock(&bond->lock);
1656 static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR,
1657 bonding_show_slaves_active, bonding_store_slaves_active);
1660 * Show and set the number of IGMP membership reports to send on link failure
1662 static ssize_t bonding_show_resend_igmp(struct device *d,
1663 struct device_attribute *attr,
1666 struct bonding *bond = to_bond(d);
1668 return sprintf(buf, "%d\n", bond->params.resend_igmp);
1671 static ssize_t bonding_store_resend_igmp(struct device *d,
1672 struct device_attribute *attr,
1673 const char *buf, size_t count)
1675 int new_value, ret = count;
1676 struct bonding *bond = to_bond(d);
1678 if (sscanf(buf, "%d", &new_value) != 1) {
1679 pr_err("%s: no resend_igmp value specified.\n",
1685 if (new_value < 0 || new_value > 255) {
1686 pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n",
1687 bond->dev->name, new_value);
1692 pr_info("%s: Setting resend_igmp to %d.\n",
1693 bond->dev->name, new_value);
1694 bond->params.resend_igmp = new_value;
1699 static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR,
1700 bonding_show_resend_igmp, bonding_store_resend_igmp);
1703 static ssize_t bonding_show_lp_interval(struct device *d,
1704 struct device_attribute *attr,
1707 struct bonding *bond = to_bond(d);
1708 return sprintf(buf, "%d\n", bond->params.lp_interval);
1711 static ssize_t bonding_store_lp_interval(struct device *d,
1712 struct device_attribute *attr,
1713 const char *buf, size_t count)
1715 struct bonding *bond = to_bond(d);
1716 int new_value, ret = count;
1718 if (sscanf(buf, "%d", &new_value) != 1) {
1719 pr_err("%s: no lp interval value specified.\n",
1725 if (new_value <= 0) {
1726 pr_err ("%s: lp_interval must be between 1 and %d\n",
1727 bond->dev->name, INT_MAX);
1732 bond->params.lp_interval = new_value;
1737 static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR,
1738 bonding_show_lp_interval, bonding_store_lp_interval);
1740 static struct attribute *per_bond_attrs[] = {
1741 &dev_attr_slaves.attr,
1742 &dev_attr_mode.attr,
1743 &dev_attr_fail_over_mac.attr,
1744 &dev_attr_arp_validate.attr,
1745 &dev_attr_arp_all_targets.attr,
1746 &dev_attr_arp_interval.attr,
1747 &dev_attr_arp_ip_target.attr,
1748 &dev_attr_downdelay.attr,
1749 &dev_attr_updelay.attr,
1750 &dev_attr_lacp_rate.attr,
1751 &dev_attr_ad_select.attr,
1752 &dev_attr_xmit_hash_policy.attr,
1753 &dev_attr_num_grat_arp.attr,
1754 &dev_attr_num_unsol_na.attr,
1755 &dev_attr_miimon.attr,
1756 &dev_attr_primary.attr,
1757 &dev_attr_primary_reselect.attr,
1758 &dev_attr_use_carrier.attr,
1759 &dev_attr_active_slave.attr,
1760 &dev_attr_mii_status.attr,
1761 &dev_attr_ad_aggregator.attr,
1762 &dev_attr_ad_num_ports.attr,
1763 &dev_attr_ad_actor_key.attr,
1764 &dev_attr_ad_partner_key.attr,
1765 &dev_attr_ad_partner_mac.attr,
1766 &dev_attr_queue_id.attr,
1767 &dev_attr_all_slaves_active.attr,
1768 &dev_attr_resend_igmp.attr,
1769 &dev_attr_min_links.attr,
1770 &dev_attr_lp_interval.attr,
1774 static struct attribute_group bonding_group = {
1776 .attrs = per_bond_attrs,
1780 * Initialize sysfs. This sets up the bonding_masters file in
1783 int bond_create_sysfs(struct bond_net *bn)
1787 bn->class_attr_bonding_masters = class_attr_bonding_masters;
1788 sysfs_attr_init(&bn->class_attr_bonding_masters.attr);
1790 ret = netdev_class_create_file(&bn->class_attr_bonding_masters);
1792 * Permit multiple loads of the module by ignoring failures to
1793 * create the bonding_masters sysfs file. Bonding devices
1794 * created by second or subsequent loads of the module will
1795 * not be listed in, or controllable by, bonding_masters, but
1796 * will have the usual "bonding" sysfs directory.
1798 * This is done to preserve backwards compatibility for
1799 * initscripts/sysconfig, which load bonding multiple times to
1800 * configure multiple bonding devices.
1802 if (ret == -EEXIST) {
1803 /* Is someone being kinky and naming a device bonding_master? */
1804 if (__dev_get_by_name(bn->net,
1805 class_attr_bonding_masters.attr.name))
1806 pr_err("network device named %s already exists in sysfs",
1807 class_attr_bonding_masters.attr.name);
1816 * Remove /sys/class/net/bonding_masters.
1818 void bond_destroy_sysfs(struct bond_net *bn)
1820 netdev_class_remove_file(&bn->class_attr_bonding_masters);
1824 * Initialize sysfs for each bond. This sets up and registers
1825 * the 'bondctl' directory for each individual bond under /sys/class/net.
1827 void bond_prepare_sysfs_group(struct bonding *bond)
1829 bond->dev->sysfs_groups[0] = &bonding_group;