Lines Matching defs:bond

3  * drivers/net/bond/bond_options.c - bonding options
19 static int bond_option_active_slave_set(struct bonding *bond,
21 static int bond_option_miimon_set(struct bonding *bond,
23 static int bond_option_updelay_set(struct bonding *bond,
25 static int bond_option_downdelay_set(struct bonding *bond,
27 static int bond_option_peer_notif_delay_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,
211 .desc = "bond device mode",
573 /* Check opt's dependencies against bond mode and currently set options */
574 static int bond_opt_check_deps(struct bonding *bond,
577 struct bond_params *params = &bond->params;
581 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond))
583 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP))
589 static void bond_opt_dep_print(struct bonding *bond,
595 params = &bond->params;
598 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n",
602 static void bond_opt_error_interpret(struct bonding *bond,
617 netdev_err(bond->dev, "option %s: invalid value (%s)\n",
620 netdev_err(bond->dev, "option %s: invalid value (%llu)\n",
628 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n",
632 bond_opt_dep_print(bond, opt);
635 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n",
639 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n",
649 * @bond: target bond device
653 * This function is used to change the bond's option value, it can be
657 int __bond_opt_set(struct bonding *bond,
669 ret = bond_opt_check_deps(bond, opt);
677 ret = opt->set(bond, retval);
680 bond_opt_error_interpret(bond, opt, ret, val);
686 * @bond: target bond device
690 * This function is used to change the bond's option value and trigger
695 int __bond_opt_set_notify(struct bonding *bond,
702 ret = __bond_opt_set(bond, option, val);
704 if (!ret && (bond->dev->reg_state == NETREG_REGISTERED))
705 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev);
712 * @bond: target bond device
719 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
727 ret = __bond_opt_set_notify(bond, option, &optval);
761 static int bond_option_mode_set(struct bonding *bond,
765 if (bond->params.arp_interval) {
766 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n",
769 bond->params.arp_interval = 0;
772 if (!bond->params.miimon) {
774 bond->params.miimon = BOND_DEFAULT_MIIMON;
775 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n",
776 bond->params.miimon);
781 bond->params.tlb_dynamic_lb = 1;
783 if (bond->dev->reg_state == NETREG_REGISTERED)
784 bond_set_xfrm_features(bond->dev, newval->value);
787 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
788 bond->params.mode = newval->value;
793 static int bond_option_active_slave_set(struct bonding *bond,
804 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname);
811 slave_err(bond->dev, slave_dev, "Device is not bonding slave\n");
815 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) {
816 slave_err(bond->dev, slave_dev, "Device is not our slave\n");
824 netdev_dbg(bond->dev, "Clearing current active slave\n");
825 RCU_INIT_POINTER(bond->curr_active_slave, NULL);
826 bond_select_active_slave(bond);
828 struct slave *old_active = rtnl_dereference(bond->curr_active_slave);
835 slave_dbg(bond->dev, new_active->dev, "is already the current active slave\n");
839 slave_dbg(bond->dev, new_active->dev, "Setting as active slave\n");
840 bond_change_active_slave(bond, new_active);
842 slave_err(bond->dev, new_active->dev, "Could not set as active slave; either %s is down or the link is down\n",
857 static int bond_option_miimon_set(struct bonding *bond,
860 netdev_dbg(bond->dev, "Setting MII monitoring interval to %llu\n",
862 bond->params.miimon = newval->value;
863 if (bond->params.updelay)
864 netdev_dbg(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n",
865 bond->params.updelay * bond->params.miimon);
866 if (bond->params.downdelay)
867 netdev_dbg(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value\n",
868 bond->params.downdelay * bond->params.miimon);
869 if (bond->params.peer_notif_delay)
870 netdev_dbg(bond->dev, "Note: Updating peer_notif_delay (to %d) since it is a multiple of the miimon value\n",
871 bond->params.peer_notif_delay * bond->params.miimon);
872 if (newval->value && bond->params.arp_interval) {
873 netdev_dbg(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitoring...\n");
874 bond->params.arp_interval = 0;
875 if (bond->params.arp_validate)
876 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
878 if (bond->dev->flags & IFF_UP) {
885 cancel_delayed_work_sync(&bond->mii_work);
887 cancel_delayed_work_sync(&bond->arp_work);
888 queue_delayed_work(bond->wq, &bond->mii_work, 0);
899 static int _bond_option_delay_set(struct bonding *bond,
906 if (!bond->params.miimon) {
907 netdev_err(bond->dev, "Unable to set %s as MII monitoring is disabled\n",
911 if ((value % bond->params.miimon) != 0) {
912 netdev_warn(bond->dev,
915 value, bond->params.miimon,
916 (value / bond->params.miimon) *
917 bond->params.miimon);
919 *target = value / bond->params.miimon;
920 netdev_dbg(bond->dev, "Setting %s to %d\n",
922 *target * bond->params.miimon);
927 static int bond_option_updelay_set(struct bonding *bond,
930 return _bond_option_delay_set(bond, newval, "up delay",
931 &bond->params.updelay);
934 static int bond_option_downdelay_set(struct bonding *bond,
937 return _bond_option_delay_set(bond, newval, "down delay",
938 &bond->params.downdelay);
941 static int bond_option_peer_notif_delay_set(struct bonding *bond,
944 int ret = _bond_option_delay_set(bond, newval,
946 &bond->params.peer_notif_delay);
950 static int bond_option_use_carrier_set(struct bonding *bond,
953 netdev_dbg(bond->dev, "Setting use_carrier to %llu\n",
955 bond->params.use_carrier = newval->value;
964 static int bond_option_arp_interval_set(struct bonding *bond,
967 netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n",
969 bond->params.arp_interval = newval->value;
971 if (bond->params.miimon) {
972 netdev_dbg(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring\n");
973 bond->params.miimon = 0;
975 if (!bond->params.arp_targets[0])
976 netdev_dbg(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n");
978 if (bond->dev->flags & IFF_UP) {
985 if (bond->params.arp_validate)
986 bond->recv_probe = NULL;
987 cancel_delayed_work_sync(&bond->arp_work);
990 bond->recv_probe = bond_arp_rcv;
991 cancel_delayed_work_sync(&bond->mii_work);
992 queue_delayed_work(bond->wq, &bond->arp_work, 0);
999 static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot,
1003 __be32 *targets = bond->params.arp_targets;
1008 bond_for_each_slave(bond, slave, iter)
1014 static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
1016 __be32 *targets = bond->params.arp_targets;
1020 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n",
1026 netdev_err(bond->dev, "ARP target %pI4 is already present\n",
1033 netdev_err(bond->dev, "ARP target table is full!\n");
1037 netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target);
1039 _bond_options_arp_ip_target_set(bond, ind, target, jiffies);
1044 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
1046 return _bond_option_arp_ip_target_add(bond, target);
1049 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
1051 __be32 *targets = bond->params.arp_targets;
1058 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n",
1065 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n",
1070 if (ind == 0 && !targets[1] && bond->params.arp_interval)
1071 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n");
1073 netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target);
1075 bond_for_each_slave(bond, slave, iter) {
1088 void bond_option_arp_ip_targets_clear(struct bonding *bond)
1093 _bond_options_arp_ip_target_set(bond, i, 0, 0);
1096 static int bond_option_arp_ip_targets_set(struct bonding *bond,
1104 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n",
1109 ret = bond_option_arp_ip_target_add(bond, target);
1111 ret = bond_option_arp_ip_target_rem(bond, target);
1113 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n");
1116 ret = bond_option_arp_ip_target_add(bond, target);
1122 static int bond_option_arp_validate_set(struct bonding *bond,
1125 netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n",
1127 bond->params.arp_validate = newval->value;
1132 static int bond_option_arp_all_targets_set(struct bonding *bond,
1135 netdev_dbg(bond->dev, "Setting arp_all_targets to %s (%llu)\n",
1137 bond->params.arp_all_targets = newval->value;
1142 static int bond_option_primary_set(struct bonding *bond,
1156 netdev_dbg(bond->dev, "Setting primary slave to None\n");
1157 RCU_INIT_POINTER(bond->primary_slave, NULL);
1158 memset(bond->params.primary, 0, sizeof(bond->params.primary));
1159 bond_select_active_slave(bond);
1163 bond_for_each_slave(bond, slave, iter) {
1165 slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n");
1166 rcu_assign_pointer(bond->primary_slave, slave);
1167 strcpy(bond->params.primary, slave->dev->name);
1168 bond->force_primary = true;
1169 bond_select_active_slave(bond);
1174 if (rtnl_dereference(bond->primary_slave)) {
1175 netdev_dbg(bond->dev, "Setting primary slave to None\n");
1176 RCU_INIT_POINTER(bond->primary_slave, NULL);
1177 bond_select_active_slave(bond);
1179 strncpy(bond->params.primary, primary, IFNAMSIZ);
1180 bond->params.primary[IFNAMSIZ - 1] = 0;
1182 netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n",
1191 static int bond_option_primary_reselect_set(struct bonding *bond,
1194 netdev_dbg(bond->dev, "Setting primary_reselect to %s (%llu)\n",
1196 bond->params.primary_reselect = newval->value;
1199 bond_select_active_slave(bond);
1205 static int bond_option_fail_over_mac_set(struct bonding *bond,
1208 netdev_dbg(bond->dev, "Setting fail_over_mac to %s (%llu)\n",
1210 bond->params.fail_over_mac = newval->value;
1215 static int bond_option_xmit_hash_policy_set(struct bonding *bond,
1218 netdev_dbg(bond->dev, "Setting xmit hash policy to %s (%llu)\n",
1220 bond->params.xmit_policy = newval->value;
1225 static int bond_option_resend_igmp_set(struct bonding *bond,
1228 netdev_dbg(bond->dev, "Setting resend_igmp to %llu\n",
1230 bond->params.resend_igmp = newval->value;
1235 static int bond_option_num_peer_notif_set(struct bonding *bond,
1238 bond->params.num_peer_notif = newval->value;
1243 static int bond_option_all_slaves_active_set(struct bonding *bond,
1249 if (newval->value == bond->params.all_slaves_active)
1251 bond->params.all_slaves_active = newval->value;
1252 bond_for_each_slave(bond, slave, iter) {
1264 static int bond_option_min_links_set(struct bonding *bond,
1267 netdev_dbg(bond->dev, "Setting min links value to %llu\n",
1269 bond->params.min_links = newval->value;
1270 bond_set_carrier(bond);
1275 static int bond_option_lp_interval_set(struct bonding *bond,
1278 bond->params.lp_interval = newval->value;
1283 static int bond_option_pps_set(struct bonding *bond,
1286 netdev_dbg(bond->dev, "Setting packets per slave to %llu\n",
1288 bond->params.packets_per_slave = newval->value;
1290 bond->params.reciprocal_packets_per_slave =
1296 bond->params.reciprocal_packets_per_slave =
1303 static int bond_option_lacp_rate_set(struct bonding *bond,
1306 netdev_dbg(bond->dev, "Setting LACP rate to %s (%llu)\n",
1308 bond->params.lacp_fast = newval->value;
1309 bond_3ad_update_lacp_rate(bond);
1314 static int bond_option_ad_select_set(struct bonding *bond,
1317 netdev_dbg(bond->dev, "Setting ad_select to %s (%llu)\n",
1319 bond->params.ad_select = newval->value;
1324 static int bond_option_queue_id_set(struct bonding *bond,
1348 qid > bond->dev->real_num_tx_queues)
1352 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string);
1358 bond_for_each_slave(bond, slave, iter) {
1379 netdev_dbg(bond->dev, "invalid input for queue_id set\n");
1385 static int bond_option_slaves_set(struct bonding *bond,
1400 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
1402 netdev_dbg(bond->dev, "interface %s does not exist!\n",
1410 slave_dbg(bond->dev, dev, "Enslaving interface\n");
1411 ret = bond_enslave(bond->dev, dev, NULL);
1415 slave_dbg(bond->dev, dev, "Releasing interface\n");
1416 ret = bond_release(bond->dev, dev);
1428 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n");
1433 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
1436 netdev_dbg(bond->dev, "Setting dynamic-lb to %s (%llu)\n",
1438 bond->params.tlb_dynamic_lb = newval->value;
1443 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
1446 netdev_dbg(bond->dev, "Setting ad_actor_sys_prio to %llu\n",
1449 bond->params.ad_actor_sys_prio = newval->value;
1450 bond_3ad_update_ad_actor_settings(bond);
1455 static int bond_option_ad_actor_system_set(struct bonding *bond,
1472 netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac);
1473 ether_addr_copy(bond->params.ad_actor_system, mac);
1474 bond_3ad_update_ad_actor_settings(bond);
1479 netdev_err(bond->dev, "Invalid ad_actor_system MAC address.\n");
1483 static int bond_option_ad_user_port_key_set(struct bonding *bond,
1486 netdev_dbg(bond->dev, "Setting ad_user_port_key to %llu\n",
1489 bond->params.ad_user_port_key = newval->value;