bonding: convert miimon to use the new option API

This patch adds the necessary changes so miimon would use
the new bonding option API. The "default" definition has been removed as
it was 0.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Nikolay Aleksandrov
2014-01-22 14:53:31 +01:00
committed by David S. Miller
parent ef56becbb3
commit b98d9c66e1
6 changed files with 24 additions and 30 deletions

View File

@@ -200,6 +200,13 @@ static struct bond_option bond_opts[] = {
.values = bond_num_peer_notif_tbl,
.set = bond_option_num_peer_notif_set
},
[BOND_OPT_MIIMON] = {
.id = BOND_OPT_MIIMON,
.name = "miimon",
.desc = "Link check interval in milliseconds",
.values = bond_intmax_tbl,
.set = bond_option_miimon_set
},
{ }
};
@@ -575,16 +582,11 @@ int bond_option_active_slave_set(struct bonding *bond,
return ret;
}
int bond_option_miimon_set(struct bonding *bond, int miimon)
int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval)
{
if (miimon < 0) {
pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
bond->dev->name, miimon, 0, INT_MAX);
return -EINVAL;
}
pr_info("%s: Setting MII monitoring interval to %d.\n",
bond->dev->name, miimon);
bond->params.miimon = miimon;
pr_info("%s: Setting MII monitoring interval to %llu.\n",
bond->dev->name, newval->value);
bond->params.miimon = newval->value;
if (bond->params.updelay)
pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
bond->dev->name,
@@ -593,7 +595,7 @@ int bond_option_miimon_set(struct bonding *bond, int miimon)
pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
bond->dev->name,
bond->params.downdelay * bond->params.miimon);
if (miimon && bond->params.arp_interval) {
if (newval->value && bond->params.arp_interval) {
pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
bond->dev->name);
bond->params.arp_interval = 0;
@@ -606,13 +608,14 @@ int bond_option_miimon_set(struct bonding *bond, int miimon)
* timer will get fired off when the open function
* is called.
*/
if (!miimon) {
if (!newval->value) {
cancel_delayed_work_sync(&bond->mii_work);
} else {
cancel_delayed_work_sync(&bond->arp_work);
queue_delayed_work(bond->wq, &bond->mii_work, 0);
}
}
return 0;
}