diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 16:30:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 16:30:35 -0400 |
commit | 43d39ae0cf8f891c35e8316948229c7cbffa3994 (patch) | |
tree | c8af6999a9327c8b9bbc7384efe8f52f851ff3d8 /drivers/net/bonding/bond_sysfs.c | |
parent | 63bd8c48e04bbbc9cee3d752857914609d8d406f (diff) | |
parent | 84284d3c1d6372bc9ab496607661d230d9c45de4 (diff) |
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (35 commits)
xen-netfront: rearrange netfront structure to separate tx and rx
netdev: convert non-obvious instances to use ARRAY_SIZE()
ucc_geth: Fix build break introduced by commit 09f75cd7bf13720738e6a196cc0107ce9a5bd5a0
gianfar: Fix regression caused by new napi interface
gianfar: Cleanup compile warning caused by 0795af57
gianfar: Fix compile regression caused by bea3348e
add new prom.h for AU1x00
update AU1000 get_ethernet_addr()
MIPSsim: General cleanup
Jazzsonic: Fix warning about unused variable.
Remove msic_dcr_read() in axon_msi.c
Use dcr_host_t.base in dcr_unmap()
Add dcr_host_t.base in dcr_read()/dcr_write()
Use dcr_host_t.base in ibm_emac_mal
Update ibm_newemac to use dcr_host_t.base
tehuti: possible leak in bdx_probe
TC35815: Fix build
SAA9730: Fix build
AR7 ethernet
myri10ge: update driver version to 1.3.2-1.287
...
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 6f49ca7e9b66..80c0c8c415ed 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -164,9 +164,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
164 | printk(KERN_INFO DRV_NAME | 164 | printk(KERN_INFO DRV_NAME |
165 | ": %s is being deleted...\n", | 165 | ": %s is being deleted...\n", |
166 | bond->dev->name); | 166 | bond->dev->name); |
167 | bond_deinit(bond->dev); | 167 | bond_destroy(bond); |
168 | bond_destroy_sysfs_entry(bond); | ||
169 | unregister_netdevice(bond->dev); | ||
170 | rtnl_unlock(); | 168 | rtnl_unlock(); |
171 | goto out; | 169 | goto out; |
172 | } | 170 | } |
@@ -260,17 +258,16 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
260 | char command[IFNAMSIZ + 1] = { 0, }; | 258 | char command[IFNAMSIZ + 1] = { 0, }; |
261 | char *ifname; | 259 | char *ifname; |
262 | int i, res, found, ret = count; | 260 | int i, res, found, ret = count; |
261 | u32 original_mtu; | ||
263 | struct slave *slave; | 262 | struct slave *slave; |
264 | struct net_device *dev = NULL; | 263 | struct net_device *dev = NULL; |
265 | struct bonding *bond = to_bond(d); | 264 | struct bonding *bond = to_bond(d); |
266 | 265 | ||
267 | /* Quick sanity check -- is the bond interface up? */ | 266 | /* Quick sanity check -- is the bond interface up? */ |
268 | if (!(bond->dev->flags & IFF_UP)) { | 267 | if (!(bond->dev->flags & IFF_UP)) { |
269 | printk(KERN_ERR DRV_NAME | 268 | printk(KERN_WARNING DRV_NAME |
270 | ": %s: Unable to update slaves because interface is down.\n", | 269 | ": %s: doing slave updates when interface is down.\n", |
271 | bond->dev->name); | 270 | bond->dev->name); |
272 | ret = -EPERM; | ||
273 | goto out; | ||
274 | } | 271 | } |
275 | 272 | ||
276 | /* Note: We can't hold bond->lock here, as bond_create grabs it. */ | 273 | /* Note: We can't hold bond->lock here, as bond_create grabs it. */ |
@@ -327,6 +324,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
327 | } | 324 | } |
328 | 325 | ||
329 | /* Set the slave's MTU to match the bond */ | 326 | /* Set the slave's MTU to match the bond */ |
327 | original_mtu = dev->mtu; | ||
330 | if (dev->mtu != bond->dev->mtu) { | 328 | if (dev->mtu != bond->dev->mtu) { |
331 | if (dev->change_mtu) { | 329 | if (dev->change_mtu) { |
332 | res = dev->change_mtu(dev, | 330 | res = dev->change_mtu(dev, |
@@ -341,6 +339,9 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
341 | } | 339 | } |
342 | rtnl_lock(); | 340 | rtnl_lock(); |
343 | res = bond_enslave(bond->dev, dev); | 341 | res = bond_enslave(bond->dev, dev); |
342 | bond_for_each_slave(bond, slave, i) | ||
343 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) | ||
344 | slave->original_mtu = original_mtu; | ||
344 | rtnl_unlock(); | 345 | rtnl_unlock(); |
345 | if (res) { | 346 | if (res) { |
346 | ret = res; | 347 | ret = res; |
@@ -353,13 +354,17 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
353 | bond_for_each_slave(bond, slave, i) | 354 | bond_for_each_slave(bond, slave, i) |
354 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | 355 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { |
355 | dev = slave->dev; | 356 | dev = slave->dev; |
357 | original_mtu = slave->original_mtu; | ||
356 | break; | 358 | break; |
357 | } | 359 | } |
358 | if (dev) { | 360 | if (dev) { |
359 | printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", | 361 | printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", |
360 | bond->dev->name, dev->name); | 362 | bond->dev->name, dev->name); |
361 | rtnl_lock(); | 363 | rtnl_lock(); |
362 | res = bond_release(bond->dev, dev); | 364 | if (bond->setup_by_slave) |
365 | res = bond_release_and_destroy(bond->dev, dev); | ||
366 | else | ||
367 | res = bond_release(bond->dev, dev); | ||
363 | rtnl_unlock(); | 368 | rtnl_unlock(); |
364 | if (res) { | 369 | if (res) { |
365 | ret = res; | 370 | ret = res; |
@@ -367,9 +372,9 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
367 | } | 372 | } |
368 | /* set the slave MTU to the default */ | 373 | /* set the slave MTU to the default */ |
369 | if (dev->change_mtu) { | 374 | if (dev->change_mtu) { |
370 | dev->change_mtu(dev, 1500); | 375 | dev->change_mtu(dev, original_mtu); |
371 | } else { | 376 | } else { |
372 | dev->mtu = 1500; | 377 | dev->mtu = original_mtu; |
373 | } | 378 | } |
374 | } | 379 | } |
375 | else { | 380 | else { |
@@ -563,6 +568,54 @@ static ssize_t bonding_store_arp_validate(struct device *d, | |||
563 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); | 568 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); |
564 | 569 | ||
565 | /* | 570 | /* |
571 | * Show and store fail_over_mac. User only allowed to change the | ||
572 | * value when there are no slaves. | ||
573 | */ | ||
574 | static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attribute *attr, char *buf) | ||
575 | { | ||
576 | struct bonding *bond = to_bond(d); | ||
577 | |||
578 | return sprintf(buf, "%d\n", bond->params.fail_over_mac) + 1; | ||
579 | } | ||
580 | |||
581 | static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attribute *attr, const char *buf, size_t count) | ||
582 | { | ||
583 | int new_value; | ||
584 | int ret = count; | ||
585 | struct bonding *bond = to_bond(d); | ||
586 | |||
587 | if (bond->slave_cnt != 0) { | ||
588 | printk(KERN_ERR DRV_NAME | ||
589 | ": %s: Can't alter fail_over_mac with slaves in bond.\n", | ||
590 | bond->dev->name); | ||
591 | ret = -EPERM; | ||
592 | goto out; | ||
593 | } | ||
594 | |||
595 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
596 | printk(KERN_ERR DRV_NAME | ||
597 | ": %s: no fail_over_mac value specified.\n", | ||
598 | bond->dev->name); | ||
599 | ret = -EINVAL; | ||
600 | goto out; | ||
601 | } | ||
602 | |||
603 | if ((new_value == 0) || (new_value == 1)) { | ||
604 | bond->params.fail_over_mac = new_value; | ||
605 | printk(KERN_INFO DRV_NAME ": %s: Setting fail_over_mac to %d.\n", | ||
606 | bond->dev->name, new_value); | ||
607 | } else { | ||
608 | printk(KERN_INFO DRV_NAME | ||
609 | ": %s: Ignoring invalid fail_over_mac value %d.\n", | ||
610 | bond->dev->name, new_value); | ||
611 | } | ||
612 | out: | ||
613 | return ret; | ||
614 | } | ||
615 | |||
616 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, bonding_show_fail_over_mac, bonding_store_fail_over_mac); | ||
617 | |||
618 | /* | ||
566 | * Show and set the arp timer interval. There are two tricky bits | 619 | * Show and set the arp timer interval. There are two tricky bits |
567 | * here. First, if ARP monitoring is activated, then we must disable | 620 | * here. First, if ARP monitoring is activated, then we must disable |
568 | * MII monitoring. Second, if the ARP timer isn't running, we must | 621 | * MII monitoring. Second, if the ARP timer isn't running, we must |
@@ -1383,6 +1436,7 @@ static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); | |||
1383 | static struct attribute *per_bond_attrs[] = { | 1436 | static struct attribute *per_bond_attrs[] = { |
1384 | &dev_attr_slaves.attr, | 1437 | &dev_attr_slaves.attr, |
1385 | &dev_attr_mode.attr, | 1438 | &dev_attr_mode.attr, |
1439 | &dev_attr_fail_over_mac.attr, | ||
1386 | &dev_attr_arp_validate.attr, | 1440 | &dev_attr_arp_validate.attr, |
1387 | &dev_attr_arp_interval.attr, | 1441 | &dev_attr_arp_interval.attr, |
1388 | &dev_attr_arp_ip_target.attr, | 1442 | &dev_attr_arp_ip_target.attr, |