2019-05-27 08:55:01 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2014-01-22 14:53:16 +01:00
|
|
|
/*
|
|
|
|
|
* drivers/net/bond/bond_options.h - bonding options
|
|
|
|
|
* Copyright (c) 2013 Nikolay Aleksandrov <nikolay@redhat.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2014-11-10 13:27:49 -05:00
|
|
|
#ifndef _NET_BOND_OPTIONS_H
|
|
|
|
|
#define _NET_BOND_OPTIONS_H
|
2014-01-22 14:53:16 +01:00
|
|
|
|
2022-07-20 16:57:58 -07:00
|
|
|
#include <linux/bits.h>
|
|
|
|
|
#include <linux/limits.h>
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
|
|
struct netlink_ext_ack;
|
|
|
|
|
struct nlattr;
|
|
|
|
|
|
2014-01-22 14:53:16 +01:00
|
|
|
#define BOND_OPT_MAX_NAMELEN 32
|
|
|
|
|
#define BOND_OPT_VALID(opt) ((opt) < BOND_OPT_LAST)
|
|
|
|
|
#define BOND_MODE_ALL_EX(x) (~(x))
|
|
|
|
|
|
|
|
|
|
/* Option flags:
|
|
|
|
|
* BOND_OPTFLAG_NOSLAVES - check if the bond device is empty before setting
|
|
|
|
|
* BOND_OPTFLAG_IFDOWN - check if the bond device is down before setting
|
|
|
|
|
* BOND_OPTFLAG_RAWVAL - the option parses the value itself
|
|
|
|
|
*/
|
|
|
|
|
enum {
|
|
|
|
|
BOND_OPTFLAG_NOSLAVES = BIT(0),
|
|
|
|
|
BOND_OPTFLAG_IFDOWN = BIT(1),
|
|
|
|
|
BOND_OPTFLAG_RAWVAL = BIT(2)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Value type flags:
|
|
|
|
|
* BOND_VALFLAG_DEFAULT - mark the value as default
|
|
|
|
|
* BOND_VALFLAG_(MIN|MAX) - mark the value as min/max
|
|
|
|
|
*/
|
|
|
|
|
enum {
|
|
|
|
|
BOND_VALFLAG_DEFAULT = BIT(0),
|
|
|
|
|
BOND_VALFLAG_MIN = BIT(1),
|
|
|
|
|
BOND_VALFLAG_MAX = BIT(2)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Option IDs, their bit positions correspond to their IDs */
|
|
|
|
|
enum {
|
2014-01-22 14:53:17 +01:00
|
|
|
BOND_OPT_MODE,
|
2014-01-22 14:53:18 +01:00
|
|
|
BOND_OPT_PACKETS_PER_SLAVE,
|
2014-01-22 14:53:19 +01:00
|
|
|
BOND_OPT_XMIT_HASH,
|
2014-01-22 14:53:20 +01:00
|
|
|
BOND_OPT_ARP_VALIDATE,
|
2014-01-22 14:53:21 +01:00
|
|
|
BOND_OPT_ARP_ALL_TARGETS,
|
2014-01-22 14:53:22 +01:00
|
|
|
BOND_OPT_FAIL_OVER_MAC,
|
2014-01-22 14:53:23 +01:00
|
|
|
BOND_OPT_ARP_INTERVAL,
|
2014-01-22 14:53:24 +01:00
|
|
|
BOND_OPT_ARP_TARGETS,
|
2014-01-22 14:53:25 +01:00
|
|
|
BOND_OPT_DOWNDELAY,
|
2014-01-22 14:53:26 +01:00
|
|
|
BOND_OPT_UPDELAY,
|
2014-01-22 14:53:27 +01:00
|
|
|
BOND_OPT_LACP_RATE,
|
2014-01-22 14:53:28 +01:00
|
|
|
BOND_OPT_MINLINKS,
|
2014-01-22 14:53:29 +01:00
|
|
|
BOND_OPT_AD_SELECT,
|
2014-01-22 14:53:30 +01:00
|
|
|
BOND_OPT_NUM_PEER_NOTIF,
|
2014-01-22 14:53:31 +01:00
|
|
|
BOND_OPT_MIIMON,
|
2014-01-22 14:53:32 +01:00
|
|
|
BOND_OPT_PRIMARY,
|
2014-01-22 14:53:33 +01:00
|
|
|
BOND_OPT_PRIMARY_RESELECT,
|
2014-01-22 14:53:34 +01:00
|
|
|
BOND_OPT_USE_CARRIER,
|
2014-01-22 14:53:35 +01:00
|
|
|
BOND_OPT_ACTIVE_SLAVE,
|
2014-01-22 14:53:36 +01:00
|
|
|
BOND_OPT_QUEUE_ID,
|
2014-01-22 14:53:37 +01:00
|
|
|
BOND_OPT_ALL_SLAVES_ACTIVE,
|
2014-01-22 14:53:38 +01:00
|
|
|
BOND_OPT_RESEND_IGMP,
|
2014-01-22 14:53:39 +01:00
|
|
|
BOND_OPT_LP_INTERVAL,
|
2014-01-22 14:53:40 +01:00
|
|
|
BOND_OPT_SLAVES,
|
2014-04-22 16:30:22 -07:00
|
|
|
BOND_OPT_TLB_DYNAMIC_LB,
|
2015-05-09 00:01:55 -07:00
|
|
|
BOND_OPT_AD_ACTOR_SYS_PRIO,
|
2015-05-09 00:01:56 -07:00
|
|
|
BOND_OPT_AD_ACTOR_SYSTEM,
|
2015-05-09 00:01:57 -07:00
|
|
|
BOND_OPT_AD_USER_PORT_KEY,
|
2015-07-24 15:50:31 +02:00
|
|
|
BOND_OPT_NUM_PEER_NOTIF_ALIAS,
|
2019-07-02 19:43:54 +02:00
|
|
|
BOND_OPT_PEER_NOTIF_DELAY,
|
2021-08-02 11:02:19 +08:00
|
|
|
BOND_OPT_LACP_ACTIVE,
|
2021-11-30 12:29:47 +08:00
|
|
|
BOND_OPT_MISSED_MAX,
|
2022-02-21 13:54:57 +08:00
|
|
|
BOND_OPT_NS_TARGETS,
|
2022-06-21 15:49:19 +08:00
|
|
|
BOND_OPT_PRIO,
|
2024-02-02 17:58:58 +00:00
|
|
|
BOND_OPT_COUPLED_CONTROL,
|
2025-06-27 21:49:28 +08:00
|
|
|
BOND_OPT_BROADCAST_NEIGH,
|
2025-09-02 06:44:59 +00:00
|
|
|
BOND_OPT_ACTOR_PORT_PRIO,
|
2014-01-22 14:53:16 +01:00
|
|
|
BOND_OPT_LAST
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* This structure is used for storing option values and for passing option
|
|
|
|
|
* values when changing an option. The logic when used as an arg is as follows:
|
2022-02-21 13:54:55 +08:00
|
|
|
* - if value != ULLONG_MAX -> parse value
|
|
|
|
|
* - if string != NULL -> parse string
|
|
|
|
|
* - if the opt is RAW data and length less than maxlen,
|
|
|
|
|
* copy the data to extra storage
|
2014-01-22 14:53:16 +01:00
|
|
|
*/
|
2022-02-21 13:54:55 +08:00
|
|
|
|
|
|
|
|
#define BOND_OPT_EXTRA_MAXLEN 16
|
2014-01-22 14:53:16 +01:00
|
|
|
struct bond_opt_value {
|
|
|
|
|
char *string;
|
|
|
|
|
u64 value;
|
|
|
|
|
u32 flags;
|
2022-06-21 15:49:18 +08:00
|
|
|
union {
|
|
|
|
|
char extra[BOND_OPT_EXTRA_MAXLEN];
|
|
|
|
|
struct net_device *slave_dev;
|
|
|
|
|
};
|
2014-01-22 14:53:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct bonding;
|
|
|
|
|
|
|
|
|
|
struct bond_option {
|
|
|
|
|
int id;
|
2014-03-04 16:36:44 -08:00
|
|
|
const char *name;
|
|
|
|
|
const char *desc;
|
2014-01-22 14:53:16 +01:00
|
|
|
u32 flags;
|
|
|
|
|
|
|
|
|
|
/* unsuppmodes is used to denote modes in which the option isn't
|
|
|
|
|
* supported.
|
|
|
|
|
*/
|
|
|
|
|
unsigned long unsuppmodes;
|
|
|
|
|
/* supported values which this option can have, can be a subset of
|
|
|
|
|
* BOND_OPTVAL_RANGE's value range
|
|
|
|
|
*/
|
2014-03-04 16:36:44 -08:00
|
|
|
const struct bond_opt_value *values;
|
2014-01-22 14:53:16 +01:00
|
|
|
|
2014-03-06 14:20:17 -08:00
|
|
|
int (*set)(struct bonding *bond, const struct bond_opt_value *val);
|
2014-01-22 14:53:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int __bond_opt_set(struct bonding *bond, unsigned int option,
|
2022-06-08 14:14:56 -04:00
|
|
|
struct bond_opt_value *val,
|
|
|
|
|
struct nlattr *bad_attr, struct netlink_ext_ack *extack);
|
2017-05-27 10:14:35 -04:00
|
|
|
int __bond_opt_set_notify(struct bonding *bond, unsigned int option,
|
|
|
|
|
struct bond_opt_value *val);
|
2014-01-22 14:53:16 +01:00
|
|
|
int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf);
|
2014-03-06 14:20:17 -08:00
|
|
|
|
2014-03-04 16:36:44 -08:00
|
|
|
const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
|
2014-03-06 14:20:17 -08:00
|
|
|
struct bond_opt_value *val);
|
2014-03-04 16:36:44 -08:00
|
|
|
const struct bond_option *bond_opt_get(unsigned int option);
|
2014-05-08 14:23:54 +02:00
|
|
|
const struct bond_option *bond_opt_get_by_name(const char *name);
|
2014-03-04 16:36:44 -08:00
|
|
|
const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val);
|
2014-01-22 14:53:16 +01:00
|
|
|
|
|
|
|
|
/* This helper is used to initialize a bond_opt_value structure for parameter
|
|
|
|
|
* passing. There should be either a valid string or value, but not both.
|
|
|
|
|
* When value is ULLONG_MAX then string will be used.
|
|
|
|
|
*/
|
|
|
|
|
static inline void __bond_opt_init(struct bond_opt_value *optval,
|
2022-02-21 13:54:55 +08:00
|
|
|
char *string, u64 value,
|
|
|
|
|
void *extra, size_t extra_len)
|
2014-01-22 14:53:16 +01:00
|
|
|
{
|
|
|
|
|
memset(optval, 0, sizeof(*optval));
|
|
|
|
|
optval->value = ULLONG_MAX;
|
2022-02-21 13:54:55 +08:00
|
|
|
if (value != ULLONG_MAX)
|
2014-01-22 14:53:16 +01:00
|
|
|
optval->value = value;
|
2022-02-21 13:54:55 +08:00
|
|
|
else if (string)
|
|
|
|
|
optval->string = string;
|
2022-06-21 15:49:18 +08:00
|
|
|
|
|
|
|
|
if (extra && extra_len <= BOND_OPT_EXTRA_MAXLEN)
|
2022-02-21 13:54:55 +08:00
|
|
|
memcpy(optval->extra, extra, extra_len);
|
2014-01-22 14:53:16 +01:00
|
|
|
}
|
2022-02-21 13:54:55 +08:00
|
|
|
#define bond_opt_initval(optval, value) __bond_opt_init(optval, NULL, value, NULL, 0)
|
|
|
|
|
#define bond_opt_initstr(optval, str) __bond_opt_init(optval, str, ULLONG_MAX, NULL, 0)
|
|
|
|
|
#define bond_opt_initextra(optval, extra, extra_len) \
|
|
|
|
|
__bond_opt_init(optval, NULL, ULLONG_MAX, extra, extra_len)
|
2022-06-21 15:49:18 +08:00
|
|
|
#define bond_opt_slave_initval(optval, slave_dev, value) \
|
|
|
|
|
__bond_opt_init(optval, NULL, value, slave_dev, sizeof(struct net_device *))
|
2014-01-22 14:53:17 +01:00
|
|
|
|
2014-01-22 14:53:24 +01:00
|
|
|
void bond_option_arp_ip_targets_clear(struct bonding *bond);
|
2022-02-21 13:54:57 +08:00
|
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
|
|
|
void bond_option_ns_ip6_targets_clear(struct bonding *bond);
|
|
|
|
|
#endif
|
2024-11-11 10:16:49 +00:00
|
|
|
void bond_slave_ns_maddrs_add(struct bonding *bond, struct slave *slave);
|
|
|
|
|
void bond_slave_ns_maddrs_del(struct bonding *bond, struct slave *slave);
|
2014-03-04 16:36:44 -08:00
|
|
|
|
2014-11-10 13:27:49 -05:00
|
|
|
#endif /* _NET_BOND_OPTIONS_H */
|