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/signal.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_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd))))
47 /* "show" function for the bond_masters attribute.
48 * The class parameter is ignored.
50 static ssize_t
bonding_show_bonds(struct class *cls
,
51 struct class_attribute
*attr
,
55 container_of(attr
, struct bond_net
, class_attr_bonding_masters
);
61 list_for_each_entry(bond
, &bn
->dev_list
, bond_list
) {
62 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
63 /* not enough space for another interface name */
64 if ((PAGE_SIZE
- res
) > 10)
66 res
+= sprintf(buf
+ res
, "++more++ ");
69 res
+= sprintf(buf
+ res
, "%s ", bond
->dev
->name
);
72 buf
[res
-1] = '\n'; /* eat the leftover space */
78 static struct net_device
*bond_get_by_name(struct bond_net
*bn
, const char *ifname
)
82 list_for_each_entry(bond
, &bn
->dev_list
, bond_list
) {
83 if (strncmp(bond
->dev
->name
, ifname
, IFNAMSIZ
) == 0)
89 /* "store" function for the bond_masters attribute. This is what
90 * creates and deletes entire bonds.
92 * The class parameter is ignored.
94 static ssize_t
bonding_store_bonds(struct class *cls
,
95 struct class_attribute
*attr
,
96 const char *buffer
, size_t count
)
99 container_of(attr
, struct bond_net
, class_attr_bonding_masters
);
100 char command
[IFNAMSIZ
+ 1] = {0, };
104 sscanf(buffer
, "%16s", command
); /* IFNAMSIZ*/
105 ifname
= command
+ 1;
106 if ((strlen(command
) <= 1) ||
107 !dev_valid_name(ifname
))
110 if (command
[0] == '+') {
111 pr_info("%s is being created...\n", ifname
);
112 rv
= bond_create(bn
->net
, ifname
);
115 pr_info("%s already exists\n", ifname
);
117 pr_info("%s creation failed\n", ifname
);
120 } else if (command
[0] == '-') {
121 struct net_device
*bond_dev
;
124 bond_dev
= bond_get_by_name(bn
, ifname
);
126 pr_info("%s is being deleted...\n", ifname
);
127 unregister_netdevice(bond_dev
);
129 pr_err("unable to delete non-existent %s\n", ifname
);
136 /* Always return either count or an error. If you return 0, you'll
137 * get called forever, which is bad.
142 pr_err("no command found in bonding_masters - use +ifname or -ifname\n");
146 /* class attribute for bond_masters file. This ends up in /sys/class/net */
147 static const struct class_attribute class_attr_bonding_masters
= {
149 .name
= "bonding_masters",
152 .show
= bonding_show_bonds
,
153 .store
= bonding_store_bonds
,
156 /* Generic "store" method for bonding sysfs option setting */
157 static ssize_t
bonding_sysfs_store_option(struct device
*d
,
158 struct device_attribute
*attr
,
159 const char *buffer
, size_t count
)
161 struct bonding
*bond
= to_bond(d
);
162 const struct bond_option
*opt
;
166 opt
= bond_opt_get_by_name(attr
->attr
.name
);
169 buffer_clone
= kstrndup(buffer
, count
, GFP_KERNEL
);
172 ret
= bond_opt_tryset_rtnl(bond
, opt
->id
, buffer_clone
);
180 /* Show the slaves in the current bond. */
181 static ssize_t
bonding_show_slaves(struct device
*d
,
182 struct device_attribute
*attr
, char *buf
)
184 struct bonding
*bond
= to_bond(d
);
185 struct list_head
*iter
;
190 return restart_syscall();
192 bond_for_each_slave(bond
, slave
, iter
) {
193 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
194 /* not enough space for another interface name */
195 if ((PAGE_SIZE
- res
) > 10)
196 res
= PAGE_SIZE
- 10;
197 res
+= sprintf(buf
+ res
, "++more++ ");
200 res
+= sprintf(buf
+ res
, "%s ", slave
->dev
->name
);
206 buf
[res
-1] = '\n'; /* eat the leftover space */
210 static DEVICE_ATTR(slaves
, 0644, bonding_show_slaves
,
211 bonding_sysfs_store_option
);
213 /* Show the bonding mode. */
214 static ssize_t
bonding_show_mode(struct device
*d
,
215 struct device_attribute
*attr
, char *buf
)
217 struct bonding
*bond
= to_bond(d
);
218 const struct bond_opt_value
*val
;
220 val
= bond_opt_get_val(BOND_OPT_MODE
, BOND_MODE(bond
));
222 return sprintf(buf
, "%s %d\n", val
->string
, BOND_MODE(bond
));
224 static DEVICE_ATTR(mode
, 0644, bonding_show_mode
, bonding_sysfs_store_option
);
226 /* Show the bonding transmit hash method. */
227 static ssize_t
bonding_show_xmit_hash(struct device
*d
,
228 struct device_attribute
*attr
,
231 struct bonding
*bond
= to_bond(d
);
232 const struct bond_opt_value
*val
;
234 val
= bond_opt_get_val(BOND_OPT_XMIT_HASH
, bond
->params
.xmit_policy
);
236 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.xmit_policy
);
238 static DEVICE_ATTR(xmit_hash_policy
, 0644,
239 bonding_show_xmit_hash
, bonding_sysfs_store_option
);
241 /* Show arp_validate. */
242 static ssize_t
bonding_show_arp_validate(struct device
*d
,
243 struct device_attribute
*attr
,
246 struct bonding
*bond
= to_bond(d
);
247 const struct bond_opt_value
*val
;
249 val
= bond_opt_get_val(BOND_OPT_ARP_VALIDATE
,
250 bond
->params
.arp_validate
);
252 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.arp_validate
);
254 static DEVICE_ATTR(arp_validate
, 0644, bonding_show_arp_validate
,
255 bonding_sysfs_store_option
);
257 /* Show arp_all_targets. */
258 static ssize_t
bonding_show_arp_all_targets(struct device
*d
,
259 struct device_attribute
*attr
,
262 struct bonding
*bond
= to_bond(d
);
263 const struct bond_opt_value
*val
;
265 val
= bond_opt_get_val(BOND_OPT_ARP_ALL_TARGETS
,
266 bond
->params
.arp_all_targets
);
267 return sprintf(buf
, "%s %d\n",
268 val
->string
, bond
->params
.arp_all_targets
);
270 static DEVICE_ATTR(arp_all_targets
, 0644,
271 bonding_show_arp_all_targets
, bonding_sysfs_store_option
);
273 /* Show fail_over_mac. */
274 static ssize_t
bonding_show_fail_over_mac(struct device
*d
,
275 struct device_attribute
*attr
,
278 struct bonding
*bond
= to_bond(d
);
279 const struct bond_opt_value
*val
;
281 val
= bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC
,
282 bond
->params
.fail_over_mac
);
284 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.fail_over_mac
);
286 static DEVICE_ATTR(fail_over_mac
, 0644,
287 bonding_show_fail_over_mac
, bonding_sysfs_store_option
);
289 /* Show the arp timer interval. */
290 static ssize_t
bonding_show_arp_interval(struct device
*d
,
291 struct device_attribute
*attr
,
294 struct bonding
*bond
= to_bond(d
);
296 return sprintf(buf
, "%d\n", bond
->params
.arp_interval
);
298 static DEVICE_ATTR(arp_interval
, 0644,
299 bonding_show_arp_interval
, bonding_sysfs_store_option
);
301 /* Show the arp targets. */
302 static ssize_t
bonding_show_arp_targets(struct device
*d
,
303 struct device_attribute
*attr
,
306 struct bonding
*bond
= to_bond(d
);
309 for (i
= 0; i
< BOND_MAX_ARP_TARGETS
; i
++) {
310 if (bond
->params
.arp_targets
[i
])
311 res
+= sprintf(buf
+ res
, "%pI4 ",
312 &bond
->params
.arp_targets
[i
]);
315 buf
[res
-1] = '\n'; /* eat the leftover space */
319 static DEVICE_ATTR(arp_ip_target
, 0644,
320 bonding_show_arp_targets
, bonding_sysfs_store_option
);
322 /* Show the up and down delays. */
323 static ssize_t
bonding_show_downdelay(struct device
*d
,
324 struct device_attribute
*attr
,
327 struct bonding
*bond
= to_bond(d
);
329 return sprintf(buf
, "%d\n", bond
->params
.downdelay
* bond
->params
.miimon
);
331 static DEVICE_ATTR(downdelay
, 0644,
332 bonding_show_downdelay
, bonding_sysfs_store_option
);
334 static ssize_t
bonding_show_updelay(struct device
*d
,
335 struct device_attribute
*attr
,
338 struct bonding
*bond
= to_bond(d
);
340 return sprintf(buf
, "%d\n", bond
->params
.updelay
* bond
->params
.miimon
);
343 static DEVICE_ATTR(updelay
, 0644,
344 bonding_show_updelay
, bonding_sysfs_store_option
);
346 /* Show the LACP interval. */
347 static ssize_t
bonding_show_lacp(struct device
*d
,
348 struct device_attribute
*attr
,
351 struct bonding
*bond
= to_bond(d
);
352 const struct bond_opt_value
*val
;
354 val
= bond_opt_get_val(BOND_OPT_LACP_RATE
, bond
->params
.lacp_fast
);
356 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.lacp_fast
);
358 static DEVICE_ATTR(lacp_rate
, 0644,
359 bonding_show_lacp
, bonding_sysfs_store_option
);
361 static ssize_t
bonding_show_min_links(struct device
*d
,
362 struct device_attribute
*attr
,
365 struct bonding
*bond
= to_bond(d
);
367 return sprintf(buf
, "%u\n", bond
->params
.min_links
);
369 static DEVICE_ATTR(min_links
, 0644,
370 bonding_show_min_links
, bonding_sysfs_store_option
);
372 static ssize_t
bonding_show_ad_select(struct device
*d
,
373 struct device_attribute
*attr
,
376 struct bonding
*bond
= to_bond(d
);
377 const struct bond_opt_value
*val
;
379 val
= bond_opt_get_val(BOND_OPT_AD_SELECT
, bond
->params
.ad_select
);
381 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.ad_select
);
383 static DEVICE_ATTR(ad_select
, 0644,
384 bonding_show_ad_select
, bonding_sysfs_store_option
);
386 /* Show the number of peer notifications to send after a failover event. */
387 static ssize_t
bonding_show_num_peer_notif(struct device
*d
,
388 struct device_attribute
*attr
,
391 struct bonding
*bond
= to_bond(d
);
392 return sprintf(buf
, "%d\n", bond
->params
.num_peer_notif
);
394 static DEVICE_ATTR(num_grat_arp
, 0644,
395 bonding_show_num_peer_notif
, bonding_sysfs_store_option
);
396 static DEVICE_ATTR(num_unsol_na
, 0644,
397 bonding_show_num_peer_notif
, bonding_sysfs_store_option
);
399 /* Show the MII monitor interval. */
400 static ssize_t
bonding_show_miimon(struct device
*d
,
401 struct device_attribute
*attr
,
404 struct bonding
*bond
= to_bond(d
);
406 return sprintf(buf
, "%d\n", bond
->params
.miimon
);
408 static DEVICE_ATTR(miimon
, 0644,
409 bonding_show_miimon
, bonding_sysfs_store_option
);
411 /* Show the primary slave. */
412 static ssize_t
bonding_show_primary(struct device
*d
,
413 struct device_attribute
*attr
,
416 struct bonding
*bond
= to_bond(d
);
417 struct slave
*primary
;
421 primary
= rcu_dereference(bond
->primary_slave
);
423 count
= sprintf(buf
, "%s\n", primary
->dev
->name
);
428 static DEVICE_ATTR(primary
, 0644,
429 bonding_show_primary
, bonding_sysfs_store_option
);
431 /* Show the primary_reselect flag. */
432 static ssize_t
bonding_show_primary_reselect(struct device
*d
,
433 struct device_attribute
*attr
,
436 struct bonding
*bond
= to_bond(d
);
437 const struct bond_opt_value
*val
;
439 val
= bond_opt_get_val(BOND_OPT_PRIMARY_RESELECT
,
440 bond
->params
.primary_reselect
);
442 return sprintf(buf
, "%s %d\n",
443 val
->string
, bond
->params
.primary_reselect
);
445 static DEVICE_ATTR(primary_reselect
, 0644,
446 bonding_show_primary_reselect
, bonding_sysfs_store_option
);
448 /* Show the use_carrier flag. */
449 static ssize_t
bonding_show_carrier(struct device
*d
,
450 struct device_attribute
*attr
,
453 struct bonding
*bond
= to_bond(d
);
455 return sprintf(buf
, "%d\n", bond
->params
.use_carrier
);
457 static DEVICE_ATTR(use_carrier
, 0644,
458 bonding_show_carrier
, bonding_sysfs_store_option
);
461 /* Show currently active_slave. */
462 static ssize_t
bonding_show_active_slave(struct device
*d
,
463 struct device_attribute
*attr
,
466 struct bonding
*bond
= to_bond(d
);
467 struct net_device
*slave_dev
;
471 slave_dev
= bond_option_active_slave_get_rcu(bond
);
473 count
= sprintf(buf
, "%s\n", slave_dev
->name
);
478 static DEVICE_ATTR(active_slave
, 0644,
479 bonding_show_active_slave
, bonding_sysfs_store_option
);
481 /* Show link status of the bond interface. */
482 static ssize_t
bonding_show_mii_status(struct device
*d
,
483 struct device_attribute
*attr
,
486 struct bonding
*bond
= to_bond(d
);
487 bool active
= netif_carrier_ok(bond
->dev
);
489 return sprintf(buf
, "%s\n", active
? "up" : "down");
491 static DEVICE_ATTR(mii_status
, 0444, bonding_show_mii_status
, NULL
);
493 /* Show current 802.3ad aggregator ID. */
494 static ssize_t
bonding_show_ad_aggregator(struct device
*d
,
495 struct device_attribute
*attr
,
499 struct bonding
*bond
= to_bond(d
);
501 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
502 struct ad_info ad_info
;
503 count
= sprintf(buf
, "%d\n",
504 bond_3ad_get_active_agg_info(bond
, &ad_info
)
505 ? 0 : ad_info
.aggregator_id
);
510 static DEVICE_ATTR(ad_aggregator
, 0444, bonding_show_ad_aggregator
, NULL
);
513 /* Show number of active 802.3ad ports. */
514 static ssize_t
bonding_show_ad_num_ports(struct device
*d
,
515 struct device_attribute
*attr
,
519 struct bonding
*bond
= to_bond(d
);
521 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
522 struct ad_info ad_info
;
523 count
= sprintf(buf
, "%d\n",
524 bond_3ad_get_active_agg_info(bond
, &ad_info
)
525 ? 0 : ad_info
.ports
);
530 static DEVICE_ATTR(ad_num_ports
, 0444, bonding_show_ad_num_ports
, NULL
);
533 /* Show current 802.3ad actor key. */
534 static ssize_t
bonding_show_ad_actor_key(struct device
*d
,
535 struct device_attribute
*attr
,
539 struct bonding
*bond
= to_bond(d
);
541 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
)) {
542 struct ad_info ad_info
;
543 count
= sprintf(buf
, "%d\n",
544 bond_3ad_get_active_agg_info(bond
, &ad_info
)
545 ? 0 : ad_info
.actor_key
);
550 static DEVICE_ATTR(ad_actor_key
, 0444, bonding_show_ad_actor_key
, NULL
);
553 /* Show current 802.3ad partner key. */
554 static ssize_t
bonding_show_ad_partner_key(struct device
*d
,
555 struct device_attribute
*attr
,
559 struct bonding
*bond
= to_bond(d
);
561 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
)) {
562 struct ad_info ad_info
;
563 count
= sprintf(buf
, "%d\n",
564 bond_3ad_get_active_agg_info(bond
, &ad_info
)
565 ? 0 : ad_info
.partner_key
);
570 static DEVICE_ATTR(ad_partner_key
, 0444, bonding_show_ad_partner_key
, NULL
);
573 /* Show current 802.3ad partner mac. */
574 static ssize_t
bonding_show_ad_partner_mac(struct device
*d
,
575 struct device_attribute
*attr
,
579 struct bonding
*bond
= to_bond(d
);
581 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
)) {
582 struct ad_info ad_info
;
583 if (!bond_3ad_get_active_agg_info(bond
, &ad_info
))
584 count
= sprintf(buf
, "%pM\n", ad_info
.partner_system
);
589 static DEVICE_ATTR(ad_partner_mac
, 0444, bonding_show_ad_partner_mac
, NULL
);
591 /* Show the queue_ids of the slaves in the current bond. */
592 static ssize_t
bonding_show_queue_id(struct device
*d
,
593 struct device_attribute
*attr
,
596 struct bonding
*bond
= to_bond(d
);
597 struct list_head
*iter
;
602 return restart_syscall();
604 bond_for_each_slave(bond
, slave
, iter
) {
605 if (res
> (PAGE_SIZE
- IFNAMSIZ
- 6)) {
606 /* not enough space for another interface_name:queue_id pair */
607 if ((PAGE_SIZE
- res
) > 10)
608 res
= PAGE_SIZE
- 10;
609 res
+= sprintf(buf
+ res
, "++more++ ");
612 res
+= sprintf(buf
+ res
, "%s:%d ",
613 slave
->dev
->name
, slave
->queue_id
);
616 buf
[res
-1] = '\n'; /* eat the leftover space */
622 static DEVICE_ATTR(queue_id
, 0644, bonding_show_queue_id
,
623 bonding_sysfs_store_option
);
626 /* Show the all_slaves_active flag. */
627 static ssize_t
bonding_show_slaves_active(struct device
*d
,
628 struct device_attribute
*attr
,
631 struct bonding
*bond
= to_bond(d
);
633 return sprintf(buf
, "%d\n", bond
->params
.all_slaves_active
);
635 static DEVICE_ATTR(all_slaves_active
, 0644,
636 bonding_show_slaves_active
, bonding_sysfs_store_option
);
638 /* Show the number of IGMP membership reports to send on link failure */
639 static ssize_t
bonding_show_resend_igmp(struct device
*d
,
640 struct device_attribute
*attr
,
643 struct bonding
*bond
= to_bond(d
);
645 return sprintf(buf
, "%d\n", bond
->params
.resend_igmp
);
647 static DEVICE_ATTR(resend_igmp
, 0644,
648 bonding_show_resend_igmp
, bonding_sysfs_store_option
);
651 static ssize_t
bonding_show_lp_interval(struct device
*d
,
652 struct device_attribute
*attr
,
655 struct bonding
*bond
= to_bond(d
);
657 return sprintf(buf
, "%d\n", bond
->params
.lp_interval
);
659 static DEVICE_ATTR(lp_interval
, 0644,
660 bonding_show_lp_interval
, bonding_sysfs_store_option
);
662 static ssize_t
bonding_show_tlb_dynamic_lb(struct device
*d
,
663 struct device_attribute
*attr
,
666 struct bonding
*bond
= to_bond(d
);
667 return sprintf(buf
, "%d\n", bond
->params
.tlb_dynamic_lb
);
669 static DEVICE_ATTR(tlb_dynamic_lb
, 0644,
670 bonding_show_tlb_dynamic_lb
, bonding_sysfs_store_option
);
672 static ssize_t
bonding_show_packets_per_slave(struct device
*d
,
673 struct device_attribute
*attr
,
676 struct bonding
*bond
= to_bond(d
);
677 unsigned int packets_per_slave
= bond
->params
.packets_per_slave
;
679 return sprintf(buf
, "%u\n", packets_per_slave
);
681 static DEVICE_ATTR(packets_per_slave
, 0644,
682 bonding_show_packets_per_slave
, bonding_sysfs_store_option
);
684 static ssize_t
bonding_show_ad_actor_sys_prio(struct device
*d
,
685 struct device_attribute
*attr
,
688 struct bonding
*bond
= to_bond(d
);
690 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
))
691 return sprintf(buf
, "%hu\n", bond
->params
.ad_actor_sys_prio
);
695 static DEVICE_ATTR(ad_actor_sys_prio
, 0644,
696 bonding_show_ad_actor_sys_prio
, bonding_sysfs_store_option
);
698 static ssize_t
bonding_show_ad_actor_system(struct device
*d
,
699 struct device_attribute
*attr
,
702 struct bonding
*bond
= to_bond(d
);
704 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
))
705 return sprintf(buf
, "%pM\n", bond
->params
.ad_actor_system
);
710 static DEVICE_ATTR(ad_actor_system
, 0644,
711 bonding_show_ad_actor_system
, bonding_sysfs_store_option
);
713 static ssize_t
bonding_show_ad_user_port_key(struct device
*d
,
714 struct device_attribute
*attr
,
717 struct bonding
*bond
= to_bond(d
);
719 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
))
720 return sprintf(buf
, "%hu\n", bond
->params
.ad_user_port_key
);
724 static DEVICE_ATTR(ad_user_port_key
, 0644,
725 bonding_show_ad_user_port_key
, bonding_sysfs_store_option
);
727 static struct attribute
*per_bond_attrs
[] = {
728 &dev_attr_slaves
.attr
,
730 &dev_attr_fail_over_mac
.attr
,
731 &dev_attr_arp_validate
.attr
,
732 &dev_attr_arp_all_targets
.attr
,
733 &dev_attr_arp_interval
.attr
,
734 &dev_attr_arp_ip_target
.attr
,
735 &dev_attr_downdelay
.attr
,
736 &dev_attr_updelay
.attr
,
737 &dev_attr_lacp_rate
.attr
,
738 &dev_attr_ad_select
.attr
,
739 &dev_attr_xmit_hash_policy
.attr
,
740 &dev_attr_num_grat_arp
.attr
,
741 &dev_attr_num_unsol_na
.attr
,
742 &dev_attr_miimon
.attr
,
743 &dev_attr_primary
.attr
,
744 &dev_attr_primary_reselect
.attr
,
745 &dev_attr_use_carrier
.attr
,
746 &dev_attr_active_slave
.attr
,
747 &dev_attr_mii_status
.attr
,
748 &dev_attr_ad_aggregator
.attr
,
749 &dev_attr_ad_num_ports
.attr
,
750 &dev_attr_ad_actor_key
.attr
,
751 &dev_attr_ad_partner_key
.attr
,
752 &dev_attr_ad_partner_mac
.attr
,
753 &dev_attr_queue_id
.attr
,
754 &dev_attr_all_slaves_active
.attr
,
755 &dev_attr_resend_igmp
.attr
,
756 &dev_attr_min_links
.attr
,
757 &dev_attr_lp_interval
.attr
,
758 &dev_attr_packets_per_slave
.attr
,
759 &dev_attr_tlb_dynamic_lb
.attr
,
760 &dev_attr_ad_actor_sys_prio
.attr
,
761 &dev_attr_ad_actor_system
.attr
,
762 &dev_attr_ad_user_port_key
.attr
,
766 static const struct attribute_group bonding_group
= {
768 .attrs
= per_bond_attrs
,
771 /* Initialize sysfs. This sets up the bonding_masters file in
774 int bond_create_sysfs(struct bond_net
*bn
)
778 bn
->class_attr_bonding_masters
= class_attr_bonding_masters
;
779 sysfs_attr_init(&bn
->class_attr_bonding_masters
.attr
);
781 ret
= netdev_class_create_file_ns(&bn
->class_attr_bonding_masters
,
783 /* Permit multiple loads of the module by ignoring failures to
784 * create the bonding_masters sysfs file. Bonding devices
785 * created by second or subsequent loads of the module will
786 * not be listed in, or controllable by, bonding_masters, but
787 * will have the usual "bonding" sysfs directory.
789 * This is done to preserve backwards compatibility for
790 * initscripts/sysconfig, which load bonding multiple times to
791 * configure multiple bonding devices.
793 if (ret
== -EEXIST
) {
794 /* Is someone being kinky and naming a device bonding_master? */
795 if (__dev_get_by_name(bn
->net
,
796 class_attr_bonding_masters
.attr
.name
))
797 pr_err("network device named %s already exists in sysfs\n",
798 class_attr_bonding_masters
.attr
.name
);
806 /* Remove /sys/class/net/bonding_masters. */
807 void bond_destroy_sysfs(struct bond_net
*bn
)
809 netdev_class_remove_file_ns(&bn
->class_attr_bonding_masters
, bn
->net
);
812 /* Initialize sysfs for each bond. This sets up and registers
813 * the 'bondctl' directory for each individual bond under /sys/class/net.
815 void bond_prepare_sysfs_group(struct bonding
*bond
)
817 bond
->dev
->sysfs_groups
[0] = &bonding_group
;