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, see <http://www.gnu.org/licenses/>.
17 * The full GNU General Public License is included in this distribution in the
18 * file called LICENSE.
22 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/device.h>
27 #include <linux/sched.h>
29 #include <linux/types.h>
30 #include <linux/string.h>
31 #include <linux/netdevice.h>
32 #include <linux/inetdevice.h>
34 #include <linux/sysfs.h>
35 #include <linux/ctype.h>
36 #include <linux/inet.h>
37 #include <linux/rtnetlink.h>
38 #include <linux/etherdevice.h>
39 #include <net/net_namespace.h>
40 #include <net/netns/generic.h>
41 #include <linux/nsproxy.h>
43 #include <net/bonding.h>
45 #define to_dev(obj) container_of(obj, struct device, kobj)
46 #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
48 /* "show" function for the bond_masters attribute.
49 * The class parameter is ignored.
51 static ssize_t
bonding_show_bonds(struct class *cls
,
52 struct class_attribute
*attr
,
56 container_of(attr
, struct bond_net
, class_attr_bonding_masters
);
62 list_for_each_entry(bond
, &bn
->dev_list
, bond_list
) {
63 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
64 /* not enough space for another interface name */
65 if ((PAGE_SIZE
- res
) > 10)
67 res
+= sprintf(buf
+ res
, "++more++ ");
70 res
+= sprintf(buf
+ res
, "%s ", bond
->dev
->name
);
73 buf
[res
-1] = '\n'; /* eat the leftover space */
79 static struct net_device
*bond_get_by_name(struct bond_net
*bn
, const char *ifname
)
83 list_for_each_entry(bond
, &bn
->dev_list
, bond_list
) {
84 if (strncmp(bond
->dev
->name
, ifname
, IFNAMSIZ
) == 0)
90 /* "store" function for the bond_masters attribute. This is what
91 * creates and deletes entire bonds.
93 * The class parameter is ignored.
95 static ssize_t
bonding_store_bonds(struct class *cls
,
96 struct class_attribute
*attr
,
97 const char *buffer
, size_t count
)
100 container_of(attr
, struct bond_net
, class_attr_bonding_masters
);
101 char command
[IFNAMSIZ
+ 1] = {0, };
105 sscanf(buffer
, "%16s", command
); /* IFNAMSIZ*/
106 ifname
= command
+ 1;
107 if ((strlen(command
) <= 1) ||
108 !dev_valid_name(ifname
))
111 if (command
[0] == '+') {
112 pr_info("%s is being created...\n", ifname
);
113 rv
= bond_create(bn
->net
, ifname
);
116 pr_info("%s already exists\n", ifname
);
118 pr_info("%s creation failed\n", ifname
);
121 } else if (command
[0] == '-') {
122 struct net_device
*bond_dev
;
125 bond_dev
= bond_get_by_name(bn
, ifname
);
127 pr_info("%s is being deleted...\n", ifname
);
128 unregister_netdevice(bond_dev
);
130 pr_err("unable to delete non-existent %s\n", ifname
);
137 /* Always return either count or an error. If you return 0, you'll
138 * get called forever, which is bad.
143 pr_err("no command found in bonding_masters - use +ifname or -ifname\n");
147 /* class attribute for bond_masters file. This ends up in /sys/class/net */
148 static const struct class_attribute class_attr_bonding_masters
= {
150 .name
= "bonding_masters",
151 .mode
= S_IWUSR
| S_IRUGO
,
153 .show
= bonding_show_bonds
,
154 .store
= bonding_store_bonds
,
157 /* Generic "store" method for bonding sysfs option setting */
158 static ssize_t
bonding_sysfs_store_option(struct device
*d
,
159 struct device_attribute
*attr
,
160 const char *buffer
, size_t count
)
162 struct bonding
*bond
= to_bond(d
);
163 const struct bond_option
*opt
;
166 opt
= bond_opt_get_by_name(attr
->attr
.name
);
169 ret
= bond_opt_tryset_rtnl(bond
, opt
->id
, (char *)buffer
);
176 /* Show the slaves in the current bond. */
177 static ssize_t
bonding_show_slaves(struct device
*d
,
178 struct device_attribute
*attr
, char *buf
)
180 struct bonding
*bond
= to_bond(d
);
181 struct list_head
*iter
;
186 return restart_syscall();
188 bond_for_each_slave(bond
, slave
, iter
) {
189 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
190 /* not enough space for another interface name */
191 if ((PAGE_SIZE
- res
) > 10)
192 res
= PAGE_SIZE
- 10;
193 res
+= sprintf(buf
+ res
, "++more++ ");
196 res
+= sprintf(buf
+ res
, "%s ", slave
->dev
->name
);
202 buf
[res
-1] = '\n'; /* eat the leftover space */
206 static DEVICE_ATTR(slaves
, S_IRUGO
| S_IWUSR
, bonding_show_slaves
,
207 bonding_sysfs_store_option
);
209 /* Show the bonding mode. */
210 static ssize_t
bonding_show_mode(struct device
*d
,
211 struct device_attribute
*attr
, char *buf
)
213 struct bonding
*bond
= to_bond(d
);
214 const struct bond_opt_value
*val
;
216 val
= bond_opt_get_val(BOND_OPT_MODE
, BOND_MODE(bond
));
218 return sprintf(buf
, "%s %d\n", val
->string
, BOND_MODE(bond
));
220 static DEVICE_ATTR(mode
, S_IRUGO
| S_IWUSR
,
221 bonding_show_mode
, bonding_sysfs_store_option
);
223 /* Show the bonding transmit hash method. */
224 static ssize_t
bonding_show_xmit_hash(struct device
*d
,
225 struct device_attribute
*attr
,
228 struct bonding
*bond
= to_bond(d
);
229 const struct bond_opt_value
*val
;
231 val
= bond_opt_get_val(BOND_OPT_XMIT_HASH
, bond
->params
.xmit_policy
);
233 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.xmit_policy
);
235 static DEVICE_ATTR(xmit_hash_policy
, S_IRUGO
| S_IWUSR
,
236 bonding_show_xmit_hash
, bonding_sysfs_store_option
);
238 /* Show arp_validate. */
239 static ssize_t
bonding_show_arp_validate(struct device
*d
,
240 struct device_attribute
*attr
,
243 struct bonding
*bond
= to_bond(d
);
244 const struct bond_opt_value
*val
;
246 val
= bond_opt_get_val(BOND_OPT_ARP_VALIDATE
,
247 bond
->params
.arp_validate
);
249 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.arp_validate
);
251 static DEVICE_ATTR(arp_validate
, S_IRUGO
| S_IWUSR
, bonding_show_arp_validate
,
252 bonding_sysfs_store_option
);
254 /* Show arp_all_targets. */
255 static ssize_t
bonding_show_arp_all_targets(struct device
*d
,
256 struct device_attribute
*attr
,
259 struct bonding
*bond
= to_bond(d
);
260 const struct bond_opt_value
*val
;
262 val
= bond_opt_get_val(BOND_OPT_ARP_ALL_TARGETS
,
263 bond
->params
.arp_all_targets
);
264 return sprintf(buf
, "%s %d\n",
265 val
->string
, bond
->params
.arp_all_targets
);
267 static DEVICE_ATTR(arp_all_targets
, S_IRUGO
| S_IWUSR
,
268 bonding_show_arp_all_targets
, bonding_sysfs_store_option
);
270 /* Show fail_over_mac. */
271 static ssize_t
bonding_show_fail_over_mac(struct device
*d
,
272 struct device_attribute
*attr
,
275 struct bonding
*bond
= to_bond(d
);
276 const struct bond_opt_value
*val
;
278 val
= bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC
,
279 bond
->params
.fail_over_mac
);
281 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.fail_over_mac
);
283 static DEVICE_ATTR(fail_over_mac
, S_IRUGO
| S_IWUSR
,
284 bonding_show_fail_over_mac
, bonding_sysfs_store_option
);
286 /* Show the arp timer interval. */
287 static ssize_t
bonding_show_arp_interval(struct device
*d
,
288 struct device_attribute
*attr
,
291 struct bonding
*bond
= to_bond(d
);
293 return sprintf(buf
, "%d\n", bond
->params
.arp_interval
);
295 static DEVICE_ATTR(arp_interval
, S_IRUGO
| S_IWUSR
,
296 bonding_show_arp_interval
, bonding_sysfs_store_option
);
298 /* Show the arp targets. */
299 static ssize_t
bonding_show_arp_targets(struct device
*d
,
300 struct device_attribute
*attr
,
303 struct bonding
*bond
= to_bond(d
);
306 for (i
= 0; i
< BOND_MAX_ARP_TARGETS
; i
++) {
307 if (bond
->params
.arp_targets
[i
])
308 res
+= sprintf(buf
+ res
, "%pI4 ",
309 &bond
->params
.arp_targets
[i
]);
312 buf
[res
-1] = '\n'; /* eat the leftover space */
316 static DEVICE_ATTR(arp_ip_target
, S_IRUGO
| S_IWUSR
,
317 bonding_show_arp_targets
, bonding_sysfs_store_option
);
319 /* Show the up and down delays. */
320 static ssize_t
bonding_show_downdelay(struct device
*d
,
321 struct device_attribute
*attr
,
324 struct bonding
*bond
= to_bond(d
);
326 return sprintf(buf
, "%d\n", bond
->params
.downdelay
* bond
->params
.miimon
);
328 static DEVICE_ATTR(downdelay
, S_IRUGO
| S_IWUSR
,
329 bonding_show_downdelay
, bonding_sysfs_store_option
);
331 static ssize_t
bonding_show_updelay(struct device
*d
,
332 struct device_attribute
*attr
,
335 struct bonding
*bond
= to_bond(d
);
337 return sprintf(buf
, "%d\n", bond
->params
.updelay
* bond
->params
.miimon
);
340 static DEVICE_ATTR(updelay
, S_IRUGO
| S_IWUSR
,
341 bonding_show_updelay
, bonding_sysfs_store_option
);
343 /* Show the LACP interval. */
344 static ssize_t
bonding_show_lacp(struct device
*d
,
345 struct device_attribute
*attr
,
348 struct bonding
*bond
= to_bond(d
);
349 const struct bond_opt_value
*val
;
351 val
= bond_opt_get_val(BOND_OPT_LACP_RATE
, bond
->params
.lacp_fast
);
353 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.lacp_fast
);
355 static DEVICE_ATTR(lacp_rate
, S_IRUGO
| S_IWUSR
,
356 bonding_show_lacp
, bonding_sysfs_store_option
);
358 static ssize_t
bonding_show_min_links(struct device
*d
,
359 struct device_attribute
*attr
,
362 struct bonding
*bond
= to_bond(d
);
364 return sprintf(buf
, "%u\n", bond
->params
.min_links
);
366 static DEVICE_ATTR(min_links
, S_IRUGO
| S_IWUSR
,
367 bonding_show_min_links
, bonding_sysfs_store_option
);
369 static ssize_t
bonding_show_ad_select(struct device
*d
,
370 struct device_attribute
*attr
,
373 struct bonding
*bond
= to_bond(d
);
374 const struct bond_opt_value
*val
;
376 val
= bond_opt_get_val(BOND_OPT_AD_SELECT
, bond
->params
.ad_select
);
378 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.ad_select
);
380 static DEVICE_ATTR(ad_select
, S_IRUGO
| S_IWUSR
,
381 bonding_show_ad_select
, bonding_sysfs_store_option
);
383 /* Show and set the number of peer notifications to send after a failover event. */
384 static ssize_t
bonding_show_num_peer_notif(struct device
*d
,
385 struct device_attribute
*attr
,
388 struct bonding
*bond
= to_bond(d
);
389 return sprintf(buf
, "%d\n", bond
->params
.num_peer_notif
);
392 static ssize_t
bonding_store_num_peer_notif(struct device
*d
,
393 struct device_attribute
*attr
,
394 const char *buf
, size_t count
)
396 struct bonding
*bond
= to_bond(d
);
399 ret
= bond_opt_tryset_rtnl(bond
, BOND_OPT_NUM_PEER_NOTIF
, (char *)buf
);
405 static DEVICE_ATTR(num_grat_arp
, S_IRUGO
| S_IWUSR
,
406 bonding_show_num_peer_notif
, bonding_store_num_peer_notif
);
407 static DEVICE_ATTR(num_unsol_na
, S_IRUGO
| S_IWUSR
,
408 bonding_show_num_peer_notif
, bonding_store_num_peer_notif
);
410 /* Show the MII monitor interval. */
411 static ssize_t
bonding_show_miimon(struct device
*d
,
412 struct device_attribute
*attr
,
415 struct bonding
*bond
= to_bond(d
);
417 return sprintf(buf
, "%d\n", bond
->params
.miimon
);
419 static DEVICE_ATTR(miimon
, S_IRUGO
| S_IWUSR
,
420 bonding_show_miimon
, bonding_sysfs_store_option
);
422 /* Show the primary slave. */
423 static ssize_t
bonding_show_primary(struct device
*d
,
424 struct device_attribute
*attr
,
427 struct bonding
*bond
= to_bond(d
);
428 struct slave
*primary
;
432 primary
= rcu_dereference(bond
->primary_slave
);
434 count
= sprintf(buf
, "%s\n", primary
->dev
->name
);
439 static DEVICE_ATTR(primary
, S_IRUGO
| S_IWUSR
,
440 bonding_show_primary
, bonding_sysfs_store_option
);
442 /* Show the primary_reselect flag. */
443 static ssize_t
bonding_show_primary_reselect(struct device
*d
,
444 struct device_attribute
*attr
,
447 struct bonding
*bond
= to_bond(d
);
448 const struct bond_opt_value
*val
;
450 val
= bond_opt_get_val(BOND_OPT_PRIMARY_RESELECT
,
451 bond
->params
.primary_reselect
);
453 return sprintf(buf
, "%s %d\n",
454 val
->string
, bond
->params
.primary_reselect
);
456 static DEVICE_ATTR(primary_reselect
, S_IRUGO
| S_IWUSR
,
457 bonding_show_primary_reselect
, bonding_sysfs_store_option
);
459 /* Show the use_carrier flag. */
460 static ssize_t
bonding_show_carrier(struct device
*d
,
461 struct device_attribute
*attr
,
464 struct bonding
*bond
= to_bond(d
);
466 return sprintf(buf
, "%d\n", bond
->params
.use_carrier
);
468 static DEVICE_ATTR(use_carrier
, S_IRUGO
| S_IWUSR
,
469 bonding_show_carrier
, bonding_sysfs_store_option
);
472 /* Show currently active_slave. */
473 static ssize_t
bonding_show_active_slave(struct device
*d
,
474 struct device_attribute
*attr
,
477 struct bonding
*bond
= to_bond(d
);
478 struct net_device
*slave_dev
;
482 slave_dev
= bond_option_active_slave_get_rcu(bond
);
484 count
= sprintf(buf
, "%s\n", slave_dev
->name
);
489 static DEVICE_ATTR(active_slave
, S_IRUGO
| S_IWUSR
,
490 bonding_show_active_slave
, bonding_sysfs_store_option
);
492 /* Show link status of the bond interface. */
493 static ssize_t
bonding_show_mii_status(struct device
*d
,
494 struct device_attribute
*attr
,
497 struct bonding
*bond
= to_bond(d
);
498 bool active
= !!rcu_access_pointer(bond
->curr_active_slave
);
500 return sprintf(buf
, "%s\n", active
? "up" : "down");
502 static DEVICE_ATTR(mii_status
, S_IRUGO
, bonding_show_mii_status
, NULL
);
504 /* Show current 802.3ad aggregator ID. */
505 static ssize_t
bonding_show_ad_aggregator(struct device
*d
,
506 struct device_attribute
*attr
,
510 struct bonding
*bond
= to_bond(d
);
512 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
513 struct ad_info ad_info
;
514 count
= sprintf(buf
, "%d\n",
515 bond_3ad_get_active_agg_info(bond
, &ad_info
)
516 ? 0 : ad_info
.aggregator_id
);
521 static DEVICE_ATTR(ad_aggregator
, S_IRUGO
, bonding_show_ad_aggregator
, NULL
);
524 /* Show number of active 802.3ad ports. */
525 static ssize_t
bonding_show_ad_num_ports(struct device
*d
,
526 struct device_attribute
*attr
,
530 struct bonding
*bond
= to_bond(d
);
532 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
533 struct ad_info ad_info
;
534 count
= sprintf(buf
, "%d\n",
535 bond_3ad_get_active_agg_info(bond
, &ad_info
)
536 ? 0 : ad_info
.ports
);
541 static DEVICE_ATTR(ad_num_ports
, S_IRUGO
, bonding_show_ad_num_ports
, NULL
);
544 /* Show current 802.3ad actor key. */
545 static ssize_t
bonding_show_ad_actor_key(struct device
*d
,
546 struct device_attribute
*attr
,
550 struct bonding
*bond
= to_bond(d
);
552 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
553 struct ad_info ad_info
;
554 count
= sprintf(buf
, "%d\n",
555 bond_3ad_get_active_agg_info(bond
, &ad_info
)
556 ? 0 : ad_info
.actor_key
);
561 static DEVICE_ATTR(ad_actor_key
, S_IRUGO
, bonding_show_ad_actor_key
, NULL
);
564 /* Show current 802.3ad partner key. */
565 static ssize_t
bonding_show_ad_partner_key(struct device
*d
,
566 struct device_attribute
*attr
,
570 struct bonding
*bond
= to_bond(d
);
572 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
573 struct ad_info ad_info
;
574 count
= sprintf(buf
, "%d\n",
575 bond_3ad_get_active_agg_info(bond
, &ad_info
)
576 ? 0 : ad_info
.partner_key
);
581 static DEVICE_ATTR(ad_partner_key
, S_IRUGO
, bonding_show_ad_partner_key
, NULL
);
584 /* Show current 802.3ad partner mac. */
585 static ssize_t
bonding_show_ad_partner_mac(struct device
*d
,
586 struct device_attribute
*attr
,
590 struct bonding
*bond
= to_bond(d
);
592 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
593 struct ad_info ad_info
;
594 if (!bond_3ad_get_active_agg_info(bond
, &ad_info
))
595 count
= sprintf(buf
, "%pM\n", ad_info
.partner_system
);
600 static DEVICE_ATTR(ad_partner_mac
, S_IRUGO
, bonding_show_ad_partner_mac
, NULL
);
602 /* Show the queue_ids of the slaves in the current bond. */
603 static ssize_t
bonding_show_queue_id(struct device
*d
,
604 struct device_attribute
*attr
,
607 struct bonding
*bond
= to_bond(d
);
608 struct list_head
*iter
;
613 return restart_syscall();
615 bond_for_each_slave(bond
, slave
, iter
) {
616 if (res
> (PAGE_SIZE
- IFNAMSIZ
- 6)) {
617 /* not enough space for another interface_name:queue_id pair */
618 if ((PAGE_SIZE
- res
) > 10)
619 res
= PAGE_SIZE
- 10;
620 res
+= sprintf(buf
+ res
, "++more++ ");
623 res
+= sprintf(buf
+ res
, "%s:%d ",
624 slave
->dev
->name
, slave
->queue_id
);
627 buf
[res
-1] = '\n'; /* eat the leftover space */
633 static DEVICE_ATTR(queue_id
, S_IRUGO
| S_IWUSR
, bonding_show_queue_id
,
634 bonding_sysfs_store_option
);
637 /* Show the all_slaves_active flag. */
638 static ssize_t
bonding_show_slaves_active(struct device
*d
,
639 struct device_attribute
*attr
,
642 struct bonding
*bond
= to_bond(d
);
644 return sprintf(buf
, "%d\n", bond
->params
.all_slaves_active
);
646 static DEVICE_ATTR(all_slaves_active
, S_IRUGO
| S_IWUSR
,
647 bonding_show_slaves_active
, bonding_sysfs_store_option
);
649 /* Show the number of IGMP membership reports to send on link failure */
650 static ssize_t
bonding_show_resend_igmp(struct device
*d
,
651 struct device_attribute
*attr
,
654 struct bonding
*bond
= to_bond(d
);
656 return sprintf(buf
, "%d\n", bond
->params
.resend_igmp
);
658 static DEVICE_ATTR(resend_igmp
, S_IRUGO
| S_IWUSR
,
659 bonding_show_resend_igmp
, bonding_sysfs_store_option
);
662 static ssize_t
bonding_show_lp_interval(struct device
*d
,
663 struct device_attribute
*attr
,
666 struct bonding
*bond
= to_bond(d
);
668 return sprintf(buf
, "%d\n", bond
->params
.lp_interval
);
670 static DEVICE_ATTR(lp_interval
, S_IRUGO
| S_IWUSR
,
671 bonding_show_lp_interval
, bonding_sysfs_store_option
);
673 static ssize_t
bonding_show_tlb_dynamic_lb(struct device
*d
,
674 struct device_attribute
*attr
,
677 struct bonding
*bond
= to_bond(d
);
678 return sprintf(buf
, "%d\n", bond
->params
.tlb_dynamic_lb
);
680 static DEVICE_ATTR(tlb_dynamic_lb
, S_IRUGO
| S_IWUSR
,
681 bonding_show_tlb_dynamic_lb
, bonding_sysfs_store_option
);
683 static ssize_t
bonding_show_packets_per_slave(struct device
*d
,
684 struct device_attribute
*attr
,
687 struct bonding
*bond
= to_bond(d
);
688 unsigned int packets_per_slave
= bond
->params
.packets_per_slave
;
690 return sprintf(buf
, "%u\n", packets_per_slave
);
692 static DEVICE_ATTR(packets_per_slave
, S_IRUGO
| S_IWUSR
,
693 bonding_show_packets_per_slave
, bonding_sysfs_store_option
);
695 static struct attribute
*per_bond_attrs
[] = {
696 &dev_attr_slaves
.attr
,
698 &dev_attr_fail_over_mac
.attr
,
699 &dev_attr_arp_validate
.attr
,
700 &dev_attr_arp_all_targets
.attr
,
701 &dev_attr_arp_interval
.attr
,
702 &dev_attr_arp_ip_target
.attr
,
703 &dev_attr_downdelay
.attr
,
704 &dev_attr_updelay
.attr
,
705 &dev_attr_lacp_rate
.attr
,
706 &dev_attr_ad_select
.attr
,
707 &dev_attr_xmit_hash_policy
.attr
,
708 &dev_attr_num_grat_arp
.attr
,
709 &dev_attr_num_unsol_na
.attr
,
710 &dev_attr_miimon
.attr
,
711 &dev_attr_primary
.attr
,
712 &dev_attr_primary_reselect
.attr
,
713 &dev_attr_use_carrier
.attr
,
714 &dev_attr_active_slave
.attr
,
715 &dev_attr_mii_status
.attr
,
716 &dev_attr_ad_aggregator
.attr
,
717 &dev_attr_ad_num_ports
.attr
,
718 &dev_attr_ad_actor_key
.attr
,
719 &dev_attr_ad_partner_key
.attr
,
720 &dev_attr_ad_partner_mac
.attr
,
721 &dev_attr_queue_id
.attr
,
722 &dev_attr_all_slaves_active
.attr
,
723 &dev_attr_resend_igmp
.attr
,
724 &dev_attr_min_links
.attr
,
725 &dev_attr_lp_interval
.attr
,
726 &dev_attr_packets_per_slave
.attr
,
727 &dev_attr_tlb_dynamic_lb
.attr
,
731 static struct attribute_group bonding_group
= {
733 .attrs
= per_bond_attrs
,
736 /* Initialize sysfs. This sets up the bonding_masters file in
739 int bond_create_sysfs(struct bond_net
*bn
)
743 bn
->class_attr_bonding_masters
= class_attr_bonding_masters
;
744 sysfs_attr_init(&bn
->class_attr_bonding_masters
.attr
);
746 ret
= netdev_class_create_file_ns(&bn
->class_attr_bonding_masters
,
748 /* Permit multiple loads of the module by ignoring failures to
749 * create the bonding_masters sysfs file. Bonding devices
750 * created by second or subsequent loads of the module will
751 * not be listed in, or controllable by, bonding_masters, but
752 * will have the usual "bonding" sysfs directory.
754 * This is done to preserve backwards compatibility for
755 * initscripts/sysconfig, which load bonding multiple times to
756 * configure multiple bonding devices.
758 if (ret
== -EEXIST
) {
759 /* Is someone being kinky and naming a device bonding_master? */
760 if (__dev_get_by_name(bn
->net
,
761 class_attr_bonding_masters
.attr
.name
))
762 pr_err("network device named %s already exists in sysfs\n",
763 class_attr_bonding_masters
.attr
.name
);
771 /* Remove /sys/class/net/bonding_masters. */
772 void bond_destroy_sysfs(struct bond_net
*bn
)
774 netdev_class_remove_file_ns(&bn
->class_attr_bonding_masters
, bn
->net
);
777 /* Initialize sysfs for each bond. This sets up and registers
778 * the 'bondctl' directory for each individual bond under /sys/class/net.
780 void bond_prepare_sysfs_group(struct bonding
*bond
)
782 bond
->dev
->sysfs_groups
[0] = &bonding_group
;