aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@redhat.com>2014-01-22 08:53:25 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-22 18:38:42 -0500
commit25a9b54a4b4a996e5a996c1e841c265d40db1d40 (patch)
treedbd8f877a0893d7c900b63684c3d274932796466 /drivers/net/bonding
parent4fb0ef585eb2825ef4e542c2b1d302dc53f36860 (diff)
bonding: convert downdelay to use the new option API
This patch adds the necessary changes so downdelay 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>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_netlink.c3
-rw-r--r--drivers/net/bonding/bond_options.c39
-rw-r--r--drivers/net/bonding/bond_options.h3
-rw-r--r--drivers/net/bonding/bond_sysfs.c13
-rw-r--r--drivers/net/bonding/bonding.h1
5 files changed, 27 insertions, 32 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 9164a5a8e44f..f30397e7131f 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -146,7 +146,8 @@ static int bond_changelink(struct net_device *bond_dev,
146 if (data[IFLA_BOND_DOWNDELAY]) { 146 if (data[IFLA_BOND_DOWNDELAY]) {
147 int downdelay = nla_get_u32(data[IFLA_BOND_DOWNDELAY]); 147 int downdelay = nla_get_u32(data[IFLA_BOND_DOWNDELAY]);
148 148
149 err = bond_option_downdelay_set(bond, downdelay); 149 bond_opt_initval(&newval, downdelay);
150 err = __bond_opt_set(bond, BOND_OPT_DOWNDELAY, &newval);
150 if (err) 151 if (err)
151 return err; 152 return err;
152 } 153 }
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index df5f007ddaa5..03514f7e17b9 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -135,6 +135,13 @@ static struct bond_option bond_opts[] = {
135 .flags = BOND_OPTFLAG_RAWVAL, 135 .flags = BOND_OPTFLAG_RAWVAL,
136 .set = bond_option_arp_ip_targets_set 136 .set = bond_option_arp_ip_targets_set
137 }, 137 },
138 [BOND_OPT_DOWNDELAY] = {
139 .id = BOND_OPT_DOWNDELAY,
140 .name = "downdelay",
141 .desc = "Delay before considering link down, in milliseconds",
142 .values = bond_intmax_tbl,
143 .set = bond_option_downdelay_set
144 },
138 { } 145 { }
139}; 146};
140 147
@@ -580,31 +587,25 @@ int bond_option_updelay_set(struct bonding *bond, int updelay)
580 return 0; 587 return 0;
581} 588}
582 589
583int bond_option_downdelay_set(struct bonding *bond, int downdelay) 590int bond_option_downdelay_set(struct bonding *bond,
591 struct bond_opt_value *newval)
584{ 592{
585 if (!(bond->params.miimon)) { 593 if (!bond->params.miimon) {
586 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n", 594 pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
587 bond->dev->name); 595 bond->dev->name);
588 return -EPERM; 596 return -EPERM;
589 } 597 }
590 598 if ((newval->value % bond->params.miimon) != 0) {
591 if (downdelay < 0) { 599 pr_warn("%s: Warning: down delay (%llu) is not a multiple of miimon (%d), delay rounded to %llu ms\n",
592 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n", 600 bond->dev->name, newval->value,
593 bond->dev->name, downdelay, 0, INT_MAX); 601 bond->params.miimon,
594 return -EINVAL; 602 (newval->value / bond->params.miimon) *
595 } else { 603 bond->params.miimon);
596 if ((downdelay % bond->params.miimon) != 0) {
597 pr_warn("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
598 bond->dev->name, downdelay,
599 bond->params.miimon,
600 (downdelay / bond->params.miimon) *
601 bond->params.miimon);
602 }
603 bond->params.downdelay = downdelay / bond->params.miimon;
604 pr_info("%s: Setting down delay to %d.\n",
605 bond->dev->name,
606 bond->params.downdelay * bond->params.miimon);
607 } 604 }
605 bond->params.downdelay = newval->value / bond->params.miimon;
606 pr_info("%s: Setting down delay to %d.\n",
607 bond->dev->name,
608 bond->params.downdelay * bond->params.miimon);
608 609
609 return 0; 610 return 0;
610} 611}
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h
index da351489a583..5a3f4053811d 100644
--- a/drivers/net/bonding/bond_options.h
+++ b/drivers/net/bonding/bond_options.h
@@ -46,6 +46,7 @@ enum {
46 BOND_OPT_FAIL_OVER_MAC, 46 BOND_OPT_FAIL_OVER_MAC,
47 BOND_OPT_ARP_INTERVAL, 47 BOND_OPT_ARP_INTERVAL,
48 BOND_OPT_ARP_TARGETS, 48 BOND_OPT_ARP_TARGETS,
49 BOND_OPT_DOWNDELAY,
49 BOND_OPT_LAST 50 BOND_OPT_LAST
50}; 51};
51 52
@@ -121,4 +122,6 @@ int bond_option_arp_interval_set(struct bonding *bond,
121int bond_option_arp_ip_targets_set(struct bonding *bond, 122int bond_option_arp_ip_targets_set(struct bonding *bond,
122 struct bond_opt_value *newval); 123 struct bond_opt_value *newval);
123void bond_option_arp_ip_targets_clear(struct bonding *bond); 124void bond_option_arp_ip_targets_clear(struct bonding *bond);
125int bond_option_downdelay_set(struct bonding *bond,
126 struct bond_opt_value *newval);
124#endif /* _BOND_OPTIONS_H */ 127#endif /* _BOND_OPTIONS_H */
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 5eeb3a2add02..b4f67132b3ba 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -501,22 +501,13 @@ static ssize_t bonding_store_downdelay(struct device *d,
501 struct device_attribute *attr, 501 struct device_attribute *attr,
502 const char *buf, size_t count) 502 const char *buf, size_t count)
503{ 503{
504 int new_value, ret;
505 struct bonding *bond = to_bond(d); 504 struct bonding *bond = to_bond(d);
505 int ret;
506 506
507 if (sscanf(buf, "%d", &new_value) != 1) { 507 ret = bond_opt_tryset_rtnl(bond, BOND_OPT_DOWNDELAY, (char *)buf);
508 pr_err("%s: no down delay value specified.\n", bond->dev->name);
509 return -EINVAL;
510 }
511
512 if (!rtnl_trylock())
513 return restart_syscall();
514
515 ret = bond_option_downdelay_set(bond, new_value);
516 if (!ret) 508 if (!ret)
517 ret = count; 509 ret = count;
518 510
519 rtnl_unlock();
520 return ret; 511 return ret;
521} 512}
522static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, 513static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 5a63c0e777e7..6286bb7b2092 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -455,7 +455,6 @@ void bond_netlink_fini(void);
455int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev); 455int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_dev);
456int bond_option_miimon_set(struct bonding *bond, int miimon); 456int bond_option_miimon_set(struct bonding *bond, int miimon);
457int bond_option_updelay_set(struct bonding *bond, int updelay); 457int bond_option_updelay_set(struct bonding *bond, int updelay);
458int bond_option_downdelay_set(struct bonding *bond, int downdelay);
459int bond_option_use_carrier_set(struct bonding *bond, int use_carrier); 458int bond_option_use_carrier_set(struct bonding *bond, int use_carrier);
460int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); 459int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);
461int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); 460int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target);