linux/include/net/bond_options.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * drivers/net/bond/bond_options.h - bonding options
 * Copyright (c) 2013 Nikolay Aleksandrov <[email protected]>
 */

#ifndef _NET_BOND_OPTIONS_H
#define _NET_BOND_OPTIONS_H

#include <linux/bits.h>
#include <linux/limits.h>
#include <linux/types.h>
#include <linux/string.h>

struct netlink_ext_ack;
struct nlattr;

#define BOND_OPT_MAX_NAMELEN
#define BOND_OPT_VALID(opt)
#define BOND_MODE_ALL_EX(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 {};

/* Value type flags:
 * BOND_VALFLAG_DEFAULT - mark the value as default
 * BOND_VALFLAG_(MIN|MAX) - mark the value as min/max
 */
enum {};

/* Option IDs, their bit positions correspond to their IDs */
enum {};

/* 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:
 * - 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
 */

#define BOND_OPT_EXTRA_MAXLEN
struct bond_opt_value {};

struct bonding;

struct bond_option {};

int __bond_opt_set(struct bonding *bond, unsigned int option,
		   struct bond_opt_value *val,
		   struct nlattr *bad_attr, struct netlink_ext_ack *extack);
int __bond_opt_set_notify(struct bonding *bond, unsigned int option,
			  struct bond_opt_value *val);
int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf);

const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
					    struct bond_opt_value *val);
const struct bond_option *bond_opt_get(unsigned int option);
const struct bond_option *bond_opt_get_by_name(const char *name);
const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val);

/* 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,
				   char *string, u64 value,
				   void *extra, size_t extra_len)
{}
#define bond_opt_initval(optval, value)
#define bond_opt_initstr(optval, str)
#define bond_opt_initextra(optval, extra, extra_len)
#define bond_opt_slave_initval(optval, slave_dev, value)

void bond_option_arp_ip_targets_clear(struct bonding *bond);
#if IS_ENABLED(CONFIG_IPV6)
void bond_option_ns_ip6_targets_clear(struct bonding *bond);
#endif

#endif /* _NET_BOND_OPTIONS_H */