aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-01-22 18:39:18 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-22 18:39:18 -0500
commitb414ac9a3ea8a547e4a413160d36bffefb2ba5c7 (patch)
treedb584c17b8682818e68913a57b7005b2afa01cfe
parent374d1125237e94f16ffa3185cff62df03977a988 (diff)
parent0e2e5b66e9de377d69f50a456fdd60462889c64f (diff)
Merge branch 'bonding_option_api'
Nikolay Aleksandrov says: ==================== bonding: introduce new option API This patchset's goal is to introduce a new option API which should be used to properly describe the bonding options with their mode dependcies and requirements. With this patchset applied we get centralized option manipulation, automatic RTNL acquire per option setting, automatic option range checking, mode dependcy checking and other various flags which are described in detail in patch 01's commit message and comments. Also the parameter passing is changed to use a specialized structure which is initialized to a value depending on the needs. The main exported functions are: __bond_opt_set() - set an option (RTNL should be acquired prior) bond_opt_init(val|str) - init a bond_opt_value struct for value or string parameter passing bond_opt_tryset_rtnl() - function which tries to acquire rtnl, mainly used for sysfs bond_opt_parse - used to parse or check for valid values bond_opt_get - retrieve a pointer to bond_option struct for some option bond_opt_get_val - retrieve a pointer to a bond_opt_value struct for some value The same functions are used to set an option via sysfs and netlink, just the parameter that's passed is usually initialized in a different way. The converted options have multiple style fixes, there're some longer lines but they looked either ugly or were strings/pr_warnings, if you think some line would be better broken just let me know :-) there're also a few sscanf false-positive warnings. I decided to keep the "unsuppmodes" way of mode dep checking since it's straight forward, if we make a more general way for checking dependencies it'll be easy to change it. Future plans for this work include: - Automatic sysfs generation from the bond_opts[]. - Use of the API in bond_check_params() and thus cleaning it up (this has actually started, I'll take care of the rest in a separate patch) - Clean up all option-unrelated files of option definitions and functions I've tried to leave as much documentation as possible, if there's anything unclear please let me know. One more thing, I haven't moved all option-related functions from bonding.h to the new bond_options.h, this will be done in a separate patch, it's in my todo list. This patchset has been tested by setting each converted option via sysfs and netlink to a couple of wrong values, a couple of correct values and some random values, also for the opts that have flags they have been tested as well. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bonding/bond_main.c179
-rw-r--r--drivers/net/bonding/bond_netlink.c87
-rw-r--r--drivers/net/bonding/bond_options.c1091
-rw-r--r--drivers/net/bonding/bond_options.h170
-rw-r--r--drivers/net/bonding/bond_procfs.c25
-rw-r--r--drivers/net/bonding/bond_sysfs.c519
-rw-r--r--drivers/net/bonding/bonding.h29
7 files changed, 1217 insertions, 883 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f100bd958b88..2ca949f6e995 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -86,13 +86,11 @@
86/*---------------------------- Module parameters ----------------------------*/ 86/*---------------------------- Module parameters ----------------------------*/
87 87
88/* monitor all links that often (in milliseconds). <=0 disables monitoring */ 88/* monitor all links that often (in milliseconds). <=0 disables monitoring */
89#define BOND_LINK_MON_INTERV 0
90#define BOND_LINK_ARP_INTERV 0
91 89
92static int max_bonds = BOND_DEFAULT_MAX_BONDS; 90static int max_bonds = BOND_DEFAULT_MAX_BONDS;
93static int tx_queues = BOND_DEFAULT_TX_QUEUES; 91static int tx_queues = BOND_DEFAULT_TX_QUEUES;
94static int num_peer_notif = 1; 92static int num_peer_notif = 1;
95static int miimon = BOND_LINK_MON_INTERV; 93static int miimon;
96static int updelay; 94static int updelay;
97static int downdelay; 95static int downdelay;
98static int use_carrier = 1; 96static int use_carrier = 1;
@@ -103,7 +101,7 @@ static char *lacp_rate;
103static int min_links; 101static int min_links;
104static char *ad_select; 102static char *ad_select;
105static char *xmit_hash_policy; 103static char *xmit_hash_policy;
106static int arp_interval = BOND_LINK_ARP_INTERV; 104static int arp_interval;
107static char *arp_ip_target[BOND_MAX_ARP_TARGETS]; 105static char *arp_ip_target[BOND_MAX_ARP_TARGETS];
108static char *arp_validate; 106static char *arp_validate;
109static char *arp_all_targets; 107static char *arp_all_targets;
@@ -208,67 +206,6 @@ static int bond_mode = BOND_MODE_ROUNDROBIN;
208static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; 206static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
209static int lacp_fast; 207static int lacp_fast;
210 208
211const struct bond_parm_tbl bond_lacp_tbl[] = {
212{ "slow", AD_LACP_SLOW},
213{ "fast", AD_LACP_FAST},
214{ NULL, -1},
215};
216
217const struct bond_parm_tbl bond_mode_tbl[] = {
218{ "balance-rr", BOND_MODE_ROUNDROBIN},
219{ "active-backup", BOND_MODE_ACTIVEBACKUP},
220{ "balance-xor", BOND_MODE_XOR},
221{ "broadcast", BOND_MODE_BROADCAST},
222{ "802.3ad", BOND_MODE_8023AD},
223{ "balance-tlb", BOND_MODE_TLB},
224{ "balance-alb", BOND_MODE_ALB},
225{ NULL, -1},
226};
227
228const struct bond_parm_tbl xmit_hashtype_tbl[] = {
229{ "layer2", BOND_XMIT_POLICY_LAYER2},
230{ "layer3+4", BOND_XMIT_POLICY_LAYER34},
231{ "layer2+3", BOND_XMIT_POLICY_LAYER23},
232{ "encap2+3", BOND_XMIT_POLICY_ENCAP23},
233{ "encap3+4", BOND_XMIT_POLICY_ENCAP34},
234{ NULL, -1},
235};
236
237const struct bond_parm_tbl arp_all_targets_tbl[] = {
238{ "any", BOND_ARP_TARGETS_ANY},
239{ "all", BOND_ARP_TARGETS_ALL},
240{ NULL, -1},
241};
242
243const struct bond_parm_tbl arp_validate_tbl[] = {
244{ "none", BOND_ARP_VALIDATE_NONE},
245{ "active", BOND_ARP_VALIDATE_ACTIVE},
246{ "backup", BOND_ARP_VALIDATE_BACKUP},
247{ "all", BOND_ARP_VALIDATE_ALL},
248{ NULL, -1},
249};
250
251const struct bond_parm_tbl fail_over_mac_tbl[] = {
252{ "none", BOND_FOM_NONE},
253{ "active", BOND_FOM_ACTIVE},
254{ "follow", BOND_FOM_FOLLOW},
255{ NULL, -1},
256};
257
258const struct bond_parm_tbl pri_reselect_tbl[] = {
259{ "always", BOND_PRI_RESELECT_ALWAYS},
260{ "better", BOND_PRI_RESELECT_BETTER},
261{ "failure", BOND_PRI_RESELECT_FAILURE},
262{ NULL, -1},
263};
264
265struct bond_parm_tbl ad_select_tbl[] = {
266{ "stable", BOND_AD_STABLE},
267{ "bandwidth", BOND_AD_BANDWIDTH},
268{ "count", BOND_AD_COUNT},
269{ NULL, -1},
270};
271
272/*-------------------------- Forward declarations ---------------------------*/ 209/*-------------------------- Forward declarations ---------------------------*/
273 210
274static int bond_init(struct net_device *bond_dev); 211static int bond_init(struct net_device *bond_dev);
@@ -3186,6 +3123,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3186 struct ifslave k_sinfo; 3123 struct ifslave k_sinfo;
3187 struct ifslave __user *u_sinfo = NULL; 3124 struct ifslave __user *u_sinfo = NULL;
3188 struct mii_ioctl_data *mii = NULL; 3125 struct mii_ioctl_data *mii = NULL;
3126 struct bond_opt_value newval;
3189 struct net *net; 3127 struct net *net;
3190 int res = 0; 3128 int res = 0;
3191 3129
@@ -3281,7 +3219,8 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3281 break; 3219 break;
3282 case BOND_CHANGE_ACTIVE_OLD: 3220 case BOND_CHANGE_ACTIVE_OLD:
3283 case SIOCBONDCHANGEACTIVE: 3221 case SIOCBONDCHANGEACTIVE:
3284 res = bond_option_active_slave_set(bond, slave_dev); 3222 bond_opt_initstr(&newval, slave_dev->name);
3223 res = __bond_opt_set(bond, BOND_OPT_ACTIVE_SLAVE, &newval);
3285 break; 3224 break;
3286 default: 3225 default:
3287 res = -EOPNOTSUPP; 3226 res = -EOPNOTSUPP;
@@ -4028,18 +3967,20 @@ int bond_parse_parm(const char *buf, const struct bond_parm_tbl *tbl)
4028static int bond_check_params(struct bond_params *params) 3967static int bond_check_params(struct bond_params *params)
4029{ 3968{
4030 int arp_validate_value, fail_over_mac_value, primary_reselect_value, i; 3969 int arp_validate_value, fail_over_mac_value, primary_reselect_value, i;
3970 struct bond_opt_value newval, *valptr;
4031 int arp_all_targets_value; 3971 int arp_all_targets_value;
4032 3972
4033 /* 3973 /*
4034 * Convert string parameters. 3974 * Convert string parameters.
4035 */ 3975 */
4036 if (mode) { 3976 if (mode) {
4037 bond_mode = bond_parse_parm(mode, bond_mode_tbl); 3977 bond_opt_initstr(&newval, mode);
4038 if (bond_mode == -1) { 3978 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_MODE), &newval);
4039 pr_err("Error: Invalid bonding mode \"%s\"\n", 3979 if (!valptr) {
4040 mode == NULL ? "NULL" : mode); 3980 pr_err("Error: Invalid bonding mode \"%s\"\n", mode);
4041 return -EINVAL; 3981 return -EINVAL;
4042 } 3982 }
3983 bond_mode = valptr->value;
4043 } 3984 }
4044 3985
4045 if (xmit_hash_policy) { 3986 if (xmit_hash_policy) {
@@ -4048,14 +3989,15 @@ static int bond_check_params(struct bond_params *params)
4048 pr_info("xmit_hash_policy param is irrelevant in mode %s\n", 3989 pr_info("xmit_hash_policy param is irrelevant in mode %s\n",
4049 bond_mode_name(bond_mode)); 3990 bond_mode_name(bond_mode));
4050 } else { 3991 } else {
4051 xmit_hashtype = bond_parse_parm(xmit_hash_policy, 3992 bond_opt_initstr(&newval, xmit_hash_policy);
4052 xmit_hashtype_tbl); 3993 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_XMIT_HASH),
4053