Lines Matching +full:primary +full:- +full:bond

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
40 struct bonding *bond; in bonding_show_bonds() local
45 list_for_each_entry_rcu(bond, &bn->dev_list, bond_list) { in bonding_show_bonds()
46 if (res > (PAGE_SIZE - IFNAMSIZ)) { in bonding_show_bonds()
48 if ((PAGE_SIZE - res) > 10) in bonding_show_bonds()
49 res = PAGE_SIZE - 10; in bonding_show_bonds()
53 res += sysfs_emit_at(buf, res, "%s ", bond->dev->name); in bonding_show_bonds()
56 buf[res-1] = '\n'; /* eat the leftover space */ in bonding_show_bonds()
64 struct bonding *bond; in bond_get_by_name() local
66 list_for_each_entry(bond, &bn->dev_list, bond_list) { in bond_get_by_name()
67 if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0) in bond_get_by_name()
68 return bond->dev; in bond_get_by_name()
96 rv = bond_create(bn->net, ifname); in bonding_store_bonds()
98 if (rv == -EEXIST) in bonding_store_bonds()
104 } else if (command[0] == '-') { in bonding_store_bonds()
113 pr_err("unable to delete non-existent %s\n", ifname); in bonding_store_bonds()
114 res = -ENODEV; in bonding_store_bonds()
126 pr_err("no command found in bonding_masters - use +ifname or -ifname\n"); in bonding_store_bonds()
127 return -EPERM; in bonding_store_bonds()
145 struct bonding *bond = to_bond(d); in bonding_sysfs_store_option() local
150 opt = bond_opt_get_by_name(attr->attr.name); in bonding_sysfs_store_option()
152 return -ENOENT; in bonding_sysfs_store_option()
155 return -ENOMEM; in bonding_sysfs_store_option()
156 ret = bond_opt_tryset_rtnl(bond, opt->id, buffer_clone); in bonding_sysfs_store_option()
164 /* Show the slaves in the current bond. */
168 struct bonding *bond = to_bond(d); in bonding_show_slaves() local
175 bond_for_each_slave_rcu(bond, slave, iter) { in bonding_show_slaves()
176 if (res > (PAGE_SIZE - IFNAMSIZ)) { in bonding_show_slaves()
178 if ((PAGE_SIZE - res) > 10) in bonding_show_slaves()
179 res = PAGE_SIZE - 10; in bonding_show_slaves()
183 res += sysfs_emit_at(buf, res, "%s ", slave->dev->name); in bonding_show_slaves()
189 buf[res-1] = '\n'; /* eat the leftover space */ in bonding_show_slaves()
200 struct bonding *bond = to_bond(d); in bonding_show_mode() local
203 val = bond_opt_get_val(BOND_OPT_MODE, BOND_MODE(bond)); in bonding_show_mode()
205 return sysfs_emit(buf, "%s %d\n", val->string, BOND_MODE(bond)); in bonding_show_mode()
214 struct bonding *bond = to_bond(d); in bonding_show_xmit_hash() local
217 val = bond_opt_get_val(BOND_OPT_XMIT_HASH, bond->params.xmit_policy); in bonding_show_xmit_hash()
219 return sysfs_emit(buf, "%s %d\n", val->string, bond->params.xmit_policy); in bonding_show_xmit_hash()
229 struct bonding *bond = to_bond(d); in bonding_show_arp_validate() local
233 bond->params.arp_validate); in bonding_show_arp_validate()
235 return sysfs_emit(buf, "%s %d\n", val->string, bond->params.arp_validate); in bonding_show_arp_validate()
245 struct bonding *bond = to_bond(d); in bonding_show_arp_all_targets() local
249 bond->params.arp_all_targets); in bonding_show_arp_all_targets()
251 val->string, bond->params.arp_all_targets); in bonding_show_arp_all_targets()
261 struct bonding *bond = to_bond(d); in bonding_show_fail_over_mac() local
265 bond->params.fail_over_mac); in bonding_show_fail_over_mac()
267 return sysfs_emit(buf, "%s %d\n", val->string, bond->params.fail_over_mac); in bonding_show_fail_over_mac()
277 struct bonding *bond = to_bond(d); in bonding_show_arp_interval() local
279 return sysfs_emit(buf, "%d\n", bond->params.arp_interval); in bonding_show_arp_interval()
289 struct bonding *bond = to_bond(d); in bonding_show_arp_targets() local
293 if (bond->params.arp_targets[i]) in bonding_show_arp_targets()
295 &bond->params.arp_targets[i]); in bonding_show_arp_targets()
298 buf[res-1] = '\n'; /* eat the leftover space */ in bonding_show_arp_targets()
310 struct bonding *bond = to_bond(d); in bonding_show_missed_max() local
312 return sysfs_emit(buf, "%u\n", bond->params.missed_max); in bonding_show_missed_max()
322 struct bonding *bond = to_bond(d); in bonding_show_downdelay() local
324 return sysfs_emit(buf, "%d\n", bond->params.downdelay * bond->params.miimon); in bonding_show_downdelay()
333 struct bonding *bond = to_bond(d); in bonding_show_updelay() local
335 return sysfs_emit(buf, "%d\n", bond->params.updelay * bond->params.miimon); in bonding_show_updelay()
345 struct bonding *bond = to_bond(d); in bonding_show_peer_notif_delay() local
348 bond->params.peer_notif_delay * bond->params.miimon); in bonding_show_peer_notif_delay()
358 struct bonding *bond = to_bond(d); in bonding_show_lacp_active() local
361 val = bond_opt_get_val(BOND_OPT_LACP_ACTIVE, bond->params.lacp_active); in bonding_show_lacp_active()
363 return sysfs_emit(buf, "%s %d\n", val->string, bond->params.lacp_active); in bonding_show_lacp_active()
372 struct bonding *bond = to_bond(d); in bonding_show_lacp_rate() local
375 val = bond_opt_get_val(BOND_OPT_LACP_RATE, bond->params.lacp_fast); in bonding_show_lacp_rate()
377 return sysfs_emit(buf, "%s %d\n", val->string, bond->params.lacp_fast); in bonding_show_lacp_rate()
386 struct bonding *bond = to_bond(d); in bonding_show_min_links() local
388 return sysfs_emit(buf, "%u\n", bond->params.min_links); in bonding_show_min_links()
397 struct bonding *bond = to_bond(d); in bonding_show_ad_select() local
400 val = bond_opt_get_val(BOND_OPT_AD_SELECT, bond->params.ad_select); in bonding_show_ad_select()
402 return sysfs_emit(buf, "%s %d\n", val->string, bond->params.ad_select); in bonding_show_ad_select()
412 struct bonding *bond = to_bond(d); in bonding_show_num_peer_notif() local
414 return sysfs_emit(buf, "%d\n", bond->params.num_peer_notif); in bonding_show_num_peer_notif()
426 struct bonding *bond = to_bond(d); in bonding_show_miimon() local
428 return sysfs_emit(buf, "%d\n", bond->params.miimon); in bonding_show_miimon()
433 /* Show the primary slave. */
438 struct bonding *bond = to_bond(d); in bonding_show_primary() local
439 struct slave *primary; in bonding_show_primary() local
443 primary = rcu_dereference(bond->primary_slave); in bonding_show_primary()
444 if (primary) in bonding_show_primary()
445 count = sysfs_emit(buf, "%s\n", primary->dev->name); in bonding_show_primary()
450 static DEVICE_ATTR(primary, 0644,
458 struct bonding *bond = to_bond(d); in bonding_show_primary_reselect() local
462 bond->params.primary_reselect); in bonding_show_primary_reselect()
465 val->string, bond->params.primary_reselect); in bonding_show_primary_reselect()
475 struct bonding *bond = to_bond(d); in bonding_show_carrier() local
477 return sysfs_emit(buf, "%d\n", bond->params.use_carrier); in bonding_show_carrier()
488 struct bonding *bond = to_bond(d); in bonding_show_active_slave() local
493 slave_dev = bond_option_active_slave_get_rcu(bond); in bonding_show_active_slave()
495 count = sysfs_emit(buf, "%s\n", slave_dev->name); in bonding_show_active_slave()
503 /* Show link status of the bond interface. */
508 struct bonding *bond = to_bond(d); in bonding_show_mii_status() local
509 bool active = netif_carrier_ok(bond->dev); in bonding_show_mii_status()
521 struct bonding *bond = to_bond(d); in bonding_show_ad_aggregator() local
523 if (BOND_MODE(bond) == BOND_MODE_8023AD) { in bonding_show_ad_aggregator()
527 bond_3ad_get_active_agg_info(bond, &ad_info) in bonding_show_ad_aggregator()
542 struct bonding *bond = to_bond(d); in bonding_show_ad_num_ports() local
544 if (BOND_MODE(bond) == BOND_MODE_8023AD) { in bonding_show_ad_num_ports()
548 bond_3ad_get_active_agg_info(bond, &ad_info) in bonding_show_ad_num_ports()
563 struct bonding *bond = to_bond(d); in bonding_show_ad_actor_key() local
565 if (BOND_MODE(bond) == BOND_MODE_8023AD && capable(CAP_NET_ADMIN)) { in bonding_show_ad_actor_key()
569 bond_3ad_get_active_agg_info(bond, &ad_info) in bonding_show_ad_actor_key()
584 struct bonding *bond = to_bond(d); in bonding_show_ad_partner_key() local
586 if (BOND_MODE(bond) == BOND_MODE_8023AD && capable(CAP_NET_ADMIN)) { in bonding_show_ad_partner_key()
590 bond_3ad_get_active_agg_info(bond, &ad_info) in bonding_show_ad_partner_key()
605 struct bonding *bond = to_bond(d); in bonding_show_ad_partner_mac() local
607 if (BOND_MODE(bond) == BOND_MODE_8023AD && capable(CAP_NET_ADMIN)) { in bonding_show_ad_partner_mac()
610 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) in bonding_show_ad_partner_mac()
618 /* Show the queue_ids of the slaves in the current bond. */
623 struct bonding *bond = to_bond(d); in bonding_show_queue_id() local
630 bond_for_each_slave_rcu(bond, slave, iter) { in bonding_show_queue_id()
631 if (res > (PAGE_SIZE - IFNAMSIZ - 6)) { in bonding_show_queue_id()
633 if ((PAGE_SIZE - res) > 10) in bonding_show_queue_id()
634 res = PAGE_SIZE - 10; in bonding_show_queue_id()
639 slave->dev->name, in bonding_show_queue_id()
640 READ_ONCE(slave->queue_id)); in bonding_show_queue_id()
643 buf[res-1] = '\n'; /* eat the leftover space */ in bonding_show_queue_id()
658 struct bonding *bond = to_bond(d); in bonding_show_slaves_active() local
660 return sysfs_emit(buf, "%d\n", bond->params.all_slaves_active); in bonding_show_slaves_active()
670 struct bonding *bond = to_bond(d); in bonding_show_resend_igmp() local
672 return sysfs_emit(buf, "%d\n", bond->params.resend_igmp); in bonding_show_resend_igmp()
682 struct bonding *bond = to_bond(d); in bonding_show_lp_interval() local
684 return sysfs_emit(buf, "%d\n", bond->params.lp_interval); in bonding_show_lp_interval()
693 struct bonding *bond = to_bond(d); in bonding_show_tlb_dynamic_lb() local
695 return sysfs_emit(buf, "%d\n", bond->params.tlb_dynamic_lb); in bonding_show_tlb_dynamic_lb()
704 struct bonding *bond = to_bond(d); in bonding_show_packets_per_slave() local
705 unsigned int packets_per_slave = bond->params.packets_per_slave; in bonding_show_packets_per_slave()
716 struct bonding *bond = to_bond(d); in bonding_show_ad_actor_sys_prio() local
718 if (BOND_MODE(bond) == BOND_MODE_8023AD && capable(CAP_NET_ADMIN)) in bonding_show_ad_actor_sys_prio()
719 return sysfs_emit(buf, "%hu\n", bond->params.ad_actor_sys_prio); in bonding_show_ad_actor_sys_prio()
730 struct bonding *bond = to_bond(d); in bonding_show_ad_actor_system() local
732 if (BOND_MODE(bond) == BOND_MODE_8023AD && capable(CAP_NET_ADMIN)) in bonding_show_ad_actor_system()
733 return sysfs_emit(buf, "%pM\n", bond->params.ad_actor_system); in bonding_show_ad_actor_system()
745 struct bonding *bond = to_bond(d); in bonding_show_ad_user_port_key() local
747 if (BOND_MODE(bond) == BOND_MODE_8023AD && capable(CAP_NET_ADMIN)) in bonding_show_ad_user_port_key()
748 return sysfs_emit(buf, "%hu\n", bond->params.ad_user_port_key); in bonding_show_ad_user_port_key()
809 bn->class_attr_bonding_masters = class_attr_bonding_masters; in bond_create_sysfs()
810 sysfs_attr_init(&bn->class_attr_bonding_masters.attr); in bond_create_sysfs()
812 ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters, in bond_create_sysfs()
813 bn->net); in bond_create_sysfs()
824 if (ret == -EEXIST) { in bond_create_sysfs()
826 if (netdev_name_in_use(bn->net, in bond_create_sysfs()
840 netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net); in bond_destroy_sysfs()
843 /* Initialize sysfs for each bond. This sets up and registers
844 * the 'bondctl' directory for each individual bond under /sys/class/net.
846 void bond_prepare_sysfs_group(struct bonding *bond) in bond_prepare_sysfs_group() argument
848 bond->dev->sysfs_groups[0] = &bonding_group; in bond_prepare_sysfs_group()