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
if (!create)
return NULL;
if (!try_module_get(THIS_MODULE))
return NULL;
dev = kmalloc(sizeof(*dev) + sizeof(*t), GFP_KERNEL);
if (dev == NULL) {
module_put(THIS_MODULE);
if (dev == NULL)
return NULL;
}
memset(dev, 0, sizeof(*dev) + sizeof(*t));
dev->priv = (void*)(dev+1);
nt = (struct ip_tunnel*)dev->priv;
......@@ -196,6 +193,7 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
goto failed;
memcpy(nt->parms.name, dev->name, IFNAMSIZ);
}
SET_MODULE_OWNER(dev);
if (register_netdevice(dev) < 0)
goto failed;
......@@ -206,16 +204,13 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
failed:
kfree(dev);
module_put(THIS_MODULE);
return NULL;
}
static void ipip6_tunnel_destructor(struct net_device *dev)
{
if (dev != &ipip6_fb_tunnel_dev) {
if (dev != &ipip6_fb_tunnel_dev)
kfree(dev);
module_put(THIS_MODULE);
}
}
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)
struct ip_tunnel_parm p;
struct ip_tunnel *t;
if (!try_module_get(THIS_MODULE))
return -EBUSY;
switch (cmd) {
case SIOCGETTUNNEL:
t = NULL;
......@@ -723,7 +715,6 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
}
done:
module_put(THIS_MODULE);
return err;
}
......@@ -800,30 +791,11 @@ static int ipip6_tunnel_init(struct net_device *dev)
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)
{
struct iphdr *iph;
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->version = 4;
......@@ -860,6 +832,7 @@ int __init sit_init(void)
ipip6_fb_tunnel_dev.priv = (void*)&ipip6_fb_tunnel;
strcpy(ipip6_fb_tunnel_dev.name, ipip6_fb_tunnel.parms.name);
SET_MODULE_OWNER(&ipip6_fb_tunnel_dev);
register_netdev(&ipip6_fb_tunnel_dev);
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