diff options
author | Nikolay Aleksandrov <nikolay@redhat.com> | 2014-01-22 08:53:34 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-22 18:38:43 -0500 |
commit | 0fff060877426f3faf6754c201e28cd5b34756c0 (patch) | |
tree | fa4c65b3091a5a8d244e1932c0ce27391aba4c84 /drivers/net/bonding | |
parent | 388d3a6d4aa356b885bcd023c185060df9ea2484 (diff) |
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: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 27 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.h | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 14 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 1 |
5 files changed, 25 insertions, 23 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 709e93861771..2175e1926e5a 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -156,7 +156,8 @@ static int bond_changelink(struct net_device *bond_dev, | |||
156 | if (data[IFLA_BOND_USE_CARRIER]) { | 156 | if (data[IFLA_BOND_USE_CARRIER]) { |
157 | int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]); | 157 | int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]); |
158 | 158 | ||
159 | err = bond_option_use_carrier_set(bond, use_carrier); | 159 | bond_opt_initval(&newval, use_carrier); |
160 | err = __bond_opt_set(bond, BOND_OPT_USE_CARRIER, &newval); | ||
160 | if (err) | 161 | if (err) |
161 | return err; | 162 | return err; |
162 | } | 163 | } |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index eaa3d4057cd3..18b1cc0d8b80 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -99,6 +99,12 @@ static struct bond_opt_value bond_primary_reselect_tbl[] = { | |||
99 | { NULL, -1}, | 99 | { NULL, -1}, |
100 | }; | 100 | }; |
101 | 101 | ||
102 | static struct bond_opt_value bond_use_carrier_tbl[] = { | ||
103 | { "off", 0, 0}, | ||
104 | { "on", 1, BOND_VALFLAG_DEFAULT}, | ||
105 | { NULL, -1, 0} | ||
106 | }; | ||
107 | |||
102 | static struct bond_option bond_opts[] = { | 108 | static struct bond_option bond_opts[] = { |
103 | [BOND_OPT_MODE] = { | 109 | [BOND_OPT_MODE] = { |
104 | .id = BOND_OPT_MODE, | 110 | .id = BOND_OPT_MODE, |
@@ -231,6 +237,13 @@ static struct bond_option bond_opts[] = { | |||
231 | .values = bond_primary_reselect_tbl, | 237 | .values = bond_primary_reselect_tbl, |
232 | .set = bond_option_primary_reselect_set | 238 | .set = bond_option_primary_reselect_set |
233 | }, | 239 | }, |
240 | [BOND_OPT_USE_CARRIER] = { | ||
241 | .id = BOND_OPT_USE_CARRIER, | ||
242 | .name = "use_carrier", | ||
243 | .desc = "Use netif_carrier_ok (vs MII ioctls) in miimon", | ||
244 | .values = bond_use_carrier_tbl, | ||
245 | .set = bond_option_use_carrier_set | ||
246 | }, | ||
234 | { } | 247 | { } |
235 | }; | 248 | }; |
236 | 249 | ||
@@ -688,16 +701,12 @@ int bond_option_downdelay_set(struct bonding *bond, | |||
688 | return 0; | 701 | return 0; |
689 | } | 702 | } |
690 | 703 | ||
691 | int bond_option_use_carrier_set(struct bonding *bond, int use_carrier) | 704 | int bond_option_use_carrier_set(struct bonding *bond, |
705 | struct bond_opt_value *newval) | ||
692 | { | 706 | { |
693 | if ((use_carrier == 0) || (use_carrier == 1)) { | 707 | pr_info("%s: Setting use_carrier to %llu.\n", |
694 | bond->params.use_carrier = use_carrier; | 708 | bond->dev->name, newval->value); |
695 | pr_info("%s: Setting use_carrier to %d.\n", | 709 | bond->params.use_carrier = newval->value; |
696 | bond->dev->name, use_carrier); | ||
697 | } else { | ||
698 | pr_info("%s: Ignoring invalid use_carrier value %d.\n", | ||
699 | bond->dev->name, use_carrier); | ||
700 | } | ||
701 | 710 | ||
702 | return 0; | 711 | return 0; |
703 | } | 712 | } |
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h index 1de315cd3bb6..229f5c15a1a4 100644 --- a/drivers/net/bonding/bond_options.h +++ b/drivers/net/bonding/bond_options.h | |||
@@ -55,6 +55,7 @@ enum { | |||
55 | BOND_OPT_MIIMON, | 55 | BOND_OPT_MIIMON, |
56 | BOND_OPT_PRIMARY, | 56 | BOND_OPT_PRIMARY, |
57 | BOND_OPT_PRIMARY_RESELECT, | 57 | BOND_OPT_PRIMARY_RESELECT, |
58 | BOND_OPT_USE_CARRIER, | ||
58 | BOND_OPT_LAST | 59 | BOND_OPT_LAST |
59 | }; | 60 | }; |
60 | 61 | ||
@@ -147,4 +148,6 @@ int bond_option_primary_set(struct bonding *bond, | |||
147 | struct bond_opt_value *newval); | 148 | struct bond_opt_value *newval); |
148 | int bond_option_primary_reselect_set(struct bonding *bond, | 149 | int bond_option_primary_reselect_set(struct bonding *bond, |
149 | struct bond_opt_value *newval); | 150 | struct bond_opt_value *newval); |
151 | int bond_option_use_carrier_set(struct bonding *bond, | ||
152 | struct bond_opt_value *newval); | ||
150 | #endif /* _BOND_OPTIONS_H */ | 153 | #endif /* _BOND_OPTIONS_H */ |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 7f307bf096d1..004048240def 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -772,23 +772,13 @@ static ssize_t bonding_store_carrier(struct device *d, | |||
772 | struct device_attribute *attr, | 772 | struct device_attribute *attr, |
773 | const char *buf, size_t count) | 773 | const char *buf, size_t count) |
774 | { | 774 | { |
775 | int new_value, ret; | ||
776 | struct bonding *bond = to_bond(d); | 775 | struct bonding *bond = to_bond(d); |
776 | int ret; | ||
777 | 777 | ||
778 | if (sscanf(buf, "%d", &new_value) != 1) { | 778 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_USE_CARRIER, (char *)buf); |
779 | pr_err("%s: no use_carrier value specified.\n", | ||
780 | bond->dev->name); | ||
781 | return -EINVAL; | ||
782 | } | ||
783 | |||
784 | if (!rtnl_trylock()) | ||
785 | return restart_syscall(); | ||
786 | |||
787 | ret = bond_option_use_carrier_set(bond, new_value); | ||
788 | if (!ret) | 779 | if (!ret) |
789 | ret = count; | 780 | ret = count; |
790 | 781 | ||
791 | rtnl_unlock(); | ||
792 | return ret; | 782 | return ret; |
793 | } | 783 | } |
794 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, | 784 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index afa443d29761..51f3b0ad11ab 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -453,7 +453,6 @@ unsigned int bond_get_num_tx_queues(void); | |||
453 | int bond_netlink_init(void); | 453 | int bond_netlink_init(void); |
454 | void bond_netlink_fini(void); | 454 | void bond_netlink_fini(void); |
455 | int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev); | 455 | int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev); |
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); | 456 | 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); | 457 | int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); |
459 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); | 458 | int bond_option_resend_igmp_set(struct bonding *bond, int resend_igmp); |