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_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,
82 { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT},
83 { "active-backup", BOND_MODE_ACTIVEBACKUP, 0},
84 { "balance-xor", BOND_MODE_XOR, 0},
87 { "balance-tlb", BOND_MODE_TLB, 0},
88 { "balance-alb", BOND_MODE_ALB, 0},
89 { NULL, -1, 0},
95 { NULL, -1, 0},
104 { NULL, -1, 0},
115 { NULL, -1, 0},
121 { NULL, -1, 0},
128 { NULL, -1, 0},
134 { NULL, -1, 0}
140 { NULL, -1, 0},
147 { NULL, -1, 0},
154 { NULL, -1, 0}
161 { NULL, -1},
167 { NULL, -1, 0}
173 { NULL, -1, 0}
180 { NULL, -1, 0}
186 { NULL, -1, 0},
192 { NULL, -1, 0}
198 { NULL, -1, 0},
204 { NULL, -1, 0},
211 .desc = "bond device mode",
227 .desc = "balance-xor, 802.3ad, and tlb hashing method",
250 .desc = "For active-backup, do not set all slaves to the same MAC",
325 .name = "primary",
326 .desc = "Primary network device to use",
336 .desc = "Reselect primary slave once it comes up",
447 if (opt && !strcmp(opt->name, name)) in bond_opt_get_by_name()
463 for (i = 0; opt->values && opt->values[i].string; i++) in bond_opt_get_val()
464 if (opt->values[i].value == val) in bond_opt_get_val()
465 return &opt->values[i]; in bond_opt_get_val()
476 for (i = 0; opt->values && opt->values[i].string; i++) in bond_opt_get_flags()
477 if (opt->values[i].flags & flagmask) in bond_opt_get_flags()
478 return &opt->values[i]; in bond_opt_get_flags()
492 if (!maxval || (minval && val < minval->value) || val > maxval->value) in bond_opt_check_range()
499 * bond_opt_parse - parse option value
506 * @val->string if it's present.
518 if (opt->flags & BOND_OPTFLAG_RAWVAL) in bond_opt_parse()
521 tbl = opt->values; in bond_opt_parse()
526 checkval = val->value != ULLONG_MAX; in bond_opt_parse()
528 if (!val->string) in bond_opt_parse()
530 p = strchr(val->string, '\n'); in bond_opt_parse()
533 for (p = val->string; *p; p++) in bond_opt_parse()
540 rv = sscanf(val->string, "%32s", valstr); in bond_opt_parse()
542 rv = sscanf(val->string, "%llu", &val->value); in bond_opt_parse()
552 if (val->value == tbl[i].value) in bond_opt_parse()
567 if (checkval && bond_opt_check_range(opt, val->value)) in bond_opt_parse()
573 /* Check opt's dependencies against bond mode and currently set options */
574 static int bond_opt_check_deps(struct bonding *bond, in bond_opt_check_deps() argument
577 struct bond_params *params = &bond->params; in bond_opt_check_deps()
579 if (test_bit(params->mode, &opt->unsuppmodes)) in bond_opt_check_deps()
580 return -EACCES; in bond_opt_check_deps()
581 if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond)) in bond_opt_check_deps()
582 return -ENOTEMPTY; in bond_opt_check_deps()
583 if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP)) in bond_opt_check_deps()
584 return -EBUSY; in bond_opt_check_deps()
589 static void bond_opt_dep_print(struct bonding *bond, in bond_opt_dep_print() argument
595 params = &bond->params; in bond_opt_dep_print()
596 modeval = bond_opt_get_val(BOND_OPT_MODE, params->mode); in bond_opt_dep_print()
597 if (test_bit(params->mode, &opt->unsuppmodes)) in bond_opt_dep_print()
598 netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n", in bond_opt_dep_print()
599 opt->name, modeval->string, modeval->value); in bond_opt_dep_print()
602 static void bond_opt_error_interpret(struct bonding *bond, in bond_opt_error_interpret() argument
610 case -EINVAL: in bond_opt_error_interpret()
612 if (val->string) { in bond_opt_error_interpret()
614 p = strchr(val->string, '\n'); in bond_opt_error_interpret()
617 netdev_err(bond->dev, "option %s: invalid value (%s)\n", in bond_opt_error_interpret()
618 opt->name, val->string); in bond_opt_error_interpret()
620 netdev_err(bond->dev, "option %s: invalid value (%llu)\n", in bond_opt_error_interpret()
621 opt->name, val->value); in bond_opt_error_interpret()
628 netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n", in bond_opt_error_interpret()
629 opt->name, minval ? minval->value : 0, maxval->value); in bond_opt_error_interpret()
631 case -EACCES: in bond_opt_error_interpret()
632 bond_opt_dep_print(bond, opt); in bond_opt_error_interpret()
634 case -ENOTEMPTY: in bond_opt_error_interpret()
635 netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n", in bond_opt_error_interpret()
636 opt->name); in bond_opt_error_interpret()
638 case -EBUSY: in bond_opt_error_interpret()
639 netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n", in bond_opt_error_interpret()
640 opt->name); in bond_opt_error_interpret()
648 * __bond_opt_set - set a bonding option
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, in __bond_opt_set() argument
662 int ret = -ENOENT; in __bond_opt_set()
669 ret = bond_opt_check_deps(bond, opt); in __bond_opt_set()
674 ret = -EINVAL; in __bond_opt_set()
677 ret = opt->set(bond, retval); in __bond_opt_set()
680 bond_opt_error_interpret(bond, opt, ret, val); in __bond_opt_set()
685 * __bond_opt_set_notify - set a bonding option
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, in __bond_opt_set_notify() argument
698 int ret = -ENOENT; in __bond_opt_set_notify()
702 ret = __bond_opt_set(bond, option, val); in __bond_opt_set_notify()
704 if (!ret && (bond->dev->reg_state == NETREG_REGISTERED)) in __bond_opt_set_notify()
705 call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev); in __bond_opt_set_notify()
711 * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set
712 * @bond: target bond device
719 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf) in bond_opt_tryset_rtnl() argument
727 ret = __bond_opt_set_notify(bond, option, &optval); in bond_opt_tryset_rtnl()
734 * bond_opt_get - get a pointer to an option
754 bond_dev->wanted_features |= BOND_XFRM_FEATURES; in bond_set_xfrm_features()
756 bond_dev->wanted_features &= ~BOND_XFRM_FEATURES; in bond_set_xfrm_features()
761 static int bond_option_mode_set(struct bonding *bond, in bond_option_mode_set() argument
764 if (!bond_mode_uses_arp(newval->value)) { in bond_option_mode_set()
765 if (bond->params.arp_interval) { in bond_option_mode_set()
766 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n", in bond_option_mode_set()
767 newval->string); in bond_option_mode_set()
769 bond->params.arp_interval = 0; in bond_option_mode_set()
772 if (!bond->params.miimon) { in bond_option_mode_set()
774 bond->params.miimon = BOND_DEFAULT_MIIMON; in bond_option_mode_set()
775 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n", in bond_option_mode_set()
776 bond->params.miimon); in bond_option_mode_set()
780 if (newval->value == BOND_MODE_ALB) in bond_option_mode_set()
781 bond->params.tlb_dynamic_lb = 1; in bond_option_mode_set()
783 if (bond->dev->reg_state == NETREG_REGISTERED) in bond_option_mode_set()
784 bond_set_xfrm_features(bond->dev, newval->value); in bond_option_mode_set()
787 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_mode_set()
788 bond->params.mode = newval->value; in bond_option_mode_set()
793 static int bond_option_active_slave_set(struct bonding *bond, in bond_option_active_slave_set() argument
800 sscanf(newval->string, "%15s", ifname); /* IFNAMSIZ */ in bond_option_active_slave_set()
801 if (!strlen(ifname) || newval->string[0] == '\n') { in bond_option_active_slave_set()
804 slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_active_slave_set()
806 return -ENODEV; in bond_option_active_slave_set()
811 slave_err(bond->dev, slave_dev, "Device is not bonding slave\n"); in bond_option_active_slave_set()
812 return -EINVAL; in bond_option_active_slave_set()
815 if (bond->dev != netdev_master_upper_dev_get(slave_dev)) { in bond_option_active_slave_set()
816 slave_err(bond->dev, slave_dev, "Device is not our slave\n"); in bond_option_active_slave_set()
817 return -EINVAL; in bond_option_active_slave_set()
824 netdev_dbg(bond->dev, "Clearing current active slave\n"); in bond_option_active_slave_set()
825 RCU_INIT_POINTER(bond->curr_active_slave, NULL); in bond_option_active_slave_set()
826 bond_select_active_slave(bond); in bond_option_active_slave_set()
828 struct slave *old_active = rtnl_dereference(bond->curr_active_slave); in bond_option_active_slave_set()
835 slave_dbg(bond->dev, new_active->dev, "is already the current active slave\n"); in bond_option_active_slave_set()
837 if (old_active && (new_active->link == BOND_LINK_UP) && in bond_option_active_slave_set()
839 slave_dbg(bond->dev, new_active->dev, "Setting as active slave\n"); in bond_option_active_slave_set()
840 bond_change_active_slave(bond, new_active); in bond_option_active_slave_set()
842 …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()
843 new_active->dev->name); in bond_option_active_slave_set()
844 ret = -EINVAL; in bond_option_active_slave_set()
857 static int bond_option_miimon_set(struct bonding *bond, in bond_option_miimon_set() argument
860 netdev_dbg(bond->dev, "Setting MII monitoring interval to %llu\n", in bond_option_miimon_set()
861 newval->value); in bond_option_miimon_set()
862 bond->params.miimon = newval->value; in bond_option_miimon_set()
863 if (bond->params.updelay) in bond_option_miimon_set()
864 …netdev_dbg(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n… in bond_option_miimon_set()
865 bond->params.updelay * bond->params.miimon); in bond_option_miimon_set()
866 if (bond->params.downdelay) in bond_option_miimon_set()
867 …netdev_dbg(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value… in bond_option_miimon_set()
868 bond->params.downdelay * bond->params.miimon); in bond_option_miimon_set()
869 if (bond->params.peer_notif_delay) in bond_option_miimon_set()
870 …netdev_dbg(bond->dev, "Note: Updating peer_notif_delay (to %d) since it is a multiple of the miimo… in bond_option_miimon_set()
871 bond->params.peer_notif_delay * bond->params.miimon); in bond_option_miimon_set()
872 if (newval->value && bond->params.arp_interval) { in bond_option_miimon_set()
873 …netdev_dbg(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitorin… in bond_option_miimon_set()
874 bond->params.arp_interval = 0; in bond_option_miimon_set()
875 if (bond->params.arp_validate) in bond_option_miimon_set()
876 bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; in bond_option_miimon_set()
878 if (bond->dev->flags & IFF_UP) { in bond_option_miimon_set()
884 if (!newval->value) { in bond_option_miimon_set()
885 cancel_delayed_work_sync(&bond->mii_work); in bond_option_miimon_set()
887 cancel_delayed_work_sync(&bond->arp_work); in bond_option_miimon_set()
888 queue_delayed_work(bond->wq, &bond->mii_work, 0); in bond_option_miimon_set()
899 static int _bond_option_delay_set(struct bonding *bond, in _bond_option_delay_set() argument
904 int value = newval->value; in _bond_option_delay_set()
906 if (!bond->params.miimon) { in _bond_option_delay_set()
907 netdev_err(bond->dev, "Unable to set %s as MII monitoring is disabled\n", in _bond_option_delay_set()
909 return -EPERM; in _bond_option_delay_set()
911 if ((value % bond->params.miimon) != 0) { in _bond_option_delay_set()
912 netdev_warn(bond->dev, in _bond_option_delay_set()
915 value, bond->params.miimon, in _bond_option_delay_set()
916 (value / bond->params.miimon) * in _bond_option_delay_set()
917 bond->params.miimon); in _bond_option_delay_set()
919 *target = value / bond->params.miimon; in _bond_option_delay_set()
920 netdev_dbg(bond->dev, "Setting %s to %d\n", in _bond_option_delay_set()
922 *target * bond->params.miimon); in _bond_option_delay_set()
927 static int bond_option_updelay_set(struct bonding *bond, in bond_option_updelay_set() argument
930 return _bond_option_delay_set(bond, newval, "up delay", in bond_option_updelay_set()
931 &bond->params.updelay); in bond_option_updelay_set()
934 static int bond_option_downdelay_set(struct bonding *bond, in bond_option_downdelay_set() argument
937 return _bond_option_delay_set(bond, newval, "down delay", in bond_option_downdelay_set()
938 &bond->params.downdelay); in bond_option_downdelay_set()
941 static int bond_option_peer_notif_delay_set(struct bonding *bond, in bond_option_peer_notif_delay_set() argument
944 int ret = _bond_option_delay_set(bond, newval, in bond_option_peer_notif_delay_set()
946 &bond->params.peer_notif_delay); in bond_option_peer_notif_delay_set()
950 static int bond_option_use_carrier_set(struct bonding *bond, in bond_option_use_carrier_set() argument
953 netdev_dbg(bond->dev, "Setting use_carrier to %llu\n", in bond_option_use_carrier_set()
954 newval->value); in bond_option_use_carrier_set()
955 bond->params.use_carrier = newval->value; in bond_option_use_carrier_set()
964 static int bond_option_arp_interval_set(struct bonding *bond, in bond_option_arp_interval_set() argument
967 netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n", in bond_option_arp_interval_set()
968 newval->value); in bond_option_arp_interval_set()
969 bond->params.arp_interval = newval->value; in bond_option_arp_interval_set()
970 if (newval->value) { in bond_option_arp_interval_set()
971 if (bond->params.miimon) { in bond_option_arp_interval_set()
972 …netdev_dbg(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring… in bond_option_arp_interval_set()
973 bond->params.miimon = 0; in bond_option_arp_interval_set()
975 if (!bond->params.arp_targets[0]) in bond_option_arp_interval_set()
976 … netdev_dbg(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n"); in bond_option_arp_interval_set()
978 if (bond->dev->flags & IFF_UP) { in bond_option_arp_interval_set()
984 if (!newval->value) { in bond_option_arp_interval_set()
985 if (bond->params.arp_validate) in bond_option_arp_interval_set()
986 bond->recv_probe = NULL; in bond_option_arp_interval_set()
987 cancel_delayed_work_sync(&bond->arp_work); in bond_option_arp_interval_set()
989 /* arp_validate can be set only in active-backup mode */ in bond_option_arp_interval_set()
990 bond->recv_probe = bond_arp_rcv; in bond_option_arp_interval_set()
991 cancel_delayed_work_sync(&bond->mii_work); in bond_option_arp_interval_set()
992 queue_delayed_work(bond->wq, &bond->arp_work, 0); in bond_option_arp_interval_set()
999 static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, in _bond_options_arp_ip_target_set() argument
1003 __be32 *targets = bond->params.arp_targets; in _bond_options_arp_ip_target_set()
1008 bond_for_each_slave(bond, slave, iter) in _bond_options_arp_ip_target_set()
1009 slave->target_last_arp_rx[slot] = last_rx; in _bond_options_arp_ip_target_set()
1014 static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in _bond_option_arp_ip_target_add() argument
1016 __be32 *targets = bond->params.arp_targets; in _bond_option_arp_ip_target_add()
1020 netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n", in _bond_option_arp_ip_target_add()
1022 return -EINVAL; in _bond_option_arp_ip_target_add()
1025 if (bond_get_targets_ip(targets, target) != -1) { /* dup */ in _bond_option_arp_ip_target_add()
1026 netdev_err(bond->dev, "ARP target %pI4 is already present\n", in _bond_option_arp_ip_target_add()
1028 return -EINVAL; in _bond_option_arp_ip_target_add()
1032 if (ind == -1) { in _bond_option_arp_ip_target_add()
1033 netdev_err(bond->dev, "ARP target table is full!\n"); in _bond_option_arp_ip_target_add()
1034 return -EINVAL; in _bond_option_arp_ip_target_add()
1037 netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target); in _bond_option_arp_ip_target_add()
1039 _bond_options_arp_ip_target_set(bond, ind, target, jiffies); in _bond_option_arp_ip_target_add()
1044 static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_add() argument
1046 return _bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_target_add()
1049 static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) in bond_option_arp_ip_target_rem() argument
1051 __be32 *targets = bond->params.arp_targets; in bond_option_arp_ip_target_rem()
1058 netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n", in bond_option_arp_ip_target_rem()
1060 return -EINVAL; in bond_option_arp_ip_target_rem()
1064 if (ind == -1) { in bond_option_arp_ip_target_rem()
1065 netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n", in bond_option_arp_ip_target_rem()
1067 return -EINVAL; in bond_option_arp_ip_target_rem()
1070 if (ind == 0 && !targets[1] && bond->params.arp_interval) in bond_option_arp_ip_target_rem()
1071 netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n"); in bond_option_arp_ip_target_rem()
1073 netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target); in bond_option_arp_ip_target_rem()
1075 bond_for_each_slave(bond, slave, iter) { in bond_option_arp_ip_target_rem()
1076 targets_rx = slave->target_last_arp_rx; in bond_option_arp_ip_target_rem()
1077 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) in bond_option_arp_ip_target_rem()
1081 for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) in bond_option_arp_ip_target_rem()
1088 void bond_option_arp_ip_targets_clear(struct bonding *bond) in bond_option_arp_ip_targets_clear() argument
1093 _bond_options_arp_ip_target_set(bond, i, 0, 0); in bond_option_arp_ip_targets_clear()
1096 static int bond_option_arp_ip_targets_set(struct bonding *bond, in bond_option_arp_ip_targets_set() argument
1099 int ret = -EPERM; in bond_option_arp_ip_targets_set()
1102 if (newval->string) { in bond_option_arp_ip_targets_set()
1103 if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) { in bond_option_arp_ip_targets_set()
1104 netdev_err(bond->dev, "invalid ARP target %pI4 specified\n", in bond_option_arp_ip_targets_set()
1108 if (newval->string[0] == '+') in bond_option_arp_ip_targets_set()
1109 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1110 else if (newval->string[0] == '-') in bond_option_arp_ip_targets_set()
1111 ret = bond_option_arp_ip_target_rem(bond, target); in bond_option_arp_ip_targets_set()
1113 netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n"); in bond_option_arp_ip_targets_set()
1115 target = newval->value; in bond_option_arp_ip_targets_set()
1116 ret = bond_option_arp_ip_target_add(bond, target); in bond_option_arp_ip_targets_set()
1122 static int bond_option_arp_validate_set(struct bonding *bond, in bond_option_arp_validate_set() argument
1125 netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n", in bond_option_arp_validate_set()
1126 newval->string, newval->value); in bond_option_arp_validate_set()
1127 bond->params.arp_validate = newval->value; in bond_option_arp_validate_set()
1132 static int bond_option_arp_all_targets_set(struct bonding *bond, in bond_option_arp_all_targets_set() argument
1135 netdev_dbg(bond->dev, "Setting arp_all_targets to %s (%llu)\n", in bond_option_arp_all_targets_set()
1136 newval->string, newval->value); in bond_option_arp_all_targets_set()
1137 bond->params.arp_all_targets = newval->value; in bond_option_arp_all_targets_set()
1142 static int bond_option_primary_set(struct bonding *bond, in bond_option_primary_set() argument
1145 char *p, *primary = newval->string; in bond_option_primary_set() local
1151 p = strchr(primary, '\n'); in bond_option_primary_set()
1154 /* check to see if we are clearing primary */ in bond_option_primary_set()
1155 if (!strlen(primary)) { in bond_option_primary_set()
1156 netdev_dbg(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1157 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1158 memset(bond->params.primary, 0, sizeof(bond->params.primary)); in bond_option_primary_set()
1159 bond_select_active_slave(bond); in bond_option_primary_set()
1163 bond_for_each_slave(bond, slave, iter) { in bond_option_primary_set()
1164 if (strncmp(slave->dev->name, primary, IFNAMSIZ) == 0) { in bond_option_primary_set()
1165 slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n"); in bond_option_primary_set()
1166 rcu_assign_pointer(bond->primary_slave, slave); in bond_option_primary_set()
1167 strcpy(bond->params.primary, slave->dev->name); in bond_option_primary_set()
1168 bond->force_primary = true; in bond_option_primary_set()
1169 bond_select_active_slave(bond); in bond_option_primary_set()
1174 if (rtnl_dereference(bond->primary_slave)) { in bond_option_primary_set()
1175 netdev_dbg(bond->dev, "Setting primary slave to None\n"); in bond_option_primary_set()
1176 RCU_INIT_POINTER(bond->primary_slave, NULL); in bond_option_primary_set()
1177 bond_select_active_slave(bond); in bond_option_primary_set()
1179 strncpy(bond->params.primary, primary, IFNAMSIZ); in bond_option_primary_set()
1180 bond->params.primary[IFNAMSIZ - 1] = 0; in bond_option_primary_set()
1182 netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n", in bond_option_primary_set()
1183 primary); in bond_option_primary_set()
1191 static int bond_option_primary_reselect_set(struct bonding *bond, in bond_option_primary_reselect_set() argument
1194 netdev_dbg(bond->dev, "Setting primary_reselect to %s (%llu)\n", in bond_option_primary_reselect_set()
1195 newval->string, newval->value); in bond_option_primary_reselect_set()
1196 bond->params.primary_reselect = newval->value; in bond_option_primary_reselect_set()
1199 bond_select_active_slave(bond); in bond_option_primary_reselect_set()
1205 static int bond_option_fail_over_mac_set(struct bonding *bond, in bond_option_fail_over_mac_set() argument
1208 netdev_dbg(bond->dev, "Setting fail_over_mac to %s (%llu)\n", in bond_option_fail_over_mac_set()
1209 newval->string, newval->value); in bond_option_fail_over_mac_set()
1210 bond->params.fail_over_mac = newval->value; in bond_option_fail_over_mac_set()
1215 static int bond_option_xmit_hash_policy_set(struct bonding *bond, in bond_option_xmit_hash_policy_set() argument
1218 netdev_dbg(bond->dev, "Setting xmit hash policy to %s (%llu)\n", in bond_option_xmit_hash_policy_set()
1219 newval->string, newval->value); in bond_option_xmit_hash_policy_set()
1220 bond->params.xmit_policy = newval->value; in bond_option_xmit_hash_policy_set()
1225 static int bond_option_resend_igmp_set(struct bonding *bond, in bond_option_resend_igmp_set() argument
1228 netdev_dbg(bond->dev, "Setting resend_igmp to %llu\n", in bond_option_resend_igmp_set()
1229 newval->value); in bond_option_resend_igmp_set()
1230 bond->params.resend_igmp = newval->value; in bond_option_resend_igmp_set()
1235 static int bond_option_num_peer_notif_set(struct bonding *bond, in bond_option_num_peer_notif_set() argument
1238 bond->params.num_peer_notif = newval->value; in bond_option_num_peer_notif_set()
1243 static int bond_option_all_slaves_active_set(struct bonding *bond, in bond_option_all_slaves_active_set() argument
1249 if (newval->value == bond->params.all_slaves_active) in bond_option_all_slaves_active_set()
1251 bond->params.all_slaves_active = newval->value; in bond_option_all_slaves_active_set()
1252 bond_for_each_slave(bond, slave, iter) { in bond_option_all_slaves_active_set()
1254 if (newval->value) in bond_option_all_slaves_active_set()
1255 slave->inactive = 0; in bond_option_all_slaves_active_set()
1257 slave->inactive = 1; in bond_option_all_slaves_active_set()
1264 static int bond_option_min_links_set(struct bonding *bond, in bond_option_min_links_set() argument
1267 netdev_dbg(bond->dev, "Setting min links value to %llu\n", in bond_option_min_links_set()
1268 newval->value); in bond_option_min_links_set()
1269 bond->params.min_links = newval->value; in bond_option_min_links_set()
1270 bond_set_carrier(bond); in bond_option_min_links_set()
1275 static int bond_option_lp_interval_set(struct bonding *bond, in bond_option_lp_interval_set() argument
1278 bond->params.lp_interval = newval->value; in bond_option_lp_interval_set()
1283 static int bond_option_pps_set(struct bonding *bond, in bond_option_pps_set() argument
1286 netdev_dbg(bond->dev, "Setting packets per slave to %llu\n", in bond_option_pps_set()
1287 newval->value); in bond_option_pps_set()
1288 bond->params.packets_per_slave = newval->value; in bond_option_pps_set()
1289 if (newval->value > 0) { in bond_option_pps_set()
1290 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1291 reciprocal_value(newval->value); in bond_option_pps_set()
1296 bond->params.reciprocal_packets_per_slave = in bond_option_pps_set()
1303 static int bond_option_lacp_rate_set(struct bonding *bond, in bond_option_lacp_rate_set() argument
1306 netdev_dbg(bond->dev, "Setting LACP rate to %s (%llu)\n", in bond_option_lacp_rate_set()
1307 newval->string, newval->value); in bond_option_lacp_rate_set()
1308 bond->params.lacp_fast = newval->value; in bond_option_lacp_rate_set()
1309 bond_3ad_update_lacp_rate(bond); in bond_option_lacp_rate_set()
1314 static int bond_option_ad_select_set(struct bonding *bond, in bond_option_ad_select_set() argument
1317 netdev_dbg(bond->dev, "Setting ad_select to %s (%llu)\n", in bond_option_ad_select_set()
1318 newval->string, newval->value); in bond_option_ad_select_set()
1319 bond->params.ad_select = newval->value; in bond_option_ad_select_set()
1324 static int bond_option_queue_id_set(struct bonding *bond, in bond_option_queue_id_set() argument
1335 delim = strchr(newval->string, ':'); in bond_option_queue_id_set()
1347 if (!dev_valid_name(newval->string) || in bond_option_queue_id_set()
1348 qid > bond->dev->real_num_tx_queues) in bond_option_queue_id_set()
1352 sdev = __dev_get_by_name(dev_net(bond->dev), newval->string); in bond_option_queue_id_set()
1358 bond_for_each_slave(bond, slave, iter) { in bond_option_queue_id_set()
1359 if (sdev == slave->dev) in bond_option_queue_id_set()
1364 else if (qid && qid == slave->queue_id) { in bond_option_queue_id_set()
1373 update_slave->queue_id = qid; in bond_option_queue_id_set()
1379 netdev_dbg(bond->dev, "invalid input for queue_id set\n"); in bond_option_queue_id_set()
1380 ret = -EPERM; in bond_option_queue_id_set()
1385 static int bond_option_slaves_set(struct bonding *bond, in bond_option_slaves_set() argument
1393 sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/ in bond_option_slaves_set()
1396 (command[0] != '+' && command[0] != '-') || in bond_option_slaves_set()
1400 dev = __dev_get_by_name(dev_net(bond->dev), ifname); in bond_option_slaves_set()
1402 netdev_dbg(bond->dev, "interface %s does not exist!\n", in bond_option_slaves_set()
1404 ret = -ENODEV; in bond_option_slaves_set()
1410 slave_dbg(bond->dev, dev, "Enslaving interface\n"); in bond_option_slaves_set()
1411 ret = bond_enslave(bond->dev, dev, NULL); in bond_option_slaves_set()
1414 case '-': in bond_option_slaves_set()
1415 slave_dbg(bond->dev, dev, "Releasing interface\n"); in bond_option_slaves_set()
1416 ret = bond_release(bond->dev, dev); in bond_option_slaves_set()
1428 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n"); in bond_option_slaves_set()
1429 ret = -EPERM; in bond_option_slaves_set()
1433 static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, in bond_option_tlb_dynamic_lb_set() argument
1436 netdev_dbg(bond->dev, "Setting dynamic-lb to %s (%llu)\n", in bond_option_tlb_dynamic_lb_set()
1437 newval->string, newval->value); in bond_option_tlb_dynamic_lb_set()
1438 bond->params.tlb_dynamic_lb = newval->value; in bond_option_tlb_dynamic_lb_set()
1443 static int bond_option_ad_actor_sys_prio_set(struct bonding *bond, in bond_option_ad_actor_sys_prio_set() argument
1446 netdev_dbg(bond->dev, "Setting ad_actor_sys_prio to %llu\n", in bond_option_ad_actor_sys_prio_set()
1447 newval->value); in bond_option_ad_actor_sys_prio_set()
1449 bond->params.ad_actor_sys_prio = newval->value; in bond_option_ad_actor_sys_prio_set()
1450 bond_3ad_update_ad_actor_settings(bond); in bond_option_ad_actor_sys_prio_set()
1455 static int bond_option_ad_actor_system_set(struct bonding *bond, in bond_option_ad_actor_system_set() argument
1461 if (newval->string) { in bond_option_ad_actor_system_set()
1462 if (!mac_pton(newval->string, macaddr)) in bond_option_ad_actor_system_set()
1466 mac = (u8 *)&newval->value; in bond_option_ad_actor_system_set()
1472 netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac); in bond_option_ad_actor_system_set()
1473 ether_addr_copy(bond->params.ad_actor_system, mac); in bond_option_ad_actor_system_set()
1474 bond_3ad_update_ad_actor_settings(bond); in bond_option_ad_actor_system_set()
1479 netdev_err(bond->dev, "Invalid ad_actor_system MAC address.\n"); in bond_option_ad_actor_system_set()
1480 return -EINVAL; in bond_option_ad_actor_system_set()
1483 static int bond_option_ad_user_port_key_set(struct bonding *bond, in bond_option_ad_user_port_key_set() argument
1486 netdev_dbg(bond->dev, "Setting ad_user_port_key to %llu\n", in bond_option_ad_user_port_key_set()
1487 newval->value); in bond_option_ad_user_port_key_set()
1489 bond->params.ad_user_port_key = newval->value; in bond_option_ad_user_port_key_set()