From: Stephen Hemminger <shemminger@vyatta.com>
To: Jay Vosburg <fubar@us.ibm.com>, "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, bonding-devel@lists.sourceforge.net
Subject: [PATCH 4/9] bonding: fix destructor
Date: Fri, 12 Jun 2009 22:02:47 -0700 [thread overview]
Message-ID: <20090613050421.816186819@vyatta.com> (raw)
In-Reply-To: 20090613050243.100086546@vyatta.com
[-- Attachment #1: bond-destruct.patch --]
[-- Type: text/plain, Size: 3271 bytes --]
It is not safe to use a network device destructor that is a function in
the module, since it can be called after module is unloaded if sysfs
handle is open.
When eventually using netlink, the device cleanup code needs to be donen
via uninit function.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/bonding/bond_sysfs.c 2009-06-12 12:02:45.186919049 -0700
+++ b/drivers/net/bonding/bond_sysfs.c 2009-06-12 21:44:52.148228948 -0700
@@ -127,7 +127,7 @@ static ssize_t bonding_store_bonds(struc
printk(KERN_INFO DRV_NAME
": %s is being deleted...\n",
bond->dev->name);
- bond_destroy(bond);
+ unregister_netdevice(bond->dev);
goto out_unlock;
}
--- a/drivers/net/bonding/bonding.h 2009-06-12 12:02:45.187973745 -0700
+++ b/drivers/net/bonding/bonding.h 2009-06-12 12:02:53.504241280 -0700
@@ -322,7 +322,6 @@ static inline void bond_unset_master_alb
struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
int bond_create(const char *name);
-void bond_destroy(struct bonding *bond);
int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev);
int bond_create_sysfs(void);
void bond_destroy_sysfs(void);
--- a/drivers/net/bonding/bond_main.c 2009-06-12 12:03:10.776948783 -0700
+++ b/drivers/net/bonding/bond_main.c 2009-06-12 21:45:37.932394640 -0700
@@ -1972,25 +1972,19 @@ int bond_release(struct net_device *bond
* Destroy a bonding device.
* Must be under rtnl_lock when this function is called.
*/
-void bond_destroy(struct bonding *bond)
-{
- bond_deinit(bond->dev);
- bond_destroy_sysfs_entry(bond);
- unregister_netdevice(bond->dev);
-}
-
-static void bond_destructor(struct net_device *bond_dev)
+static void bond_uninit(struct net_device *bond_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
+ bond_deinit(bond_dev);
+ bond_destroy_sysfs_entry(bond);
+
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);
}
/*
@@ -2006,7 +2000,7 @@ int bond_release_and_destroy(struct net
if ((ret == 0) && (bond->slave_cnt == 0)) {
printk(KERN_INFO DRV_NAME ": %s: destroying bond %s.\n",
bond_dev->name, bond_dev->name);
- bond_destroy(bond);
+ unregister_netdevice(bond_dev);
}
return ret;
}
@@ -4572,6 +4566,7 @@ static const struct ethtool_ops bond_eth
};
static const struct net_device_ops bond_netdev_ops = {
+ .ndo_uninit = bond_uninit,
.ndo_open = bond_open,
.ndo_stop = bond_close,
.ndo_start_xmit = bond_start_xmit,
@@ -4622,7 +4617,7 @@ static int bond_init(struct net_device *
bond_dev->ethtool_ops = &bond_ethtool_ops;
bond_set_mode_ops(bond, bond->params.mode);
- bond_dev->destructor = bond_destructor;
+ bond_dev->destructor = free_netdev;
/* Initialize the device options */
bond_dev->tx_queue_len = 0;
@@ -4706,7 +4701,7 @@ static void bond_free_all(void)
bond_work_cancel_all(bond);
/* Release the bonded slaves */
bond_release_all(bond_dev);
- bond_destroy(bond);
+ unregister_netdevice(bond_dev);
}
bond_destroy_proc_dir();
--
next prev parent reply other threads:[~2009-06-13 5:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-13 5:02 [PATCH 0/9] Bonding patches for 2.6.31 Stephen Hemminger
2009-06-13 5:02 ` [PATCH 1/9] bonding: bond_create always called with default parameters Stephen Hemminger
2009-06-13 5:02 ` [PATCH 2/9] bonding: initialize before registration Stephen Hemminger
2009-06-13 5:02 ` [PATCH 3/9] Subjec: bonding: remove bonding read/write semaphore Stephen Hemminger
2009-06-13 5:02 ` Stephen Hemminger [this message]
2009-06-13 5:02 ` [PATCH 5/9] bonding: fix style issues Stephen Hemminger
2009-06-13 5:02 ` [PATCH 6/9] bonding: elminate bad refcount code Stephen Hemminger
2009-06-13 5:02 ` [PATCH 7/9] bonding: network device names are case sensative Stephen Hemminger
2009-06-13 5:02 ` [PATCH 8/9] bonding: use is_zero_ether_addr Stephen Hemminger
2009-06-13 5:02 ` [PATCH 9/9] bonding: initialization rework Stephen Hemminger
2009-06-14 6:37 ` [PATCH 0/9] Bonding patches for 2.6.31 David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090613050421.816186819@vyatta.com \
--to=shemminger@vyatta.com \
--cc=bonding-devel@lists.sourceforge.net \
--cc=davem@davemloft.net \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).