Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90755
b: refs/heads/master
c: 10dc4c7
h: refs/heads/master
i:
  90753: ad780f2
  90751: c54b5a1
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Apr 16, 2008
1 parent 1127666 commit 2c7c4bf
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 30688a9a3e06d83d187658bd1c15f0e306bed38b
refs/heads/master: 10dc4c7bb70533d16184aaaa69e137a7d2b9a3a8
50 changes: 50 additions & 0 deletions trunk/net/ipv4/ipip.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@
#include <net/ipip.h>
#include <net/inet_ecn.h>
#include <net/xfrm.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>

#define HASH_SIZE 16
#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)

static int ipip_net_id;
struct ipip_net {
};

static int ipip_fb_tunnel_init(struct net_device *dev);
static int ipip_tunnel_init(struct net_device *dev);
static void ipip_tunnel_setup(struct net_device *dev);
Expand Down Expand Up @@ -867,6 +873,41 @@ static struct xfrm_tunnel ipip_handler = {
static char banner[] __initdata =
KERN_INFO "IPv4 over IPv4 tunneling driver\n";

static int ipip_init_net(struct net *net)
{
int err;
struct ipip_net *ipn;

err = -ENOMEM;
ipn = kmalloc(sizeof(struct ipip_net), GFP_KERNEL);
if (ipn == NULL)
goto err_alloc;

err = net_assign_generic(net, ipip_net_id, ipn);
if (err < 0)
goto err_assign;

return 0;

err_assign:
kfree(ipn);
err_alloc:
return err;
}

static void ipip_exit_net(struct net *net)
{
struct ipip_net *ipn;

ipn = net_generic(net, ipip_net_id);
kfree(ipn);
}

static struct pernet_operations ipip_net_ops = {
.init = ipip_init_net,
.exit = ipip_exit_net,
};

static int __init ipip_init(void)
{
int err;
Expand All @@ -890,13 +931,20 @@ static int __init ipip_init(void)

if ((err = register_netdev(ipip_fb_tunnel_dev)))
goto err2;

err = register_pernet_gen_device(&ipip_net_id, &ipip_net_ops);
if (err)
goto err3;
out:
return err;
err2:
free_netdev(ipip_fb_tunnel_dev);
err1:
xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
goto out;
err3:
unregister_netdevice(ipip_fb_tunnel_dev);
goto err1;
}

static void __exit ipip_destroy_tunnels(void)
Expand All @@ -922,6 +970,8 @@ static void __exit ipip_fini(void)
ipip_destroy_tunnels();
unregister_netdevice(ipip_fb_tunnel_dev);
rtnl_unlock();

unregister_pernet_gen_device(ipip_net_id, &ipip_net_ops);
}

module_init(ipip_init);
Expand Down

0 comments on commit 2c7c4bf

Please sign in to comment.