bonding: convert updelay to use the new option API
This patch adds the necessary changes so updelay would use the new bonding option API. Also some trivial style fixes. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
25a9b54a4b
Коммит
e499461275
|
@ -139,7 +139,8 @@ static int bond_changelink(struct net_device *bond_dev,
|
||||||
if (data[IFLA_BOND_UPDELAY]) {
|
if (data[IFLA_BOND_UPDELAY]) {
|
||||||
int updelay = nla_get_u32(data[IFLA_BOND_UPDELAY]);
|
int updelay = nla_get_u32(data[IFLA_BOND_UPDELAY]);
|
||||||
|
|
||||||
err = bond_option_updelay_set(bond, updelay);
|
bond_opt_initval(&newval, updelay);
|
||||||
|
err = __bond_opt_set(bond, BOND_OPT_UPDELAY, &newval);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,14 @@ static struct bond_option bond_opts[] = {
|
||||||
.values = bond_intmax_tbl,
|
.values = bond_intmax_tbl,
|
||||||
.set = bond_option_downdelay_set
|
.set = bond_option_downdelay_set
|
||||||
},
|
},
|
||||||
|
[BOND_OPT_UPDELAY] = {
|
||||||
|
.id = BOND_OPT_UPDELAY,
|
||||||
|
.name = "updelay",
|
||||||
|
.desc = "Delay before considering link up, in milliseconds",
|
||||||
|
.values = bond_intmax_tbl,
|
||||||
|
.set = bond_option_updelay_set
|
||||||
|
},
|
||||||
|
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -558,31 +566,24 @@ int bond_option_miimon_set(struct bonding *bond, int miimon)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bond_option_updelay_set(struct bonding *bond, int updelay)
|
int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval)
|
||||||
{
|
{
|
||||||
if (!(bond->params.miimon)) {
|
if (!bond->params.miimon) {
|
||||||
pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
|
pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
|
||||||
bond->dev->name);
|
bond->dev->name);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
if ((newval->value % bond->params.miimon) != 0) {
|
||||||
if (updelay < 0) {
|
pr_warn("%s: Warning: up delay (%llu) is not a multiple of miimon (%d), updelay rounded to %llu ms\n",
|
||||||
pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n",
|
bond->dev->name, newval->value,
|
||||||
bond->dev->name, updelay, 0, INT_MAX);
|
bond->params.miimon,
|
||||||
return -EINVAL;
|
(newval->value / bond->params.miimon) *
|
||||||
} else {
|
bond->params.miimon);
|
||||||
if ((updelay % bond->params.miimon) != 0) {
|
|
||||||
pr_warn("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
|
|
||||||
bond->dev->name, updelay,
|
|
||||||
bond->params.miimon,
|
|
||||||
(updelay / bond->params.miimon) *
|
|
||||||
bond->params.miimon);
|
|
||||||
}
|
|
||||||
bond->params.updelay = updelay / bond->params.miimon;
|
|
||||||
pr_info("%s: Setting up delay to %d.\n",
|
|
||||||
bond->dev->name,
|
|
||||||
bond->params.updelay * bond->params.miimon);
|
|
||||||
}
|
}
|
||||||
|
bond->params.updelay = newval->value / bond->params.miimon;
|
||||||
|
pr_info("%s: Setting up delay to %d.\n",
|
||||||
|
bond->dev->name,
|
||||||
|
bond->params.updelay * bond->params.miimon);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ enum {
|
||||||
BOND_OPT_ARP_INTERVAL,
|
BOND_OPT_ARP_INTERVAL,
|
||||||
BOND_OPT_ARP_TARGETS,
|
BOND_OPT_ARP_TARGETS,
|
||||||
BOND_OPT_DOWNDELAY,
|
BOND_OPT_DOWNDELAY,
|
||||||
|
BOND_OPT_UPDELAY,
|
||||||
BOND_OPT_LAST
|
BOND_OPT_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,4 +125,6 @@ int bond_option_arp_ip_targets_set(struct bonding *bond,
|
||||||
void bond_option_arp_ip_targets_clear(struct bonding *bond);
|
void bond_option_arp_ip_targets_clear(struct bonding *bond);
|
||||||
int bond_option_downdelay_set(struct bonding *bond,
|
int bond_option_downdelay_set(struct bonding *bond,
|
||||||
struct bond_opt_value *newval);
|
struct bond_opt_value *newval);
|
||||||
|
int bond_option_updelay_set(struct bonding *bond,
|
||||||
|
struct bond_opt_value *newval);
|
||||||
#endif /* _BOND_OPTIONS_H */
|
#endif /* _BOND_OPTIONS_H */
|
||||||
|
|
|
@ -527,23 +527,13 @@ static ssize_t bonding_store_updelay(struct device *d,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
int new_value, ret;
|
|
||||||
struct bonding *bond = to_bond(d);
|
struct bonding *bond = to_bond(d);
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (sscanf(buf, "%d", &new_value) != 1) {
|
ret = bond_opt_tryset_rtnl(bond, BOND_OPT_UPDELAY, (char *)buf);
|
||||||
pr_err("%s: no up delay value specified.\n",
|
|
||||||
bond->dev->name);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rtnl_trylock())
|
|
||||||
return restart_syscall();
|
|
||||||
|
|
||||||
ret = bond_option_updelay_set(bond, new_value);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = count;
|
ret = count;
|
||||||
|
|
||||||
rtnl_unlock();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
|
static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR,
|
||||||
|
|
|
@ -454,7 +454,6 @@ int bond_netlink_init(void);
|
||||||
void bond_netlink_fini(void);
|
void bond_netlink_fini(void);
|
||||||
int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev);
|
int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev);
|
||||||
int bond_option_miimon_set(struct bonding *bond, int miimon);
|
int bond_option_miimon_set(struct bonding *bond, int miimon);
|
||||||
int bond_option_updelay_set(struct bonding *bond, int updelay);
|
|
||||||
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_ip_target_add(struct bonding *bond, __be32 target);
|
int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
|
||||||
int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
|
int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче