Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * drivers/net/bond/bond_options.c - bonding options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Copyright (c) 2013 Scott Feldman <sfeldma@cumulusnetworks.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #include <linux/if.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/rcupdate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/inet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <net/bonding.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) static int bond_option_active_slave_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) 					const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) static int bond_option_miimon_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 				  const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) static int bond_option_updelay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) 				   const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) static int bond_option_downdelay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 				     const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) static int bond_option_peer_notif_delay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 					    const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) static int bond_option_use_carrier_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 				       const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) static int bond_option_arp_interval_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 					const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) static int bond_option_arp_ip_targets_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 					  const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) static int bond_option_arp_validate_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 					const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) static int bond_option_arp_all_targets_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 					   const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) static int bond_option_primary_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 				   const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) static int bond_option_primary_reselect_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 					    const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) static int bond_option_fail_over_mac_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 					 const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) static int bond_option_xmit_hash_policy_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 					    const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) static int bond_option_resend_igmp_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 				       const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) static int bond_option_num_peer_notif_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 					  const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) static int bond_option_all_slaves_active_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 					     const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) static int bond_option_min_links_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 				     const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) static int bond_option_lp_interval_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 				       const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) static int bond_option_pps_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 			       const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) static int bond_option_lacp_rate_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 				     const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) static int bond_option_ad_select_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 				     const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) static int bond_option_queue_id_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 				    const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) static int bond_option_mode_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 				const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) static int bond_option_slaves_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 				  const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 				  const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 					     const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) static int bond_option_ad_actor_system_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 					   const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) static int bond_option_ad_user_port_key_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 					    const struct bond_opt_value *newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) static const struct bond_opt_value bond_mode_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	{ "balance-rr",    BOND_MODE_ROUNDROBIN,   BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 	{ "active-backup", BOND_MODE_ACTIVEBACKUP, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 	{ "balance-xor",   BOND_MODE_XOR,          0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 	{ "broadcast",     BOND_MODE_BROADCAST,    0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	{ "802.3ad",       BOND_MODE_8023AD,       0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	{ "balance-tlb",   BOND_MODE_TLB,          0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	{ "balance-alb",   BOND_MODE_ALB,          0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	{ NULL,            -1,                     0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) static const struct bond_opt_value bond_pps_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	{ "default", 1,         BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	{ "maxval",  USHRT_MAX, BOND_VALFLAG_MAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	{ NULL,      -1,        0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) static const struct bond_opt_value bond_xmit_hashtype_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	{ "layer2",   BOND_XMIT_POLICY_LAYER2, BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	{ "layer3+4", BOND_XMIT_POLICY_LAYER34, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 	{ "layer2+3", BOND_XMIT_POLICY_LAYER23, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 	{ "encap2+3", BOND_XMIT_POLICY_ENCAP23, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	{ "encap3+4", BOND_XMIT_POLICY_ENCAP34, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	{ NULL,       -1,                       0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) static const struct bond_opt_value bond_arp_validate_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	{ "none",		BOND_ARP_VALIDATE_NONE,		BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	{ "active",		BOND_ARP_VALIDATE_ACTIVE,	0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	{ "backup",		BOND_ARP_VALIDATE_BACKUP,	0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	{ "all",		BOND_ARP_VALIDATE_ALL,		0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	{ "filter",		BOND_ARP_FILTER,		0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	{ "filter_active",	BOND_ARP_FILTER_ACTIVE,		0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	{ "filter_backup",	BOND_ARP_FILTER_BACKUP,		0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	{ NULL,			-1,				0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) static const struct bond_opt_value bond_arp_all_targets_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	{ "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	{ "all", BOND_ARP_TARGETS_ALL, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	{ NULL,  -1,                   0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) static const struct bond_opt_value bond_fail_over_mac_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	{ "none",   BOND_FOM_NONE,   BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	{ "active", BOND_FOM_ACTIVE, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	{ "follow", BOND_FOM_FOLLOW, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 	{ NULL,     -1,              0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) static const struct bond_opt_value bond_intmax_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	{ "off",     0,       BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	{ "maxval",  INT_MAX, BOND_VALFLAG_MAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	{ NULL,      -1,      0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) static const struct bond_opt_value bond_lacp_rate_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 	{ "slow", AD_LACP_SLOW, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 	{ "fast", AD_LACP_FAST, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	{ NULL,   -1,           0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) static const struct bond_opt_value bond_ad_select_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	{ "stable",    BOND_AD_STABLE,    BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	{ "bandwidth", BOND_AD_BANDWIDTH, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	{ "count",     BOND_AD_COUNT,     0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	{ NULL,        -1,                0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) static const struct bond_opt_value bond_num_peer_notif_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	{ "off",     0,   0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	{ "maxval",  255, BOND_VALFLAG_MAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	{ "default", 1,   BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	{ NULL,      -1,  0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) static const struct bond_opt_value bond_primary_reselect_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	{ "always",  BOND_PRI_RESELECT_ALWAYS,  BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	{ "better",  BOND_PRI_RESELECT_BETTER,  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	{ "failure", BOND_PRI_RESELECT_FAILURE, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	{ NULL,      -1},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) static const struct bond_opt_value bond_use_carrier_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	{ "off", 0,  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	{ "on",  1,  BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	{ NULL,  -1, 0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) static const struct bond_opt_value bond_all_slaves_active_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	{ "off", 0,  BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	{ "on",  1,  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	{ NULL,  -1, 0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) static const struct bond_opt_value bond_resend_igmp_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	{ "off",     0,   0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	{ "maxval",  255, BOND_VALFLAG_MAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	{ "default", 1,   BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	{ NULL,      -1,  0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) static const struct bond_opt_value bond_lp_interval_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	{ "minval",  1,       BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	{ "maxval",  INT_MAX, BOND_VALFLAG_MAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	{ NULL,      -1,      0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) static const struct bond_opt_value bond_tlb_dynamic_lb_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	{ "off", 0,  0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	{ "on",  1,  BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	{ NULL,  -1, 0}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) static const struct bond_opt_value bond_ad_actor_sys_prio_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	{ "minval",  1,     BOND_VALFLAG_MIN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	{ "maxval",  65535, BOND_VALFLAG_MAX | BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	{ NULL,      -1,    0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) static const struct bond_opt_value bond_ad_user_port_key_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	{ "minval",  0,     BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	{ "maxval",  1023,  BOND_VALFLAG_MAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	{ NULL,      -1,    0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) static const struct bond_option bond_opts[BOND_OPT_LAST] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	[BOND_OPT_MODE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		.id = BOND_OPT_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 		.name = "mode",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		.desc = "bond device mode",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 		.flags = BOND_OPTFLAG_NOSLAVES | BOND_OPTFLAG_IFDOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 		.values = bond_mode_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 		.set = bond_option_mode_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	[BOND_OPT_PACKETS_PER_SLAVE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 		.id = BOND_OPT_PACKETS_PER_SLAVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 		.name = "packets_per_slave",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 		.desc = "Packets to send per slave in RR mode",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ROUNDROBIN)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 		.values = bond_pps_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 		.set = bond_option_pps_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	[BOND_OPT_XMIT_HASH] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 		.id = BOND_OPT_XMIT_HASH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 		.name = "xmit_hash_policy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 		.desc = "balance-xor, 802.3ad, and tlb hashing method",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 		.values = bond_xmit_hashtype_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 		.set = bond_option_xmit_hash_policy_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	[BOND_OPT_ARP_VALIDATE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 		.id = BOND_OPT_ARP_VALIDATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		.name = "arp_validate",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		.desc = "validate src/dst of ARP probes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 		.unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 			       BIT(BOND_MODE_ALB),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		.values = bond_arp_validate_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 		.set = bond_option_arp_validate_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	[BOND_OPT_ARP_ALL_TARGETS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 		.id = BOND_OPT_ARP_ALL_TARGETS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		.name = "arp_all_targets",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 		.desc = "fail on any/all arp targets timeout",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 		.values = bond_arp_all_targets_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 		.set = bond_option_arp_all_targets_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	[BOND_OPT_FAIL_OVER_MAC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 		.id = BOND_OPT_FAIL_OVER_MAC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 		.name = "fail_over_mac",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 		.desc = "For active-backup, do not set all slaves to the same MAC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 		.flags = BOND_OPTFLAG_NOSLAVES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 		.values = bond_fail_over_mac_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 		.set = bond_option_fail_over_mac_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	[BOND_OPT_ARP_INTERVAL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		.id = BOND_OPT_ARP_INTERVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 		.name = "arp_interval",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 		.desc = "arp interval in milliseconds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 		.unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 			       BIT(BOND_MODE_ALB),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 		.values = bond_intmax_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 		.set = bond_option_arp_interval_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	[BOND_OPT_ARP_TARGETS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 		.id = BOND_OPT_ARP_TARGETS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 		.name = "arp_ip_target",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 		.desc = "arp targets in n.n.n.n form",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 		.flags = BOND_OPTFLAG_RAWVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 		.set = bond_option_arp_ip_targets_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	[BOND_OPT_DOWNDELAY] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 		.id = BOND_OPT_DOWNDELAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 		.name = "downdelay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 		.desc = "Delay before considering link down, in milliseconds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 		.values = bond_intmax_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 		.set = bond_option_downdelay_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	[BOND_OPT_UPDELAY] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 		.id = BOND_OPT_UPDELAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 		.name = "updelay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 		.desc = "Delay before considering link up, in milliseconds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		.values = bond_intmax_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		.set = bond_option_updelay_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	[BOND_OPT_LACP_RATE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 		.id = BOND_OPT_LACP_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		.name = "lacp_rate",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		.desc = "LACPDU tx rate to request from 802.3ad partner",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		.flags = BOND_OPTFLAG_IFDOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		.values = bond_lacp_rate_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 		.set = bond_option_lacp_rate_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	[BOND_OPT_MINLINKS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 		.id = BOND_OPT_MINLINKS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 		.name = "min_links",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 		.desc = "Minimum number of available links before turning on carrier",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 		.values = bond_intmax_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		.set = bond_option_min_links_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	[BOND_OPT_AD_SELECT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 		.id = BOND_OPT_AD_SELECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 		.name = "ad_select",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 		.desc = "803.ad aggregation selection logic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 		.flags = BOND_OPTFLAG_IFDOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 		.values = bond_ad_select_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 		.set = bond_option_ad_select_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	[BOND_OPT_NUM_PEER_NOTIF] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 		.id = BOND_OPT_NUM_PEER_NOTIF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 		.name = "num_unsol_na",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		.desc = "Number of peer notifications to send on failover event",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 		.values = bond_num_peer_notif_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 		.set = bond_option_num_peer_notif_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	[BOND_OPT_MIIMON] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 		.id = BOND_OPT_MIIMON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		.name = "miimon",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		.desc = "Link check interval in milliseconds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 		.values = bond_intmax_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		.set = bond_option_miimon_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	[BOND_OPT_PRIMARY] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 		.id = BOND_OPT_PRIMARY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		.name = "primary",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		.desc = "Primary network device to use",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 		.flags = BOND_OPTFLAG_RAWVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 						BIT(BOND_MODE_TLB) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 						BIT(BOND_MODE_ALB)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 		.set = bond_option_primary_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	[BOND_OPT_PRIMARY_RESELECT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 		.id = BOND_OPT_PRIMARY_RESELECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 		.name = "primary_reselect",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 		.desc = "Reselect primary slave once it comes up",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 		.values = bond_primary_reselect_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 		.set = bond_option_primary_reselect_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	[BOND_OPT_USE_CARRIER] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 		.id = BOND_OPT_USE_CARRIER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 		.name = "use_carrier",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 		.desc = "Use netif_carrier_ok (vs MII ioctls) in miimon",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		.values = bond_use_carrier_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		.set = bond_option_use_carrier_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	[BOND_OPT_ACTIVE_SLAVE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 		.id = BOND_OPT_ACTIVE_SLAVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 		.name = "active_slave",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		.desc = "Currently active slave",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 		.flags = BOND_OPTFLAG_RAWVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 						BIT(BOND_MODE_TLB) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 						BIT(BOND_MODE_ALB)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 		.set = bond_option_active_slave_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	[BOND_OPT_QUEUE_ID] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		.id = BOND_OPT_QUEUE_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 		.name = "queue_id",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 		.desc = "Set queue id of a slave",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		.flags = BOND_OPTFLAG_RAWVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		.set = bond_option_queue_id_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 	[BOND_OPT_ALL_SLAVES_ACTIVE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 		.id = BOND_OPT_ALL_SLAVES_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		.name = "all_slaves_active",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 		.desc = "Keep all frames received on an interface by setting active flag for all slaves",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 		.values = bond_all_slaves_active_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 		.set = bond_option_all_slaves_active_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	[BOND_OPT_RESEND_IGMP] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		.id = BOND_OPT_RESEND_IGMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		.name = "resend_igmp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 		.desc = "Number of IGMP membership reports to send on link failure",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 		.values = bond_resend_igmp_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 		.set = bond_option_resend_igmp_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	[BOND_OPT_LP_INTERVAL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		.id = BOND_OPT_LP_INTERVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		.name = "lp_interval",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 		.desc = "The number of seconds between instances where the bonding driver sends learning packets to each slave's peer switch",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		.values = bond_lp_interval_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 		.set = bond_option_lp_interval_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	[BOND_OPT_SLAVES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		.id = BOND_OPT_SLAVES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		.name = "slaves",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 		.desc = "Slave membership management",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		.flags = BOND_OPTFLAG_RAWVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 		.set = bond_option_slaves_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	[BOND_OPT_TLB_DYNAMIC_LB] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 		.id = BOND_OPT_TLB_DYNAMIC_LB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 		.name = "tlb_dynamic_lb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 		.desc = "Enable dynamic flow shuffling",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_TLB) | BIT(BOND_MODE_ALB)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 		.values = bond_tlb_dynamic_lb_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 		.flags = BOND_OPTFLAG_IFDOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 		.set = bond_option_tlb_dynamic_lb_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	[BOND_OPT_AD_ACTOR_SYS_PRIO] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 		.id = BOND_OPT_AD_ACTOR_SYS_PRIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 		.name = "ad_actor_sys_prio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 		.values = bond_ad_actor_sys_prio_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		.set = bond_option_ad_actor_sys_prio_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	[BOND_OPT_AD_ACTOR_SYSTEM] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		.id = BOND_OPT_AD_ACTOR_SYSTEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		.name = "ad_actor_system",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		.flags = BOND_OPTFLAG_RAWVAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		.set = bond_option_ad_actor_system_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	[BOND_OPT_AD_USER_PORT_KEY] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		.id = BOND_OPT_AD_USER_PORT_KEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		.name = "ad_user_port_key",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		.flags = BOND_OPTFLAG_IFDOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		.values = bond_ad_user_port_key_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 		.set = bond_option_ad_user_port_key_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	[BOND_OPT_NUM_PEER_NOTIF_ALIAS] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		.id = BOND_OPT_NUM_PEER_NOTIF_ALIAS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		.name = "num_grat_arp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		.desc = "Number of peer notifications to send on failover event",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 		.values = bond_num_peer_notif_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		.set = bond_option_num_peer_notif_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	[BOND_OPT_PEER_NOTIF_DELAY] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		.id = BOND_OPT_PEER_NOTIF_DELAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		.name = "peer_notif_delay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		.desc = "Delay between each peer notification on failover event, in milliseconds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 		.values = bond_intmax_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 		.set = bond_option_peer_notif_delay_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) /* Searches for an option by name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) const struct bond_option *bond_opt_get_by_name(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	const struct bond_option *opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	int option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	for (option = 0; option < BOND_OPT_LAST; option++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 		opt = bond_opt_get(option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 		if (opt && !strcmp(opt->name, name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 			return opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) /* Searches for a value in opt's values[] table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	const struct bond_option *opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	opt = bond_opt_get(option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	if (WARN_ON(!opt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	for (i = 0; opt->values && opt->values[i].string; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 		if (opt->values[i].value == val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 			return &opt->values[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) /* Searches for a value in opt's values[] table which matches the flagmask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) static const struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 						       u32 flagmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	for (i = 0; opt->values && opt->values[i].string; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 		if (opt->values[i].flags & flagmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 			return &opt->values[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) /* If maxval is missing then there's no range to check. In case minval is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484)  * missing then it's considered to be 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) static bool bond_opt_check_range(const struct bond_option *opt, u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	const struct bond_opt_value *minval, *maxval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	if (!maxval || (minval && val < minval->value) || val > maxval->value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499)  * bond_opt_parse - parse option value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500)  * @opt: the option to parse against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501)  * @val: value to parse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503)  * This function tries to extract the value from @val and check if it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504)  * a possible match for the option and returns NULL if a match isn't found,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505)  * or the struct_opt_value that matched. It also strips the new line from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506)  * @val->string if it's present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 					    struct bond_opt_value *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	char *p, valstr[BOND_OPT_MAX_NAMELEN + 1] = { 0, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	const struct bond_opt_value *tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	const struct bond_opt_value *ret = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	bool checkval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	int i, rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	/* No parsing if the option wants a raw val */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	if (opt->flags & BOND_OPTFLAG_RAWVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 		return val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	tbl = opt->values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	if (!tbl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	/* ULLONG_MAX is used to bypass string processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	checkval = val->value != ULLONG_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	if (!checkval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		if (!val->string)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		p = strchr(val->string, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 		if (p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 			*p = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 		for (p = val->string; *p; p++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 			if (!(isdigit(*p) || isspace(*p)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		/* The following code extracts the string to match or the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 		 * and sets checkval appropriately
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 		if (*p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 			rv = sscanf(val->string, "%32s", valstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 			rv = sscanf(val->string, "%llu", &val->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 			checkval = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 		if (!rv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	for (i = 0; tbl[i].string; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		/* Check for exact match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 		if (checkval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 			if (val->value == tbl[i].value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 				ret = &tbl[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 			if (!strcmp(valstr, "default") &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 			    (tbl[i].flags & BOND_VALFLAG_DEFAULT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 				ret = &tbl[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 			if (!strcmp(valstr, tbl[i].string))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 				ret = &tbl[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		/* Found an exact match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	/* Possible range match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	if (checkval && bond_opt_check_range(opt, val->value))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		ret = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) /* Check opt's dependencies against bond mode and currently set options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) static int bond_opt_check_deps(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 			       const struct bond_option *opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	struct bond_params *params = &bond->params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	if (test_bit(params->mode, &opt->unsuppmodes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 		return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		return -ENOTEMPTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) static void bond_opt_dep_print(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 			       const struct bond_option *opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	const struct bond_opt_value *modeval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	struct bond_params *params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	params = &bond->params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	modeval = bond_opt_get_val(BOND_OPT_MODE, params->mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	if (test_bit(params->mode, &opt->unsuppmodes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 			   opt->name, modeval->string, modeval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) static void bond_opt_error_interpret(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 				     const struct bond_option *opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 				     int error, const struct bond_opt_value *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	const struct bond_opt_value *minval, *maxval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	switch (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	case -EINVAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		if (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 			if (val->string) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 				/* sometimes RAWVAL opts may have new lines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 				p = strchr(val->string, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 				if (p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 					*p = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 				netdev_err(bond->dev, "option %s: invalid value (%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 					   opt->name, val->string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 				netdev_err(bond->dev, "option %s: invalid value (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 					   opt->name, val->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 		maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 		if (!maxval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 		netdev_err(bond->dev, "option %s: allowed values %llu - %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 			   opt->name, minval ? minval->value : 0, maxval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	case -EACCES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 		bond_opt_dep_print(bond, opt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	case -ENOTEMPTY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 		netdev_err(bond->dev, "option %s: unable to set because the bond device has slaves\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 			   opt->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	case -EBUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 		netdev_err(bond->dev, "option %s: unable to set because the bond device is up\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 			   opt->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648)  * __bond_opt_set - set a bonding option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649)  * @bond: target bond device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650)  * @option: option to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651)  * @val: value to set it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653)  * This function is used to change the bond's option value, it can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654)  * used for both enabling/changing an option and for disabling it. RTNL lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655)  * must be obtained before calling this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) int __bond_opt_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 		   unsigned int option, struct bond_opt_value *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	const struct bond_opt_value *retval = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	const struct bond_option *opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	int ret = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	ASSERT_RTNL();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	opt = bond_opt_get(option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	if (WARN_ON(!val) || WARN_ON(!opt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	ret = bond_opt_check_deps(bond, opt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	retval = bond_opt_parse(opt, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	if (!retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	ret = opt->set(bond, retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		bond_opt_error_interpret(bond, opt, ret, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685)  * __bond_opt_set_notify - set a bonding option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686)  * @bond: target bond device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687)  * @option: option to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688)  * @val: value to set it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690)  * This function is used to change the bond's option value and trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691)  * a notification to user sapce. It can be used for both enabling/changing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692)  * an option and for disabling it. RTNL lock must be obtained before calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693)  * this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) int __bond_opt_set_notify(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 			  unsigned int option, struct bond_opt_value *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	int ret = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	ASSERT_RTNL();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	ret = __bond_opt_set(bond, option, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	if (!ret && (bond->dev->reg_state == NETREG_REGISTERED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711)  * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712)  * @bond: target bond device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713)  * @option: option to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714)  * @buf: value to set it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716)  * This function tries to acquire RTNL without blocking and if successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717)  * calls __bond_opt_set. It is mainly used for sysfs option manipulation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	struct bond_opt_value optval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	if (!rtnl_trylock())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 		return restart_syscall();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	bond_opt_initstr(&optval, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	ret = __bond_opt_set_notify(bond, option, &optval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734)  * bond_opt_get - get a pointer to an option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735)  * @option: option for which to return a pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737)  * This function checks if option is valid and if so returns a pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738)  * to its entry in the bond_opts[] option array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) const struct bond_option *bond_opt_get(unsigned int option)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	if (!BOND_OPT_VALID(option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	return &bond_opts[option];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) static void bond_set_xfrm_features(struct net_device *bond_dev, u64 mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	if (!IS_ENABLED(CONFIG_XFRM_OFFLOAD))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	if (mode == BOND_MODE_ACTIVEBACKUP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 		bond_dev->wanted_features |= BOND_XFRM_FEATURES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 		bond_dev->wanted_features &= ~BOND_XFRM_FEATURES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	netdev_update_features(bond_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) static int bond_option_mode_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 				const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	if (!bond_mode_uses_arp(newval->value)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		if (bond->params.arp_interval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 			netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 				   newval->string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 			/* disable arp monitoring */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 			bond->params.arp_interval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 		if (!bond->params.miimon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 			/* set miimon to default value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 			bond->params.miimon = BOND_DEFAULT_MIIMON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 			netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 				   bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	if (newval->value == BOND_MODE_ALB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		bond->params.tlb_dynamic_lb = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	if (bond->dev->reg_state == NETREG_REGISTERED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 		bond_set_xfrm_features(bond->dev, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	/* don't cache arp_validate between modes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	bond->params.mode = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) static int bond_option_active_slave_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 					const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 	char ifname[IFNAMSIZ] = { 0, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	struct net_device *slave_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	sscanf(newval->string, "%15s", ifname); /* IFNAMSIZ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	if (!strlen(ifname) || newval->string[0] == '\n') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 		slave_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		slave_dev = __dev_get_by_name(dev_net(bond->dev), ifname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		if (!slave_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 			return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	if (slave_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 		if (!netif_is_bond_slave(slave_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 			slave_err(bond->dev, slave_dev, "Device is not bonding slave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		if (bond->dev != netdev_master_upper_dev_get(slave_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 			slave_err(bond->dev, slave_dev, "Device is not our slave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	block_netpoll_tx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	/* check to see if we are clearing active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	if (!slave_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		netdev_dbg(bond->dev, "Clearing current active slave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 		RCU_INIT_POINTER(bond->curr_active_slave, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 		bond_select_active_slave(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		struct slave *old_active = rtnl_dereference(bond->curr_active_slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		struct slave *new_active = bond_slave_get_rtnl(slave_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		BUG_ON(!new_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 		if (new_active == old_active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 			/* do nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 			slave_dbg(bond->dev, new_active->dev, "is already the current active slave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 			if (old_active && (new_active->link == BOND_LINK_UP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 			    bond_slave_is_up(new_active)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 				slave_dbg(bond->dev, new_active->dev, "Setting as active slave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 				bond_change_active_slave(bond, new_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 				slave_err(bond->dev, new_active->dev, "Could not set as active slave; either %s is down or the link is down\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 					  new_active->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 				ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	unblock_netpoll_tx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) /* There are two tricky bits here.  First, if MII monitoring is activated, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854)  * we must disable ARP monitoring.  Second, if the timer isn't running, we must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855)  * start it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) static int bond_option_miimon_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 				  const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	netdev_dbg(bond->dev, "Setting MII monitoring interval to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	bond->params.miimon = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	if (bond->params.updelay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 		netdev_dbg(bond->dev, "Note: Updating updelay (to %d) since it is a multiple of the miimon value\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 			   bond->params.updelay * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	if (bond->params.downdelay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		netdev_dbg(bond->dev, "Note: Updating downdelay (to %d) since it is a multiple of the miimon value\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 			   bond->params.downdelay * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	if (bond->params.peer_notif_delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 		netdev_dbg(bond->dev, "Note: Updating peer_notif_delay (to %d) since it is a multiple of the miimon value\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 			   bond->params.peer_notif_delay * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 	if (newval->value && bond->params.arp_interval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		netdev_dbg(bond->dev, "MII monitoring cannot be used with ARP monitoring - disabling ARP monitoring...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		bond->params.arp_interval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		if (bond->params.arp_validate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 			bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	if (bond->dev->flags & IFF_UP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		/* If the interface is up, we may need to fire off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 		 * the MII timer. If the interface is down, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 		 * timer will get fired off when the open function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 		 * is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 		if (!newval->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 			cancel_delayed_work_sync(&bond->mii_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 			cancel_delayed_work_sync(&bond->arp_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 			queue_delayed_work(bond->wq, &bond->mii_work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) /* Set up, down and peer notification delays. These must be multiples
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896)  * of the MII monitoring value, and are stored internally as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897)  * multiplier. Thus, we must translate to MS for the real world.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) static int _bond_option_delay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 				  const struct bond_opt_value *newval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 				  const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 				  int *target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	int value = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	if (!bond->params.miimon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 		netdev_err(bond->dev, "Unable to set %s as MII monitoring is disabled\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 			   name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	if ((value % bond->params.miimon) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 		netdev_warn(bond->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 			    "%s (%d) is not a multiple of miimon (%d), value rounded to %d ms\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 			    name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 			    value, bond->params.miimon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 			    (value / bond->params.miimon) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 			    bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	*target = value / bond->params.miimon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	netdev_dbg(bond->dev, "Setting %s to %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 		   name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 		   *target * bond->params.miimon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) static int bond_option_updelay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 				   const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	return _bond_option_delay_set(bond, newval, "up delay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 				      &bond->params.updelay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) static int bond_option_downdelay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 				     const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	return _bond_option_delay_set(bond, newval, "down delay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 				      &bond->params.downdelay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) static int bond_option_peer_notif_delay_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 					    const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	int ret = _bond_option_delay_set(bond, newval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 					 "peer notification delay",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 					 &bond->params.peer_notif_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) static int bond_option_use_carrier_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 				       const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	netdev_dbg(bond->dev, "Setting use_carrier to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	bond->params.use_carrier = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) /* There are two tricky bits here.  First, if ARP monitoring is activated, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961)  * we must disable MII monitoring.  Second, if the ARP timer isn't running,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962)  * we must start it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) static int bond_option_arp_interval_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 					const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	netdev_dbg(bond->dev, "Setting ARP monitoring interval to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	bond->params.arp_interval = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	if (newval->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 		if (bond->params.miimon) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 			netdev_dbg(bond->dev, "ARP monitoring cannot be used with MII monitoring. Disabling MII monitoring\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 			bond->params.miimon = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		if (!bond->params.arp_targets[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 			netdev_dbg(bond->dev, "ARP monitoring has been set up, but no ARP targets have been specified\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	if (bond->dev->flags & IFF_UP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 		/* If the interface is up, we may need to fire off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 		 * the ARP timer.  If the interface is down, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		 * timer will get fired off when the open function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 		 * is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 		if (!newval->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 			if (bond->params.arp_validate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 				bond->recv_probe = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 			cancel_delayed_work_sync(&bond->arp_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 			/* arp_validate can be set only in active-backup mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 			bond->recv_probe = bond_arp_rcv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 			cancel_delayed_work_sync(&bond->mii_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 			queue_delayed_work(bond->wq, &bond->arp_work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 					    __be32 target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 					    unsigned long last_rx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	__be32 *targets = bond->params.arp_targets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	struct slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	if (slot >= 0 && slot < BOND_MAX_ARP_TARGETS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 		bond_for_each_slave(bond, slave, iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 			slave->target_last_arp_rx[slot] = last_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 		targets[slot] = target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	__be32 *targets = bond->params.arp_targets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	int ind;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	if (!bond_is_ip_target_ok(target)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 		netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 			   &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	if (bond_get_targets_ip(targets, target) != -1) { /* dup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 		netdev_err(bond->dev, "ARP target %pI4 is already present\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 			   &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	ind = bond_get_targets_ip(targets, 0); /* first free slot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	if (ind == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 		netdev_err(bond->dev, "ARP target table is full!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	_bond_options_arp_ip_target_set(bond, ind, target, jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	return _bond_option_arp_ip_target_add(bond, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	__be32 *targets = bond->params.arp_targets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	struct slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	unsigned long *targets_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	int ind, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	if (!bond_is_ip_target_ok(target)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 		netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 			   &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	ind = bond_get_targets_ip(targets, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	if (ind == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 		netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 			   &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	if (ind == 0 && !targets[1] && bond->params.arp_interval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 		netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	bond_for_each_slave(bond, slave, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 		targets_rx = slave->target_last_arp_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 		for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 			targets_rx[i] = targets_rx[i+1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 		targets_rx[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 		targets[i] = targets[i+1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	targets[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) void bond_option_arp_ip_targets_clear(struct bonding *bond)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	for (i = 0; i < BOND_MAX_ARP_TARGETS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 		_bond_options_arp_ip_target_set(bond, i, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) static int bond_option_arp_ip_targets_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 					  const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	int ret = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	__be32 target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	if (newval->string) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 		if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 			netdev_err(bond->dev, "invalid ARP target %pI4 specified\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 				   &target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 		if (newval->string[0] == '+')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 			ret = bond_option_arp_ip_target_add(bond, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 		else if (newval->string[0] == '-')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 			ret = bond_option_arp_ip_target_rem(bond, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 			netdev_err(bond->dev, "no command found in arp_ip_targets file - use +<addr> or -<addr>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 		target = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 		ret = bond_option_arp_ip_target_add(bond, target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) static int bond_option_arp_validate_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 					const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	netdev_dbg(bond->dev, "Setting arp_validate to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	bond->params.arp_validate = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) static int bond_option_arp_all_targets_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 					   const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	netdev_dbg(bond->dev, "Setting arp_all_targets to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 	bond->params.arp_all_targets = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) static int bond_option_primary_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 				   const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 	char *p, *primary = newval->string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	struct slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	block_netpoll_tx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	p = strchr(primary, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	if (p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 		*p = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	/* check to see if we are clearing primary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	if (!strlen(primary)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 		netdev_dbg(bond->dev, "Setting primary slave to None\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 		RCU_INIT_POINTER(bond->primary_slave, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 		memset(bond->params.primary, 0, sizeof(bond->params.primary));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		bond_select_active_slave(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	bond_for_each_slave(bond, slave, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 		if (strncmp(slave->dev->name, primary, IFNAMSIZ) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 			slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 			rcu_assign_pointer(bond->primary_slave, slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 			strcpy(bond->params.primary, slave->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 			bond->force_primary = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 			bond_select_active_slave(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	if (rtnl_dereference(bond->primary_slave)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 		netdev_dbg(bond->dev, "Setting primary slave to None\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 		RCU_INIT_POINTER(bond->primary_slave, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 		bond_select_active_slave(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	strncpy(bond->params.primary, primary, IFNAMSIZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	bond->params.primary[IFNAMSIZ - 1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 	netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 		   primary);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	unblock_netpoll_tx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) static int bond_option_primary_reselect_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 					    const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	netdev_dbg(bond->dev, "Setting primary_reselect to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	bond->params.primary_reselect = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	block_netpoll_tx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	bond_select_active_slave(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	unblock_netpoll_tx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) static int bond_option_fail_over_mac_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 					 const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	netdev_dbg(bond->dev, "Setting fail_over_mac to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	bond->params.fail_over_mac = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) static int bond_option_xmit_hash_policy_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 					    const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 	netdev_dbg(bond->dev, "Setting xmit hash policy to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	bond->params.xmit_policy = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) static int bond_option_resend_igmp_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 				       const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 	netdev_dbg(bond->dev, "Setting resend_igmp to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	bond->params.resend_igmp = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) static int bond_option_num_peer_notif_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 				   const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	bond->params.num_peer_notif = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) static int bond_option_all_slaves_active_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 					     const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	struct slave *slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	if (newval->value == bond->params.all_slaves_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	bond->params.all_slaves_active = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	bond_for_each_slave(bond, slave, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 		if (!bond_is_active_slave(slave)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 			if (newval->value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 				slave->inactive = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 				slave->inactive = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) static int bond_option_min_links_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 				     const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	netdev_dbg(bond->dev, "Setting min links value to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	bond->params.min_links = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	bond_set_carrier(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) static int bond_option_lp_interval_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 				       const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	bond->params.lp_interval = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) static int bond_option_pps_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 			       const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 	netdev_dbg(bond->dev, "Setting packets per slave to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	bond->params.packets_per_slave = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	if (newval->value > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 		bond->params.reciprocal_packets_per_slave =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 			reciprocal_value(newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 		/* reciprocal_packets_per_slave is unused if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 		 * packets_per_slave is 0 or 1, just initialize it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 		bond->params.reciprocal_packets_per_slave =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 			(struct reciprocal_value) { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) static int bond_option_lacp_rate_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 				     const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	netdev_dbg(bond->dev, "Setting LACP rate to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	bond->params.lacp_fast = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	bond_3ad_update_lacp_rate(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) static int bond_option_ad_select_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 				     const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	netdev_dbg(bond->dev, "Setting ad_select to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 	bond->params.ad_select = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) static int bond_option_queue_id_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 				    const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	struct slave *slave, *update_slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	struct net_device *sdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	struct list_head *iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	char *delim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	u16 qid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	/* delim will point to queue id if successful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	delim = strchr(newval->string, ':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	if (!delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 	/* Terminate string that points to device name and bump it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	 * up one, so we can read the queue id there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	*delim = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	if (sscanf(++delim, "%hd\n", &qid) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	/* Check buffer length, valid ifname and queue id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	if (!dev_valid_name(newval->string) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	    qid > bond->dev->real_num_tx_queues)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	/* Get the pointer to that interface if it exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	sdev = __dev_get_by_name(dev_net(bond->dev), newval->string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	if (!sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	/* Search for thes slave and check for duplicate qids */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	update_slave = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	bond_for_each_slave(bond, slave, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 		if (sdev == slave->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 			/* We don't need to check the matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 			 * slave for dups, since we're overwriting it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 			update_slave = slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 		else if (qid && qid == slave->queue_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 			goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 	if (!update_slave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 	/* Actually set the qids for the slave */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	update_slave->queue_id = qid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) err_no_cmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	netdev_dbg(bond->dev, "invalid input for queue_id set\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	ret = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) static int bond_option_slaves_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 				  const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	char command[IFNAMSIZ + 1] = { 0, };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	char *ifname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	ifname = command + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 	if ((strlen(command) <= 1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	    (command[0] != '+' && command[0] != '-') ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	    !dev_valid_name(ifname))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	dev = __dev_get_by_name(dev_net(bond->dev), ifname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	if (!dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 		netdev_dbg(bond->dev, "interface %s does not exist!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 			   ifname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 		ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	switch (command[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 	case '+':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 		slave_dbg(bond->dev, dev, "Enslaving interface\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 		ret = bond_enslave(bond->dev, dev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 	case '-':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 		slave_dbg(bond->dev, dev, "Releasing interface\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 		ret = bond_release(bond->dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 		/* should not run here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 		goto err_no_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) err_no_cmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 	netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 	ret = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 					  const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	netdev_dbg(bond->dev, "Setting dynamic-lb to %s (%llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 		   newval->string, newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 	bond->params.tlb_dynamic_lb = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 					     const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 	netdev_dbg(bond->dev, "Setting ad_actor_sys_prio to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 	bond->params.ad_actor_sys_prio = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	bond_3ad_update_ad_actor_settings(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) static int bond_option_ad_actor_system_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 					   const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	u8 macaddr[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	u8 *mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	if (newval->string) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 		if (!mac_pton(newval->string, macaddr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 			goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 		mac = macaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 		mac = (u8 *)&newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 	if (is_multicast_ether_addr(mac))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 		goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	netdev_dbg(bond->dev, "Setting ad_actor_system to %pM\n", mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 	ether_addr_copy(bond->params.ad_actor_system, mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 	bond_3ad_update_ad_actor_settings(bond);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 	netdev_err(bond->dev, "Invalid ad_actor_system MAC address.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) static int bond_option_ad_user_port_key_set(struct bonding *bond,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 					    const struct bond_opt_value *newval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	netdev_dbg(bond->dev, "Setting ad_user_port_key to %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 		   newval->value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 	bond->params.ad_user_port_key = newval->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) }