Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90771
b: refs/heads/master
c: 8190d90
h: refs/heads/master
i:
  90769: 1f0592a
  90767: f4e9048
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Apr 16, 2008
1 parent 406ce73 commit d426560
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: f96c148fd53a2a0dbb2d768895c7cf6951e35cc5
refs/heads/master: 8190d9009a74e7862b31874cd347b394d390cc6e
50 changes: 50 additions & 0 deletions trunk/net/ipv6/sit.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include <net/inet_ecn.h>
#include <net/xfrm.h>
#include <net/dsfield.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>

/*
This version of net/ipv6/sit.c is cloned of net/ipv4/ip_gre.c
Expand All @@ -66,6 +68,10 @@ static int ipip6_fb_tunnel_init(struct net_device *dev);
static int ipip6_tunnel_init(struct net_device *dev);
static void ipip6_tunnel_setup(struct net_device *dev);

static int sit_net_id;
struct sit_net {
};

static struct net_device *ipip6_fb_tunnel_dev;

static struct ip_tunnel *tunnels_r_l[HASH_SIZE];
Expand Down Expand Up @@ -1068,6 +1074,41 @@ static void __exit sit_destroy_tunnels(void)
}
}

static int sit_init_net(struct net *net)
{
int err;
struct sit_net *sitn;

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

err = net_assign_generic(net, sit_net_id, sitn);
if (err < 0)
goto err_assign;

return 0;

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

static void sit_exit_net(struct net *net)
{
struct sit_net *sitn;

sitn = net_generic(net, sit_net_id);
kfree(sitn);
}

static struct pernet_operations sit_net_ops = {
.init = sit_init_net,
.exit = sit_exit_net,
};

static void __exit sit_cleanup(void)
{
xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
Expand All @@ -1076,6 +1117,8 @@ static void __exit sit_cleanup(void)
sit_destroy_tunnels();
unregister_netdevice(ipip6_fb_tunnel_dev);
rtnl_unlock();

unregister_pernet_gen_device(sit_net_id, &sit_net_ops);
}

static int __init sit_init(void)
Expand All @@ -1101,13 +1144,20 @@ static int __init sit_init(void)
if ((err = register_netdev(ipip6_fb_tunnel_dev)))
goto err2;

err = register_pernet_gen_device(&sit_net_id, &sit_net_ops);
if (err < 0)
goto err3;

out:
return err;
err2:
free_netdev(ipip6_fb_tunnel_dev);
err1:
xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
goto out;
err3:
unregister_netdevice(ipip6_fb_tunnel_dev);
goto err1;
}

module_init(sit_init);
Expand Down

0 comments on commit d426560

Please sign in to comment.