aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_sysfs.c
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 14:53:16 +0100
committerDavid S. Miller <davem@davemloft.net>2014-01-22 15:38:41 -0800
commit0911736245df19b423a3b156f6709e7bba48b18a (patch)
tree17505f5989f60dc6d4371dfdce00872623f3e0ee /drivers/net/bonding/bond_sysfs.c
parentMerge branch 'reciprocal' (diff)
downloadlinux-dev-0911736245df19b423a3b156f6709e7bba48b18a.tar.xz
linux-dev-0911736245df19b423a3b156f6709e7bba48b18a.zip
bonding: add infrastructure for an option API
This patch adds the necessary basic infrastructure to support centralized and unified option manipulation API for the bonding. The new structure bond_option will be used to describe each option with its dependencies on modes which will be checked automatically thus removing a lot of duplicated code. Also automatic range checking is added for some options. Currently the option setting function requires RTNL to be acquired prior to calling it, since many options already rely on RTNL it seemed like the best choice to protect all against common race conditions. In order to add an option the following steps need to be done: 1. Add an entry BOND_OPT_<option> to bond_options.h so it gets a unique id and a bit corresponding to the id 2. Add a bond_option entry to the bond_opts[] array in bond_options.c which describes the option, its dependencies and its manipulation function 3. Add code to export the option through sysfs and/or as a module parameter (the sysfs export will be made automatically in the future) The options can have different flags set, currently the following are supported: BOND_OPTFLAG_NOSLAVES - require that the bond device has no slaves prior to setting the option BOND_OPTFLAG_IFDOWN - require that the bond device is down prior to setting the option BOND_OPTFLAG_RAWVAL - don't parse the value but return it raw for the option to parse There's a new value structure to describe different types of values which can have the following flags: BOND_VALFLAG_DEFAULT - marks the default option (permanent string alias to this option is "default") BOND_VALFLAG_MIN - the minimum value that this option can have BOND_VALFLAG_MAX - the maximum value that this option can have An example would be nice here, so if we have an option which can have the values "off"(2), "special"(4, default) and supports a range, say 16 - 32, it should be defined as follows: "off", 2, "special", 4, BOND_VALFLAG_DEFAULT, "rangemin", 16, BOND_VALFLAG_MIN, "rangemax", 32, BOND_VALFLAG_MAX So we have the valid intervals: [2, 2], [4, 4], [16, 32] Also the valid strings: "off" = 2, "special" and "default" = 4 "rangemin" = 16, "rangemax" = 32 BOND_VALFLAG_(MIN|MAX) can be used to specify a valid range for an option, if MIN is omitted then 0 is considered as a minimum. If an exact match is found in the values[] table it will be returned, otherwise the range is tried (if available). The option parameter passing is done by using a special structure called bond_opt_value which can take either a string or a value to parse. One of the bond_opt_init(val|str) macros should be used depending on which one does the user want to parse (string or value). Then a call to __bond_opt_set should be done under RTNL. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
0 files changed, 0 insertions, 0 deletions