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
;
165 opt
= bond_opt_get_by_name(attr
->attr
.name
);
168 ret
= bond_opt_tryset_rtnl(bond
, opt
->id
, (char *)buffer
);
175 /* Show the slaves in the current bond. */
176 static ssize_t
bonding_show_slaves(struct device
*d
,
177 struct device_attribute
*attr
, char *buf
)
179 struct bonding
*bond
= to_bond(d
);
180 struct list_head
*iter
;
185 return restart_syscall();
187 bond_for_each_slave(bond
, slave
, iter
) {
188 if (res
> (PAGE_SIZE
- IFNAMSIZ
)) {
189 /* not enough space for another interface name */
190 if ((PAGE_SIZE
- res
) > 10)
191 res
= PAGE_SIZE
- 10;
192 res
+= sprintf(buf
+ res
, "++more++ ");
195 res
+= sprintf(buf
+ res
, "%s ", slave
->dev
->name
);
201 buf
[res
-1] = '\n'; /* eat the leftover space */
205 static DEVICE_ATTR(slaves
, 0644, bonding_show_slaves
,
206 bonding_sysfs_store_option
);
208 /* Show the bonding mode. */
209 static ssize_t
bonding_show_mode(struct device
*d
,
210 struct device_attribute
*attr
, char *buf
)
212 struct bonding
*bond
= to_bond(d
);
213 const struct bond_opt_value
*val
;
215 val
= bond_opt_get_val(BOND_OPT_MODE
, BOND_MODE(bond
));
217 return sprintf(buf
, "%s %d\n", val
->string
, BOND_MODE(bond
));
219 static DEVICE_ATTR(mode
, 0644, bonding_show_mode
, bonding_sysfs_store_option
);
221 /* Show the bonding transmit hash method. */
222 static ssize_t
bonding_show_xmit_hash(struct device
*d
,
223 struct device_attribute
*attr
,
226 struct bonding
*bond
= to_bond(d
);
227 const struct bond_opt_value
*val
;
229 val
= bond_opt_get_val(BOND_OPT_XMIT_HASH
, bond
->params
.xmit_policy
);
231 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.xmit_policy
);
233 static DEVICE_ATTR(xmit_hash_policy
, 0644,
234 bonding_show_xmit_hash
, bonding_sysfs_store_option
);
236 /* Show arp_validate. */
237 static ssize_t
bonding_show_arp_validate(struct device
*d
,
238 struct device_attribute
*attr
,
241 struct bonding
*bond
= to_bond(d
);
242 const struct bond_opt_value
*val
;
244 val
= bond_opt_get_val(BOND_OPT_ARP_VALIDATE
,
245 bond
->params
.arp_validate
);
247 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.arp_validate
);
249 static DEVICE_ATTR(arp_validate
, 0644, bonding_show_arp_validate
,
250 bonding_sysfs_store_option
);
252 /* Show arp_all_targets. */
253 static ssize_t
bonding_show_arp_all_targets(struct device
*d
,
254 struct device_attribute
*attr
,
257 struct bonding
*bond
= to_bond(d
);
258 const struct bond_opt_value
*val
;
260 val
= bond_opt_get_val(BOND_OPT_ARP_ALL_TARGETS
,
261 bond
->params
.arp_all_targets
);
262 return sprintf(buf
, "%s %d\n",
263 val
->string
, bond
->params
.arp_all_targets
);
265 static DEVICE_ATTR(arp_all_targets
, 0644,
266 bonding_show_arp_all_targets
, bonding_sysfs_store_option
);
268 /* Show fail_over_mac. */
269 static ssize_t
bonding_show_fail_over_mac(struct device
*d
,
270 struct device_attribute
*attr
,
273 struct bonding
*bond
= to_bond(d
);
274 const struct bond_opt_value
*val
;
276 val
= bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC
,
277 bond
->params
.fail_over_mac
);
279 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.fail_over_mac
);
281 static DEVICE_ATTR(fail_over_mac
, 0644,
282 bonding_show_fail_over_mac
, bonding_sysfs_store_option
);
284 /* Show the arp timer interval. */
285 static ssize_t
bonding_show_arp_interval(struct device
*d
,
286 struct device_attribute
*attr
,
289 struct bonding
*bond
= to_bond(d
);
291 return sprintf(buf
, "%d\n", bond
->params
.arp_interval
);
293 static DEVICE_ATTR(arp_interval
, 0644,
294 bonding_show_arp_interval
, bonding_sysfs_store_option
);
296 /* Show the arp targets. */
297 static ssize_t
bonding_show_arp_targets(struct device
*d
,
298 struct device_attribute
*attr
,
301 struct bonding
*bond
= to_bond(d
);
304 for (i
= 0; i
< BOND_MAX_ARP_TARGETS
; i
++) {
305 if (bond
->params
.arp_targets
[i
])
306 res
+= sprintf(buf
+ res
, "%pI4 ",
307 &bond
->params
.arp_targets
[i
]);
310 buf
[res
-1] = '\n'; /* eat the leftover space */
314 static DEVICE_ATTR(arp_ip_target
, 0644,
315 bonding_show_arp_targets
, bonding_sysfs_store_option
);
317 /* Show the up and down delays. */
318 static ssize_t
bonding_show_downdelay(struct device
*d
,
319 struct device_attribute
*attr
,
322 struct bonding
*bond
= to_bond(d
);
324 return sprintf(buf
, "%d\n", bond
->params
.downdelay
* bond
->params
.miimon
);
326 static DEVICE_ATTR(downdelay
, 0644,
327 bonding_show_downdelay
, bonding_sysfs_store_option
);
329 static ssize_t
bonding_show_updelay(struct device
*d
,
330 struct device_attribute
*attr
,
333 struct bonding
*bond
= to_bond(d
);
335 return sprintf(buf
, "%d\n", bond
->params
.updelay
* bond
->params
.miimon
);
338 static DEVICE_ATTR(updelay
, 0644,
339 bonding_show_updelay
, bonding_sysfs_store_option
);
341 /* Show the LACP interval. */
342 static ssize_t
bonding_show_lacp(struct device
*d
,
343 struct device_attribute
*attr
,
346 struct bonding
*bond
= to_bond(d
);
347 const struct bond_opt_value
*val
;
349 val
= bond_opt_get_val(BOND_OPT_LACP_RATE
, bond
->params
.lacp_fast
);
351 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.lacp_fast
);
353 static DEVICE_ATTR(lacp_rate
, 0644,
354 bonding_show_lacp
, bonding_sysfs_store_option
);
356 static ssize_t
bonding_show_min_links(struct device
*d
,
357 struct device_attribute
*attr
,
360 struct bonding
*bond
= to_bond(d
);
362 return sprintf(buf
, "%u\n", bond
->params
.min_links
);
364 static DEVICE_ATTR(min_links
, 0644,
365 bonding_show_min_links
, bonding_sysfs_store_option
);
367 static ssize_t
bonding_show_ad_select(struct device
*d
,
368 struct device_attribute
*attr
,
371 struct bonding
*bond
= to_bond(d
);
372 const struct bond_opt_value
*val
;
374 val
= bond_opt_get_val(BOND_OPT_AD_SELECT
, bond
->params
.ad_select
);
376 return sprintf(buf
, "%s %d\n", val
->string
, bond
->params
.ad_select
);
378 static DEVICE_ATTR(ad_select
, 0644,
379 bonding_show_ad_select
, bonding_sysfs_store_option
);
381 /* Show the number of peer notifications to send after a failover event. */
382 static ssize_t
bonding_show_num_peer_notif(struct device
*d
,
383 struct device_attribute
*attr
,
386 struct bonding
*bond
= to_bond(d
);
387 return sprintf(buf
, "%d\n", bond
->params
.num_peer_notif
);
389 static DEVICE_ATTR(num_grat_arp
, 0644,
390 bonding_show_num_peer_notif
, bonding_sysfs_store_option
);
391 static DEVICE_ATTR(num_unsol_na
, 0644,
392 bonding_show_num_peer_notif
, bonding_sysfs_store_option
);
394 /* Show the MII monitor interval. */
395 static ssize_t
bonding_show_miimon(struct device
*d
,
396 struct device_attribute
*attr
,
399 struct bonding
*bond
= to_bond(d
);
401 return sprintf(buf
, "%d\n", bond
->params
.miimon
);
403 static DEVICE_ATTR(miimon
, 0644,
404 bonding_show_miimon
, bonding_sysfs_store_option
);
406 /* Show the primary slave. */
407 static ssize_t
bonding_show_primary(struct device
*d
,
408 struct device_attribute
*attr
,
411 struct bonding
*bond
= to_bond(d
);
412 struct slave
*primary
;
416 primary
= rcu_dereference(bond
->primary_slave
);
418 count
= sprintf(buf
, "%s\n", primary
->dev
->name
);
423 static DEVICE_ATTR(primary
, 0644,
424 bonding_show_primary
, bonding_sysfs_store_option
);
426 /* Show the primary_reselect flag. */
427 static ssize_t
bonding_show_primary_reselect(struct device
*d
,
428 struct device_attribute
*attr
,
431 struct bonding
*bond
= to_bond(d
);
432 const struct bond_opt_value
*val
;
434 val
= bond_opt_get_val(BOND_OPT_PRIMARY_RESELECT
,
435 bond
->params
.primary_reselect
);
437 return sprintf(buf
, "%s %d\n",
438 val
->string
, bond
->params
.primary_reselect
);
440 static DEVICE_ATTR(primary_reselect
, 0644,
441 bonding_show_primary_reselect
, bonding_sysfs_store_option
);
443 /* Show the use_carrier flag. */
444 static ssize_t
bonding_show_carrier(struct device
*d
,
445 struct device_attribute
*attr
,
448 struct bonding
*bond
= to_bond(d
);
450 return sprintf(buf
, "%d\n", bond
->params
.use_carrier
);
452 static DEVICE_ATTR(use_carrier
, 0644,
453 bonding_show_carrier
, bonding_sysfs_store_option
);
456 /* Show currently active_slave. */
457 static ssize_t
bonding_show_active_slave(struct device
*d
,
458 struct device_attribute
*attr
,
461 struct bonding
*bond
= to_bond(d
);
462 struct net_device
*slave_dev
;
466 slave_dev
= bond_option_active_slave_get_rcu(bond
);
468 count
= sprintf(buf
, "%s\n", slave_dev
->name
);
473 static DEVICE_ATTR(active_slave
, 0644,
474 bonding_show_active_slave
, bonding_sysfs_store_option
);
476 /* Show link status of the bond interface. */
477 static ssize_t
bonding_show_mii_status(struct device
*d
,
478 struct device_attribute
*attr
,
481 struct bonding
*bond
= to_bond(d
);
482 bool active
= netif_carrier_ok(bond
->dev
);
484 return sprintf(buf
, "%s\n", active
? "up" : "down");
486 static DEVICE_ATTR(mii_status
, 0444, bonding_show_mii_status
, NULL
);
488 /* Show current 802.3ad aggregator ID. */
489 static ssize_t
bonding_show_ad_aggregator(struct device
*d
,
490 struct device_attribute
*attr
,
494 struct bonding
*bond
= to_bond(d
);
496 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
497 struct ad_info ad_info
;
498 count
= sprintf(buf
, "%d\n",
499 bond_3ad_get_active_agg_info(bond
, &ad_info
)
500 ? 0 : ad_info
.aggregator_id
);
505 static DEVICE_ATTR(ad_aggregator
, 0444, bonding_show_ad_aggregator
, NULL
);
508 /* Show number of active 802.3ad ports. */
509 static ssize_t
bonding_show_ad_num_ports(struct device
*d
,
510 struct device_attribute
*attr
,
514 struct bonding
*bond
= to_bond(d
);
516 if (BOND_MODE(bond
) == BOND_MODE_8023AD
) {
517 struct ad_info ad_info
;
518 count
= sprintf(buf
, "%d\n",
519 bond_3ad_get_active_agg_info(bond
, &ad_info
)
520 ? 0 : ad_info
.ports
);
525 static DEVICE_ATTR(ad_num_ports
, 0444, bonding_show_ad_num_ports
, NULL
);
528 /* Show current 802.3ad actor key. */
529 static ssize_t
bonding_show_ad_actor_key(struct device
*d
,
530 struct device_attribute
*attr
,
534 struct bonding
*bond
= to_bond(d
);
536 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
)) {
537 struct ad_info ad_info
;
538 count
= sprintf(buf
, "%d\n",
539 bond_3ad_get_active_agg_info(bond
, &ad_info
)
540 ? 0 : ad_info
.actor_key
);
545 static DEVICE_ATTR(ad_actor_key
, 0444, bonding_show_ad_actor_key
, NULL
);
548 /* Show current 802.3ad partner key. */
549 static ssize_t
bonding_show_ad_partner_key(struct device
*d
,
550 struct device_attribute
*attr
,
554 struct bonding
*bond
= to_bond(d
);
556 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
)) {
557 struct ad_info ad_info
;
558 count
= sprintf(buf
, "%d\n",
559 bond_3ad_get_active_agg_info(bond
, &ad_info
)
560 ? 0 : ad_info
.partner_key
);
565 static DEVICE_ATTR(ad_partner_key
, 0444, bonding_show_ad_partner_key
, NULL
);
568 /* Show current 802.3ad partner mac. */
569 static ssize_t
bonding_show_ad_partner_mac(struct device
*d
,
570 struct device_attribute
*attr
,
574 struct bonding
*bond
= to_bond(d
);
576 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
)) {
577 struct ad_info ad_info
;
578 if (!bond_3ad_get_active_agg_info(bond
, &ad_info
))
579 count
= sprintf(buf
, "%pM\n", ad_info
.partner_system
);
584 static DEVICE_ATTR(ad_partner_mac
, 0444, bonding_show_ad_partner_mac
, NULL
);
586 /* Show the queue_ids of the slaves in the current bond. */
587 static ssize_t
bonding_show_queue_id(struct device
*d
,
588 struct device_attribute
*attr
,
591 struct bonding
*bond
= to_bond(d
);
592 struct list_head
*iter
;
597 return restart_syscall();
599 bond_for_each_slave(bond
, slave
, iter
) {
600 if (res
> (PAGE_SIZE
- IFNAMSIZ
- 6)) {
601 /* not enough space for another interface_name:queue_id pair */
602 if ((PAGE_SIZE
- res
) > 10)
603 res
= PAGE_SIZE
- 10;
604 res
+= sprintf(buf
+ res
, "++more++ ");
607 res
+= sprintf(buf
+ res
, "%s:%d ",
608 slave
->dev
->name
, slave
->queue_id
);
611 buf
[res
-1] = '\n'; /* eat the leftover space */
617 static DEVICE_ATTR(queue_id
, 0644, bonding_show_queue_id
,
618 bonding_sysfs_store_option
);
621 /* Show the all_slaves_active flag. */
622 static ssize_t
bonding_show_slaves_active(struct device
*d
,
623 struct device_attribute
*attr
,
626 struct bonding
*bond
= to_bond(d
);
628 return sprintf(buf
, "%d\n", bond
->params
.all_slaves_active
);
630 static DEVICE_ATTR(all_slaves_active
, 0644,
631 bonding_show_slaves_active
, bonding_sysfs_store_option
);
633 /* Show the number of IGMP membership reports to send on link failure */
634 static ssize_t
bonding_show_resend_igmp(struct device
*d
,
635 struct device_attribute
*attr
,
638 struct bonding
*bond
= to_bond(d
);
640 return sprintf(buf
, "%d\n", bond
->params
.resend_igmp
);
642 static DEVICE_ATTR(resend_igmp
, 0644,
643 bonding_show_resend_igmp
, bonding_sysfs_store_option
);
646 static ssize_t
bonding_show_lp_interval(struct device
*d
,
647 struct device_attribute
*attr
,
650 struct bonding
*bond
= to_bond(d
);
652 return sprintf(buf
, "%d\n", bond
->params
.lp_interval
);
654 static DEVICE_ATTR(lp_interval
, 0644,
655 bonding_show_lp_interval
, bonding_sysfs_store_option
);
657 static ssize_t
bonding_show_tlb_dynamic_lb(struct device
*d
,
658 struct device_attribute
*attr
,
661 struct bonding
*bond
= to_bond(d
);
662 return sprintf(buf
, "%d\n", bond
->params
.tlb_dynamic_lb
);
664 static DEVICE_ATTR(tlb_dynamic_lb
, 0644,
665 bonding_show_tlb_dynamic_lb
, bonding_sysfs_store_option
);
667 static ssize_t
bonding_show_packets_per_slave(struct device
*d
,
668 struct device_attribute
*attr
,
671 struct bonding
*bond
= to_bond(d
);
672 unsigned int packets_per_slave
= bond
->params
.packets_per_slave
;
674 return sprintf(buf
, "%u\n", packets_per_slave
);
676 static DEVICE_ATTR(packets_per_slave
, 0644,
677 bonding_show_packets_per_slave
, bonding_sysfs_store_option
);
679 static ssize_t
bonding_show_ad_actor_sys_prio(struct device
*d
,
680 struct device_attribute
*attr
,
683 struct bonding
*bond
= to_bond(d
);
685 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
))
686 return sprintf(buf
, "%hu\n", bond
->params
.ad_actor_sys_prio
);
690 static DEVICE_ATTR(ad_actor_sys_prio
, 0644,
691 bonding_show_ad_actor_sys_prio
, bonding_sysfs_store_option
);
693 static ssize_t
bonding_show_ad_actor_system(struct device
*d
,
694 struct device_attribute
*attr
,
697 struct bonding
*bond
= to_bond(d
);
699 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
))
700 return sprintf(buf
, "%pM\n", bond
->params
.ad_actor_system
);
705 static DEVICE_ATTR(ad_actor_system
, 0644,
706 bonding_show_ad_actor_system
, bonding_sysfs_store_option
);
708 static ssize_t
bonding_show_ad_user_port_key(struct device
*d
,
709 struct device_attribute
*attr
,
712 struct bonding
*bond
= to_bond(d
);
714 if (BOND_MODE(bond
) == BOND_MODE_8023AD
&& capable(CAP_NET_ADMIN
))
715 return sprintf(buf
, "%hu\n", bond
->params
.ad_user_port_key
);
719 static DEVICE_ATTR(ad_user_port_key
, 0644,
720 bonding_show_ad_user_port_key
, bonding_sysfs_store_option
);
722 static struct attribute
*per_bond_attrs
[] = {
723 &dev_attr_slaves
.attr
,
725 &dev_attr_fail_over_mac
.attr
,
726 &dev_attr_arp_validate
.attr
,
727 &dev_attr_arp_all_targets
.attr
,
728 &dev_attr_arp_interval
.attr
,
729 &dev_attr_arp_ip_target
.attr
,
730 &dev_attr_downdelay
.attr
,
731 &dev_attr_updelay
.attr
,
732 &dev_attr_lacp_rate
.attr
,
733 &dev_attr_ad_select
.attr
,
734 &dev_attr_xmit_hash_policy
.attr
,
735 &dev_attr_num_grat_arp
.attr
,
736 &dev_attr_num_unsol_na
.attr
,
737 &dev_attr_miimon
.attr
,
738 &dev_attr_primary
.attr
,
739 &dev_attr_primary_reselect
.attr
,
740 &dev_attr_use_carrier
.attr
,
741 &dev_attr_active_slave
.attr
,
742 &dev_attr_mii_status
.attr
,
743 &dev_attr_ad_aggregator
.attr
,
744 &dev_attr_ad_num_ports
.attr
,
745 &dev_attr_ad_actor_key
.attr
,
746 &dev_attr_ad_partner_key
.attr
,
747 &dev_attr_ad_partner_mac
.attr
,
748 &dev_attr_queue_id
.attr
,
749 &dev_attr_all_slaves_active
.attr
,
750 &dev_attr_resend_igmp
.attr
,
751 &dev_attr_min_links
.attr
,
752 &dev_attr_lp_interval
.attr
,
753 &dev_attr_packets_per_slave
.attr
,
754 &dev_attr_tlb_dynamic_lb
.attr
,
755 &dev_attr_ad_actor_sys_prio
.attr
,
756 &dev_attr_ad_actor_system
.attr
,
757 &dev_attr_ad_user_port_key
.attr
,
761 static const struct attribute_group bonding_group
= {
763 .attrs
= per_bond_attrs
,
766 /* Initialize sysfs. This sets up the bonding_masters file in
769 int bond_create_sysfs(struct bond_net
*bn
)
773 bn
->class_attr_bonding_masters
= class_attr_bonding_masters
;
774 sysfs_attr_init(&bn
->class_attr_bonding_masters
.attr
);
776 ret
= netdev_class_create_file_ns(&bn
->class_attr_bonding_masters
,
778 /* Permit multiple loads of the module by ignoring failures to
779 * create the bonding_masters sysfs file. Bonding devices
780 * created by second or subsequent loads of the module will
781 * not be listed in, or controllable by, bonding_masters, but
782 * will have the usual "bonding" sysfs directory.
784 * This is done to preserve backwards compatibility for
785 * initscripts/sysconfig, which load bonding multiple times to
786 * configure multiple bonding devices.
788 if (ret
== -EEXIST
) {
789 /* Is someone being kinky and naming a device bonding_master? */
790 if (__dev_get_by_name(bn
->net
,
791 class_attr_bonding_masters
.attr
.name
))
792 pr_err("network device named %s already exists in sysfs\n",
793 class_attr_bonding_masters
.attr
.name
);
801 /* Remove /sys/class/net/bonding_masters. */
802 void bond_destroy_sysfs(struct bond_net
*bn
)
804 netdev_class_remove_file_ns(&bn
->class_attr_bonding_masters
, bn
->net
);
807 /* Initialize sysfs for each bond. This sets up and registers
808 * the 'bondctl' directory for each individual bond under /sys/class/net.
810 void bond_prepare_sysfs_group(struct bonding
*bond
)
812 bond
->dev
->sysfs_groups
[0] = &bonding_group
;