Patchwork [RFC,4/6] netback: add module get/put operations along with vif connect/disconnect.

login
register
mail settings
Submitter Wei Liu
Date Jan. 13, 2012, 4:59 p.m.
Message ID <1326473949-22389-5-git-send-email-wei.liu2@citrix.com>
Download mbox | patch
Permalink /patch/135932/
State RFC
Delegated to: David Miller
Headers show

Comments

Wei Liu - Jan. 13, 2012, 4:59 p.m.
If there is vif running and user unloads netback, it will certainly
cause problems.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 drivers/net/xen-netback/interface.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
David Vrabel - Jan. 13, 2012, 6:44 p.m.
On 13/01/12 16:59, Wei Liu wrote:
> If there is vif running and user unloads netback, it will certainly
> cause problems.

Is this necessary?  As part of module unload netback_remove() will be
called and this will clean everything correctly, yes?

> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  drivers/net/xen-netback/interface.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
> index 93cb212..3126028 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -323,6 +323,8 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
>  	if (vif->irq)
>  		return 0;
>  
> +	__module_get(THIS_MODULE);
> +
>  	err = xen_netbk_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref);
>  	if (err < 0)
>  		goto err;
> @@ -405,4 +407,6 @@ void xenvif_disconnect(struct xenvif *vif)
>  	xen_netbk_unmap_frontend_rings(vif);
>  
>  	free_netdev(vif->dev);
> +
> +	module_put(THIS_MODULE);
>  }

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wei Liu - Jan. 16, 2012, 9:43 a.m.
On Fri, 2012-01-13 at 18:44 +0000, David Vrabel wrote:
> On 13/01/12 16:59, Wei Liu wrote:
> > If there is vif running and user unloads netback, it will certainly
> > cause problems.
> 
> Is this necessary?  As part of module unload netback_remove() will be
> called and this will clean everything correctly, yes?
> 

You're right here from the host's perspective of view. Everything gets
cleaned up.

But from the guest's perspective of view, its network interface just
mysteriously stops working.

So my "problems" in the above statements comes from guest, will make
commit message more clear.


Wei.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 93cb212..3126028 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -323,6 +323,8 @@  int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
 	if (vif->irq)
 		return 0;
 
+	__module_get(THIS_MODULE);
+
 	err = xen_netbk_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref);
 	if (err < 0)
 		goto err;
@@ -405,4 +407,6 @@  void xenvif_disconnect(struct xenvif *vif)
 	xen_netbk_unmap_frontend_rings(vif);
 
 	free_netdev(vif->dev);
+
+	module_put(THIS_MODULE);
 }