[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [NET] front: Fix interface teardown.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1166614762 0
# Node ID e99ba0c6c0461159a40f27c9891e13098e791dca
# Parent  301bcae1692814d4261560cb053278ee51bfb1c0
[NET] front: Fix interface teardown.

Original bug discovered and fixed by Glauber de Oliveira Costa
<gcosta@xxxxxxxxxx>.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c |  105 +++++--------------
 1 files changed, 32 insertions(+), 73 deletions(-)

diff -r 301bcae16928 -r e99ba0c6c046 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Wed Dec 20 
11:21:04 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Wed Dec 20 
11:39:22 2006 +0000
@@ -244,12 +244,8 @@ static int setup_device(struct xenbus_de
 static int setup_device(struct xenbus_device *, struct netfront_info *);
 static struct net_device *create_netdev(struct xenbus_device *);
 
-static void netfront_closing(struct xenbus_device *);
-
 static void end_access(int, void *);
 static void netif_disconnect_backend(struct netfront_info *);
-static int open_netdev(struct netfront_info *);
-static void close_netdev(struct netfront_info *);
 
 static int network_connect(struct net_device *);
 static void network_tx_buf_gc(struct net_device *);
@@ -293,9 +289,20 @@ static int __devinit netfront_probe(stru
        info = netdev_priv(netdev);
        dev->dev.driver_data = info;
 
-       err = open_netdev(info);
-       if (err)
+       err = register_netdev(info->netdev);
+       if (err) {
+               printk(KERN_WARNING "%s: register_netdev err=%d\n",
+                      __FUNCTION__, err);
                goto fail;
+       }
+
+       err = xennet_sysfs_addif(info->netdev);
+       if (err) {
+               unregister_netdev(info->netdev);
+               printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
+                      __FUNCTION__, err);
+               goto fail;
+       }
 
        return 0;
 
@@ -305,6 +312,24 @@ static int __devinit netfront_probe(stru
        return err;
 }
 
+static int __devexit netfront_remove(struct xenbus_device *dev)
+{
+       struct netfront_info *info = dev->dev.driver_data;
+
+       DPRINTK("%s\n", dev->nodename);
+
+       netif_disconnect_backend(info);
+
+       del_timer_sync(&info->rx_refill_timer);
+
+       xennet_sysfs_delif(info->netdev);
+
+       unregister_netdev(info->netdev);
+
+       free_netdev(info->netdev);
+
+       return 0;
+}
 
 /**
  * We are reconnecting to the backend, due to a suspend/resume, or a backend
@@ -534,9 +559,7 @@ static void backend_changed(struct xenbu
                break;
 
        case XenbusStateClosing:
-               if (dev->state == XenbusStateClosed)
-                       break;
-               netfront_closing(dev);
+               xenbus_frontend_closed(dev);
                break;
        }
 }
@@ -1995,70 +2018,6 @@ inetdev_notify(struct notifier_block *th
 }
 
 
-/* ** Close down ** */
-
-
-/**
- * Handle the change of state of the backend to Closing.  We must delete our
- * device-layer structures now, to ensure that writes are flushed through to
- * the backend.  Once is this done, we can switch to Closed in
- * acknowledgement.
- */
-static void netfront_closing(struct xenbus_device *dev)
-{
-       struct netfront_info *info = dev->dev.driver_data;
-
-       DPRINTK("%s\n", dev->nodename);
-
-       close_netdev(info);
-       xenbus_frontend_closed(dev);
-}
-
-
-static int __devexit netfront_remove(struct xenbus_device *dev)
-{
-       struct netfront_info *info = dev->dev.driver_data;
-
-       DPRINTK("%s\n", dev->nodename);
-
-       netif_disconnect_backend(info);
-       free_netdev(info->netdev);
-
-       return 0;
-}
-
-
-static int open_netdev(struct netfront_info *info)
-{
-       int err;
-       
-       err = register_netdev(info->netdev);
-       if (err) {
-               printk(KERN_WARNING "%s: register_netdev err=%d\n",
-                      __FUNCTION__, err);
-               return err;
-       }
-
-       err = xennet_sysfs_addif(info->netdev);
-       if (err) {
-               unregister_netdev(info->netdev);
-               printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
-                      __FUNCTION__, err);
-               return err;
-       }
-
-       return 0;
-}
-
-static void close_netdev(struct netfront_info *info)
-{
-       del_timer_sync(&info->rx_refill_timer);
-
-       xennet_sysfs_delif(info->netdev);
-       unregister_netdev(info->netdev);
-}
-
-
 static void netif_disconnect_backend(struct netfront_info *info)
 {
        /* Stop old i/f to prevent errors whilst we rebuild the state. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.