diff options
author | Nikolay Aleksandrov <nikolay@redhat.com> | 2014-01-22 08:53:37 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-22 18:38:44 -0500 |
commit | 3df011625135fa1c670cb8e24618fc7ca38e00b0 (patch) | |
tree | ea2b9dcd8d94be3cace8fc3bb73934989d601f09 | |
parent | 24089ba1026a684d64bc0eeb6af634e26c9501c4 (diff) |
bonding: convert all_slaves_active to use the new option API
This patch adds the necessary changes so all_slaves_active would use
the new bonding option API.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 4 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 29 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.h | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 15 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 2 |
5 files changed, 25 insertions, 28 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index dba1f2e22371..828013a16c52 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -282,8 +282,8 @@ static int bond_changelink(struct net_device *bond_dev, | |||
282 | int all_slaves_active = | 282 | int all_slaves_active = |
283 | nla_get_u8(data[IFLA_BOND_ALL_SLAVES_ACTIVE]); | 283 | nla_get_u8(data[IFLA_BOND_ALL_SLAVES_ACTIVE]); |
284 | 284 | ||
285 | err = bond_option_all_slaves_active_set(bond, | 285 | bond_opt_initval(&newval, all_slaves_active); |
286 | all_slaves_active); | 286 | err = __bond_opt_set(bond, BOND_OPT_ALL_SLAVES_ACTIVE, &newval); |
287 | if (err) | 287 | if (err) |
288 | return err; | 288 | return err; |
289 | } | 289 | } |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 8775c724c700..7fafc34ca47b 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -105,6 +105,12 @@ static struct bond_opt_value bond_use_carrier_tbl[] = { | |||
105 | { NULL, -1, 0} | 105 | { NULL, -1, 0} |
106 | }; | 106 | }; |
107 | 107 | ||
108 | static struct bond_opt_value bond_all_slaves_active_tbl[] = { | ||
109 | { "off", 0, BOND_VALFLAG_DEFAULT}, | ||
110 | { "on", 1, 0}, | ||
111 | { NULL, -1, 0} | ||
112 | }; | ||
113 | |||
108 | static struct bond_option bond_opts[] = { | 114 | static struct bond_option bond_opts[] = { |
109 | [BOND_OPT_MODE] = { | 115 | [BOND_OPT_MODE] = { |
110 | .id = BOND_OPT_MODE, | 116 | .id = BOND_OPT_MODE, |
@@ -261,6 +267,13 @@ static struct bond_option bond_opts[] = { | |||
261 | .flags = BOND_OPTFLAG_RAWVAL, | 267 | .flags = BOND_OPTFLAG_RAWVAL, |
262 | .set = bond_option_queue_id_set | 268 | .set = bond_option_queue_id_set |
263 | }, | 269 | }, |
270 | [BOND_OPT_ALL_SLAVES_ACTIVE] = { | ||
271 | .id = BOND_OPT_ALL_SLAVES_ACTIVE, | ||
272 | .name = "all_slaves_active", | ||
273 | .desc = "Keep all frames received on an interface by setting active flag for all slaves", | ||
274 | .values = bond_all_slaves_active_tbl, | ||
275 | .set = bond_option_all_slaves_active_set | ||
276 | }, | ||
264 | { } | 277 | { } |
265 | }; | 278 | }; |
266 | 279 | ||
@@ -1049,25 +1062,17 @@ int bond_option_num_peer_notif_set(struct bonding *bond, | |||
1049 | } | 1062 | } |
1050 | 1063 | ||
1051 | int bond_option_all_slaves_active_set(struct bonding *bond, | 1064 | int bond_option_all_slaves_active_set(struct bonding *bond, |
1052 | int all_slaves_active) | 1065 | struct bond_opt_value *newval) |
1053 | { | 1066 | { |
1054 | struct list_head *iter; | 1067 | struct list_head *iter; |
1055 | struct slave *slave; | 1068 | struct slave *slave; |
1056 | 1069 | ||
1057 | if (all_slaves_active == bond->params.all_slaves_active) | 1070 | if (newval->value == bond->params.all_slaves_active) |
1058 | return 0; | 1071 | return 0; |
1059 | 1072 | bond->params.all_slaves_active = newval->value; | |
1060 | if ((all_slaves_active == 0) || (all_slaves_active == 1)) { | ||
1061 | bond->params.all_slaves_active = all_slaves_active; | ||
1062 | } else { | ||
1063 | pr_info("%s: Ignoring invalid all_slaves_active value %d.\n", | ||
1064 | bond->dev->name, all_slaves_active); | ||
1065 | return -EINVAL; | ||
1066 | } | ||
1067 | |||
1068 | bond_for_each_slave(bond, slave, iter) { | 1073 | bond_for_each_slave(bond, slave, iter) { |
1069 | if (!bond_is_active_slave(slave)) { | 1074 | if (!bond_is_active_slave(slave)) { |
1070 | if (all_slaves_active) | 1075 | if (newval->value) |
1071 | slave->inactive = 0; | 1076 | slave->inactive = 0; |
1072 | else | 1077 | else |
1073 | slave->inactive = 1; | 1078 | slave->inactive = 1; |
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h index 396d504214e4..09ee8c8bb19b 100644 --- a/drivers/net/bonding/bond_options.h +++ b/drivers/net/bonding/bond_options.h | |||
@@ -58,6 +58,7 @@ enum { | |||
58 | BOND_OPT_USE_CARRIER, | 58 | BOND_OPT_USE_CARRIER, |
59 | BOND_OPT_ACTIVE_SLAVE, | 59 | BOND_OPT_ACTIVE_SLAVE, |
60 | BOND_OPT_QUEUE_ID, | 60 | BOND_OPT_QUEUE_ID, |
61 | BOND_OPT_ALL_SLAVES_ACTIVE, | ||
61 | BOND_OPT_LAST | 62 | BOND_OPT_LAST |
62 | }; | 63 | }; |
63 | 64 | ||
@@ -156,4 +157,6 @@ int bond_option_active_slave_set(struct bonding *bond, | |||
156 | struct bond_opt_value *newval); | 157 | struct bond_opt_value *newval); |
157 | int bond_option_queue_id_set(struct bonding *bond, | 158 | int bond_option_queue_id_set(struct bonding *bond, |
158 | struct bond_opt_value *newval); | 159 | struct bond_opt_value *newval); |
160 | int bond_option_all_slaves_active_set(struct bonding *bond, | ||
161 | struct bond_opt_value *newval); | ||
159 | #endif /* _BOND_OPTIONS_H */ | 162 | #endif /* _BOND_OPTIONS_H */ |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index a9cd3f514c8c..20210d29e86b 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -1015,22 +1015,13 @@ static ssize_t bonding_store_slaves_active(struct device *d, | |||
1015 | const char *buf, size_t count) | 1015 | const char *buf, size_t count) |
1016 | { | 1016 | { |
1017 | struct bonding *bond = to_bond(d); | 1017 | struct bonding *bond = to_bond(d); |
1018 | int new_value, ret; | 1018 | int ret; |
1019 | |||
1020 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
1021 | pr_err("%s: no all_slaves_active value specified.\n", | ||
1022 | bond->dev->name); | ||
1023 | return -EINVAL; | ||
1024 | } | ||
1025 | |||
1026 | if (!rtnl_trylock()) | ||
1027 | return restart_syscall(); | ||
1028 | 1019 | ||
1029 | ret = bond_option_all_slaves_active_set(bond, new_value); | 1020 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ALL_SLAVES_ACTIVE, |
1021 | (char *)buf); | ||
1030 | if (!ret) | 1022 | if (!ret) |
1031 | ret = count; | 1023 | ret = count; |
1032 | 1024 | ||
1033 | rtnl_unlock(); | ||
1034 | return ret; | 1025 | return ret; |
1035 | } | 1026 | } |
1036 | static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR, | 1027 | static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 4ac79e1dd78f..9801c5d6cee4 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -455,8 +455,6 @@ void bond_netlink_fini(void); | |||
455 | int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); | 455 | int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); |
456 | int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); | 456 | int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); |
457 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); | 457 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); |
458 | int bond_option_all_slaves_active_set(struct bonding *bond, | ||
459 | int all_slaves_active); | ||
460 | int bond_option_lp_interval_set(struct bonding *bond, int min_links); | 458 | int bond_option_lp_interval_set(struct bonding *bond, int min_links); |
461 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); | 459 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); |
462 | struct net_device *bond_option_active_slave_get(struct bonding *bond); | 460 | struct net_device *bond_option_active_slave_get(struct bonding *bond); |