aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipip.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-04-16 04:03:13 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-16 04:03:13 -0400
commit10dc4c7bb70533d16184aaaa69e137a7d2b9a3a8 (patch)
tree6fb4348ea85911deb3e8d1154b8ab3cb14d42a0a /net/ipv4/ipip.c
parent30688a9a3e06d83d187658bd1c15f0e306bed38b (diff)
[IPIP]: Introduce empty ipip_net structure and net init/exit ops.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipip.c')
-rw-r--r--net/ipv4/ipip.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 894bce96284a..e39a4c279a20 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -115,10 +115,16 @@
115#include <net/ipip.h> 115#include <net/ipip.h>
116#include <net/inet_ecn.h> 116#include <net/inet_ecn.h>
117#include <net/xfrm.h> 117#include <net/xfrm.h>
118#include <net/net_namespace.h>
119#include <net/netns/generic.h>
118 120
119#define HASH_SIZE 16 121#define HASH_SIZE 16
120#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF) 122#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
121 123
124static int ipip_net_id;
125struct ipip_net {
126};
127
122static int ipip_fb_tunnel_init(struct net_device *dev); 128static int ipip_fb_tunnel_init(struct net_device *dev);
123static int ipip_tunnel_init(struct net_device *dev); 129static int ipip_tunnel_init(struct net_device *dev);
124static void ipip_tunnel_setup(struct net_device *dev); 130static void ipip_tunnel_setup(struct net_device *dev);
@@ -867,6 +873,41 @@ static struct xfrm_tunnel ipip_handler = {
867static char banner[] __initdata = 873static char banner[] __initdata =
868 KERN_INFO "IPv4 over IPv4 tunneling driver\n"; 874 KERN_INFO "IPv4 over IPv4 tunneling driver\n";
869 875
876static int ipip_init_net(struct net *net)
877{
878 int err;
879 struct ipip_net *ipn;
880
881 err = -ENOMEM;
882 ipn = kmalloc(sizeof(struct ipip_net), GFP_KERNEL);
883 if (ipn == NULL)
884 goto err_alloc;
885
886 err = net_assign_generic(net, ipip_net_id, ipn);
887 if (err < 0)
888 goto err_assign;
889
890 return 0;
891
892err_assign:
893 kfree(ipn);
894err_alloc:
895 return err;
896}
897
898static void ipip_exit_net(struct net *net)
899{
900 struct ipip_net *ipn;
901
902 ipn = net_generic(net, ipip_net_id);
903 kfree(ipn);
904}
905
906static struct pernet_operations ipip_net_ops = {
907 .init = ipip_init_net,
908 .exit = ipip_exit_net,
909};
910
870static int __init ipip_init(void) 911static int __init ipip_init(void)
871{ 912{
872 int err; 913 int err;
@@ -890,6 +931,10 @@ static int __init ipip_init(void)
890 931
891 if ((err = register_netdev(ipip_fb_tunnel_dev))) 932 if ((err = register_netdev(ipip_fb_tunnel_dev)))
892 goto err2; 933 goto err2;
934
935 err = register_pernet_gen_device(&ipip_net_id, &ipip_net_ops);
936 if (err)
937 goto err3;
893 out: 938 out:
894 return err; 939 return err;
895 err2: 940 err2:
@@ -897,6 +942,9 @@ static int __init ipip_init(void)
897 err1: 942 err1:
898 xfrm4_tunnel_deregister(&ipip_handler, AF_INET); 943 xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
899 goto out; 944 goto out;
945err3:
946 unregister_netdevice(ipip_fb_tunnel_dev);
947 goto err1;
900} 948}
901 949
902static void __exit ipip_destroy_tunnels(void) 950static void __exit ipip_destroy_tunnels(void)
@@ -922,6 +970,8 @@ static void __exit ipip_fini(void)
922 ipip_destroy_tunnels(); 970 ipip_destroy_tunnels();
923 unregister_netdevice(ipip_fb_tunnel_dev); 971 unregister_netdevice(ipip_fb_tunnel_dev);
924 rtnl_unlock(); 972 rtnl_unlock();
973
974 unregister_pernet_gen_device(ipip_net_id, &ipip_net_ops);
925} 975}
926 976
927module_init(ipip_init); 977module_init(ipip_init);