netdev
[Top] [All Lists]

Re: netdevice interface changes in 2.4.0test13pre4ac1

To: <netdev@xxxxxxxxxxx>
Subject: Re: netdevice interface changes in 2.4.0test13pre4ac1
From: Hans Grobler <grobh@xxxxxxxxx>
Date: Sun, 31 Dec 2000 15:28:18 +0200 (SAST)
In-reply-to: <3A4448DE.DEE4C43C@xxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
On Sat, 23 Dec 2000, Andrew Morton wrote:
>      unregister_netdev()
>
>           This function remains in place.  Should only be
>           called for an unhidden interface.  It closes the device,
>           removes the interface from the namespace, notifies protocols
>           of the disappearing interface and then calls /sbin/hotplug.

Comments in this function talk about "New style" devices with destructors.
The current implementation blocks until the device reference count reaches
1. The comment appears to imply that at some point in the future this
routine will not block if it detects a new style device. The cleanup will
then be done via the destructor.

However, where the destructor is called in netdev_finish_unregister, the
dev handle is again dereferenced after the destructor has been called.

Does this imply that the destructor cannot be used to deallocate the
device structure (i.e. dev->features & NETIF_F_DYNALLOC = 0)?

Or is the dev handle assume to still be valid?

Or would the patch below be desired?

Or could someone give an indication to what the destructor is allowed to
destroy...

Thanks,
-- Hans.


diff -u4Nr -X dontdiff linux-2.4.0test13pre7.orig/net/core/dev.c 
linux-2.4.0test13pre7/net/core/dev.c
--- linux-2.4.0test13pre7.orig/net/core/dev.c   Mon Dec 11 21:29:35 2000
+++ linux-2.4.0test13pre7/net/core/dev.c        Sun Dec 31 13:16:41 2000
@@ -2418,8 +2418,10 @@
  */

 int netdev_finish_unregister(struct net_device *dev)
 {
+       int features = dev->features;
+
        BUG_TRAP(dev->ip_ptr==NULL);
        BUG_TRAP(dev->ip6_ptr==NULL);
        BUG_TRAP(dev->dn_ptr==NULL);

@@ -2432,9 +2434,9 @@
               (dev->features & NETIF_F_DYNALLOC)?"":", old style");
 #endif
        if (dev->destructor)
                dev->destructor(dev);
-       if (dev->features & NETIF_F_DYNALLOC)
+       if (features & NETIF_F_DYNALLOC)
                kfree(dev);
        return 0;
 }






<Prev in Thread] Current Thread [Next in Thread>