Commit 7d941b75 authored by David S. Miller's avatar David S. Miller

[IPV6]: Apply ipv4 tunnel module fixes to SIT driver.

parent c18e4c72
...@@ -170,13 +170,10 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int ...@@ -170,13 +170,10 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
if (!create) if (!create)
return NULL; return NULL;
if (!try_module_get(THIS_MODULE))
return NULL;
dev = kmalloc(sizeof(*dev) + sizeof(*t), GFP_KERNEL); dev = kmalloc(sizeof(*dev) + sizeof(*t), GFP_KERNEL);
if (dev == NULL) { if (dev == NULL)
module_put(THIS_MODULE);
return NULL; return NULL;
}
memset(dev, 0, sizeof(*dev) + sizeof(*t)); memset(dev, 0, sizeof(*dev) + sizeof(*t));
dev->priv = (void*)(dev+1); dev->priv = (void*)(dev+1);
nt = (struct ip_tunnel*)dev->priv; nt = (struct ip_tunnel*)dev->priv;
...@@ -196,6 +193,7 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int ...@@ -196,6 +193,7 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
goto failed; goto failed;
memcpy(nt->parms.name, dev->name, IFNAMSIZ); memcpy(nt->parms.name, dev->name, IFNAMSIZ);
} }
SET_MODULE_OWNER(dev);
if (register_netdevice(dev) < 0) if (register_netdevice(dev) < 0)
goto failed; goto failed;
...@@ -206,16 +204,13 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int ...@@ -206,16 +204,13 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
failed: failed:
kfree(dev); kfree(dev);
module_put(THIS_MODULE);
return NULL; return NULL;
} }
static void ipip6_tunnel_destructor(struct net_device *dev) static void ipip6_tunnel_destructor(struct net_device *dev)
{ {
if (dev != &ipip6_fb_tunnel_dev) { if (dev != &ipip6_fb_tunnel_dev)
kfree(dev); kfree(dev);
module_put(THIS_MODULE);
}
} }
static void ipip6_tunnel_uninit(struct net_device *dev) static void ipip6_tunnel_uninit(struct net_device *dev)
...@@ -623,9 +618,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -623,9 +618,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
struct ip_tunnel_parm p; struct ip_tunnel_parm p;
struct ip_tunnel *t; struct ip_tunnel *t;
if (!try_module_get(THIS_MODULE))
return -EBUSY;
switch (cmd) { switch (cmd) {
case SIOCGETTUNNEL: case SIOCGETTUNNEL:
t = NULL; t = NULL;
...@@ -723,7 +715,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -723,7 +715,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
} }
done: done:
module_put(THIS_MODULE);
return err; return err;
} }
...@@ -800,30 +791,11 @@ static int ipip6_tunnel_init(struct net_device *dev) ...@@ -800,30 +791,11 @@ static int ipip6_tunnel_init(struct net_device *dev)
return 0; return 0;
} }
#ifdef MODULE
static int ipip6_fb_tunnel_open(struct net_device *dev)
{
if (!try_module_get(THIS_MODULE))
return -EBUSY;
return 0;
}
static int ipip6_fb_tunnel_close(struct net_device *dev)
{
module_put(THIS_MODULE);
return 0;
}
#endif
int __init ipip6_fb_tunnel_init(struct net_device *dev) int __init ipip6_fb_tunnel_init(struct net_device *dev)
{ {
struct iphdr *iph; struct iphdr *iph;
ipip6_tunnel_init_gen(dev); ipip6_tunnel_init_gen(dev);
#ifdef MODULE
dev->open = ipip6_fb_tunnel_open;
dev->stop = ipip6_fb_tunnel_close;
#endif
iph = &ipip6_fb_tunnel.parms.iph; iph = &ipip6_fb_tunnel.parms.iph;
iph->version = 4; iph->version = 4;
...@@ -860,6 +832,7 @@ int __init sit_init(void) ...@@ -860,6 +832,7 @@ int __init sit_init(void)
ipip6_fb_tunnel_dev.priv = (void*)&ipip6_fb_tunnel; ipip6_fb_tunnel_dev.priv = (void*)&ipip6_fb_tunnel;
strcpy(ipip6_fb_tunnel_dev.name, ipip6_fb_tunnel.parms.name); strcpy(ipip6_fb_tunnel_dev.name, ipip6_fb_tunnel.parms.name);
SET_MODULE_OWNER(&ipip6_fb_tunnel_dev);
register_netdev(&ipip6_fb_tunnel_dev); register_netdev(&ipip6_fb_tunnel_dev);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment