* [PATCH 2.6.28 0/3] bonding: two fixes and one small regression
@ 2008-10-31 0:41 Jay Vosburgh
2008-10-31 0:41 ` [PATCH 1/3] bonding: fix miimon failure counter Jay Vosburgh
0 siblings, 1 reply; 5+ messages in thread
From: Jay Vosburgh @ 2008-10-31 0:41 UTC (permalink / raw)
To: netdev; +Cc: Jeff Garzik
Three patches for bonding; these apply to net-2.6.
Patch 1 replaces an increment of the link failure count that was
left out during the mii monitor refactor a few months ago.
Patch 2 reworks the resource free logic to fix leaks of workqueues
and multicast lists.
Patch 3 fixes a panic in alb/tlb mode when removing a bond under
various circumstances (when the bond is down, for example).
Please apply for 2.6.28.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] bonding: fix miimon failure counter
2008-10-31 0:41 [PATCH 2.6.28 0/3] bonding: two fixes and one small regression Jay Vosburgh
@ 2008-10-31 0:41 ` Jay Vosburgh
2008-10-31 0:41 ` [PATCH 2/3] bonding: Clean up resource leaks Jay Vosburgh
2008-10-31 4:49 ` [PATCH 1/3] bonding: fix miimon failure counter Jeff Garzik
0 siblings, 2 replies; 5+ messages in thread
From: Jay Vosburgh @ 2008-10-31 0:41 UTC (permalink / raw)
To: netdev; +Cc: Jeff Garzik
During the rework of the mii monitor for:
commit f0c76d61779b153dbfb955db3f144c62d02173c2
Author: Jay Vosburgh <fubar@us.ibm.com>
Date: Wed Jul 2 18:21:58 2008 -0700
bonding: refactor mii monitor
I left out the increment of the link failure counter. This
patch corrects that omission.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
---
drivers/net/bonding/bond_main.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 832739f..85de1d0 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2376,6 +2376,9 @@ static void bond_miimon_commit(struct bonding *bond)
continue;
case BOND_LINK_DOWN:
+ if (slave->link_failure_count < UINT_MAX)
+ slave->link_failure_count++;
+
slave->link = BOND_LINK_DOWN;
if (bond->params.mode == BOND_MODE_ACTIVEBACKUP ||
--
1.6.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] bonding: Clean up resource leaks
2008-10-31 0:41 ` [PATCH 1/3] bonding: fix miimon failure counter Jay Vosburgh
@ 2008-10-31 0:41 ` Jay Vosburgh
2008-10-31 0:41 ` [PATCH 3/3] bonding: fix panic when taking bond interface down before removing module Jay Vosburgh
2008-10-31 4:49 ` [PATCH 1/3] bonding: fix miimon failure counter Jeff Garzik
1 sibling, 1 reply; 5+ messages in thread
From: Jay Vosburgh @ 2008-10-31 0:41 UTC (permalink / raw)
To: netdev; +Cc: Jeff Garzik
This patch reworks the resource free logic performed at the time
a bonding device is released. This (a) closes two resource leaks, one
for workqueues and one for multicast lists, and (b) improves commonality
of code between the "destroy one" and "destroy all" paths by performing
final free activity via destructor instead of explicitly (and differently)
in each path.
"Sean E. Millichamp" <sean@bruenor.org> reported the workqueue
leak, and included a different patch.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
---
drivers/net/bonding/bond_main.c | 49 ++++++++++++++++++++++++--------------
1 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 85de1d0..a3efba5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1979,6 +1979,20 @@ void bond_destroy(struct bonding *bond)
unregister_netdevice(bond->dev);
}
+static void bond_destructor(struct net_device *bond_dev)
+{
+ struct bonding *bond = bond_dev->priv;
+
+ if (bond->wq)
+ destroy_workqueue(bond->wq);
+
+ netif_addr_lock_bh(bond_dev);
+ bond_mc_list_destroy(bond);
+ netif_addr_unlock_bh(bond_dev);
+
+ free_netdev(bond_dev);
+}
+
/*
* First release a slave and than destroy the bond if no more slaves iare left.
* Must be under rtnl_lock when this function is called.
@@ -4553,7 +4567,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
bond_set_mode_ops(bond, bond->params.mode);
- bond_dev->destructor = free_netdev;
+ bond_dev->destructor = bond_destructor;
/* Initialize the device options */
bond_dev->tx_queue_len = 0;
@@ -4592,20 +4606,6 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
return 0;
}
-/* De-initialize device specific data.
- * Caller must hold rtnl_lock.
- */
-static void bond_deinit(struct net_device *bond_dev)
-{
- struct bonding *bond = bond_dev->priv;
-
- list_del(&bond->bond_list);
-
-#ifdef CONFIG_PROC_FS
- bond_remove_proc_entry(bond);
-#endif
-}
-
static void bond_work_cancel_all(struct bonding *bond)
{
write_lock_bh(&bond->lock);
@@ -4627,6 +4627,22 @@ static void bond_work_cancel_all(struct bonding *bond)
cancel_delayed_work(&bond->ad_work);
}
+/* De-initialize device specific data.
+ * Caller must hold rtnl_lock.
+ */
+static void bond_deinit(struct net_device *bond_dev)
+{
+ struct bonding *bond = bond_dev->priv;
+
+ list_del(&bond->bond_list);
+
+ bond_work_cancel_all(bond);
+
+#ifdef CONFIG_PROC_FS
+ bond_remove_proc_entry(bond);
+#endif
+}
+
/* Unregister and free all bond devices.
* Caller must hold rtnl_lock.
*/
@@ -4638,9 +4654,6 @@ static void bond_free_all(void)
struct net_device *bond_dev = bond->dev;
bond_work_cancel_all(bond);
- netif_addr_lock_bh(bond_dev);
- bond_mc_list_destroy(bond);
- netif_addr_unlock_bh(bond_dev);
/* Release the bonded slaves */
bond_release_all(bond_dev);
bond_destroy(bond);
--
1.6.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] bonding: fix panic when taking bond interface down before removing module
2008-10-31 0:41 ` [PATCH 2/3] bonding: Clean up resource leaks Jay Vosburgh
@ 2008-10-31 0:41 ` Jay Vosburgh
0 siblings, 0 replies; 5+ messages in thread
From: Jay Vosburgh @ 2008-10-31 0:41 UTC (permalink / raw)
To: netdev; +Cc: Jeff Garzik, Andy Gospodarek
From: Andy Gospodarek <andy@greyhouse.net>
A panic was discovered with bonding when using mode 5 or 6 and trying to
remove the slaves from the bond after the interface was taken down.
When calling 'ifconfig bond0 down' the following happens:
bond_close()
bond_alb_deinitialize()
tlb_deinitialize()
kfree(bond_info->tx_hashtbl)
bond_info->tx_hashtbl = NULL
Unfortunately if there are still slaves in the bond, when removing the
module the following happens:
bonding_exit()
bond_free_all()
bond_release_all()
bond_alb_deinit_slave()
tlb_clear_slave()
tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl
u32 next_index = tx_hash_table[index].next
As you might guess we panic when trying to access a few entries into the
table that no longer exists.
I experimented with several options (like moving the calls to
tlb_deinitialize somewhere else), but it really makes the most sense to
be part of the bond_close routine. It also didn't seem logical move
tlb_clear_slave around too much, so the simplest option seems to add a
check in tlb_clear_slave to make sure we haven't already wiped the
tx_hashtbl away before searching for all the non-existent hash-table
entries that used to point to the slave as the output interface.
Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
---
drivers/net/bonding/bond_alb.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index ade5f3f..87437c7 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -169,11 +169,14 @@ static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_
/* clear slave from tx_hashtbl */
tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
- index = SLAVE_TLB_INFO(slave).head;
- while (index != TLB_NULL_INDEX) {
- u32 next_index = tx_hash_table[index].next;
- tlb_init_table_entry(&tx_hash_table[index], save_load);
- index = next_index;
+ /* skip this if we've already freed the tx hash table */
+ if (tx_hash_table) {
+ index = SLAVE_TLB_INFO(slave).head;
+ while (index != TLB_NULL_INDEX) {
+ u32 next_index = tx_hash_table[index].next;
+ tlb_init_table_entry(&tx_hash_table[index], save_load);
+ index = next_index;
+ }
}
tlb_init_slave(slave);
--
1.6.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] bonding: fix miimon failure counter
2008-10-31 0:41 ` [PATCH 1/3] bonding: fix miimon failure counter Jay Vosburgh
2008-10-31 0:41 ` [PATCH 2/3] bonding: Clean up resource leaks Jay Vosburgh
@ 2008-10-31 4:49 ` Jeff Garzik
1 sibling, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2008-10-31 4:49 UTC (permalink / raw)
To: Jay Vosburgh; +Cc: netdev, David Miller
Jay Vosburgh wrote:
> During the rework of the mii monitor for:
>
> commit f0c76d61779b153dbfb955db3f144c62d02173c2
> Author: Jay Vosburgh <fubar@us.ibm.com>
> Date: Wed Jul 2 18:21:58 2008 -0700
>
> bonding: refactor mii monitor
>
> I left out the increment of the link failure counter. This
> patch corrects that omission.
>
> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
> ---
> drivers/net/bonding/bond_main.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 832739f..85de1d0 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2376,6 +2376,9 @@ static void bond_miimon_commit(struct bonding *bond)
> continue;
>
> case BOND_LINK_DOWN:
> + if (slave->link_failure_count < UINT_MAX)
> + slave->link_failure_count++;
> +
> slave->link = BOND_LINK_DOWN;
applied 1-3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-10-31 4:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-31 0:41 [PATCH 2.6.28 0/3] bonding: two fixes and one small regression Jay Vosburgh
2008-10-31 0:41 ` [PATCH 1/3] bonding: fix miimon failure counter Jay Vosburgh
2008-10-31 0:41 ` [PATCH 2/3] bonding: Clean up resource leaks Jay Vosburgh
2008-10-31 0:41 ` [PATCH 3/3] bonding: fix panic when taking bond interface down before removing module Jay Vosburgh
2008-10-31 4:49 ` [PATCH 1/3] bonding: fix miimon failure counter Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).