Lines Matching +full:primary +full:- +full:bond
1 // SPDX-License-Identifier: GPL-2.0-or-later
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,
90 { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT},
91 { "active-backup", BOND_MODE_ACTIVEBACKUP, 0},
92 { "balance-xor", BOND_MODE_XOR, 0},
95 { "balance-tlb", BOND_MODE_TLB, 0},
96 { "balance-alb", BOND_MODE_ALB, 0},
97 { NULL, -1, 0},
103 { NULL, -1, 0},
113 { NULL, -1, 0},
124 { NULL, -1, 0},
130 { NULL, -1, 0},
137 { NULL, -1, 0},
143 { NULL, -1, 0}
149 { NULL, -1, 0}
155 { NULL, -1, 0},
162 { NULL, -1, 0},
169 { NULL, -1, 0}
175 { NULL, -1, 0}
182 { NULL, -1},
188 { NULL, -1, 0}
194 { NULL, -1, 0}
201 { NULL, -1, 0}
207 { NULL, -1, 0},
213 { NULL, -1, 0}
219 { NULL, -1, 0},
225 { NULL, -1, 0},
232 { NULL, -1, 0},
239 .desc = "bond device mode",
255 .desc = "balance-xor, 802.3ad, and tlb hashing method",
278 .desc = "For active-backup, do not set all slaves to the same MAC",
379 .desc = "Link priority for failover re-selection",
388 .name = "primary",
389 .desc = "Primary network device to use",
399 .desc = "Reselect primary slave once it comes up",
510 if (opt && !strcmp(opt->name, name)) in bond_opt_get_by_name()
526 for (i = 0; opt->values && opt->values[i].string; i++) in bond_opt_get_val()
527 if (opt->values[i].value == val) in bond_opt_get_val()
528 return &opt->values[i]; in bond_opt_get_val()
539 for (i = 0; opt->values && opt->values[i].string; i++) in bond_opt_get_flags()
540 if (opt->values[i].flags & flagmask) in bond_opt_get_flags()
541 return &opt->values[i]; in bond_opt_get_flags()
555 if (!maxval || (minval && val < minval->value) || val > maxval->value) in bond_opt_check_range()
562 * bond_opt_parse - parse option value
569 * @val->string if it's present.
581 if (opt->flags & BOND_OPTFLAG_RAWVAL) in bond_opt_parse()
584 tbl = opt->values; in bond_opt_parse()
589 checkval = val->value != ULLONG_MAX; in bond_opt_parse()
591 if (!val->string) in bond_opt_parse()
593 p = strchr(val->string, '\n'); in bond_opt_parse()
596 for (p = val->string; *p; p++) in bond_opt_parse()
603 rv = sscanf(val->string, "%32s", valstr); in bond_opt_parse()
605 rv = sscanf(val->string, "%llu", &val->value); in bond_opt_parse()
615 if (val->value == tbl[i].value) in bond_opt_parse()
630 if (checkval && bond_opt_check_range(opt, val->value)) in bond_opt_parse()
636 /* Check opt's dependencies against bond mode and currently set options */
637 static int bond_opt_check_deps(struct bonding *bond, in bond_opt_check_deps() argument
640 struct bond_params *params = &bond->params; in bond_opt_check_deps()
642 if (test_bit(params->mode, &opt->unsuppmodes)) in bond_opt_check_deps()
643 return -EACCES; in bond_opt_check_deps()
644 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond)) in bond_opt_check_deps()
645 return -ENOTEMPTY; in bond_opt_check_deps()
646 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP)) in bond_opt_check_deps()
647 return -EBUSY; in bond_opt_check_deps()
652 static void bond_opt_dep_print(struct bonding *bond, in bond_opt_dep_print() argument
660 params = &bond->params; in bond_opt_dep_print()
661 modeval = bond_opt_get_val(BOND_OPT_MODE, params->mode); in bond_opt_dep_print()
662 if (test_bit(params->mode, &opt->unsuppmodes)) { in bond_opt_dep_print()
663 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n", in bond_opt_dep_print()
664 opt->name, modeval->string, modeval->value); in bond_opt_dep_print()
670 static void bond_opt_error_interpret(struct bonding *bond, in bond_opt_error_interpret() argument
680 case -EINVAL: in bond_opt_error_interpret()
683 if (val->string) { in bond_opt_error_interpret()
685 p = strchr(val->string, '\n'); in bond_opt_error_interpret()
688 netdev_err(bond->dev, "option %s: invalid value (%s)\n", in bond_opt_error_interpret()
689 opt->name, val->string); in bond_opt_error_interpret()
691 netdev_err(bond->dev, "option %s: invalid value (%llu)\n", in bond_opt_error_interpret()
692 opt->name, val->value); in bond_opt_error_interpret()
699 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n", in bond_opt_error_interpret()
700 opt->name, minval ? minval->value : 0, maxval->value); in bond_opt_error_interpret()
702 case -EACCES: in bond_opt_error_interpret()
703 bond_opt_dep_print(bond, opt, bad_attr, extack); in bond_opt_error_interpret()
705 case -ENOTEMPTY: in bond_opt_error_interpret()
707 "unable to set option because the bond device has slaves"); in bond_opt_error_interpret()
708 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n", in bond_opt_error_interpret()
709 opt->name); in bond_opt_error_interpret()
711 case -EBUSY: in bond_opt_error_interpret()
713 "unable to set option because the bond is up"); in bond_opt_error_interpret()
714 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n", in bond_opt_error_interpret()
715 opt->name); in bond_opt_error_interpret()
717 case -ENODEV: in bond_opt_error_interpret()
718 if (val && val->string) { in bond_opt_error_interpret()
719 p = strchr(val->string, '\n'); in bond_opt_error_interpret()
722 netdev_err(bond->dev, "option %s: interface %s does not exist!\n", in bond_opt_error_interpret()
723 opt->name, val->string); in bond_opt_error_interpret()
734 * __bond_opt_set - set a bonding option
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, in __bond_opt_set() argument
752 int ret = -ENOENT; in __bond_opt_set()
759 ret = bond_opt_check_deps(bond, opt); in __bond_opt_set()
764 ret = -EINVAL; in __bond_opt_set()
767 ret = opt->set(bond, retval); in __bond_opt_set()
770 bond_opt_error_interpret(bond, opt, ret, val, bad_attr, extack); in __bond_opt_set()
775 * __bond_opt_set_notify - set a bonding option
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, in __bond_opt_set_notify() argument
792 ret = __bond_opt_set(bond, option, val, NULL, NULL); in __bond_opt_set_notify()
794 if (!ret && (bond->dev->reg_state == NETREG_REGISTERED)) in __bond_opt_set_notify()
795 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev); in __bond_opt_set_notify()
801 * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set
802 * @bond: target bond device
809 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf) in bond_opt_tryset_rtnl() argument
817 ret = __bond_opt_set_notify(bond, option, &optval); in bond_opt_tryset_rtnl()
824 * bond_opt_get - get a pointer to an option
838 static bool bond_set_xfrm_features(struct bonding *bond) in bond_set_xfrm_features() argument
843 if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) in bond_set_xfrm_features()
844 bond->dev->wanted_features |= BOND_XFRM_FEATURES; in bond_set_xfrm_features()
846 bond->dev->wanted_features &= ~BOND_XFRM_FEATURES; in bond_set_xfrm_features()
851 static int bond_option_mode_set(struct bonding *bond, in bond_option_mode_set() argument
854 if (!bond_mode_uses_arp(newval->value)) { in bond_option_mode_set()
855 if (bond->params.arp_interval) { in bond_option_mode_set()
856 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n", in bond_option_mode_set()
857 newval->string); in bond_option_mode_set()
859 bond->params.arp_interval = 0; in bond_option_mode_set()
862 if (!bond->params.miimon) { in bond_option_mode_set()
864 bond->params.miimon = BOND_DEFAULT_MIIMON; in bond_option_mode_set()
865 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n", in bond_option_mode_set()
866 bond->params.miimon); in bond_option_mode_set()
870 if (newval->value == BOND_MODE_ALB) in bond_option_mode_set()
871 bond->params.tlb_dynamic_lb = 1; in bond_option_mode_set()
874 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_mode_set()
875 bond->params.mode = newval->value; in bond_option_mode_set()
877 if (bond->dev->reg_state == NETREG_REGISTERED) { in bond_option_mode_set()
880 update |= bond_set_xfrm_features(bond); in bond_option_mode_set()
883 netdev_update_features(bond->dev); in bond_option_mode_set()
886 bond_xdp_set_features(bond->dev); in bond_option_mode_set()
891 static int bond_option_active_slave_set(struct bonding *bond, in bond_option_active_slave_set() argument
898 sscanf(newval->string, "%15s", ifname); /* IFNAMSIZ */ in bond_option_active_slave_set()
899 if (!strlen(ifname) || newval->string[0] == '\n') { in bond_option_active_slave_set()
902 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_active_slave_set()
904 return -ENODEV; in bond_option_active_slave_set()
909 slave_err(bond->dev, slave_dev, "Device is not bonding slave\n"); in bond_option_active_slave_set()
910 return -EINVAL; in bond_option_active_slave_set()
913 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) { in bond_option_active_slave_set()
914 slave_err(bond->dev, slave_dev, "Device is not our slave\n"); in bond_option_active_slave_set()
915 return -EINVAL; in bond_option_active_slave_set()
922 netdev_dbg(bond->dev, "Clearing current active slave\n"); in bond_option_active_slave_set()
923 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in bond_option_active_slave_set()
924 bond_select_active_slave(bond); in bond_option_active_slave_set()
926 struct slave *old_active = rtnl_dereference(bond->curr_active_slave); in bond_option_active_slave_set()
933 slave_dbg(bond->dev, new_active->dev, "is already the current active slave\n"); in bond_option_active_slave_set()
935 if (old_active && (new_active->link == BOND_LINK_UP) && in bond_option_active_slave_set()
937 slave_dbg(bond->dev, new_active->dev, "Setting as active slave\n"); in bond_option_active_slave_set()
938 bond_change_active_slave(bond, new_active); in bond_option_active_slave_set()
940 …slave_err(bond->dev, new_active->dev, "Could not set as active slave; either %s is down or the lin… in bond_option_active_slave_set()
941 new_active->dev->name); in bond_option_active_slave_set()
942 ret = -EINVAL; in bond_option_active_slave_set()
955 static int bond_option_miimon_set(struct bonding *bond, in bond_option_miimon_set() argument
958 netdev_dbg(bond->dev, "Setting MII monitoring interval to %llu\n", in bond_option_miimon_set()
959 newval->value); in bond_option_miimon_set()
960 bond->params.miimon = newval->value; in bond_option_miimon_set()
961 if (bond->params.updelay) in bond_option_miimon_set()
962 …netdev_dbg(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n… in bond_option_miimon_set()
963 bond->params.updelay * bond->params.miimon); in bond_option_miimon_set()
964 if (bond->params.downdelay) in bond_option_miimon_set()
965 …netdev_dbg(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value… in bond_option_miimon_set()
966 bond->params.downdelay * bond->params.miimon); in bond_option_miimon_set()
967 if (bond->params.peer_notif_delay) in bond_option_miimon_set()
968 …netdev_dbg(bond->dev, "Note: Updating peer_notif_delay (to %d) since it is a multiple of the miimo… in bond_option_miimon_set()
969 bond->params.peer_notif_delay * bond->params.miimon); in bond_option_miimon_set()
970 if (newval->value && bond->params.arp_interval) { in bond_option_miimon_set()
971 …netdev_dbg(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitorin… in bond_option_miimon_set()
972 bond->params.arp_interval = 0; in bond_option_miimon_set()
973 if (bond->params.arp_validate) in bond_option_miimon_set()
974 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_miimon_set()
976 if (bond->dev->flags & IFF_UP) { in bond_option_miimon_set()
982 if (!newval->value) { in bond_option_miimon_set()
983 cancel_delayed_work_sync(&bond->mii_work); in bond_option_miimon_set()
985 cancel_delayed_work_sync(&bond->arp_work); in bond_option_miimon_set()
986 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_option_miimon_set()
997 static int _bond_option_delay_set(struct bonding *bond, in _bond_option_delay_set() argument
1002 int value = newval->value; in _bond_option_delay_set()
1004 if (!bond->params.miimon) { in _bond_option_delay_set()
1005 netdev_err(bond->dev, "Unable to set %s as MII monitoring is disabled\n", in _bond_option_delay_set()
1007 return -EPERM; in _bond_option_delay_set()
1009 if ((value % bond->params.miimon) != 0) { in _bond_option_delay_set()
1010 netdev_warn(bond->dev, in _bond_option_delay_set()
1013 value, bond->params.miimon, in _bond_option_delay_set()
1014 (value / bond->params.miimon) * in _bond_option_delay_set()
1015 bond->params.miimon); in _bond_option_delay_set()
1017 *target = value / bond->params.miimon; in _bond_option_delay_set()
1018 netdev_dbg(bond->dev, "Setting %s to %d\n", in _bond_option_delay_set()
1020 *target * bond->params.miimon); in _bond_option_delay_set()
1025 static int bond_option_updelay_set(struct bonding *bond, in bond_option_updelay_set() argument
1028 return _bond_option_delay_set(bond, newval, "up delay", in bond_option_updelay_set()
1029 &bond->params.updelay); in bond_option_updelay_set()
1032 static int bond_option_downdelay_set(struct bonding *bond, in bond_option_downdelay_set() argument
1035 return _bond_option_delay_set(bond, newval, "down delay", in bond_option_downdelay_set()
1036 &bond->params.downdelay); in bond_option_downdelay_set()
1039 static int bond_option_peer_notif_delay_set(struct bonding *bond, in bond_option_peer_notif_delay_set() argument
1042 int ret = _bond_option_delay_set(bond, newval, in bond_option_peer_notif_delay_set()
1044 &bond->params.peer_notif_delay); in bond_option_peer_notif_delay_set()
1048 static int bond_option_use_carrier_set(struct bonding *bond, in bond_option_use_carrier_set() argument
1051 netdev_dbg(bond->dev, "Setting use_carrier to %llu\n", in bond_option_use_carrier_set()
1052 newval->value); in bond_option_use_carrier_set()
1053 bond->params.use_carrier = newval->value; in bond_option_use_carrier_set()
1062 static int bond_option_arp_interval_set(struct bonding *bond, in bond_option_arp_interval_set() argument
1065 netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n", in bond_option_arp_interval_set()
1066 newval->value); in bond_option_arp_interval_set()
1067 bond->params.arp_interval = newval->value; in bond_option_arp_interval_set()
1068 if (newval->value) { in bond_option_arp_interval_set()
1069 if (bond->params.miimon) { in bond_option_arp_interval_set()
1070 …netdev_dbg(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring… in bond_option_arp_interval_set()
1071 bond->params.miimon = 0; in bond_option_arp_interval_set()
1073 if (!bond->params.arp_targets[0]) in bond_option_arp_interval_set()
1074 … netdev_dbg(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n"); in bond_option_arp_interval_set()
1076 if (bond->dev->flags & IFF_UP) { in bond_option_arp_interval_set()
1082 if (!newval->value) { in bond_option_arp_interval_set()
1083 if (bond->params.arp_validate) in bond_option_arp_interval_set()
1084 bond->recv_probe = NULL; in bond_option_arp_interval_set()
1085 cancel_delayed_work_sync(&bond->arp_work); in bond_option_arp_interval_set()
1087 /* arp_validate can be set only in active-backup mode */ in bond_option_arp_interval_set()
1088 bond->recv_probe = bond_rcv_validate; in bond_option_arp_interval_set()
1089 cancel_delayed_work_sync(&bond->mii_work); in bond_option_arp_interval_set()
1090 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_option_arp_interval_set()
1097 static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, in _bond_options_arp_ip_target_set() argument
1101 __be32 *targets = bond->params.arp_targets; in _bond_options_arp_ip_target_set()
1106 bond_for_each_slave(bond, slave, iter) in _bond_options_arp_ip_target_set()
1107 slave->target_last_arp_rx[slot] = last_rx; in _bond_options_arp_ip_target_set()
1112 static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in _bond_option_arp_ip_target_add() argument
1114 __be32 *targets = bond->params.arp_targets; in _bond_option_arp_ip_target_add()
1118 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n", in _bond_option_arp_ip_target_add()
1120 return -EINVAL; in _bond_option_arp_ip_target_add()
1123 if (bond_get_targets_ip(targets, target) != -1) { /* dup */ in _bond_option_arp_ip_target_add()
1124 netdev_err(bond->dev, "ARP target %pI4 is already present\n", in _bond_option_arp_ip_target_add()
1126 return -EINVAL; in _bond_option_arp_ip_target_add()
1130 if (ind == -1) { in _bond_option_arp_ip_target_add()
1131 netdev_err(bond->dev, "ARP target table is full!\n"); in _bond_option_arp_ip_target_add()
1132 return -EINVAL; in _bond_option_arp_ip_target_add()
1135 netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target); in _bond_option_arp_ip_target_add()
1137 _bond_options_arp_ip_target_set(bond, ind, target, jiffies); in _bond_option_arp_ip_target_add()
1142 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_add() argument
1144 return _bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_target_add()
1147 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_rem() argument
1149 __be32 *targets = bond->params.arp_targets; in bond_option_arp_ip_target_rem()
1156 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n", in bond_option_arp_ip_target_rem()
1158 return -EINVAL; in bond_option_arp_ip_target_rem()
1162 if (ind == -1) { in bond_option_arp_ip_target_rem()
1163 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n", in bond_option_arp_ip_target_rem()
1165 return -EINVAL; in bond_option_arp_ip_target_rem()
1168 if (ind == 0 && !targets[1] && bond->params.arp_interval) in bond_option_arp_ip_target_rem()
1169 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n"); in bond_option_arp_ip_target_rem()
1171 netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target); in bond_option_arp_ip_target_rem()
1173 bond_for_each_slave(bond, slave, iter) { in bond_option_arp_ip_target_rem()
1174 targets_rx = slave->target_last_arp_rx; in bond_option_arp_ip_target_rem()
1175 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) in bond_option_arp_ip_target_rem()
1179 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) in bond_option_arp_ip_target_rem()
1186 void bond_option_arp_ip_targets_clear(struct bonding *bond) in bond_option_arp_ip_targets_clear() argument
1191 _bond_options_arp_ip_target_set(bond, i, 0, 0); in bond_option_arp_ip_targets_clear()
1194 static int bond_option_arp_ip_targets_set(struct bonding *bond, in bond_option_arp_ip_targets_set() argument
1197 int ret = -EPERM; in bond_option_arp_ip_targets_set()
1200 if (newval->string) { in bond_option_arp_ip_targets_set()
1201 if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) { in bond_option_arp_ip_targets_set()
1202 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n", in bond_option_arp_ip_targets_set()
1206 if (newval->string[0] == '+') in bond_option_arp_ip_targets_set()
1207 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1208 else if (newval->string[0] == '-') in bond_option_arp_ip_targets_set()
1209 ret = bond_option_arp_ip_target_rem(bond, target); in bond_option_arp_ip_targets_set()
1211 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n"); in bond_option_arp_ip_targets_set()
1213 target = newval->value; in bond_option_arp_ip_targets_set()
1214 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1221 static void _bond_options_ns_ip6_target_set(struct bonding *bond, int slot, in _bond_options_ns_ip6_target_set() argument
1225 struct in6_addr *targets = bond->params.ns_targets; in _bond_options_ns_ip6_target_set()
1230 bond_for_each_slave(bond, slave, iter) in _bond_options_ns_ip6_target_set()
1231 slave->target_last_arp_rx[slot] = last_rx; in _bond_options_ns_ip6_target_set()
1236 void bond_option_ns_ip6_targets_clear(struct bonding *bond) in bond_option_ns_ip6_targets_clear() argument
1242 _bond_options_ns_ip6_target_set(bond, i, &addr_any, 0); in bond_option_ns_ip6_targets_clear()
1245 static int bond_option_ns_ip6_targets_set(struct bonding *bond, in bond_option_ns_ip6_targets_set() argument
1248 struct in6_addr *target = (struct in6_addr *)newval->extra; in bond_option_ns_ip6_targets_set()
1249 struct in6_addr *targets = bond->params.ns_targets; in bond_option_ns_ip6_targets_set()
1254 netdev_err(bond->dev, "invalid NS target %pI6c specified for addition\n", in bond_option_ns_ip6_targets_set()
1256 return -EINVAL; in bond_option_ns_ip6_targets_set()
1259 if (bond_get_targets_ip6(targets, target) != -1) { /* dup */ in bond_option_ns_ip6_targets_set()
1260 netdev_err(bond->dev, "NS target %pI6c is already present\n", in bond_option_ns_ip6_targets_set()
1262 return -EINVAL; in bond_option_ns_ip6_targets_set()
1266 if (index == -1) { in bond_option_ns_ip6_targets_set()
1267 netdev_err(bond->dev, "NS target table is full!\n"); in bond_option_ns_ip6_targets_set()
1268 return -EINVAL; in bond_option_ns_ip6_targets_set()
1271 netdev_dbg(bond->dev, "Adding NS target %pI6c\n", target); in bond_option_ns_ip6_targets_set()
1273 _bond_options_ns_ip6_target_set(bond, index, target, jiffies); in bond_option_ns_ip6_targets_set()
1278 static int bond_option_ns_ip6_targets_set(struct bonding *bond, in bond_option_ns_ip6_targets_set() argument
1281 return -EPERM; in bond_option_ns_ip6_targets_set()
1285 static int bond_option_arp_validate_set(struct bonding *bond, in bond_option_arp_validate_set() argument
1288 netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n", in bond_option_arp_validate_set()
1289 newval->string, newval->value); in bond_option_arp_validate_set()
1290 bond->params.arp_validate = newval->value; in bond_option_arp_validate_set()
1295 static int bond_option_arp_all_targets_set(struct bonding *bond, in bond_option_arp_all_targets_set() argument
1298 netdev_dbg(bond->dev, "Setting arp_all_targets to %s (%llu)\n", in bond_option_arp_all_targets_set()
1299 newval->string, newval->value); in bond_option_arp_all_targets_set()
1300 bond->params.arp_all_targets = newval->value; in bond_option_arp_all_targets_set()
1305 static int bond_option_missed_max_set(struct bonding *bond, in bond_option_missed_max_set() argument
1308 netdev_dbg(bond->dev, "Setting missed max to %s (%llu)\n", in bond_option_missed_max_set()
1309 newval->string, newval->value); in bond_option_missed_max_set()
1310 bond->params.missed_max = newval->value; in bond_option_missed_max_set()
1315 static int bond_option_prio_set(struct bonding *bond, in bond_option_prio_set() argument
1320 slave = bond_slave_get_rtnl(newval->slave_dev); in bond_option_prio_set()
1322 netdev_dbg(newval->slave_dev, "%s called on NULL slave\n", __func__); in bond_option_prio_set()
1323 return -ENODEV; in bond_option_prio_set()
1325 slave->prio = newval->value; in bond_option_prio_set()
1327 if (rtnl_dereference(bond->primary_slave)) in bond_option_prio_set()
1328 slave_warn(bond->dev, slave->dev, in bond_option_prio_set()
1329 "prio updated, but will not affect failover re-selection as primary slave have been set\n"); in bond_option_prio_set()
1331 bond_select_active_slave(bond); in bond_option_prio_set()
1336 static int bond_option_primary_set(struct bonding *bond, in bond_option_primary_set() argument
1339 char *p, *primary = newval->string; in bond_option_primary_set() local
1345 p = strchr(primary, '\n'); in bond_option_primary_set()
1348 /* check to see if we are clearing primary */ in bond_option_primary_set()
1349 if (!strlen(primary)) { in bond_option_primary_set()
1350 netdev_dbg(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1351 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1352 memset(bond->params.primary, 0, sizeof(bond->params.primary)); in bond_option_primary_set()
1353 bond_select_active_slave(bond); in bond_option_primary_set()
1357 bond_for_each_slave(bond, slave, iter) { in bond_option_primary_set()
1358 if (strncmp(slave->dev->name, primary, IFNAMSIZ) == 0) { in bond_option_primary_set()
1359 slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n"); in bond_option_primary_set()
1360 rcu_assign_pointer(bond->primary_slave, slave); in bond_option_primary_set()
1361 strcpy(bond->params.primary, slave->dev->name); in bond_option_primary_set()
1362 bond->force_primary = true; in bond_option_primary_set()
1363 bond_select_active_slave(bond); in bond_option_primary_set()
1368 if (rtnl_dereference(bond->primary_slave)) { in bond_option_primary_set()
1369 netdev_dbg(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1370 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1371 bond_select_active_slave(bond); in bond_option_primary_set()
1373 strscpy_pad(bond->params.primary, primary, IFNAMSIZ); in bond_option_primary_set()
1375 netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n", in bond_option_primary_set()
1376 primary); in bond_option_primary_set()
1384 static int bond_option_primary_reselect_set(struct bonding *bond, in bond_option_primary_reselect_set() argument
1387 netdev_dbg(bond->dev, "Setting primary_reselect to %s (%llu)\n", in bond_option_primary_reselect_set()
1388 newval->string, newval->value); in bond_option_primary_reselect_set()
1389 bond->params.primary_reselect = newval->value; in bond_option_primary_reselect_set()
1392 bond_select_active_slave(bond); in bond_option_primary_reselect_set()
1398 static int bond_option_fail_over_mac_set(struct bonding *bond, in bond_option_fail_over_mac_set() argument
1401 netdev_dbg(bond->dev, "Setting fail_over_mac to %s (%llu)\n", in bond_option_fail_over_mac_set()
1402 newval->string, newval->value); in bond_option_fail_over_mac_set()
1403 bond->params.fail_over_mac = newval->value; in bond_option_fail_over_mac_set()
1408 static int bond_option_xmit_hash_policy_set(struct bonding *bond, in bond_option_xmit_hash_policy_set() argument
1411 netdev_dbg(bond->dev, "Setting xmit hash policy to %s (%llu)\n", in bond_option_xmit_hash_policy_set()
1412 newval->string, newval->value); in bond_option_xmit_hash_policy_set()
1413 bond->params.xmit_policy = newval->value; in bond_option_xmit_hash_policy_set()
1418 static int bond_option_resend_igmp_set(struct bonding *bond, in bond_option_resend_igmp_set() argument
1421 netdev_dbg(bond->dev, "Setting resend_igmp to %llu\n", in bond_option_resend_igmp_set()
1422 newval->value); in bond_option_resend_igmp_set()
1423 bond->params.resend_igmp = newval->value; in bond_option_resend_igmp_set()
1428 static int bond_option_num_peer_notif_set(struct bonding *bond, in bond_option_num_peer_notif_set() argument
1431 bond->params.num_peer_notif = newval->value; in bond_option_num_peer_notif_set()
1436 static int bond_option_all_slaves_active_set(struct bonding *bond, in bond_option_all_slaves_active_set() argument
1442 if (newval->value == bond->params.all_slaves_active) in bond_option_all_slaves_active_set()
1444 bond->params.all_slaves_active = newval->value; in bond_option_all_slaves_active_set()
1445 bond_for_each_slave(bond, slave, iter) { in bond_option_all_slaves_active_set()
1447 if (newval->value) in bond_option_all_slaves_active_set()
1448 slave->inactive = 0; in bond_option_all_slaves_active_set()
1450 slave->inactive = 1; in bond_option_all_slaves_active_set()
1457 static int bond_option_min_links_set(struct bonding *bond, in bond_option_min_links_set() argument
1460 netdev_dbg(bond->dev, "Setting min links value to %llu\n", in bond_option_min_links_set()
1461 newval->value); in bond_option_min_links_set()
1462 bond->params.min_links = newval->value; in bond_option_min_links_set()
1463 bond_set_carrier(bond); in bond_option_min_links_set()
1468 static int bond_option_lp_interval_set(struct bonding *bond, in bond_option_lp_interval_set() argument
1471 bond->params.lp_interval = newval->value; in bond_option_lp_interval_set()
1476 static int bond_option_pps_set(struct bonding *bond, in bond_option_pps_set() argument
1479 netdev_dbg(bond->dev, "Setting packets per slave to %llu\n", in bond_option_pps_set()
1480 newval->value); in bond_option_pps_set()
1481 bond->params.packets_per_slave = newval->value; in bond_option_pps_set()
1482 if (newval->value > 0) { in bond_option_pps_set()
1483 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1484 reciprocal_value(newval->value); in bond_option_pps_set()
1489 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1496 static int bond_option_lacp_active_set(struct bonding *bond, in bond_option_lacp_active_set() argument
1499 netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n", in bond_option_lacp_active_set()
1500 newval->string, newval->value); in bond_option_lacp_active_set()
1501 bond->params.lacp_active = newval->value; in bond_option_lacp_active_set()
1506 static int bond_option_lacp_rate_set(struct bonding *bond, in bond_option_lacp_rate_set() argument
1509 netdev_dbg(bond->dev, "Setting LACP rate to %s (%llu)\n", in bond_option_lacp_rate_set()
1510 newval->string, newval->value); in bond_option_lacp_rate_set()
1511 bond->params.lacp_fast = newval->value; in bond_option_lacp_rate_set()
1512 bond_3ad_update_lacp_rate(bond); in bond_option_lacp_rate_set()
1517 static int bond_option_ad_select_set(struct bonding *bond, in bond_option_ad_select_set() argument
1520 netdev_dbg(bond->dev, "Setting ad_select to %s (%llu)\n", in bond_option_ad_select_set()
1521 newval->string, newval->value); in bond_option_ad_select_set()
1522 bond->params.ad_select = newval->value; in bond_option_ad_select_set()
1527 static int bond_option_queue_id_set(struct bonding *bond, in bond_option_queue_id_set() argument
1538 delim = strchr(newval->string, ':'); in bond_option_queue_id_set()
1550 if (!dev_valid_name(newval->string) || in bond_option_queue_id_set()
1551 qid > bond->dev->real_num_tx_queues) in bond_option_queue_id_set()
1555 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string); in bond_option_queue_id_set()
1561 bond_for_each_slave(bond, slave, iter) { in bond_option_queue_id_set()
1562 if (sdev == slave->dev) in bond_option_queue_id_set()
1567 else if (qid && qid == slave->queue_id) { in bond_option_queue_id_set()
1576 update_slave->queue_id = qid; in bond_option_queue_id_set()
1582 netdev_dbg(bond->dev, "invalid input for queue_id set\n"); in bond_option_queue_id_set()
1583 ret = -EPERM; in bond_option_queue_id_set()
1588 static int bond_option_slaves_set(struct bonding *bond, in bond_option_slaves_set() argument
1596 sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/ in bond_option_slaves_set()
1599 (command[0] != '+' && command[0] != '-') || in bond_option_slaves_set()
1603 dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_slaves_set()
1605 netdev_dbg(bond->dev, "interface %s does not exist!\n", in bond_option_slaves_set()
1607 ret = -ENODEV; in bond_option_slaves_set()
1613 slave_dbg(bond->dev, dev, "Enslaving interface\n"); in bond_option_slaves_set()
1614 ret = bond_enslave(bond->dev, dev, NULL); in bond_option_slaves_set()
1617 case '-': in bond_option_slaves_set()
1618 slave_dbg(bond->dev, dev, "Releasing interface\n"); in bond_option_slaves_set()
1619 ret = bond_release(bond->dev, dev); in bond_option_slaves_set()
1631 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n"); in bond_option_slaves_set()
1632 ret = -EPERM; in bond_option_slaves_set()
1636 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, in bond_option_tlb_dynamic_lb_set() argument
1639 netdev_dbg(bond->dev, "Setting dynamic-lb to %s (%llu)\n", in bond_option_tlb_dynamic_lb_set()
1640 newval->string, newval->value); in bond_option_tlb_dynamic_lb_set()
1641 bond->params.tlb_dynamic_lb = newval->value; in bond_option_tlb_dynamic_lb_set()
1646 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond, in bond_option_ad_actor_sys_prio_set() argument
1649 netdev_dbg(bond->dev, "Setting ad_actor_sys_prio to %llu\n", in bond_option_ad_actor_sys_prio_set()
1650 newval->value); in bond_option_ad_actor_sys_prio_set()
1652 bond->params.ad_actor_sys_prio = newval->value; in bond_option_ad_actor_sys_prio_set()
1653 bond_3ad_update_ad_actor_settings(bond); in bond_option_ad_actor_sys_prio_set()
1658 static int bond_option_ad_actor_system_set(struct bonding *bond, in bond_option_ad_actor_system_set() argument
1664 if (newval->string) { in bond_option_ad_actor_system_set()
1665 if (!mac_pton(newval->string, macaddr)) in bond_option_ad_actor_system_set()
1669 mac = (u8 *)&newval->value; in bond_option_ad_actor_system_set()
1675 netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac); in bond_option_ad_actor_system_set()
1676 ether_addr_copy(bond->params.ad_actor_system, mac); in bond_option_ad_actor_system_set()
1677 bond_3ad_update_ad_actor_settings(bond); in bond_option_ad_actor_system_set()
1682 netdev_err(bond->dev, "Invalid ad_actor_system MAC address.\n"); in bond_option_ad_actor_system_set()
1683 return -EINVAL; in bond_option_ad_actor_system_set()
1686 static int bond_option_ad_user_port_key_set(struct bonding *bond, in bond_option_ad_user_port_key_set() argument
1689 netdev_dbg(bond->dev, "Setting ad_user_port_key to %llu\n", in bond_option_ad_user_port_key_set()
1690 newval->value); in bond_option_ad_user_port_key_set()
1692 bond->params.ad_user_port_key = newval->value; in bond_option_ad_user_port_key_set()