diff options
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 855dc10ffa1b..7a06ade85b02 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -229,7 +229,7 @@ static ssize_t bonding_show_slaves(struct device *d, | |||
229 | int i, res = 0; | 229 | int i, res = 0; |
230 | struct bonding *bond = to_bond(d); | 230 | struct bonding *bond = to_bond(d); |
231 | 231 | ||
232 | read_lock_bh(&bond->lock); | 232 | read_lock(&bond->lock); |
233 | bond_for_each_slave(bond, slave, i) { | 233 | bond_for_each_slave(bond, slave, i) { |
234 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | 234 | if (res > (PAGE_SIZE - IFNAMSIZ)) { |
235 | /* not enough space for another interface name */ | 235 | /* not enough space for another interface name */ |
@@ -240,7 +240,7 @@ static ssize_t bonding_show_slaves(struct device *d, | |||
240 | } | 240 | } |
241 | res += sprintf(buf + res, "%s ", slave->dev->name); | 241 | res += sprintf(buf + res, "%s ", slave->dev->name); |
242 | } | 242 | } |
243 | read_unlock_bh(&bond->lock); | 243 | read_unlock(&bond->lock); |
244 | res += sprintf(buf + res, "\n"); | 244 | res += sprintf(buf + res, "\n"); |
245 | res++; | 245 | res++; |
246 | return res; | 246 | return res; |
@@ -282,18 +282,18 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
282 | 282 | ||
283 | /* Got a slave name in ifname. Is it already in the list? */ | 283 | /* Got a slave name in ifname. Is it already in the list? */ |
284 | found = 0; | 284 | found = 0; |
285 | read_lock_bh(&bond->lock); | 285 | read_lock(&bond->lock); |
286 | bond_for_each_slave(bond, slave, i) | 286 | bond_for_each_slave(bond, slave, i) |
287 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | 287 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { |
288 | printk(KERN_ERR DRV_NAME | 288 | printk(KERN_ERR DRV_NAME |
289 | ": %s: Interface %s is already enslaved!\n", | 289 | ": %s: Interface %s is already enslaved!\n", |
290 | bond->dev->name, ifname); | 290 | bond->dev->name, ifname); |
291 | ret = -EPERM; | 291 | ret = -EPERM; |
292 | read_unlock_bh(&bond->lock); | 292 | read_unlock(&bond->lock); |
293 | goto out; | 293 | goto out; |
294 | } | 294 | } |
295 | 295 | ||
296 | read_unlock_bh(&bond->lock); | 296 | read_unlock(&bond->lock); |
297 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", | 297 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", |
298 | bond->dev->name, ifname); | 298 | bond->dev->name, ifname); |
299 | dev = dev_get_by_name(&init_net, ifname); | 299 | dev = dev_get_by_name(&init_net, ifname); |
@@ -662,12 +662,9 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
662 | "%s Disabling MII monitoring.\n", | 662 | "%s Disabling MII monitoring.\n", |
663 | bond->dev->name, bond->dev->name); | 663 | bond->dev->name, bond->dev->name); |
664 | bond->params.miimon = 0; | 664 | bond->params.miimon = 0; |
665 | /* Kill MII timer, else it brings bond's link down */ | 665 | if (delayed_work_pending(&bond->mii_work)) { |
666 | if (bond->arp_timer.function) { | 666 | cancel_delayed_work(&bond->mii_work); |
667 | printk(KERN_INFO DRV_NAME | 667 | flush_workqueue(bond->wq); |
668 | ": %s: Kill MII timer, else it brings bond's link down...\n", | ||
669 | bond->dev->name); | ||
670 | del_timer_sync(&bond->mii_timer); | ||
671 | } | 668 | } |
672 | } | 669 | } |
673 | if (!bond->params.arp_targets[0]) { | 670 | if (!bond->params.arp_targets[0]) { |
@@ -682,25 +679,15 @@ static ssize_t bonding_store_arp_interval(struct device *d, | |||
682 | * timer will get fired off when the open function | 679 | * timer will get fired off when the open function |
683 | * is called. | 680 | * is called. |
684 | */ | 681 | */ |
685 | if (bond->arp_timer.function) { | 682 | if (!delayed_work_pending(&bond->arp_work)) { |
686 | /* The timer's already set up, so fire it off */ | 683 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) |
687 | mod_timer(&bond->arp_timer, jiffies + 1); | 684 | INIT_DELAYED_WORK(&bond->arp_work, |
688 | } else { | 685 | bond_activebackup_arp_mon); |
689 | /* Set up the timer. */ | 686 | else |
690 | init_timer(&bond->arp_timer); | 687 | INIT_DELAYED_WORK(&bond->arp_work, |
691 | bond->arp_timer.expires = jiffies + 1; | 688 | bond_loadbalance_arp_mon); |
692 | bond->arp_timer.data = | 689 | |
693 | (unsigned long) bond->dev; | 690 | queue_delayed_work(bond->wq, &bond->arp_work, 0); |
694 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { | ||
695 | bond->arp_timer.function = | ||
696 | (void *) | ||
697 | &bond_activebackup_arp_mon; | ||
698 | } else { | ||
699 | bond->arp_timer.function = | ||
700 | (void *) | ||
701 | &bond_loadbalance_arp_mon; | ||
702 | } | ||
703 | add_timer(&bond->arp_timer); | ||
704 | } | 691 | } |
705 | } | 692 | } |
706 | 693 | ||
@@ -1056,12 +1043,9 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1056 | bond->params.arp_validate = | 1043 | bond->params.arp_validate = |
1057 | BOND_ARP_VALIDATE_NONE; | 1044 | BOND_ARP_VALIDATE_NONE; |
1058 | } | 1045 | } |
1059 | /* Kill ARP timer, else it brings bond's link down */ | 1046 | if (delayed_work_pending(&bond->arp_work)) { |
1060 | if (bond->mii_timer.function) { | 1047 | cancel_delayed_work(&bond->arp_work); |
1061 | printk(KERN_INFO DRV_NAME | 1048 | flush_workqueue(bond->wq); |
1062 | ": %s: Kill ARP timer, else it brings bond's link down...\n", | ||
1063 | bond->dev->name); | ||
1064 | del_timer_sync(&bond->arp_timer); | ||
1065 | } | 1049 | } |
1066 | } | 1050 | } |
1067 | 1051 | ||
@@ -1071,18 +1055,11 @@ static ssize_t bonding_store_miimon(struct device *d, | |||
1071 | * timer will get fired off when the open function | 1055 | * timer will get fired off when the open function |
1072 | * is called. | 1056 | * is called. |
1073 | */ | 1057 | */ |
1074 | if (bond->mii_timer.function) { | 1058 | if (!delayed_work_pending(&bond->mii_work)) { |
1075 | /* The timer's already set up, so fire it off */ | 1059 | INIT_DELAYED_WORK(&bond->mii_work, |
1076 | mod_timer(&bond->mii_timer, jiffies + 1); | 1060 | bond_mii_monitor); |
1077 | } else { | 1061 | queue_delayed_work(bond->wq, |
1078 | /* Set up the timer. */ | 1062 | &bond->mii_work, 0); |
1079 | init_timer(&bond->mii_timer); | ||
1080 | bond->mii_timer.expires = jiffies + 1; | ||
1081 | bond->mii_timer.data = | ||
1082 | (unsigned long) bond->dev; | ||
1083 | bond->mii_timer.function = | ||
1084 | (void *) &bond_mii_monitor; | ||
1085 | add_timer(&bond->mii_timer); | ||
1086 | } | 1063 | } |
1087 | } | 1064 | } |
1088 | } | 1065 | } |
@@ -1156,6 +1133,9 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1156 | } | 1133 | } |
1157 | out: | 1134 | out: |
1158 | write_unlock_bh(&bond->lock); | 1135 | write_unlock_bh(&bond->lock); |
1136 | |||
1137 | rtnl_unlock(); | ||
1138 | |||
1159 | return count; | 1139 | return count; |
1160 | } | 1140 | } |
1161 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); | 1141 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); |
@@ -1213,6 +1193,7 @@ static ssize_t bonding_show_active_slave(struct device *d, | |||
1213 | struct bonding *bond = to_bond(d); | 1193 | struct bonding *bond = to_bond(d); |
1214 | int count; | 1194 | int count; |
1215 | 1195 | ||
1196 | rtnl_lock(); | ||
1216 | 1197 | ||
1217 | read_lock(&bond->curr_slave_lock); | 1198 | read_lock(&bond->curr_slave_lock); |
1218 | curr = bond->curr_active_slave; | 1199 | curr = bond->curr_active_slave; |
@@ -1292,6 +1273,8 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1292 | } | 1273 | } |
1293 | out: | 1274 | out: |
1294 | write_unlock_bh(&bond->lock); | 1275 | write_unlock_bh(&bond->lock); |
1276 | rtnl_unlock(); | ||
1277 | |||
1295 | return count; | 1278 | return count; |
1296 | 1279 | ||
1297 | } | 1280 | } |