Lines Matching refs:bond
21 static int bond_option_active_slave_set(struct bonding *bond,
23 static int bond_option_miimon_set(struct bonding *bond,
25 static int bond_option_updelay_set(struct bonding *bond,
27 static int bond_option_downdelay_set(struct bonding *bond,
29 static int bond_option_use_carrier_set(struct bonding *bond,
31 static int bond_option_arp_interval_set(struct bonding *bond,
33 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
34 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
35 static int bond_option_arp_ip_targets_set(struct bonding *bond,
37 static int bond_option_arp_validate_set(struct bonding *bond,
39 static int bond_option_arp_all_targets_set(struct bonding *bond,
41 static int bond_option_primary_set(struct bonding *bond,
43 static int bond_option_primary_reselect_set(struct bonding *bond,
45 static int bond_option_fail_over_mac_set(struct bonding *bond,
47 static int bond_option_xmit_hash_policy_set(struct bonding *bond,
49 static int bond_option_resend_igmp_set(struct bonding *bond,
51 static int bond_option_num_peer_notif_set(struct bonding *bond,
53 static int bond_option_all_slaves_active_set(struct bonding *bond,
55 static int bond_option_min_links_set(struct bonding *bond,
57 static int bond_option_lp_interval_set(struct bonding *bond,
59 static int bond_option_pps_set(struct bonding *bond,
61 static int bond_option_lacp_rate_set(struct bonding *bond,
63 static int bond_option_ad_select_set(struct bonding *bond,
65 static int bond_option_queue_id_set(struct bonding *bond,
67 static int bond_option_mode_set(struct bonding *bond,
69 static int bond_option_slaves_set(struct bonding *bond,
71 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
520 static int bond_opt_check_deps(struct bonding *bond, in bond_opt_check_deps() argument
523 struct bond_params *params = &bond->params; in bond_opt_check_deps()
527 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond)) in bond_opt_check_deps()
529 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP)) in bond_opt_check_deps()
535 static void bond_opt_dep_print(struct bonding *bond, in bond_opt_dep_print() argument
541 params = &bond->params; in bond_opt_dep_print()
544 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n", in bond_opt_dep_print()
548 static void bond_opt_error_interpret(struct bonding *bond, in bond_opt_error_interpret() argument
563 netdev_err(bond->dev, "option %s: invalid value (%s)\n", in bond_opt_error_interpret()
566 netdev_err(bond->dev, "option %s: invalid value (%llu)\n", in bond_opt_error_interpret()
574 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n", in bond_opt_error_interpret()
578 bond_opt_dep_print(bond, opt); in bond_opt_error_interpret()
581 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n", in bond_opt_error_interpret()
585 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n", in bond_opt_error_interpret()
603 int __bond_opt_set(struct bonding *bond, in __bond_opt_set() argument
615 ret = bond_opt_check_deps(bond, opt); in __bond_opt_set()
623 ret = opt->set(bond, retval); in __bond_opt_set()
626 bond_opt_error_interpret(bond, opt, ret, val); in __bond_opt_set()
627 else if (bond->dev->reg_state == NETREG_REGISTERED) in __bond_opt_set()
628 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev); in __bond_opt_set()
642 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf) in bond_opt_tryset_rtnl() argument
650 ret = __bond_opt_set(bond, option, &optval); in bond_opt_tryset_rtnl()
671 static int bond_option_mode_set(struct bonding *bond, in bond_option_mode_set() argument
674 if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) { in bond_option_mode_set()
675 netdev_info(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n", in bond_option_mode_set()
678 bond->params.arp_interval = 0; in bond_option_mode_set()
680 bond->params.miimon = BOND_DEFAULT_MIIMON; in bond_option_mode_set()
681 netdev_info(bond->dev, "Setting MII monitoring interval to %d\n", in bond_option_mode_set()
682 bond->params.miimon); in bond_option_mode_set()
686 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_mode_set()
687 bond->params.mode = newval->value; in bond_option_mode_set()
692 static struct net_device *__bond_option_active_slave_get(struct bonding *bond, in __bond_option_active_slave_get() argument
695 return bond_uses_primary(bond) && slave ? slave->dev : NULL; in __bond_option_active_slave_get()
698 struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) in bond_option_active_slave_get_rcu() argument
700 struct slave *slave = rcu_dereference(bond->curr_active_slave); in bond_option_active_slave_get_rcu()
702 return __bond_option_active_slave_get(bond, slave); in bond_option_active_slave_get_rcu()
705 static int bond_option_active_slave_set(struct bonding *bond, in bond_option_active_slave_set() argument
716 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_active_slave_set()
723 netdev_err(bond->dev, "Device %s is not bonding slave\n", in bond_option_active_slave_set()
728 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) { in bond_option_active_slave_set()
729 netdev_err(bond->dev, "Device %s is not our slave\n", in bond_option_active_slave_set()
738 netdev_info(bond->dev, "Clearing current active slave\n"); in bond_option_active_slave_set()
739 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in bond_option_active_slave_set()
740 bond_select_active_slave(bond); in bond_option_active_slave_set()
742 struct slave *old_active = rtnl_dereference(bond->curr_active_slave); in bond_option_active_slave_set()
749 netdev_info(bond->dev, "%s is already the current active slave\n", in bond_option_active_slave_set()
754 netdev_info(bond->dev, "Setting %s as active slave\n", in bond_option_active_slave_set()
756 bond_change_active_slave(bond, new_active); in bond_option_active_slave_set()
758 … netdev_err(bond->dev, "Could not set %s as active slave; either %s is down or the link is down\n", in bond_option_active_slave_set()
774 static int bond_option_miimon_set(struct bonding *bond, in bond_option_miimon_set() argument
777 netdev_info(bond->dev, "Setting MII monitoring interval to %llu\n", in bond_option_miimon_set()
779 bond->params.miimon = newval->value; in bond_option_miimon_set()
780 if (bond->params.updelay) in bond_option_miimon_set()
781 …netdev_info(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\… in bond_option_miimon_set()
782 bond->params.updelay * bond->params.miimon); in bond_option_miimon_set()
783 if (bond->params.downdelay) in bond_option_miimon_set()
784 …netdev_info(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon valu… in bond_option_miimon_set()
785 bond->params.downdelay * bond->params.miimon); in bond_option_miimon_set()
786 if (newval->value && bond->params.arp_interval) { in bond_option_miimon_set()
787 …netdev_info(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitori… in bond_option_miimon_set()
788 bond->params.arp_interval = 0; in bond_option_miimon_set()
789 if (bond->params.arp_validate) in bond_option_miimon_set()
790 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_miimon_set()
792 if (bond->dev->flags & IFF_UP) { in bond_option_miimon_set()
799 cancel_delayed_work_sync(&bond->mii_work); in bond_option_miimon_set()
801 cancel_delayed_work_sync(&bond->arp_work); in bond_option_miimon_set()
802 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_option_miimon_set()
813 static int bond_option_updelay_set(struct bonding *bond, in bond_option_updelay_set() argument
818 if (!bond->params.miimon) { in bond_option_updelay_set()
819 netdev_err(bond->dev, "Unable to set up delay as MII monitoring is disabled\n"); in bond_option_updelay_set()
822 if ((value % bond->params.miimon) != 0) { in bond_option_updelay_set()
823 …netdev_warn(bond->dev, "up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n… in bond_option_updelay_set()
824 value, bond->params.miimon, in bond_option_updelay_set()
825 (value / bond->params.miimon) * in bond_option_updelay_set()
826 bond->params.miimon); in bond_option_updelay_set()
828 bond->params.updelay = value / bond->params.miimon; in bond_option_updelay_set()
829 netdev_info(bond->dev, "Setting up delay to %d\n", in bond_option_updelay_set()
830 bond->params.updelay * bond->params.miimon); in bond_option_updelay_set()
835 static int bond_option_downdelay_set(struct bonding *bond, in bond_option_downdelay_set() argument
840 if (!bond->params.miimon) { in bond_option_downdelay_set()
841 netdev_err(bond->dev, "Unable to set down delay as MII monitoring is disabled\n"); in bond_option_downdelay_set()
844 if ((value % bond->params.miimon) != 0) { in bond_option_downdelay_set()
845 …netdev_warn(bond->dev, "down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n… in bond_option_downdelay_set()
846 value, bond->params.miimon, in bond_option_downdelay_set()
847 (value / bond->params.miimon) * in bond_option_downdelay_set()
848 bond->params.miimon); in bond_option_downdelay_set()
850 bond->params.downdelay = value / bond->params.miimon; in bond_option_downdelay_set()
851 netdev_info(bond->dev, "Setting down delay to %d\n", in bond_option_downdelay_set()
852 bond->params.downdelay * bond->params.miimon); in bond_option_downdelay_set()
857 static int bond_option_use_carrier_set(struct bonding *bond, in bond_option_use_carrier_set() argument
860 netdev_info(bond->dev, "Setting use_carrier to %llu\n", in bond_option_use_carrier_set()
862 bond->params.use_carrier = newval->value; in bond_option_use_carrier_set()
871 static int bond_option_arp_interval_set(struct bonding *bond, in bond_option_arp_interval_set() argument
874 netdev_info(bond->dev, "Setting ARP monitoring interval to %llu\n", in bond_option_arp_interval_set()
876 bond->params.arp_interval = newval->value; in bond_option_arp_interval_set()
878 if (bond->params.miimon) { in bond_option_arp_interval_set()
879 …netdev_info(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitorin… in bond_option_arp_interval_set()
880 bond->params.miimon = 0; in bond_option_arp_interval_set()
882 if (!bond->params.arp_targets[0]) in bond_option_arp_interval_set()
883 …netdev_info(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n"); in bond_option_arp_interval_set()
885 if (bond->dev->flags & IFF_UP) { in bond_option_arp_interval_set()
892 if (bond->params.arp_validate) in bond_option_arp_interval_set()
893 bond->recv_probe = NULL; in bond_option_arp_interval_set()
894 cancel_delayed_work_sync(&bond->arp_work); in bond_option_arp_interval_set()
897 bond->recv_probe = bond_arp_rcv; in bond_option_arp_interval_set()
898 cancel_delayed_work_sync(&bond->mii_work); in bond_option_arp_interval_set()
899 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_option_arp_interval_set()
906 static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, in _bond_options_arp_ip_target_set() argument
910 __be32 *targets = bond->params.arp_targets; in _bond_options_arp_ip_target_set()
915 bond_for_each_slave(bond, slave, iter) in _bond_options_arp_ip_target_set()
921 static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in _bond_option_arp_ip_target_add() argument
923 __be32 *targets = bond->params.arp_targets; in _bond_option_arp_ip_target_add()
927 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n", in _bond_option_arp_ip_target_add()
933 netdev_err(bond->dev, "ARP target %pI4 is already present\n", in _bond_option_arp_ip_target_add()
940 netdev_err(bond->dev, "ARP target table is full!\n"); in _bond_option_arp_ip_target_add()
944 netdev_info(bond->dev, "Adding ARP target %pI4\n", &target); in _bond_option_arp_ip_target_add()
946 _bond_options_arp_ip_target_set(bond, ind, target, jiffies); in _bond_option_arp_ip_target_add()
951 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_add() argument
953 return _bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_target_add()
956 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_rem() argument
958 __be32 *targets = bond->params.arp_targets; in bond_option_arp_ip_target_rem()
965 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n", in bond_option_arp_ip_target_rem()
972 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n", in bond_option_arp_ip_target_rem()
977 if (ind == 0 && !targets[1] && bond->params.arp_interval) in bond_option_arp_ip_target_rem()
978 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n"); in bond_option_arp_ip_target_rem()
980 netdev_info(bond->dev, "Removing ARP target %pI4\n", &target); in bond_option_arp_ip_target_rem()
982 bond_for_each_slave(bond, slave, iter) { in bond_option_arp_ip_target_rem()
995 void bond_option_arp_ip_targets_clear(struct bonding *bond) in bond_option_arp_ip_targets_clear() argument
1000 _bond_options_arp_ip_target_set(bond, i, 0, 0); in bond_option_arp_ip_targets_clear()
1003 static int bond_option_arp_ip_targets_set(struct bonding *bond, in bond_option_arp_ip_targets_set() argument
1011 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n", in bond_option_arp_ip_targets_set()
1016 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1018 ret = bond_option_arp_ip_target_rem(bond, target); in bond_option_arp_ip_targets_set()
1020 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n"); in bond_option_arp_ip_targets_set()
1023 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1029 static int bond_option_arp_validate_set(struct bonding *bond, in bond_option_arp_validate_set() argument
1032 netdev_info(bond->dev, "Setting arp_validate to %s (%llu)\n", in bond_option_arp_validate_set()
1035 if (bond->dev->flags & IFF_UP) { in bond_option_arp_validate_set()
1037 bond->recv_probe = NULL; in bond_option_arp_validate_set()
1038 else if (bond->params.arp_interval) in bond_option_arp_validate_set()
1039 bond->recv_probe = bond_arp_rcv; in bond_option_arp_validate_set()
1041 bond->params.arp_validate = newval->value; in bond_option_arp_validate_set()
1046 static int bond_option_arp_all_targets_set(struct bonding *bond, in bond_option_arp_all_targets_set() argument
1049 netdev_info(bond->dev, "Setting arp_all_targets to %s (%llu)\n", in bond_option_arp_all_targets_set()
1051 bond->params.arp_all_targets = newval->value; in bond_option_arp_all_targets_set()
1056 static int bond_option_primary_set(struct bonding *bond, in bond_option_primary_set() argument
1070 netdev_info(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1071 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1072 memset(bond->params.primary, 0, sizeof(bond->params.primary)); in bond_option_primary_set()
1073 bond_select_active_slave(bond); in bond_option_primary_set()
1077 bond_for_each_slave(bond, slave, iter) { in bond_option_primary_set()
1079 netdev_info(bond->dev, "Setting %s as primary slave\n", in bond_option_primary_set()
1081 rcu_assign_pointer(bond->primary_slave, slave); in bond_option_primary_set()
1082 strcpy(bond->params.primary, slave->dev->name); in bond_option_primary_set()
1083 bond_select_active_slave(bond); in bond_option_primary_set()
1088 if (rtnl_dereference(bond->primary_slave)) { in bond_option_primary_set()
1089 netdev_info(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1090 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1091 bond_select_active_slave(bond); in bond_option_primary_set()
1093 strncpy(bond->params.primary, primary, IFNAMSIZ); in bond_option_primary_set()
1094 bond->params.primary[IFNAMSIZ - 1] = 0; in bond_option_primary_set()
1096 netdev_info(bond->dev, "Recording %s as primary, but it has not been enslaved to %s yet\n", in bond_option_primary_set()
1097 primary, bond->dev->name); in bond_option_primary_set()
1105 static int bond_option_primary_reselect_set(struct bonding *bond, in bond_option_primary_reselect_set() argument
1108 netdev_info(bond->dev, "Setting primary_reselect to %s (%llu)\n", in bond_option_primary_reselect_set()
1110 bond->params.primary_reselect = newval->value; in bond_option_primary_reselect_set()
1113 bond_select_active_slave(bond); in bond_option_primary_reselect_set()
1119 static int bond_option_fail_over_mac_set(struct bonding *bond, in bond_option_fail_over_mac_set() argument
1122 netdev_info(bond->dev, "Setting fail_over_mac to %s (%llu)\n", in bond_option_fail_over_mac_set()
1124 bond->params.fail_over_mac = newval->value; in bond_option_fail_over_mac_set()
1129 static int bond_option_xmit_hash_policy_set(struct bonding *bond, in bond_option_xmit_hash_policy_set() argument
1132 netdev_info(bond->dev, "Setting xmit hash policy to %s (%llu)\n", in bond_option_xmit_hash_policy_set()
1134 bond->params.xmit_policy = newval->value; in bond_option_xmit_hash_policy_set()
1139 static int bond_option_resend_igmp_set(struct bonding *bond, in bond_option_resend_igmp_set() argument
1142 netdev_info(bond->dev, "Setting resend_igmp to %llu\n", in bond_option_resend_igmp_set()
1144 bond->params.resend_igmp = newval->value; in bond_option_resend_igmp_set()
1149 static int bond_option_num_peer_notif_set(struct bonding *bond, in bond_option_num_peer_notif_set() argument
1152 bond->params.num_peer_notif = newval->value; in bond_option_num_peer_notif_set()
1157 static int bond_option_all_slaves_active_set(struct bonding *bond, in bond_option_all_slaves_active_set() argument
1163 if (newval->value == bond->params.all_slaves_active) in bond_option_all_slaves_active_set()
1165 bond->params.all_slaves_active = newval->value; in bond_option_all_slaves_active_set()
1166 bond_for_each_slave(bond, slave, iter) { in bond_option_all_slaves_active_set()
1178 static int bond_option_min_links_set(struct bonding *bond, in bond_option_min_links_set() argument
1181 netdev_info(bond->dev, "Setting min links value to %llu\n", in bond_option_min_links_set()
1183 bond->params.min_links = newval->value; in bond_option_min_links_set()
1184 bond_set_carrier(bond); in bond_option_min_links_set()
1189 static int bond_option_lp_interval_set(struct bonding *bond, in bond_option_lp_interval_set() argument
1192 bond->params.lp_interval = newval->value; in bond_option_lp_interval_set()
1197 static int bond_option_pps_set(struct bonding *bond, in bond_option_pps_set() argument
1200 bond->params.packets_per_slave = newval->value; in bond_option_pps_set()
1202 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1208 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1215 static int bond_option_lacp_rate_set(struct bonding *bond, in bond_option_lacp_rate_set() argument
1218 netdev_info(bond->dev, "Setting LACP rate to %s (%llu)\n", in bond_option_lacp_rate_set()
1220 bond->params.lacp_fast = newval->value; in bond_option_lacp_rate_set()
1221 bond_3ad_update_lacp_rate(bond); in bond_option_lacp_rate_set()
1226 static int bond_option_ad_select_set(struct bonding *bond, in bond_option_ad_select_set() argument
1229 netdev_info(bond->dev, "Setting ad_select to %s (%llu)\n", in bond_option_ad_select_set()
1231 bond->params.ad_select = newval->value; in bond_option_ad_select_set()
1236 static int bond_option_queue_id_set(struct bonding *bond, in bond_option_queue_id_set() argument
1260 qid > bond->dev->real_num_tx_queues) in bond_option_queue_id_set()
1264 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string); in bond_option_queue_id_set()
1270 bond_for_each_slave(bond, slave, iter) { in bond_option_queue_id_set()
1291 netdev_info(bond->dev, "invalid input for queue_id set\n"); in bond_option_queue_id_set()
1297 static int bond_option_slaves_set(struct bonding *bond, in bond_option_slaves_set() argument
1311 dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_slaves_set()
1313 netdev_info(bond->dev, "interface %s does not exist!\n", in bond_option_slaves_set()
1321 netdev_info(bond->dev, "Adding slave %s\n", dev->name); in bond_option_slaves_set()
1322 ret = bond_enslave(bond->dev, dev); in bond_option_slaves_set()
1326 netdev_info(bond->dev, "Removing slave %s\n", dev->name); in bond_option_slaves_set()
1327 ret = bond_release(bond->dev, dev); in bond_option_slaves_set()
1338 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n"); in bond_option_slaves_set()
1343 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, in bond_option_tlb_dynamic_lb_set() argument
1346 netdev_info(bond->dev, "Setting dynamic-lb to %s (%llu)\n", in bond_option_tlb_dynamic_lb_set()
1348 bond->params.tlb_dynamic_lb = newval->value; in bond_option_tlb_dynamic_lb_set()