提交 0fff0608 编写于 作者: N Nikolay Aleksandrov 提交者: David S. Miller

bonding: convert use_carrier to use the new option API

This patch adds the necessary changes so use_carrier would use
the new bonding option API.
Signed-off-by: NNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 388d3a6d
...@@ -156,7 +156,8 @@ static int bond_changelink(struct net_device *bond_dev, ...@@ -156,7 +156,8 @@ static int bond_changelink(struct net_device *bond_dev,
if (data[IFLA_BOND_USE_CARRIER]) { if (data[IFLA_BOND_USE_CARRIER]) {
int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]); int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]);
err = bond_option_use_carrier_set(bond, use_carrier); bond_opt_initval(&newval, use_carrier);
err = __bond_opt_set(bond, BOND_OPT_USE_CARRIER, &newval);
if (err) if (err)
return err; return err;
} }
......
...@@ -99,6 +99,12 @@ static struct bond_opt_value bond_primary_reselect_tbl[] = { ...@@ -99,6 +99,12 @@ static struct bond_opt_value bond_primary_reselect_tbl[] = {
{ NULL, -1}, { NULL, -1},
}; };
static struct bond_opt_value bond_use_carrier_tbl[] = {
{ "off", 0, 0},
{ "on", 1, BOND_VALFLAG_DEFAULT},
{ NULL, -1, 0}
};
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,
...@@ -231,6 +237,13 @@ static struct bond_option bond_opts[] = { ...@@ -231,6 +237,13 @@ static struct bond_option bond_opts[] = {
.values = bond_primary_reselect_tbl, .values = bond_primary_reselect_tbl,
.set = bond_option_primary_reselect_set .set = bond_option_primary_reselect_set
}, },
[BOND_OPT_USE_CARRIER] = {
.id = BOND_OPT_USE_CARRIER,
.name = "use_carrier",
.desc = "Use netif_carrier_ok (vs MII ioctls) in miimon",
.values = bond_use_carrier_tbl,
.set = bond_option_use_carrier_set
},
{ } { }
}; };
...@@ -688,16 +701,12 @@ int bond_option_downdelay_set(struct bonding *bond, ...@@ -688,16 +701,12 @@ int bond_option_downdelay_set(struct bonding *bond,
return 0; return 0;
} }
int bond_option_use_carrier_set(struct bonding *bond, int use_carrier) int bond_option_use_carrier_set(struct bonding *bond,
struct bond_opt_value *newval)
{ {
if ((use_carrier == 0) || (use_carrier == 1)) { pr_info("%s: Setting use_carrier to %llu.\n",
bond->params.use_carrier = use_carrier; bond->dev->name, newval->value);
pr_info("%s: Setting use_carrier to %d.\n", bond->params.use_carrier = newval->value;
bond->dev->name, use_carrier);
} else {
pr_info("%s: Ignoring invalid use_carrier value %d.\n",
bond->dev->name, use_carrier);
}
return 0; return 0;
} }
......
...@@ -55,6 +55,7 @@ enum { ...@@ -55,6 +55,7 @@ enum {
BOND_OPT_MIIMON, BOND_OPT_MIIMON,
BOND_OPT_PRIMARY, BOND_OPT_PRIMARY,
BOND_OPT_PRIMARY_RESELECT, BOND_OPT_PRIMARY_RESELECT,
BOND_OPT_USE_CARRIER,
BOND_OPT_LAST BOND_OPT_LAST
}; };
...@@ -147,4 +148,6 @@ int bond_option_primary_set(struct bonding *bond, ...@@ -147,4 +148,6 @@ int bond_option_primary_set(struct bonding *bond,
struct bond_opt_value *newval); struct bond_opt_value *newval);
int bond_option_primary_reselect_set(struct bonding *bond, int bond_option_primary_reselect_set(struct bonding *bond,
struct bond_opt_value *newval); struct bond_opt_value *newval);
int bond_option_use_carrier_set(struct bonding *bond,
struct bond_opt_value *newval);
#endif /* _BOND_OPTIONS_H */ #endif /* _BOND_OPTIONS_H */
...@@ -772,23 +772,13 @@ static ssize_t bonding_store_carrier(struct device *d, ...@@ -772,23 +772,13 @@ static ssize_t bonding_store_carrier(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_USE_CARRIER, (char *)buf);
pr_err("%s: no use_carrier value specified.\n",
bond->dev->name);
return -EINVAL;
}
if (!rtnl_trylock())
return restart_syscall();
ret = bond_option_use_carrier_set(bond, new_value);
if (!ret) if (!ret)
ret = count; ret = count;
rtnl_unlock();
return ret; return ret;
} }
static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR,
......
...@@ -453,7 +453,6 @@ unsigned int bond_get_num_tx_queues(void); ...@@ -453,7 +453,6 @@ unsigned int bond_get_num_tx_queues(void);
int bond_netlink_init(void); 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_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);
int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册