Commit 7bdb04ed authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

bonding: convert arp_interval to use the new option API

This patch adds the necessary changes so arp_interval would use
the new bonding option API. The "default" definition has been removed as
it was 0.
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1df6b6aa
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
/* monitor all links that often (in milliseconds). <=0 disables monitoring */ /* monitor all links that often (in milliseconds). <=0 disables monitoring */
#define BOND_LINK_MON_INTERV 0 #define BOND_LINK_MON_INTERV 0
#define BOND_LINK_ARP_INTERV 0
static int max_bonds = BOND_DEFAULT_MAX_BONDS; static int max_bonds = BOND_DEFAULT_MAX_BONDS;
static int tx_queues = BOND_DEFAULT_TX_QUEUES; static int tx_queues = BOND_DEFAULT_TX_QUEUES;
...@@ -103,7 +102,7 @@ static char *lacp_rate; ...@@ -103,7 +102,7 @@ static char *lacp_rate;
static int min_links; static int min_links;
static char *ad_select; static char *ad_select;
static char *xmit_hash_policy; static char *xmit_hash_policy;
static int arp_interval = BOND_LINK_ARP_INTERV; static int arp_interval;
static char *arp_ip_target[BOND_MAX_ARP_TARGETS]; static char *arp_ip_target[BOND_MAX_ARP_TARGETS];
static char *arp_validate; static char *arp_validate;
static char *arp_all_targets; static char *arp_all_targets;
...@@ -4162,9 +4161,9 @@ static int bond_check_params(struct bond_params *params) ...@@ -4162,9 +4161,9 @@ static int bond_check_params(struct bond_params *params)
} }
if (arp_interval < 0) { if (arp_interval < 0) {
pr_warning("Warning: arp_interval module parameter (%d) , not in range 0-%d, so it was reset to %d\n", pr_warning("Warning: arp_interval module parameter (%d) , not in range 0-%d, so it was reset to 0\n",
arp_interval, INT_MAX, BOND_LINK_ARP_INTERV); arp_interval, INT_MAX);
arp_interval = BOND_LINK_ARP_INTERV; arp_interval = 0;
} }
for (arp_ip_count = 0, i = 0; for (arp_ip_count = 0, i = 0;
......
...@@ -166,7 +166,8 @@ static int bond_changelink(struct net_device *bond_dev, ...@@ -166,7 +166,8 @@ static int bond_changelink(struct net_device *bond_dev,
return -EINVAL; return -EINVAL;
} }
err = bond_option_arp_interval_set(bond, arp_interval); bond_opt_initval(&newval, arp_interval);
err = __bond_opt_set(bond, BOND_OPT_ARP_INTERVAL, &newval);
if (err) if (err)
return err; return err;
} }
......
...@@ -66,6 +66,11 @@ static struct bond_opt_value bond_fail_over_mac_tbl[] = { ...@@ -66,6 +66,11 @@ static struct bond_opt_value bond_fail_over_mac_tbl[] = {
{ NULL, -1, 0}, { NULL, -1, 0},
}; };
static struct bond_opt_value bond_intmax_tbl[] = {
{ "off", 0, BOND_VALFLAG_DEFAULT},
{ "maxval", INT_MAX, BOND_VALFLAG_MAX},
};
static struct bond_option bond_opts[] = { static struct bond_option bond_opts[] = {
[BOND_OPT_MODE] = { [BOND_OPT_MODE] = {
.id = BOND_OPT_MODE, .id = BOND_OPT_MODE,
...@@ -113,6 +118,15 @@ static struct bond_option bond_opts[] = { ...@@ -113,6 +118,15 @@ static struct bond_option bond_opts[] = {
.values = bond_fail_over_mac_tbl, .values = bond_fail_over_mac_tbl,
.set = bond_option_fail_over_mac_set .set = bond_option_fail_over_mac_set
}, },
[BOND_OPT_ARP_INTERVAL] = {
.id = BOND_OPT_ARP_INTERVAL,
.name = "arp_interval",
.desc = "arp interval in milliseconds",
.unsuppmodes = BIT(BOND_MODE_8023AD) | BIT(BOND_MODE_TLB) |
BIT(BOND_MODE_ALB),
.values = bond_intmax_tbl,
.set = bond_option_arp_interval_set
},
{ } { }
}; };
...@@ -601,22 +615,13 @@ int bond_option_use_carrier_set(struct bonding *bond, int use_carrier) ...@@ -601,22 +615,13 @@ int bond_option_use_carrier_set(struct bonding *bond, int use_carrier)
return 0; return 0;
} }
int bond_option_arp_interval_set(struct bonding *bond, int arp_interval) int bond_option_arp_interval_set(struct bonding *bond,
struct bond_opt_value *newval)
{ {
if (arp_interval < 0) { pr_info("%s: Setting ARP monitoring interval to %llu.\n",
pr_err("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n", bond->dev->name, newval->value);
bond->dev->name, arp_interval, INT_MAX); bond->params.arp_interval = newval->value;
return -EINVAL; if (newval->value) {
}
if (BOND_NO_USES_ARP(bond->params.mode)) {
pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n",
bond->dev->name, bond->dev->name);
return -EINVAL;
}
pr_info("%s: Setting ARP monitoring interval to %d.\n",
bond->dev->name, arp_interval);
bond->params.arp_interval = arp_interval;
if (arp_interval) {
if (bond->params.miimon) { if (bond->params.miimon) {
pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
bond->dev->name, bond->dev->name); bond->dev->name, bond->dev->name);
...@@ -632,7 +637,7 @@ int bond_option_arp_interval_set(struct bonding *bond, int arp_interval) ...@@ -632,7 +637,7 @@ int bond_option_arp_interval_set(struct bonding *bond, int arp_interval)
* timer will get fired off when the open function * timer will get fired off when the open function
* is called. * is called.
*/ */
if (!arp_interval) { if (!newval->value) {
if (bond->params.arp_validate) if (bond->params.arp_validate)
bond->recv_probe = NULL; bond->recv_probe = NULL;
cancel_delayed_work_sync(&bond->arp_work); cancel_delayed_work_sync(&bond->arp_work);
......
...@@ -44,6 +44,7 @@ enum { ...@@ -44,6 +44,7 @@ enum {
BOND_OPT_ARP_VALIDATE, BOND_OPT_ARP_VALIDATE,
BOND_OPT_ARP_ALL_TARGETS, BOND_OPT_ARP_ALL_TARGETS,
BOND_OPT_FAIL_OVER_MAC, BOND_OPT_FAIL_OVER_MAC,
BOND_OPT_ARP_INTERVAL,
BOND_OPT_LAST BOND_OPT_LAST
}; };
...@@ -114,4 +115,6 @@ int bond_option_arp_all_targets_set(struct bonding *bond, ...@@ -114,4 +115,6 @@ int bond_option_arp_all_targets_set(struct bonding *bond,
struct bond_opt_value *newval); struct bond_opt_value *newval);
int bond_option_fail_over_mac_set(struct bonding *bond, int bond_option_fail_over_mac_set(struct bonding *bond,
struct bond_opt_value *newval); struct bond_opt_value *newval);
int bond_option_arp_interval_set(struct bonding *bond,
struct bond_opt_value *newval);
#endif /* _BOND_OPTIONS_H */ #endif /* _BOND_OPTIONS_H */
...@@ -436,22 +436,12 @@ static ssize_t bonding_store_arp_interval(struct device *d, ...@@ -436,22 +436,12 @@ static ssize_t bonding_store_arp_interval(struct device *d,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
int new_value, ret; int ret;
if (sscanf(buf, "%d", &new_value) != 1) {
pr_err("%s: no arp_interval value specified.\n",
bond->dev->name);
return -EINVAL;
}
if (!rtnl_trylock())
return restart_syscall();
ret = bond_option_arp_interval_set(bond, new_value); ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_INTERVAL, (char *)buf);
if (!ret) if (!ret)
ret = count; ret = count;
rtnl_unlock();
return ret; return ret;
} }
static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR,
......
...@@ -457,7 +457,6 @@ int bond_option_miimon_set(struct bonding *bond, int miimon); ...@@ -457,7 +457,6 @@ int bond_option_miimon_set(struct bonding *bond, int miimon);
int bond_option_updelay_set(struct bonding *bond, int updelay); int bond_option_updelay_set(struct bonding *bond, int updelay);
int bond_option_downdelay_set(struct bonding *bond, int downdelay); int bond_option_downdelay_set(struct bonding *bond, int downdelay);
int bond_option_use_carrier_set(struct bonding *bond, int use_carrier); int bond_option_use_carrier_set(struct bonding *bond, int use_carrier);
int bond_option_arp_interval_set(struct bonding *bond, int arp_interval);
int bond_option_arp_ip_targets_set(struct bonding *bond, __be32 *targets, int bond_option_arp_ip_targets_set(struct bonding *bond, __be32 *targets,
int count); int count);
int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment