aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-07-11 19:42:13 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-11 19:45:33 -0700
commit2d85cba2b272a5201a60966a65a4f8c0bcc0bb71 (patch)
treef8dd1ca6d7c963eade714a4ecc7aec4d7751f55a /net
parent[VLAN]: Fix MAC address handling (diff)
downloadlinux-dev-2d85cba2b272a5201a60966a65a4f8c0bcc0bb71.tar.xz
linux-dev-2d85cba2b272a5201a60966a65a4f8c0bcc0bb71.zip
[RTNETLINK]: rtnl_link API simplification
All drivers need to unregister their devices in the module unload function. While doing so they must hold the rtnl and atomically unregister the rtnl_link ops as well. This makes the rtnl_link_unregister function that takes the rtnl itself completely useless. Provide default newlink/dellink functions, make __rtnl_link_unregister and rtnl_link_unregister unregister all devices with matching rtnl_link_ops and change the existing users to take advantage of that. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--net/8021q/vlan.c21
-rw-r--r--net/core/rtnetlink.c18
2 files changed, 14 insertions, 25 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index b463ba47024d..34c1d0b241ca 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -115,26 +115,6 @@ err1:
return err;
}
-/* Cleanup all vlan devices
- * Note: devices that have been registered that but not
- * brought up will exist but have no module ref count.
- */
-static void __exit vlan_cleanup_devices(void)
-{
- struct net_device *dev, *nxt;
-
- rtnl_lock();
- for_each_netdev_safe(dev, nxt) {
- if (dev->priv_flags & IFF_802_1Q_VLAN) {
- unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
- VLAN_DEV_INFO(dev)->vlan_id);
-
- unregister_netdevice(dev);
- }
- }
- rtnl_unlock();
-}
-
/*
* Module 'remove' entry point.
* o delete /proc/net/router directory and static entries.
@@ -150,7 +130,6 @@ static void __exit vlan_cleanup_module(void)
unregister_netdevice_notifier(&vlan_notifier_block);
dev_remove_pack(&vlan_packet_type);
- vlan_cleanup_devices();
/* This table must be empty if there are no module
* references left.
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 54c17e4cd28f..7b6b16396745 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -270,6 +270,9 @@ static LIST_HEAD(link_ops);
*/
int __rtnl_link_register(struct rtnl_link_ops *ops)
{
+ if (!ops->dellink)
+ ops->dellink = unregister_netdevice;
+
list_add_tail(&ops->list, &link_ops);
return 0;
}
@@ -298,12 +301,16 @@ EXPORT_SYMBOL_GPL(rtnl_link_register);
* __rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.
* @ops: struct rtnl_link_ops * to unregister
*
- * The caller must hold the rtnl_mutex. This function should be used
- * by drivers that unregister devices during module unloading. It must
- * be called after unregistering the devices.
+ * The caller must hold the rtnl_mutex.
*/
void __rtnl_link_unregister(struct rtnl_link_ops *ops)
{
+ struct net_device *dev, *n;
+
+ for_each_netdev_safe(dev, n) {
+ if (dev->rtnl_link_ops == ops)
+ ops->dellink(dev);
+ }
list_del(&ops->list);
}
@@ -1067,7 +1074,10 @@ replay:
if (tb[IFLA_LINKMODE])
dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
- err = ops->newlink(dev, tb, data);
+ if (ops->newlink)
+ err = ops->newlink(dev, tb, data);
+ else
+ err = register_netdevice(dev);
err_free:
if (err < 0)
free_netdev(dev);