ia64/xen-unstable

changeset 13136:e99ba0c6c046

[NET] front: Fix interface teardown.

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

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Dec 20 11:39:22 2006 +0000 (2006-12-20)
parents 301bcae16928
children f7a2cd8b0a8e
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Dec 20 11:21:04 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Dec 20 11:39:22 2006 +0000
     1.3 @@ -244,12 +244,8 @@ static inline grant_ref_t xennet_get_rx_
     1.4  static int setup_device(struct xenbus_device *, struct netfront_info *);
     1.5  static struct net_device *create_netdev(struct xenbus_device *);
     1.6  
     1.7 -static void netfront_closing(struct xenbus_device *);
     1.8 -
     1.9  static void end_access(int, void *);
    1.10  static void netif_disconnect_backend(struct netfront_info *);
    1.11 -static int open_netdev(struct netfront_info *);
    1.12 -static void close_netdev(struct netfront_info *);
    1.13  
    1.14  static int network_connect(struct net_device *);
    1.15  static void network_tx_buf_gc(struct net_device *);
    1.16 @@ -293,9 +289,20 @@ static int __devinit netfront_probe(stru
    1.17  	info = netdev_priv(netdev);
    1.18  	dev->dev.driver_data = info;
    1.19  
    1.20 -	err = open_netdev(info);
    1.21 -	if (err)
    1.22 +	err = register_netdev(info->netdev);
    1.23 +	if (err) {
    1.24 +		printk(KERN_WARNING "%s: register_netdev err=%d\n",
    1.25 +		       __FUNCTION__, err);
    1.26  		goto fail;
    1.27 +	}
    1.28 +
    1.29 +	err = xennet_sysfs_addif(info->netdev);
    1.30 +	if (err) {
    1.31 +		unregister_netdev(info->netdev);
    1.32 +		printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
    1.33 +		       __FUNCTION__, err);
    1.34 +		goto fail;
    1.35 +	}
    1.36  
    1.37  	return 0;
    1.38  
    1.39 @@ -305,6 +312,24 @@ static int __devinit netfront_probe(stru
    1.40  	return err;
    1.41  }
    1.42  
    1.43 +static int __devexit netfront_remove(struct xenbus_device *dev)
    1.44 +{
    1.45 +	struct netfront_info *info = dev->dev.driver_data;
    1.46 +
    1.47 +	DPRINTK("%s\n", dev->nodename);
    1.48 +
    1.49 +	netif_disconnect_backend(info);
    1.50 +
    1.51 +	del_timer_sync(&info->rx_refill_timer);
    1.52 +
    1.53 +	xennet_sysfs_delif(info->netdev);
    1.54 +
    1.55 +	unregister_netdev(info->netdev);
    1.56 +
    1.57 +	free_netdev(info->netdev);
    1.58 +
    1.59 +	return 0;
    1.60 +}
    1.61  
    1.62  /**
    1.63   * We are reconnecting to the backend, due to a suspend/resume, or a backend
    1.64 @@ -534,9 +559,7 @@ static void backend_changed(struct xenbu
    1.65  		break;
    1.66  
    1.67  	case XenbusStateClosing:
    1.68 -		if (dev->state == XenbusStateClosed)
    1.69 -			break;
    1.70 -		netfront_closing(dev);
    1.71 +		xenbus_frontend_closed(dev);
    1.72  		break;
    1.73  	}
    1.74  }
    1.75 @@ -1995,70 +2018,6 @@ inetdev_notify(struct notifier_block *th
    1.76  }
    1.77  
    1.78  
    1.79 -/* ** Close down ** */
    1.80 -
    1.81 -
    1.82 -/**
    1.83 - * Handle the change of state of the backend to Closing.  We must delete our
    1.84 - * device-layer structures now, to ensure that writes are flushed through to
    1.85 - * the backend.  Once is this done, we can switch to Closed in
    1.86 - * acknowledgement.
    1.87 - */
    1.88 -static void netfront_closing(struct xenbus_device *dev)
    1.89 -{
    1.90 -	struct netfront_info *info = dev->dev.driver_data;
    1.91 -
    1.92 -	DPRINTK("%s\n", dev->nodename);
    1.93 -
    1.94 -	close_netdev(info);
    1.95 -	xenbus_frontend_closed(dev);
    1.96 -}
    1.97 -
    1.98 -
    1.99 -static int __devexit netfront_remove(struct xenbus_device *dev)
   1.100 -{
   1.101 -	struct netfront_info *info = dev->dev.driver_data;
   1.102 -
   1.103 -	DPRINTK("%s\n", dev->nodename);
   1.104 -
   1.105 -	netif_disconnect_backend(info);
   1.106 -	free_netdev(info->netdev);
   1.107 -
   1.108 -	return 0;
   1.109 -}
   1.110 -
   1.111 -
   1.112 -static int open_netdev(struct netfront_info *info)
   1.113 -{
   1.114 -	int err;
   1.115 -	
   1.116 -	err = register_netdev(info->netdev);
   1.117 -	if (err) {
   1.118 -		printk(KERN_WARNING "%s: register_netdev err=%d\n",
   1.119 -		       __FUNCTION__, err);
   1.120 -		return err;
   1.121 -	}
   1.122 -
   1.123 -	err = xennet_sysfs_addif(info->netdev);
   1.124 -	if (err) {
   1.125 -		unregister_netdev(info->netdev);
   1.126 -		printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
   1.127 -		       __FUNCTION__, err);
   1.128 -		return err;
   1.129 -	}
   1.130 -
   1.131 -	return 0;
   1.132 -}
   1.133 -
   1.134 -static void close_netdev(struct netfront_info *info)
   1.135 -{
   1.136 -	del_timer_sync(&info->rx_refill_timer);
   1.137 -
   1.138 -	xennet_sysfs_delif(info->netdev);
   1.139 -	unregister_netdev(info->netdev);
   1.140 -}
   1.141 -
   1.142 -
   1.143  static void netif_disconnect_backend(struct netfront_info *info)
   1.144  {
   1.145  	/* Stop old i/f to prevent errors whilst we rebuild the state. */