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,
73 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
75 static int bond_option_ad_actor_system_set(struct bonding *bond,
77 static int bond_option_ad_user_port_key_set(struct bonding *bond,
568 static int bond_opt_check_deps(struct bonding *bond, in bond_opt_check_deps() argument
571 struct bond_params *params = &bond->params; in bond_opt_check_deps()
575 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond)) in bond_opt_check_deps()
577 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP)) in bond_opt_check_deps()
583 static void bond_opt_dep_print(struct bonding *bond, in bond_opt_dep_print() argument
589 params = &bond->params; in bond_opt_dep_print()
592 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n", in bond_opt_dep_print()
596 static void bond_opt_error_interpret(struct bonding *bond, in bond_opt_error_interpret() argument
611 netdev_err(bond->dev, "option %s: invalid value (%s)\n", in bond_opt_error_interpret()
614 netdev_err(bond->dev, "option %s: invalid value (%llu)\n", in bond_opt_error_interpret()
622 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n", in bond_opt_error_interpret()
626 bond_opt_dep_print(bond, opt); in bond_opt_error_interpret()
629 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n", in bond_opt_error_interpret()
633 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n", in bond_opt_error_interpret()
651 int __bond_opt_set(struct bonding *bond, in __bond_opt_set() argument
663 ret = bond_opt_check_deps(bond, opt); in __bond_opt_set()
671 ret = opt->set(bond, retval); in __bond_opt_set()
674 bond_opt_error_interpret(bond, opt, ret, val); in __bond_opt_set()
675 else if (bond->dev->reg_state == NETREG_REGISTERED) in __bond_opt_set()
676 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev); in __bond_opt_set()
690 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf) in bond_opt_tryset_rtnl() argument
698 ret = __bond_opt_set(bond, option, &optval); in bond_opt_tryset_rtnl()
719 static int bond_option_mode_set(struct bonding *bond, in bond_option_mode_set() argument
722 if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) { in bond_option_mode_set()
723 netdev_info(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n", in bond_option_mode_set()
726 bond->params.arp_interval = 0; in bond_option_mode_set()
728 bond->params.miimon = BOND_DEFAULT_MIIMON; in bond_option_mode_set()
729 netdev_info(bond->dev, "Setting MII monitoring interval to %d\n", in bond_option_mode_set()
730 bond->params.miimon); in bond_option_mode_set()
734 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_mode_set()
735 bond->params.mode = newval->value; in bond_option_mode_set()
740 static int bond_option_active_slave_set(struct bonding *bond, in bond_option_active_slave_set() argument
751 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_active_slave_set()
758 netdev_err(bond->dev, "Device %s is not bonding slave\n", in bond_option_active_slave_set()
763 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) { in bond_option_active_slave_set()
764 netdev_err(bond->dev, "Device %s is not our slave\n", in bond_option_active_slave_set()
773 netdev_info(bond->dev, "Clearing current active slave\n"); in bond_option_active_slave_set()
774 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in bond_option_active_slave_set()
775 bond_select_active_slave(bond); in bond_option_active_slave_set()
777 struct slave *old_active = rtnl_dereference(bond->curr_active_slave); in bond_option_active_slave_set()
784 netdev_info(bond->dev, "%s is already the current active slave\n", in bond_option_active_slave_set()
789 netdev_info(bond->dev, "Setting %s as active slave\n", in bond_option_active_slave_set()
791 bond_change_active_slave(bond, new_active); in bond_option_active_slave_set()
793 … 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()
809 static int bond_option_miimon_set(struct bonding *bond, in bond_option_miimon_set() argument
812 netdev_info(bond->dev, "Setting MII monitoring interval to %llu\n", in bond_option_miimon_set()
814 bond->params.miimon = newval->value; in bond_option_miimon_set()
815 if (bond->params.updelay) in bond_option_miimon_set()
816 …netdev_info(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\… in bond_option_miimon_set()
817 bond->params.updelay * bond->params.miimon); in bond_option_miimon_set()
818 if (bond->params.downdelay) in bond_option_miimon_set()
819 …netdev_info(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon valu… in bond_option_miimon_set()
820 bond->params.downdelay * bond->params.miimon); in bond_option_miimon_set()
821 if (newval->value && bond->params.arp_interval) { in bond_option_miimon_set()
822 …netdev_info(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitori… in bond_option_miimon_set()
823 bond->params.arp_interval = 0; in bond_option_miimon_set()
824 if (bond->params.arp_validate) in bond_option_miimon_set()
825 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_miimon_set()
827 if (bond->dev->flags & IFF_UP) { in bond_option_miimon_set()
834 cancel_delayed_work_sync(&bond->mii_work); in bond_option_miimon_set()
836 cancel_delayed_work_sync(&bond->arp_work); in bond_option_miimon_set()
837 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_option_miimon_set()
848 static int bond_option_updelay_set(struct bonding *bond, in bond_option_updelay_set() argument
853 if (!bond->params.miimon) { in bond_option_updelay_set()
854 netdev_err(bond->dev, "Unable to set up delay as MII monitoring is disabled\n"); in bond_option_updelay_set()
857 if ((value % bond->params.miimon) != 0) { in bond_option_updelay_set()
858 …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()
859 value, bond->params.miimon, in bond_option_updelay_set()
860 (value / bond->params.miimon) * in bond_option_updelay_set()
861 bond->params.miimon); in bond_option_updelay_set()
863 bond->params.updelay = value / bond->params.miimon; in bond_option_updelay_set()
864 netdev_info(bond->dev, "Setting up delay to %d\n", in bond_option_updelay_set()
865 bond->params.updelay * bond->params.miimon); in bond_option_updelay_set()
870 static int bond_option_downdelay_set(struct bonding *bond, in bond_option_downdelay_set() argument
875 if (!bond->params.miimon) { in bond_option_downdelay_set()
876 netdev_err(bond->dev, "Unable to set down delay as MII monitoring is disabled\n"); in bond_option_downdelay_set()
879 if ((value % bond->params.miimon) != 0) { in bond_option_downdelay_set()
880 …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()
881 value, bond->params.miimon, in bond_option_downdelay_set()
882 (value / bond->params.miimon) * in bond_option_downdelay_set()
883 bond->params.miimon); in bond_option_downdelay_set()
885 bond->params.downdelay = value / bond->params.miimon; in bond_option_downdelay_set()
886 netdev_info(bond->dev, "Setting down delay to %d\n", in bond_option_downdelay_set()
887 bond->params.downdelay * bond->params.miimon); in bond_option_downdelay_set()
892 static int bond_option_use_carrier_set(struct bonding *bond, in bond_option_use_carrier_set() argument
895 netdev_info(bond->dev, "Setting use_carrier to %llu\n", in bond_option_use_carrier_set()
897 bond->params.use_carrier = newval->value; in bond_option_use_carrier_set()
906 static int bond_option_arp_interval_set(struct bonding *bond, in bond_option_arp_interval_set() argument
909 netdev_info(bond->dev, "Setting ARP monitoring interval to %llu\n", in bond_option_arp_interval_set()
911 bond->params.arp_interval = newval->value; in bond_option_arp_interval_set()
913 if (bond->params.miimon) { in bond_option_arp_interval_set()
914 …netdev_info(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitorin… in bond_option_arp_interval_set()
915 bond->params.miimon = 0; in bond_option_arp_interval_set()
917 if (!bond->params.arp_targets[0]) in bond_option_arp_interval_set()
918 …netdev_info(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n"); in bond_option_arp_interval_set()
920 if (bond->dev->flags & IFF_UP) { in bond_option_arp_interval_set()
927 if (bond->params.arp_validate) in bond_option_arp_interval_set()
928 bond->recv_probe = NULL; in bond_option_arp_interval_set()
929 cancel_delayed_work_sync(&bond->arp_work); in bond_option_arp_interval_set()
932 bond->recv_probe = bond_arp_rcv; in bond_option_arp_interval_set()
933 cancel_delayed_work_sync(&bond->mii_work); in bond_option_arp_interval_set()
934 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_option_arp_interval_set()
941 static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, in _bond_options_arp_ip_target_set() argument
945 __be32 *targets = bond->params.arp_targets; in _bond_options_arp_ip_target_set()
950 bond_for_each_slave(bond, slave, iter) in _bond_options_arp_ip_target_set()
956 static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in _bond_option_arp_ip_target_add() argument
958 __be32 *targets = bond->params.arp_targets; in _bond_option_arp_ip_target_add()
962 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n", in _bond_option_arp_ip_target_add()
968 netdev_err(bond->dev, "ARP target %pI4 is already present\n", in _bond_option_arp_ip_target_add()
975 netdev_err(bond->dev, "ARP target table is full!\n"); in _bond_option_arp_ip_target_add()
979 netdev_info(bond->dev, "Adding ARP target %pI4\n", &target); in _bond_option_arp_ip_target_add()
981 _bond_options_arp_ip_target_set(bond, ind, target, jiffies); in _bond_option_arp_ip_target_add()
986 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_add() argument
988 return _bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_target_add()
991 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_rem() argument
993 __be32 *targets = bond->params.arp_targets; in bond_option_arp_ip_target_rem()
1000 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n", in bond_option_arp_ip_target_rem()
1007 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n", in bond_option_arp_ip_target_rem()
1012 if (ind == 0 && !targets[1] && bond->params.arp_interval) in bond_option_arp_ip_target_rem()
1013 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n"); in bond_option_arp_ip_target_rem()
1015 netdev_info(bond->dev, "Removing ARP target %pI4\n", &target); in bond_option_arp_ip_target_rem()
1017 bond_for_each_slave(bond, slave, iter) { in bond_option_arp_ip_target_rem()
1030 void bond_option_arp_ip_targets_clear(struct bonding *bond) in bond_option_arp_ip_targets_clear() argument
1035 _bond_options_arp_ip_target_set(bond, i, 0, 0); in bond_option_arp_ip_targets_clear()
1038 static int bond_option_arp_ip_targets_set(struct bonding *bond, in bond_option_arp_ip_targets_set() argument
1046 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n", in bond_option_arp_ip_targets_set()
1051 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1053 ret = bond_option_arp_ip_target_rem(bond, target); in bond_option_arp_ip_targets_set()
1055 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n"); in bond_option_arp_ip_targets_set()
1058 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1064 static int bond_option_arp_validate_set(struct bonding *bond, in bond_option_arp_validate_set() argument
1067 netdev_info(bond->dev, "Setting arp_validate to %s (%llu)\n", in bond_option_arp_validate_set()
1070 if (bond->dev->flags & IFF_UP) { in bond_option_arp_validate_set()
1072 bond->recv_probe = NULL; in bond_option_arp_validate_set()
1073 else if (bond->params.arp_interval) in bond_option_arp_validate_set()
1074 bond->recv_probe = bond_arp_rcv; in bond_option_arp_validate_set()
1076 bond->params.arp_validate = newval->value; in bond_option_arp_validate_set()
1081 static int bond_option_arp_all_targets_set(struct bonding *bond, in bond_option_arp_all_targets_set() argument
1084 netdev_info(bond->dev, "Setting arp_all_targets to %s (%llu)\n", in bond_option_arp_all_targets_set()
1086 bond->params.arp_all_targets = newval->value; in bond_option_arp_all_targets_set()
1091 static int bond_option_primary_set(struct bonding *bond, in bond_option_primary_set() argument
1105 netdev_info(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1106 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1107 memset(bond->params.primary, 0, sizeof(bond->params.primary)); in bond_option_primary_set()
1108 bond_select_active_slave(bond); in bond_option_primary_set()
1112 bond_for_each_slave(bond, slave, iter) { in bond_option_primary_set()
1114 netdev_info(bond->dev, "Setting %s as primary slave\n", in bond_option_primary_set()
1116 rcu_assign_pointer(bond->primary_slave, slave); in bond_option_primary_set()
1117 strcpy(bond->params.primary, slave->dev->name); in bond_option_primary_set()
1118 bond_select_active_slave(bond); in bond_option_primary_set()
1123 if (rtnl_dereference(bond->primary_slave)) { in bond_option_primary_set()
1124 netdev_info(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1125 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1126 bond_select_active_slave(bond); in bond_option_primary_set()
1128 strncpy(bond->params.primary, primary, IFNAMSIZ); in bond_option_primary_set()
1129 bond->params.primary[IFNAMSIZ - 1] = 0; in bond_option_primary_set()
1131 netdev_info(bond->dev, "Recording %s as primary, but it has not been enslaved to %s yet\n", in bond_option_primary_set()
1132 primary, bond->dev->name); in bond_option_primary_set()
1140 static int bond_option_primary_reselect_set(struct bonding *bond, in bond_option_primary_reselect_set() argument
1143 netdev_info(bond->dev, "Setting primary_reselect to %s (%llu)\n", in bond_option_primary_reselect_set()
1145 bond->params.primary_reselect = newval->value; in bond_option_primary_reselect_set()
1148 bond_select_active_slave(bond); in bond_option_primary_reselect_set()
1154 static int bond_option_fail_over_mac_set(struct bonding *bond, in bond_option_fail_over_mac_set() argument
1157 netdev_info(bond->dev, "Setting fail_over_mac to %s (%llu)\n", in bond_option_fail_over_mac_set()
1159 bond->params.fail_over_mac = newval->value; in bond_option_fail_over_mac_set()
1164 static int bond_option_xmit_hash_policy_set(struct bonding *bond, in bond_option_xmit_hash_policy_set() argument
1167 netdev_info(bond->dev, "Setting xmit hash policy to %s (%llu)\n", in bond_option_xmit_hash_policy_set()
1169 bond->params.xmit_policy = newval->value; in bond_option_xmit_hash_policy_set()
1174 static int bond_option_resend_igmp_set(struct bonding *bond, in bond_option_resend_igmp_set() argument
1177 netdev_info(bond->dev, "Setting resend_igmp to %llu\n", in bond_option_resend_igmp_set()
1179 bond->params.resend_igmp = newval->value; in bond_option_resend_igmp_set()
1184 static int bond_option_num_peer_notif_set(struct bonding *bond, in bond_option_num_peer_notif_set() argument
1187 bond->params.num_peer_notif = newval->value; in bond_option_num_peer_notif_set()
1192 static int bond_option_all_slaves_active_set(struct bonding *bond, in bond_option_all_slaves_active_set() argument
1198 if (newval->value == bond->params.all_slaves_active) in bond_option_all_slaves_active_set()
1200 bond->params.all_slaves_active = newval->value; in bond_option_all_slaves_active_set()
1201 bond_for_each_slave(bond, slave, iter) { in bond_option_all_slaves_active_set()
1213 static int bond_option_min_links_set(struct bonding *bond, in bond_option_min_links_set() argument
1216 netdev_info(bond->dev, "Setting min links value to %llu\n", in bond_option_min_links_set()
1218 bond->params.min_links = newval->value; in bond_option_min_links_set()
1219 bond_set_carrier(bond); in bond_option_min_links_set()
1224 static int bond_option_lp_interval_set(struct bonding *bond, in bond_option_lp_interval_set() argument
1227 bond->params.lp_interval = newval->value; in bond_option_lp_interval_set()
1232 static int bond_option_pps_set(struct bonding *bond, in bond_option_pps_set() argument
1235 bond->params.packets_per_slave = newval->value; in bond_option_pps_set()
1237 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1243 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1250 static int bond_option_lacp_rate_set(struct bonding *bond, in bond_option_lacp_rate_set() argument
1253 netdev_info(bond->dev, "Setting LACP rate to %s (%llu)\n", in bond_option_lacp_rate_set()
1255 bond->params.lacp_fast = newval->value; in bond_option_lacp_rate_set()
1256 bond_3ad_update_lacp_rate(bond); in bond_option_lacp_rate_set()
1261 static int bond_option_ad_select_set(struct bonding *bond, in bond_option_ad_select_set() argument
1264 netdev_info(bond->dev, "Setting ad_select to %s (%llu)\n", in bond_option_ad_select_set()
1266 bond->params.ad_select = newval->value; in bond_option_ad_select_set()
1271 static int bond_option_queue_id_set(struct bonding *bond, in bond_option_queue_id_set() argument
1295 qid > bond->dev->real_num_tx_queues) in bond_option_queue_id_set()
1299 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string); in bond_option_queue_id_set()
1305 bond_for_each_slave(bond, slave, iter) { in bond_option_queue_id_set()
1326 netdev_info(bond->dev, "invalid input for queue_id set\n"); in bond_option_queue_id_set()
1332 static int bond_option_slaves_set(struct bonding *bond, in bond_option_slaves_set() argument
1346 dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_slaves_set()
1348 netdev_info(bond->dev, "interface %s does not exist!\n", in bond_option_slaves_set()
1356 netdev_info(bond->dev, "Adding slave %s\n", dev->name); in bond_option_slaves_set()
1357 ret = bond_enslave(bond->dev, dev); in bond_option_slaves_set()
1361 netdev_info(bond->dev, "Removing slave %s\n", dev->name); in bond_option_slaves_set()
1362 ret = bond_release(bond->dev, dev); in bond_option_slaves_set()
1373 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n"); in bond_option_slaves_set()
1378 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, in bond_option_tlb_dynamic_lb_set() argument
1381 netdev_info(bond->dev, "Setting dynamic-lb to %s (%llu)\n", in bond_option_tlb_dynamic_lb_set()
1383 bond->params.tlb_dynamic_lb = newval->value; in bond_option_tlb_dynamic_lb_set()
1388 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond, in bond_option_ad_actor_sys_prio_set() argument
1391 netdev_info(bond->dev, "Setting ad_actor_sys_prio to %llu\n", in bond_option_ad_actor_sys_prio_set()
1394 bond->params.ad_actor_sys_prio = newval->value; in bond_option_ad_actor_sys_prio_set()
1398 static int bond_option_ad_actor_system_set(struct bonding *bond, in bond_option_ad_actor_system_set() argument
1419 netdev_info(bond->dev, "Setting ad_actor_system to %pM\n", mac); in bond_option_ad_actor_system_set()
1420 ether_addr_copy(bond->params.ad_actor_system, mac); in bond_option_ad_actor_system_set()
1424 netdev_err(bond->dev, "Invalid MAC address.\n"); in bond_option_ad_actor_system_set()
1428 static int bond_option_ad_user_port_key_set(struct bonding *bond, in bond_option_ad_user_port_key_set() argument
1431 netdev_info(bond->dev, "Setting ad_user_port_key to %llu\n", in bond_option_ad_user_port_key_set()
1434 bond->params.ad_user_port_key = newval->value; in bond_option_ad_user_port_key_set()