diff options
author | stephen hemminger <stephen@networkplumber.org> | 2014-03-05 04:36:44 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-07 01:08:52 +0400 |
commit | f3253339a47ff3690ce52e2acd95ec295f8521b3 (patch) | |
tree | b1785d926e67f74c09549a3b070541c17e409b5e /drivers/net/bonding/bond_options.c | |
parent | fca28094cd628e187520f412caa0fb687bfbc8d4 (diff) | |
download | linux-f3253339a47ff3690ce52e2acd95ec295f8521b3.tar.xz |
bonding: options handling cleanup
Make local functions static (ie. only used in bond_options.c)
Make bond options parsing tables constant.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_options.c')
-rw-r--r-- | drivers/net/bonding/bond_options.c | 190 |
1 files changed, 124 insertions, 66 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 23f365510b58..fc6d25e7d053 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -20,7 +20,59 @@ #include <linux/inet.h> #include "bonding.h" -static struct bond_opt_value bond_mode_tbl[] = { +static int bond_option_active_slave_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_miimon_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_updelay_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_downdelay_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_use_carrier_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_arp_interval_set(struct bonding *bond, + 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, + struct bond_opt_value *newval); +static int bond_option_arp_validate_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_arp_all_targets_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_primary_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_primary_reselect_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_fail_over_mac_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_xmit_hash_policy_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_resend_igmp_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_num_peer_notif_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_all_slaves_active_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_min_links_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_lp_interval_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_pps_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_lacp_rate_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_ad_select_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_queue_id_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_mode_set(struct bonding *bond, + struct bond_opt_value *newval); +static int bond_option_slaves_set(struct bonding *bond, + struct bond_opt_value *newval); + + +static const struct bond_opt_value bond_mode_tbl[] = { { "balance-rr", BOND_MODE_ROUNDROBIN, BOND_VALFLAG_DEFAULT}, { "active-backup", BOND_MODE_ACTIVEBACKUP, 0}, { "balance-xor", BOND_MODE_XOR, 0}, @@ -31,13 +83,13 @@ static struct bond_opt_value bond_mode_tbl[] = { { NULL, -1, 0}, }; -static struct bond_opt_value bond_pps_tbl[] = { +static const struct bond_opt_value bond_pps_tbl[] = { { "default", 1, BOND_VALFLAG_DEFAULT}, { "maxval", USHRT_MAX, BOND_VALFLAG_MAX}, { NULL, -1, 0}, }; -static struct bond_opt_value bond_xmit_hashtype_tbl[] = { +static const struct bond_opt_value bond_xmit_hashtype_tbl[] = { { "layer2", BOND_XMIT_POLICY_LAYER2, BOND_VALFLAG_DEFAULT}, { "layer3+4", BOND_XMIT_POLICY_LAYER34, 0}, { "layer2+3", BOND_XMIT_POLICY_LAYER23, 0}, @@ -46,7 +98,7 @@ static struct bond_opt_value bond_xmit_hashtype_tbl[] = { { NULL, -1, 0}, }; -static struct bond_opt_value bond_arp_validate_tbl[] = { +static const struct bond_opt_value bond_arp_validate_tbl[] = { { "none", BOND_ARP_VALIDATE_NONE, BOND_VALFLAG_DEFAULT}, { "active", BOND_ARP_VALIDATE_ACTIVE, 0}, { "backup", BOND_ARP_VALIDATE_BACKUP, 0}, @@ -57,76 +109,76 @@ static struct bond_opt_value bond_arp_validate_tbl[] = { { NULL, -1, 0}, }; -static struct bond_opt_value bond_arp_all_targets_tbl[] = { +static const struct bond_opt_value bond_arp_all_targets_tbl[] = { { "any", BOND_ARP_TARGETS_ANY, BOND_VALFLAG_DEFAULT}, { "all", BOND_ARP_TARGETS_ALL, 0}, { NULL, -1, 0}, }; -static struct bond_opt_value bond_fail_over_mac_tbl[] = { +static const struct bond_opt_value bond_fail_over_mac_tbl[] = { { "none", BOND_FOM_NONE, BOND_VALFLAG_DEFAULT}, { "active", BOND_FOM_ACTIVE, 0}, { "follow", BOND_FOM_FOLLOW, 0}, { NULL, -1, 0}, }; -static struct bond_opt_value bond_intmax_tbl[] = { +static const struct bond_opt_value bond_intmax_tbl[] = { { "off", 0, BOND_VALFLAG_DEFAULT}, { "maxval", INT_MAX, BOND_VALFLAG_MAX}, }; -static struct bond_opt_value bond_lacp_rate_tbl[] = { +static const struct bond_opt_value bond_lacp_rate_tbl[] = { { "slow", AD_LACP_SLOW, 0}, { "fast", AD_LACP_FAST, 0}, { NULL, -1, 0}, }; -static struct bond_opt_value bond_ad_select_tbl[] = { +static const struct bond_opt_value bond_ad_select_tbl[] = { { "stable", BOND_AD_STABLE, BOND_VALFLAG_DEFAULT}, { "bandwidth", BOND_AD_BANDWIDTH, 0}, { "count", BOND_AD_COUNT, 0}, { NULL, -1, 0}, }; -static struct bond_opt_value bond_num_peer_notif_tbl[] = { +static const struct bond_opt_value bond_num_peer_notif_tbl[] = { { "off", 0, 0}, { "maxval", 255, BOND_VALFLAG_MAX}, { "default", 1, BOND_VALFLAG_DEFAULT}, { NULL, -1, 0} }; -static struct bond_opt_value bond_primary_reselect_tbl[] = { +static const struct bond_opt_value bond_primary_reselect_tbl[] = { { "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT}, { "better", BOND_PRI_RESELECT_BETTER, 0}, { "failure", BOND_PRI_RESELECT_FAILURE, 0}, { NULL, -1}, }; -static struct bond_opt_value bond_use_carrier_tbl[] = { +static const struct bond_opt_value bond_use_carrier_tbl[] = { { "off", 0, 0}, { "on", 1, BOND_VALFLAG_DEFAULT}, { NULL, -1, 0} }; -static struct bond_opt_value bond_all_slaves_active_tbl[] = { +static const struct bond_opt_value bond_all_slaves_active_tbl[] = { { "off", 0, BOND_VALFLAG_DEFAULT}, { "on", 1, 0}, { NULL, -1, 0} }; -static struct bond_opt_value bond_resend_igmp_tbl[] = { +static const struct bond_opt_value bond_resend_igmp_tbl[] = { { "off", 0, 0}, { "maxval", 255, BOND_VALFLAG_MAX}, { "default", 1, BOND_VALFLAG_DEFAULT}, { NULL, -1, 0} }; -static struct bond_opt_value bond_lp_interval_tbl[] = { +static const struct bond_opt_value bond_lp_interval_tbl[] = { { "minval", 1, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT}, { "maxval", INT_MAX, BOND_VALFLAG_MAX}, }; -static struct bond_option bond_opts[] = { +static const struct bond_option bond_opts[] = { [BOND_OPT_MODE] = { .id = BOND_OPT_MODE, .name = "mode", @@ -315,9 +367,9 @@ static struct bond_option bond_opts[] = { }; /* Searches for a value in opt's values[] table */ -struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val) +const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val) { - struct bond_option *opt; + const struct bond_option *opt; int i; opt = bond_opt_get(option); @@ -331,7 +383,7 @@ 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 struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt, +static const struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt, u32 flagmask) { int i; @@ -348,7 +400,7 @@ static struct bond_opt_value *bond_opt_get_flags(const struct bond_option *opt, */ static bool bond_opt_check_range(const struct bond_option *opt, u64 val) { - struct bond_opt_value *minval, *maxval; + const struct bond_opt_value *minval, *maxval; minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN); maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX); @@ -368,11 +420,12 @@ static bool bond_opt_check_range(const struct bond_option *opt, u64 val) * or the struct_opt_value that matched. It also strips the new line from * @val->string if it's present. */ -struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, - struct bond_opt_value *val) +const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, + struct bond_opt_value *val) { char *p, valstr[BOND_OPT_MAX_NAMELEN + 1] = { 0, }; - struct bond_opt_value *tbl, *ret = NULL; + const struct bond_opt_value *tbl; + const struct bond_opt_value *ret = NULL; bool checkval; int i, rv; @@ -576,7 +629,7 @@ int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf) * This function checks if option is valid and if so returns a pointer * to its entry in the bond_opts[] option array. */ -struct bond_option *bond_opt_get(unsigned int option) +const struct bond_option *bond_opt_get(unsigned int option) { if (!BOND_OPT_VALID(option)) return NULL; @@ -622,8 +675,8 @@ struct net_device *bond_option_active_slave_get(struct bonding *bond) return __bond_option_active_slave_get(bond, bond->curr_active_slave); } -int bond_option_active_slave_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_active_slave_set(struct bonding *bond, + struct bond_opt_value *newval) { char ifname[IFNAMSIZ] = { 0, }; struct net_device *slave_dev; @@ -691,7 +744,8 @@ int bond_option_active_slave_set(struct bonding *bond, return ret; } -int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval) +static int bond_option_miimon_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting MII monitoring interval to %llu\n", bond->dev->name, newval->value); @@ -728,7 +782,8 @@ int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval) return 0; } -int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval) +static int bond_option_updelay_set(struct bonding *bond, + struct bond_opt_value *newval) { int value = newval->value; @@ -751,8 +806,8 @@ int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval) return 0; } -int bond_option_downdelay_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_downdelay_set(struct bonding *bond, + struct bond_opt_value *newval) { int value = newval->value; @@ -775,8 +830,8 @@ int bond_option_downdelay_set(struct bonding *bond, return 0; } -int bond_option_use_carrier_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_use_carrier_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting use_carrier to %llu\n", bond->dev->name, newval->value); @@ -785,8 +840,8 @@ int bond_option_use_carrier_set(struct bonding *bond, return 0; } -int bond_option_arp_interval_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_arp_interval_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting ARP monitoring interval to %llu\n", bond->dev->name, newval->value); @@ -867,7 +922,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) return 0; } -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) { int ret; @@ -879,7 +934,7 @@ int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) return ret; } -int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) +static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) { __be32 *targets = bond->params.arp_targets; struct list_head *iter; @@ -935,8 +990,8 @@ void bond_option_arp_ip_targets_clear(struct bonding *bond) write_unlock_bh(&bond->lock); } -int bond_option_arp_ip_targets_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_arp_ip_targets_set(struct bonding *bond, + struct bond_opt_value *newval) { int ret = -EPERM; __be32 target; @@ -962,8 +1017,8 @@ int bond_option_arp_ip_targets_set(struct bonding *bond, return ret; } -int bond_option_arp_validate_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_arp_validate_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting arp_validate to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -979,8 +1034,8 @@ int bond_option_arp_validate_set(struct bonding *bond, return 0; } -int bond_option_arp_all_targets_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_arp_all_targets_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting arp_all_targets to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -989,7 +1044,8 @@ int bond_option_arp_all_targets_set(struct bonding *bond, return 0; } -int bond_option_primary_set(struct bonding *bond, struct bond_opt_value *newval) +static int bond_option_primary_set(struct bonding *bond, + struct bond_opt_value *newval) { char *p, *primary = newval->string; struct list_head *iter; @@ -1041,8 +1097,8 @@ out: return 0; } -int bond_option_primary_reselect_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_primary_reselect_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting primary_reselect to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -1057,8 +1113,8 @@ int bond_option_primary_reselect_set(struct bonding *bond, return 0; } -int bond_option_fail_over_mac_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_fail_over_mac_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting fail_over_mac to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -1067,8 +1123,8 @@ int bond_option_fail_over_mac_set(struct bonding *bond, return 0; } -int bond_option_xmit_hash_policy_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_xmit_hash_policy_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting xmit hash policy to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -1077,8 +1133,8 @@ int bond_option_xmit_hash_policy_set(struct bonding *bond, return 0; } -int bond_option_resend_igmp_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_resend_igmp_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting resend_igmp to %llu\n", bond->dev->name, newval->value); @@ -1087,7 +1143,7 @@ int bond_option_resend_igmp_set(struct bonding *bond, return 0; } -int bond_option_num_peer_notif_set(struct bonding *bond, +static int bond_option_num_peer_notif_set(struct bonding *bond, struct bond_opt_value *newval) { bond->params.num_peer_notif = newval->value; @@ -1095,8 +1151,8 @@ int bond_option_num_peer_notif_set(struct bonding *bond, return 0; } -int bond_option_all_slaves_active_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_all_slaves_active_set(struct bonding *bond, + struct bond_opt_value *newval) { struct list_head *iter; struct slave *slave; @@ -1116,8 +1172,8 @@ int bond_option_all_slaves_active_set(struct bonding *bond, return 0; } -int bond_option_min_links_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_min_links_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting min links value to %llu\n", bond->dev->name, newval->value); @@ -1126,15 +1182,16 @@ int bond_option_min_links_set(struct bonding *bond, return 0; } -int bond_option_lp_interval_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_lp_interval_set(struct bonding *bond, + struct bond_opt_value *newval) { bond->params.lp_interval = newval->value; return 0; } -int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval) +static int bond_option_pps_set(struct bonding *bond, + struct bond_opt_value *newval) { bond->params.packets_per_slave = newval->value; if (newval->value > 0) { @@ -1151,8 +1208,8 @@ int bond_option_pps_set(struct bonding *bond, struct bond_opt_value *newval) return 0; } -int bond_option_lacp_rate_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_lacp_rate_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting LACP rate to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -1162,8 +1219,8 @@ int bond_option_lacp_rate_set(struct bonding *bond, return 0; } -int bond_option_ad_select_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_ad_select_set(struct bonding *bond, + struct bond_opt_value *newval) { pr_info("%s: Setting ad_select to %s (%llu)\n", bond->dev->name, newval->string, newval->value); @@ -1172,8 +1229,8 @@ int bond_option_ad_select_set(struct bonding *bond, return 0; } -int bond_option_queue_id_set(struct bonding *bond, - struct bond_opt_value *newval) +static int bond_option_queue_id_set(struct bonding *bond, + struct bond_opt_value *newval) { struct slave *slave, *update_slave; struct net_device *sdev; @@ -1233,7 +1290,8 @@ err_no_cmd: } -int bond_option_slaves_set(struct bonding *bond, struct bond_opt_value *newval) +static int bond_option_slaves_set(struct bonding *bond, + struct bond_opt_value *newval) { char command[IFNAMSIZ + 1] = { 0, }; struct net_device *dev; |