linux/drivers/net/bonding/bond_options.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * drivers/net/bond/bond_options.c - bonding options
 * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us>
 * Copyright (c) 2013 Scott Feldman <sfeldma@cumulusnetworks.com>
 */

#include <linux/errno.h>
#include <linux/if.h>
#include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include <linux/ctype.h>
#include <linux/inet.h>
#include <linux/sched/signal.h>

#include <net/bonding.h>

static int bond_option_active_slave_set(struct bonding *bond,
					const struct bond_opt_value *newval);
static int bond_option_miimon_set(struct bonding *bond,
				  const struct bond_opt_value *newval);
static int bond_option_updelay_set(struct bonding *bond,
				   const struct bond_opt_value *newval);
static int bond_option_downdelay_set(struct bonding *bond,
				     const struct bond_opt_value *newval);
static int bond_option_peer_notif_delay_set(struct bonding *bond,
					    const struct bond_opt_value *newval);
static int bond_option_use_carrier_set(struct bonding *bond,
				       const struct bond_opt_value *newval);
static int bond_option_arp_interval_set(struct bonding *bond,
					const struct bond_opt_value *newval);
static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
static int bond_option_arp_ip_targets_set(struct bonding *bond,
					  const struct bond_opt_value *newval);
static int bond_option_ns_ip6_targets_set(struct bonding *bond,
					  const struct bond_opt_value *newval);
static int bond_option_arp_validate_set(struct bonding *bond,
					const struct bond_opt_value *newval);
static int bond_option_arp_all_targets_set(struct bonding *bond,
					   const struct bond_opt_value *newval);
static int bond_option_prio_set(struct bonding *bond,
				const struct bond_opt_value *newval);
static int bond_option_primary_set(struct bonding *bond,
				   const struct bond_opt_value *newval);
static int bond_option_primary_reselect_set(struct bonding *bond,
					    const struct bond_opt_value *newval);
static int bond_option_fail_over_mac_set(struct bonding *bond,
					 const struct bond_opt_value *newval);
static int bond_option_xmit_hash_policy_set(struct bonding *bond,
					    const struct bond_opt_value *newval);
static int bond_option_resend_igmp_set(struct bonding *bond,
				       const struct bond_opt_value *newval);
static int bond_option_num_peer_notif_set(struct bonding *bond,
					  const struct bond_opt_value *newval);
static int bond_option_all_slaves_active_set(struct bonding *bond,
					     const struct bond_opt_value *newval);
static int bond_option_min_links_set(struct bonding *bond,
				     const struct bond_opt_value *newval);
static int bond_option_lp_interval_set(struct bonding *bond,
				       const struct bond_opt_value *newval);
static int bond_option_pps_set(struct bonding *bond,
			       const struct bond_opt_value *newval);
static int bond_option_lacp_active_set(struct bonding *bond,
				       const struct bond_opt_value *newval);
static int bond_option_lacp_rate_set(struct bonding *bond,
				     const struct bond_opt_value *newval);
static int bond_option_ad_select_set(struct bonding *bond,
				     const struct bond_opt_value *newval);
static int bond_option_queue_id_set(struct bonding *bond,
				    const struct bond_opt_value *newval);
static int bond_option_mode_set(struct bonding *bond,
				const struct bond_opt_value *newval);
static int bond_option_slaves_set(struct bonding *bond,
				  const struct bond_opt_value *newval);
static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
				  const struct bond_opt_value *newval);
static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
					     const struct bond_opt_value *newval);
static int bond_option_ad_actor_system_set(struct bonding *bond,
					   const struct bond_opt_value *newval);
static int bond_option_ad_user_port_key_set(struct bonding *bond,
					    const struct bond_opt_value *newval);
static int bond_option_missed_max_set(struct bonding *bond,
				      const struct bond_opt_value *newval);
static int bond_option_coupled_control_set(struct bonding *bond,
					   const struct bond_opt_value *newval);

static const struct bond_opt_value bond_mode_tbl[] =;

static const struct bond_opt_value bond_pps_tbl[] =;

static const struct bond_opt_value bond_xmit_hashtype_tbl[] =;

static const struct bond_opt_value bond_arp_validate_tbl[] =;

static const struct bond_opt_value bond_arp_all_targets_tbl[] =;

static const struct bond_opt_value bond_fail_over_mac_tbl[] =;

static const struct bond_opt_value bond_intmax_tbl[] =;

static const struct bond_opt_value bond_lacp_active[] =;

static const struct bond_opt_value bond_lacp_rate_tbl[] =;

static const struct bond_opt_value bond_ad_select_tbl[] =;

static const struct bond_opt_value bond_num_peer_notif_tbl[] =;

static const struct bond_opt_value bond_peer_notif_delay_tbl[] =;

static const struct bond_opt_value bond_primary_reselect_tbl[] =;

static const struct bond_opt_value bond_use_carrier_tbl[] =;

static const struct bond_opt_value bond_all_slaves_active_tbl[] =;

static const struct bond_opt_value bond_resend_igmp_tbl[] =;

static const struct bond_opt_value bond_lp_interval_tbl[] =;

static const struct bond_opt_value bond_tlb_dynamic_lb_tbl[] =;

static const struct bond_opt_value bond_ad_actor_sys_prio_tbl[] =;

static const struct bond_opt_value bond_ad_user_port_key_tbl[] =;

static const struct bond_opt_value bond_missed_max_tbl[] =;

static const struct bond_opt_value bond_coupled_control_tbl[] =;

static const struct bond_option bond_opts[BOND_OPT_LAST] =;

/* Searches for an option by name */
const struct bond_option *bond_opt_get_by_name(const char *name)
{}

/* Searches for a value in opt's values[] table */
const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val)
{}

/* Searches for a value in opt's values[] table which matches the flagmask */
static const struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt,
						       u32 flagmask)
{}

/* If maxval is missing then there's no range to check. In case minval is
 * missing then it's considered to be 0.
 */
static bool bond_opt_check_range(const struct bond_option *opt, u64 val)
{}

/**
 * bond_opt_parse - parse option value
 * @opt: the option to parse against
 * @val: value to parse
 *
 * This function tries to extract the value from @val and check if it's
 * a possible match for the option and returns NULL if a match isn't found,
 * or the struct_opt_value that matched. It also strips the new line from
 * @val->string if it's present.
 */
const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
					    struct bond_opt_value *val)
{}

/* Check opt's dependencies against bond mode and currently set options */
static int bond_opt_check_deps(struct bonding *bond,
			       const struct bond_option *opt)
{}

static void bond_opt_dep_print(struct bonding *bond,
			       const struct bond_option *opt,
			       struct nlattr *bad_attr,
			       struct netlink_ext_ack *extack)
{}

static void bond_opt_error_interpret(struct bonding *bond,
				     const struct bond_option *opt,
				     int error, const struct bond_opt_value *val,
				     struct nlattr *bad_attr,
				     struct netlink_ext_ack *extack)
{}

/**
 * __bond_opt_set - set a bonding option
 * @bond: target bond device
 * @option: option to set
 * @val: value to set it to
 * @bad_attr: netlink attribue that caused the error
 * @extack: extended netlink error structure, used when an error message
 *          needs to be returned to the caller via netlink
 *
 * This function is used to change the bond's option value, it can be
 * used for both enabling/changing an option and for disabling it. RTNL lock
 * must be obtained before calling this function.
 */
int __bond_opt_set(struct bonding *bond,
		   unsigned int option, struct bond_opt_value *val,
		   struct nlattr *bad_attr, struct netlink_ext_ack *extack)
{}
/**
 * __bond_opt_set_notify - set a bonding option
 * @bond: target bond device
 * @option: option to set
 * @val: value to set it to
 *
 * This function is used to change the bond's option value and trigger
 * a notification to user sapce. It can be used for both enabling/changing
 * an option and for disabling it. RTNL lock must be obtained before calling
 * this function.
 */
int __bond_opt_set_notify(struct bonding *bond,
			  unsigned int option, struct bond_opt_value *val)
{}

/**
 * bond_opt_tryset_rtnl - try to acquire rtnl and call __bond_opt_set
 * @bond: target bond device
 * @option: option to set
 * @buf: value to set it to
 *
 * This function tries to acquire RTNL without blocking and if successful
 * calls __bond_opt_set. It is mainly used for sysfs option manipulation.
 */
int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
{}

/**
 * bond_opt_get - get a pointer to an option
 * @option: option for which to return a pointer
 *
 * This function checks if option is valid and if so returns a pointer
 * to its entry in the bond_opts[] option array.
 */
const struct bond_option *bond_opt_get(unsigned int option)
{}

static bool bond_set_xfrm_features(struct bonding *bond)
{}

static int bond_option_mode_set(struct bonding *bond,
				const struct bond_opt_value *newval)
{}

static int bond_option_active_slave_set(struct bonding *bond,
					const struct bond_opt_value *newval)
{}

/* There are two tricky bits here.  First, if MII monitoring is activated, then
 * we must disable ARP monitoring.  Second, if the timer isn't running, we must
 * start it.
 */
static int bond_option_miimon_set(struct bonding *bond,
				  const struct bond_opt_value *newval)
{}

/* Set up, down and peer notification delays. These must be multiples
 * of the MII monitoring value, and are stored internally as the
 * multiplier. Thus, we must translate to MS for the real world.
 */
static int _bond_option_delay_set(struct bonding *bond,
				  const struct bond_opt_value *newval,
				  const char *name,
				  int *target)
{}

static int bond_option_updelay_set(struct bonding *bond,
				   const struct bond_opt_value *newval)
{}

static int bond_option_downdelay_set(struct bonding *bond,
				     const struct bond_opt_value *newval)
{}

static int bond_option_peer_notif_delay_set(struct bonding *bond,
					    const struct bond_opt_value *newval)
{}

static int bond_option_use_carrier_set(struct bonding *bond,
				       const struct bond_opt_value *newval)
{}

/* There are two tricky bits here.  First, if ARP monitoring is activated, then
 * we must disable MII monitoring.  Second, if the ARP timer isn't running,
 * we must start it.
 */
static int bond_option_arp_interval_set(struct bonding *bond,
					const struct bond_opt_value *newval)
{}

static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot,
					    __be32 target,
					    unsigned long last_rx)
{}

static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
{}

static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target)
{}

static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target)
{}

void bond_option_arp_ip_targets_clear(struct bonding *bond)
{}

static int bond_option_arp_ip_targets_set(struct bonding *bond,
					  const struct bond_opt_value *newval)
{}

#if IS_ENABLED(CONFIG_IPV6)
static void _bond_options_ns_ip6_target_set(struct bonding *bond, int slot,
					    struct in6_addr *target,
					    unsigned long last_rx)
{}

void bond_option_ns_ip6_targets_clear(struct bonding *bond)
{}

static int bond_option_ns_ip6_targets_set(struct bonding *bond,
					  const struct bond_opt_value *newval)
{}
#else
static int bond_option_ns_ip6_targets_set(struct bonding *bond,
					  const struct bond_opt_value *newval)
{
	return -EPERM;
}
#endif

static int bond_option_arp_validate_set(struct bonding *bond,
					const struct bond_opt_value *newval)
{}

static int bond_option_arp_all_targets_set(struct bonding *bond,
					   const struct bond_opt_value *newval)
{}

static int bond_option_missed_max_set(struct bonding *bond,
				      const struct bond_opt_value *newval)
{}

static int bond_option_prio_set(struct bonding *bond,
				const struct bond_opt_value *newval)
{}

static int bond_option_primary_set(struct bonding *bond,
				   const struct bond_opt_value *newval)
{}

static int bond_option_primary_reselect_set(struct bonding *bond,
					    const struct bond_opt_value *newval)
{}

static int bond_option_fail_over_mac_set(struct bonding *bond,
					 const struct bond_opt_value *newval)
{}

static int bond_option_xmit_hash_policy_set(struct bonding *bond,
					    const struct bond_opt_value *newval)
{}

static int bond_option_resend_igmp_set(struct bonding *bond,
				       const struct bond_opt_value *newval)
{}

static int bond_option_num_peer_notif_set(struct bonding *bond,
				   const struct bond_opt_value *newval)
{}

static int bond_option_all_slaves_active_set(struct bonding *bond,
					     const struct bond_opt_value *newval)
{}

static int bond_option_min_links_set(struct bonding *bond,
				     const struct bond_opt_value *newval)
{}

static int bond_option_lp_interval_set(struct bonding *bond,
				       const struct bond_opt_value *newval)
{}

static int bond_option_pps_set(struct bonding *bond,
			       const struct bond_opt_value *newval)
{}

static int bond_option_lacp_active_set(struct bonding *bond,
				       const struct bond_opt_value *newval)
{}

static int bond_option_lacp_rate_set(struct bonding *bond,
				     const struct bond_opt_value *newval)
{}

static int bond_option_ad_select_set(struct bonding *bond,
				     const struct bond_opt_value *newval)
{}

static int bond_option_queue_id_set(struct bonding *bond,
				    const struct bond_opt_value *newval)
{}

static int bond_option_slaves_set(struct bonding *bond,
				  const struct bond_opt_value *newval)
{}

static int bond_option_tlb_dynamic_lb_set(struct bonding *bond,
					  const struct bond_opt_value *newval)
{}

static int bond_option_ad_actor_sys_prio_set(struct bonding *bond,
					     const struct bond_opt_value *newval)
{}

static int bond_option_ad_actor_system_set(struct bonding *bond,
					   const struct bond_opt_value *newval)
{}

static int bond_option_ad_user_port_key_set(struct bonding *bond,
					    const struct bond_opt_value *newval)
{}

static int bond_option_coupled_control_set(struct bonding *bond,
					   const struct bond_opt_value *newval)
{}