diff options
author | Nikolay Aleksandrov <nikolay@redhat.com> | 2014-01-22 08:53:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-22 18:38:43 -0500 |
commit | 180222f08861d8206b3ff1c6392101e29d4ae161 (patch) | |
tree | 4ce7f73dc463164f8539bdc40f627b4b0808b95e | |
parent | b98d9c66e1c3823c50a3cd5e8e59f12b97d7ba5d (diff) |
bonding: convert primary to use the new option API
This patch adds the necessary changes so primary 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 | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 26 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.h | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 11 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 1 |
5 files changed, 22 insertions, 22 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 64e45c97c244..b27e09d1e2e4 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -227,7 +227,8 @@ static int bond_changelink(struct net_device *bond_dev, | |||
227 | if (dev) | 227 | if (dev) |
228 | primary = dev->name; | 228 | primary = dev->name; |
229 | 229 | ||
230 | err = bond_option_primary_set(bond, primary); | 230 | bond_opt_initstr(&newval, primary); |
231 | err = __bond_opt_set(bond, BOND_OPT_PRIMARY, &newval); | ||
231 | if (err) | 232 | if (err) |
232 | return err; | 233 | return err; |
233 | } | 234 | } |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index cb515d94864d..f094a313adb3 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -207,6 +207,16 @@ static struct bond_option bond_opts[] = { | |||
207 | .values = bond_intmax_tbl, | 207 | .values = bond_intmax_tbl, |
208 | .set = bond_option_miimon_set | 208 | .set = bond_option_miimon_set |
209 | }, | 209 | }, |
210 | [BOND_OPT_PRIMARY] = { | ||
211 | .id = BOND_OPT_PRIMARY, | ||
212 | .name = "primary", | ||
213 | .desc = "Primary network device to use", | ||
214 | .flags = BOND_OPTFLAG_RAWVAL, | ||
215 | .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_ACTIVEBACKUP) | | ||
216 | BIT(BOND_MODE_TLB) | | ||
217 | BIT(BOND_MODE_ALB)), | ||
218 | .set = bond_option_primary_set | ||
219 | }, | ||
210 | { } | 220 | { } |
211 | }; | 221 | }; |
212 | 222 | ||
@@ -885,23 +895,19 @@ int bond_option_arp_all_targets_set(struct bonding *bond, | |||
885 | return 0; | 895 | return 0; |
886 | } | 896 | } |
887 | 897 | ||
888 | int bond_option_primary_set(struct bonding *bond, const char *primary) | 898 | int bond_option_primary_set(struct bonding *bond, struct bond_opt_value *newval) |
889 | { | 899 | { |
900 | char *p, *primary = newval->string; | ||
890 | struct list_head *iter; | 901 | struct list_head *iter; |
891 | struct slave *slave; | 902 | struct slave *slave; |
892 | int err = 0; | ||
893 | 903 | ||
894 | block_netpoll_tx(); | 904 | block_netpoll_tx(); |
895 | read_lock(&bond->lock); | 905 | read_lock(&bond->lock); |
896 | write_lock_bh(&bond->curr_slave_lock); | 906 | write_lock_bh(&bond->curr_slave_lock); |
897 | 907 | ||
898 | if (!USES_PRIMARY(bond->params.mode)) { | 908 | p = strchr(primary, '\n'); |
899 | pr_err("%s: Unable to set primary slave; %s is in mode %d\n", | 909 | if (p) |
900 | bond->dev->name, bond->dev->name, bond->params.mode); | 910 | *p = '\0'; |
901 | err = -EINVAL; | ||
902 | goto out; | ||
903 | } | ||
904 | |||
905 | /* check to see if we are clearing primary */ | 911 | /* check to see if we are clearing primary */ |
906 | if (!strlen(primary)) { | 912 | if (!strlen(primary)) { |
907 | pr_info("%s: Setting primary slave to None.\n", | 913 | pr_info("%s: Setting primary slave to None.\n", |
@@ -934,7 +940,7 @@ out: | |||
934 | read_unlock(&bond->lock); | 940 | read_unlock(&bond->lock); |
935 | unblock_netpoll_tx(); | 941 | unblock_netpoll_tx(); |
936 | 942 | ||
937 | return err; | 943 | return 0; |
938 | } | 944 | } |
939 | 945 | ||
940 | int bond_option_primary_reselect_set(struct bonding *bond, int primary_reselect) | 946 | int bond_option_primary_reselect_set(struct bonding *bond, int primary_reselect) |
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h index 90f00c64030c..6ff831030545 100644 --- a/drivers/net/bonding/bond_options.h +++ b/drivers/net/bonding/bond_options.h | |||
@@ -53,6 +53,7 @@ enum { | |||
53 | BOND_OPT_AD_SELECT, | 53 | BOND_OPT_AD_SELECT, |
54 | BOND_OPT_NUM_PEER_NOTIF, | 54 | BOND_OPT_NUM_PEER_NOTIF, |
55 | BOND_OPT_MIIMON, | 55 | BOND_OPT_MIIMON, |
56 | BOND_OPT_PRIMARY, | ||
56 | BOND_OPT_LAST | 57 | BOND_OPT_LAST |
57 | }; | 58 | }; |
58 | 59 | ||
@@ -141,4 +142,6 @@ int bond_option_ad_select_set(struct bonding *bond, | |||
141 | int bond_option_num_peer_notif_set(struct bonding *bond, | 142 | int bond_option_num_peer_notif_set(struct bonding *bond, |
142 | struct bond_opt_value *newval); | 143 | struct bond_opt_value *newval); |
143 | int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval); | 144 | int bond_option_miimon_set(struct bonding *bond, struct bond_opt_value *newval); |
145 | int bond_option_primary_set(struct bonding *bond, | ||
146 | struct bond_opt_value *newval); | ||
144 | #endif /* _BOND_OPTIONS_H */ | 147 | #endif /* _BOND_OPTIONS_H */ |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 3f6e4d614a47..10c58ef4876d 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -710,21 +710,12 @@ static ssize_t bonding_store_primary(struct device *d, | |||
710 | const char *buf, size_t count) | 710 | const char *buf, size_t count) |
711 | { | 711 | { |
712 | struct bonding *bond = to_bond(d); | 712 | struct bonding *bond = to_bond(d); |
713 | char ifname[IFNAMSIZ]; | ||
714 | int ret; | 713 | int ret; |
715 | 714 | ||
716 | sscanf(buf, "%15s", ifname); /* IFNAMSIZ */ | 715 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_PRIMARY, (char *)buf); |
717 | if (ifname[0] == '\n') | ||
718 | ifname[0] = '\0'; | ||
719 | |||
720 | if (!rtnl_trylock()) | ||
721 | return restart_syscall(); | ||
722 | |||
723 | ret = bond_option_primary_set(bond, ifname); | ||
724 | if (!ret) | 716 | if (!ret) |
725 | ret = count; | 717 | ret = count; |
726 | 718 | ||
727 | rtnl_unlock(); | ||
728 | return ret; | 719 | return ret; |
729 | } | 720 | } |
730 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, | 721 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 4d0461959357..891685483034 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -456,7 +456,6 @@ int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_ | |||
456 | int bond_option_use_carrier_set(struct bonding *bond, int use_carrier); | 456 | int bond_option_use_carrier_set(struct bonding *bond, int use_carrier); |
457 | int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); | 457 | int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); |
458 | int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); | 458 | int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); |
459 | int bond_option_primary_set(struct bonding *bond, const char *primary); | ||
460 | int bond_option_primary_reselect_set(struct bonding *bond, | 459 | int bond_option_primary_reselect_set(struct bonding *bond, |
461 | int primary_reselect); | 460 | int primary_reselect); |
462 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); | 461 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); |