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_ns_ip6_targets_set(struct bonding *bond,
39 static int bond_option_arp_validate_set(struct bonding *bond,
41 static int bond_option_arp_all_targets_set(struct bonding *bond,
43 static int bond_option_prio_set(struct bonding *bond,
45 static int bond_option_primary_set(struct bonding *bond,
47 static int bond_option_primary_reselect_set(struct bonding *bond,
49 static int bond_option_fail_over_mac_set(struct bonding *bond,
51 static int bond_option_xmit_hash_policy_set(struct bonding *bond,
53 static int bond_option_resend_igmp_set(struct bonding *bond,
55 static int bond_option_num_peer_notif_set(struct bonding *bond,
57 static int bond_option_all_slaves_active_set(struct bonding *bond,
59 static int bond_option_min_links_set(struct bonding *bond,
61 static int bond_option_lp_interval_set(struct bonding *bond,
63 static int bond_option_pps_set(struct bonding *bond,
65 static int bond_option_lacp_active_set(struct bonding *bond,
67 static int bond_option_lacp_rate_set(struct bonding *bond,
69 static int bond_option_ad_select_set(struct bonding *bond,
71 static int bond_option_queue_id_set(struct bonding *bond,
73 static int bond_option_mode_set(struct bonding *bond,
75 static int bond_option_slaves_set(struct bonding *bond,
77 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
79 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
81 static int bond_option_ad_actor_system_set(struct bonding *bond,
83 static int bond_option_ad_user_port_key_set(struct bonding *bond,
85 static int bond_option_missed_max_set(struct bonding *bond,
239 .desc = "bond device mode",
636 /* Check opt's dependencies against bond mode and currently set options */
637 static int bond_opt_check_deps(struct bonding *bond,
640 struct bond_params *params = &bond->params;
644 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond))
646 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP))
652 static void bond_opt_dep_print(struct bonding *bond,
660 params = &bond->params;
663 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n",
670 static void bond_opt_error_interpret(struct bonding *bond,
688 netdev_err(bond->dev, "option %s: invalid value (%s)\n",
691 netdev_err(bond->dev, "option %s: invalid value (%llu)\n",
699 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n",
703 bond_opt_dep_print(bond, opt, bad_attr, extack);
707 "unable to set option because the bond device has slaves");
708 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n",
713 "unable to set option because the bond is up");
714 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n",
722 netdev_err(bond->dev, "option %s: interface %s does not exist!\n",
735 * @bond: target bond device
742 * This function is used to change the bond's option value, it can be
746 int __bond_opt_set(struct bonding *bond,
759 ret = bond_opt_check_deps(bond, opt);
767 ret = opt->set(bond, retval);
770 bond_opt_error_interpret(bond, opt, ret, val, bad_attr, extack);
776 * @bond: target bond device
780 * This function is used to change the bond's option value and trigger
785 int __bond_opt_set_notify(struct bonding *bond,
792 ret = __bond_opt_set(bond, option, val, NULL, NULL);
794 if (!ret && (bond->dev->reg_state == NETREG_REGISTERED))
795 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev);
802 * @bond: target bond device
809 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
817 ret = __bond_opt_set_notify(bond, option, &optval);
838 static bool bond_set_xfrm_features(struct bonding *bond)
843 if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
844 bond->dev->wanted_features |= BOND_XFRM_FEATURES;
846 bond->dev->wanted_features &= ~BOND_XFRM_FEATURES;
851 static int bond_option_mode_set(struct bonding *bond,
855 if (bond->params.arp_interval) {
856 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n",
859 bond->params.arp_interval = 0;
862 if (!bond->params.miimon) {
864 bond->params.miimon = BOND_DEFAULT_MIIMON;
865 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n",
866 bond->params.miimon);
871 bond->params.tlb_dynamic_lb = 1;
874 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
875 bond->params.mode = newval->value;
877 if (bond->dev->reg_state == NETREG_REGISTERED) {
880 update |= bond_set_xfrm_features(bond);
883 netdev_update_features(bond->dev);
886 bond_xdp_set_features(bond->dev);
891 static int bond_option_active_slave_set(struct bonding *bond,
902 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname);
909 slave_err(bond->dev, slave_dev, "Device is not bonding slave\n");
913 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) {
914 slave_err(bond->dev, slave_dev, "Device is not our slave\n");
922 netdev_dbg(bond->dev, "Clearing current active slave\n");
923 RCU_INIT_POINTER(bond->curr_active_slave, NULL);
924 bond_select_active_slave(bond);
926 struct slave *old_active = rtnl_dereference(bond->curr_active_slave);
933 slave_dbg(bond->dev, new_active->dev, "is already the current active slave\n");
937 slave_dbg(bond->dev, new_active->dev, "Setting as active slave\n");
938 bond_change_active_slave(bond, new_active);
940 slave_err(bond->dev, new_active->dev, "Could not set as active slave; either %s is down or the link is down\n",
955 static int bond_option_miimon_set(struct bonding *bond,
958 netdev_dbg(bond->dev, "Setting MII monitoring interval to %llu\n",
960 bond->params.miimon = newval->value;
961 if (bond->params.updelay)
962 netdev_dbg(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n",
963 bond->params.updelay * bond->params.miimon);
964 if (bond->params.downdelay)
965 netdev_dbg(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value\n",
966 bond->params.downdelay * bond->params.miimon);
967 if (bond->params.peer_notif_delay)
968 netdev_dbg(bond->dev, "Note: Updating peer_notif_delay (to %d) since it is a multiple of the miimon value\n",
969 bond->params.peer_notif_delay * bond->params.miimon);
970 if (newval->value && bond->params.arp_interval) {
971 netdev_dbg(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitoring...\n");
972 bond->params.arp_interval = 0;
973 if (bond->params.arp_validate)
974 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
976 if (bond->dev->flags & IFF_UP) {
983 cancel_delayed_work_sync(&bond->mii_work);
985 cancel_delayed_work_sync(&bond->arp_work);
986 queue_delayed_work(bond->wq, &bond->mii_work, 0);
997 static int _bond_option_delay_set(struct bonding *bond,
1004 if (!bond->params.miimon) {
1005 netdev_err(bond->dev, "Unable to set %s as MII monitoring is disabled\n",
1009 if ((value % bond->params.miimon) != 0) {
1010 netdev_warn(bond->dev,
1013 value, bond->params.miimon,
1014 (value / bond->params.miimon) *
1015 bond->params.miimon);
1017 *target = value / bond->params.miimon;
1018 netdev_dbg(bond->dev, "Setting %s to %d\n",
1020 *target * bond->params.miimon);
1025 static int bond_option_updelay_set(struct bonding *bond,
1028 return _bond_option_delay_set(bond, newval, "up delay",
1029 &bond->params.updelay);
1032 static int bond_option_downdelay_set(struct bonding *bond,
1035 return _bond_option_delay_set(bond, newval, "down delay",
1036 &bond->params.downdelay);
1039 static int bond_option_peer_notif_delay_set(struct bonding *bond,
1042 int ret = _bond_option_delay_set(bond, newval,
1044 &bond->params.peer_notif_delay);
1048 static int bond_option_use_carrier_set(struct bonding *bond,
1051 netdev_dbg(bond->dev, "Setting use_carrier to %llu\n",
1053 bond->params.use_carrier = newval->value;
1062 static int bond_option_arp_interval_set(struct bonding *bond,
1065 netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n",
1067 bond->params.arp_interval = newval->value;
1069 if (bond->params.miimon) {
1070 netdev_dbg(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring\n");
1071 bond->params.miimon = 0;
1073 if (!bond->params.arp_targets[0])
1074 netdev_dbg(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n");
1076 if (bond->dev->flags & IFF_UP) {
1083 if (bond->params.arp_validate)
1084 bond->recv_probe = NULL;
1085 cancel_delayed_work_sync(&bond->arp_work);
1088 bond->recv_probe = bond_rcv_validate;
1089 cancel_delayed_work_sync(&bond->mii_work);
1090 queue_delayed_work(bond->wq, &bond->arp_work, 0);
1097 static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot,
1101 __be32 *targets = bond->params.arp_targets;
1106 bond_for_each_slave(bond, slave, iter)
1112 static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
1114 __be32 *targets = bond->params.arp_targets;
1118 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n",
1124 netdev_err(bond->dev, "ARP target %pI4 is already present\n",
1131 netdev_err(bond->dev, "ARP target table is full!\n");
1135 netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target);
1137 _bond_options_arp_ip_target_set(bond, ind, target, jiffies);
1142 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
1144 return _bond_option_arp_ip_target_add(bond, target);
1147 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
1149 __be32 *targets = bond->params.arp_targets;
1156 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n",
1163 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n",
1168 if (ind == 0 && !targets[1] && bond->params.arp_interval)
1169 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n");
1171 netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target);
1173 bond_for_each_slave(bond, slave, iter) {
1186 void bond_option_arp_ip_targets_clear(struct bonding *bond)
1191 _bond_options_arp_ip_target_set(bond, i, 0, 0);
1194 static int bond_option_arp_ip_targets_set(struct bonding *bond,
1202 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n",
1207 ret = bond_option_arp_ip_target_add(bond, target);
1209 ret = bond_option_arp_ip_target_rem(bond, target);
1211 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n");
1214 ret = bond_option_arp_ip_target_add(bond, target);
1221 static void _bond_options_ns_ip6_target_set(struct bonding *bond, int slot,
1225 struct in6_addr *targets = bond->params.ns_targets;
1230 bond_for_each_slave(bond, slave, iter)
1236 void bond_option_ns_ip6_targets_clear(struct bonding *bond)
1242 _bond_options_ns_ip6_target_set(bond, i, &addr_any, 0);
1245 static int bond_option_ns_ip6_targets_set(struct bonding *bond,
1249 struct in6_addr *targets = bond->params.ns_targets;
1254 netdev_err(bond->dev, "invalid NS target %pI6c specified for addition\n",
1260 netdev_err(bond->dev, "NS target %pI6c is already present\n",
1267 netdev_err(bond->dev, "NS target table is full!\n");
1271 netdev_dbg(bond->dev, "Adding NS target %pI6c\n", target);
1273 _bond_options_ns_ip6_target_set(bond, index, target, jiffies);
1278 static int bond_option_ns_ip6_targets_set(struct bonding *bond,
1285 static int bond_option_arp_validate_set(struct bonding *bond,
1288 netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n",
1290 bond->params.arp_validate = newval->value;
1295 static int bond_option_arp_all_targets_set(struct bonding *bond,
1298 netdev_dbg(bond->dev, "Setting arp_all_targets to %s (%llu)\n",
1300 bond->params.arp_all_targets = newval->value;
1305 static int bond_option_missed_max_set(struct bonding *bond,
1308 netdev_dbg(bond->dev, "Setting missed max to %s (%llu)\n",
1310 bond->params.missed_max = newval->value;
1315 static int bond_option_prio_set(struct bonding *bond,
1327 if (rtnl_dereference(bond->primary_slave))
1328 slave_warn(bond->dev, slave->dev,
1331 bond_select_active_slave(bond);
1336 static int bond_option_primary_set(struct bonding *bond,
1350 netdev_dbg(bond->dev, "Setting primary slave to None\n");
1351 RCU_INIT_POINTER(bond->primary_slave, NULL);
1352 memset(bond->params.primary, 0, sizeof(bond->params.primary));
1353 bond_select_active_slave(bond);
1357 bond_for_each_slave(bond, slave, iter) {
1359 slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n");
1360 rcu_assign_pointer(bond->primary_slave, slave);
1361 strcpy(bond->params.primary, slave->dev->name);
1362 bond->force_primary = true;
1363 bond_select_active_slave(bond);
1368 if (rtnl_dereference(bond->primary_slave)) {
1369 netdev_dbg(bond->dev, "Setting primary slave to None\n");
1370 RCU_INIT_POINTER(bond->primary_slave, NULL);
1371 bond_select_active_slave(bond);
1373 strscpy_pad(bond->params.primary, primary, IFNAMSIZ);
1375 netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n",
1384 static int bond_option_primary_reselect_set(struct bonding *bond,
1387 netdev_dbg(bond->dev, "Setting primary_reselect to %s (%llu)\n",
1389 bond->params.primary_reselect = newval->value;
1392 bond_select_active_slave(bond);
1398 static int bond_option_fail_over_mac_set(struct bonding *bond,
1401 netdev_dbg(bond->dev, "Setting fail_over_mac to %s (%llu)\n",
1403 bond->params.fail_over_mac = newval->value;
1408 static int bond_option_xmit_hash_policy_set(struct bonding *bond,
1411 netdev_dbg(bond->dev, "Setting xmit hash policy to %s (%llu)\n",
1413 bond->params.xmit_policy = newval->value;
1418 static int bond_option_resend_igmp_set(struct bonding *bond,
1421 netdev_dbg(bond->dev, "Setting resend_igmp to %llu\n",
1423 bond->params.resend_igmp = newval->value;
1428 static int bond_option_num_peer_notif_set(struct bonding *bond,
1431 bond->params.num_peer_notif = newval->value;
1436 static int bond_option_all_slaves_active_set(struct bonding *bond,
1442 if (newval->value == bond->params.all_slaves_active)
1444 bond->params.all_slaves_active = newval->value;
1445 bond_for_each_slave(bond, slave, iter) {
1457 static int bond_option_min_links_set(struct bonding *bond,
1460 netdev_dbg(bond->dev, "Setting min links value to %llu\n",
1462 bond->params.min_links = newval->value;
1463 bond_set_carrier(bond);
1468 static int bond_option_lp_interval_set(struct bonding *bond,
1471 bond->params.lp_interval = newval->value;
1476 static int bond_option_pps_set(struct bonding *bond,
1479 netdev_dbg(bond->dev, "Setting packets per slave to %llu\n",
1481 bond->params.packets_per_slave = newval->value;
1483 bond->params.reciprocal_packets_per_slave =
1489 bond->params.reciprocal_packets_per_slave =
1496 static int bond_option_lacp_active_set(struct bonding *bond,
1499 netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n",
1501 bond->params.lacp_active = newval->value;
1506 static int bond_option_lacp_rate_set(struct bonding *bond,
1509 netdev_dbg(bond->dev, "Setting LACP rate to %s (%llu)\n",
1511 bond->params.lacp_fast = newval->value;
1512 bond_3ad_update_lacp_rate(bond);
1517 static int bond_option_ad_select_set(struct bonding *bond,
1520 netdev_dbg(bond->dev, "Setting ad_select to %s (%llu)\n",
1522 bond->params.ad_select = newval->value;
1527 static int bond_option_queue_id_set(struct bonding *bond,
1551 qid > bond->dev->real_num_tx_queues)
1555 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string);
1561 bond_for_each_slave(bond, slave, iter) {
1582 netdev_dbg(bond->dev, "invalid input for queue_id set\n");
1588 static int bond_option_slaves_set(struct bonding *bond,
1603 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
1605 netdev_dbg(bond->dev, "interface %s does not exist!\n",
1613 slave_dbg(bond->dev, dev, "Enslaving interface\n");
1614 ret = bond_enslave(bond->dev, dev, NULL);
1618 slave_dbg(bond->dev, dev, "Releasing interface\n");
1619 ret = bond_release(bond->dev, dev);
1631 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n");
1636 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
1639 netdev_dbg(bond->dev, "Setting dynamic-lb to %s (%llu)\n",
1641 bond->params.tlb_dynamic_lb = newval->value;
1646 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
1649 netdev_dbg(bond->dev, "Setting ad_actor_sys_prio to %llu\n",
1652 bond->params.ad_actor_sys_prio = newval->value;
1653 bond_3ad_update_ad_actor_settings(bond);
1658 static int bond_option_ad_actor_system_set(struct bonding *bond,
1675 netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac);
1676 ether_addr_copy(bond->params.ad_actor_system, mac);
1677 bond_3ad_update_ad_actor_settings(bond);
1682 netdev_err(bond->dev, "Invalid ad_actor_system MAC address.\n");
1686 static int bond_option_ad_user_port_key_set(struct bonding *bond,
1689 netdev_dbg(bond->dev, "Setting ad_user_port_key to %llu\n",
1692 bond->params.ad_user_port_key = newval->value;