netfilter: nf_conntrack: add support for "conntrack zones"
[safe/jmp/linux-2.6] / net / ipv6 / ip6_tunnel.c
index 1d61411..fbd7869 100644 (file)
@@ -74,11 +74,10 @@ MODULE_LICENSE("GPL");
                     (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
                    (HASH_SIZE - 1))
 
-static void ip6_fb_tnl_dev_init(struct net_device *dev);
 static void ip6_tnl_dev_init(struct net_device *dev);
 static void ip6_tnl_dev_setup(struct net_device *dev);
 
-static int ip6_tnl_net_id;
+static int ip6_tnl_net_id __read_mostly;
 struct ip6_tnl_net {
        /* the IPv6 tunnel fallback device */
        struct net_device *fb_tnl_dev;
@@ -1364,7 +1363,7 @@ static void ip6_tnl_dev_init(struct net_device *dev)
  * Return: 0
  **/
 
-static void ip6_fb_tnl_dev_init(struct net_device *dev)
+static void __net_init ip6_fb_tnl_dev_init(struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
        struct net *net = dev_net(dev);
@@ -1388,7 +1387,7 @@ static struct xfrm6_tunnel ip6ip6_handler = {
        .priority       =       1,
 };
 
-static void ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
+static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
 {
        int h;
        struct ip6_tnl *t;
@@ -1407,19 +1406,10 @@ static void ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
        unregister_netdevice_many(&list);
 }
 
-static int ip6_tnl_init_net(struct net *net)
+static int __net_init ip6_tnl_init_net(struct net *net)
 {
+       struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
        int err;
-       struct ip6_tnl_net *ip6n;
-
-       err = -ENOMEM;
-       ip6n = kzalloc(sizeof(struct ip6_tnl_net), GFP_KERNEL);
-       if (ip6n == NULL)
-               goto err_alloc;
-
-       err = net_assign_generic(net, ip6_tnl_net_id, ip6n);
-       if (err < 0)
-               goto err_assign;
 
        ip6n->tnls[0] = ip6n->tnls_wc;
        ip6n->tnls[1] = ip6n->tnls_r_l;
@@ -1442,27 +1432,23 @@ static int ip6_tnl_init_net(struct net *net)
 err_register:
        free_netdev(ip6n->fb_tnl_dev);
 err_alloc_dev:
-       /* nothing */
-err_assign:
-       kfree(ip6n);
-err_alloc:
        return err;
 }
 
-static void ip6_tnl_exit_net(struct net *net)
+static void __net_exit ip6_tnl_exit_net(struct net *net)
 {
-       struct ip6_tnl_net *ip6n;
+       struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
 
-       ip6n = net_generic(net, ip6_tnl_net_id);
        rtnl_lock();
        ip6_tnl_destroy_tunnels(ip6n);
        rtnl_unlock();
-       kfree(ip6n);
 }
 
 static struct pernet_operations ip6_tnl_net_ops = {
        .init = ip6_tnl_init_net,
        .exit = ip6_tnl_exit_net,
+       .id   = &ip6_tnl_net_id,
+       .size = sizeof(struct ip6_tnl_net),
 };
 
 /**
@@ -1487,7 +1473,7 @@ static int __init ip6_tunnel_init(void)
                goto unreg_ip4ip6;
        }
 
-       err = register_pernet_gen_device(&ip6_tnl_net_id, &ip6_tnl_net_ops);
+       err = register_pernet_device(&ip6_tnl_net_ops);
        if (err < 0)
                goto err_pernet;
        return 0;
@@ -1511,7 +1497,7 @@ static void __exit ip6_tunnel_cleanup(void)
        if (xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6))
                printk(KERN_INFO "ip6_tunnel close: can't deregister ip6ip6\n");
 
-       unregister_pernet_gen_device(ip6_tnl_net_id, &ip6_tnl_net_ops);
+       unregister_pernet_device(&ip6_tnl_net_ops);
 }
 
 module_init(ip6_tunnel_init);