netns: add stub functions for per/namespace mibs allocation
[safe/jmp/linux-2.6] / net / ipv6 / af_inet6.c
index 6b39af1..e8f82ec 100644 (file)
@@ -50,6 +50,7 @@
 #include <net/ipip.h>
 #include <net/protocol.h>
 #include <net/inet_common.h>
+#include <net/route.h>
 #include <net/transp_v6.h>
 #include <net/ip6_route.h>
 #include <net/addrconf.h>
@@ -59,9 +60,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#ifdef CONFIG_IPV6_MROUTE
 #include <linux/mroute6.h>
-#endif
 
 MODULE_AUTHOR("Cast of dozens");
 MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
@@ -85,7 +84,6 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
        struct inet_sock *inet;
        struct ipv6_pinfo *np;
        struct sock *sk;
-       struct list_head *p;
        struct inet_protosw *answer;
        struct proto *answer_prot;
        unsigned char answer_flags;
@@ -99,13 +97,12 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
                build_ehash_secret();
 
        /* Look for the requested type/protocol pair. */
-       answer = NULL;
 lookup_protocol:
        err = -ESOCKTNOSUPPORT;
        rcu_read_lock();
-       list_for_each_rcu(p, &inetsw6[sock->type]) {
-               answer = list_entry(p, struct inet_protosw, list);
+       list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) {
 
+               err = 0;
                /* Check the non-wild match. */
                if (protocol == answer->protocol) {
                        if (protocol != IPPROTO_IP)
@@ -120,10 +117,9 @@ lookup_protocol:
                                break;
                }
                err = -EPROTONOSUPPORT;
-               answer = NULL;
        }
 
-       if (!answer) {
+       if (err) {
                if (try_loading_module < 2) {
                        rcu_read_unlock();
                        /*
@@ -155,7 +151,7 @@ lookup_protocol:
        answer_flags = answer->flags;
        rcu_read_unlock();
 
-       BUG_TRAP(answer_prot->slab != NULL);
+       WARN_ON(answer_prot->slab == NULL);
 
        err = -ENOBUFS;
        sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot);
@@ -839,21 +835,25 @@ static void cleanup_ipv6_mibs(void)
        snmp_mib_free((void **)udplite_stats_in6);
 }
 
+static int __net_init ipv6_init_mibs(struct net *net)
+{
+       return 0;
+}
+
+static void __net_exit ipv6_cleanup_mibs(struct net *net)
+{
+}
+
 static int inet6_net_init(struct net *net)
 {
        int err = 0;
 
        net->ipv6.sysctl.bindv6only = 0;
-       net->ipv6.sysctl.flush_delay = 0;
-       net->ipv6.sysctl.ip6_rt_max_size = 4096;
-       net->ipv6.sysctl.ip6_rt_gc_min_interval = HZ / 2;
-       net->ipv6.sysctl.ip6_rt_gc_timeout = 60*HZ;
-       net->ipv6.sysctl.ip6_rt_gc_interval = 30*HZ;
-       net->ipv6.sysctl.ip6_rt_gc_elasticity = 9;
-       net->ipv6.sysctl.ip6_rt_mtu_expires = 10*60*HZ;
-       net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
        net->ipv6.sysctl.icmpv6_time = 1*HZ;
 
+       err = ipv6_init_mibs(net);
+       if (err)
+               return err;
 #ifdef CONFIG_PROC_FS
        err = udp6_proc_init(net);
        if (err)
@@ -864,7 +864,6 @@ static int inet6_net_init(struct net *net)
        err = ac6_proc_init(net);
        if (err)
                goto proc_ac6_fail;
-out:
 #endif
        return err;
 
@@ -873,7 +872,9 @@ proc_ac6_fail:
        tcp6_proc_exit(net);
 proc_tcp6_fail:
        udp6_proc_exit(net);
-       goto out;
+out:
+       ipv6_cleanup_mibs(net);
+       return err;
 #endif
 }
 
@@ -884,6 +885,7 @@ static void inet6_net_exit(struct net *net)
        tcp6_proc_exit(net);
        ac6_proc_exit(net);
 #endif
+       ipv6_cleanup_mibs(net);
 }
 
 static struct pernet_operations inet6_net_ops = {
@@ -939,6 +941,11 @@ static int __init inet6_init(void)
        if (err)
                goto out_unregister_sock;
 
+#ifdef CONFIG_SYSCTL
+       err = ipv6_static_sysctl_register();
+       if (err)
+               goto static_sysctl_fail;
+#endif
        /*
         *      ipngwg API draft makes clear that the correct semantics
         *      for TCP and UDP is to consider one TCP and UDP instance
@@ -952,11 +959,9 @@ static int __init inet6_init(void)
        err = icmpv6_init();
        if (err)
                goto icmp_fail;
-#ifdef CONFIG_IPV6_MROUTE
        err = ip6_mr_init();
        if (err)
                goto ipmr_fail;
-#endif
        err = ndisc_init();
        if (err)
                goto ndisc_fail;
@@ -1059,14 +1064,16 @@ netfilter_fail:
 igmp_fail:
        ndisc_cleanup();
 ndisc_fail:
-#ifdef CONFIG_IPV6_MROUTE
        ip6_mr_cleanup();
 ipmr_fail:
-#endif
        icmpv6_cleanup();
 icmp_fail:
        unregister_pernet_subsys(&inet6_net_ops);
 register_pernet_fail:
+#ifdef CONFIG_SYSCTL
+       ipv6_static_sysctl_unregister();
+static_sysctl_fail:
+#endif
        cleanup_ipv6_mibs();
 out_unregister_sock:
        sock_unregister(PF_INET6);
@@ -1117,13 +1124,14 @@ static void __exit inet6_exit(void)
        ipv6_netfilter_fini();
        igmp6_cleanup();
        ndisc_cleanup();
-#ifdef CONFIG_IPV6_MROUTE
        ip6_mr_cleanup();
-#endif
        icmpv6_cleanup();
        rawv6_exit();
 
        unregister_pernet_subsys(&inet6_net_ops);
+#ifdef CONFIG_SYSCTL
+       ipv6_static_sysctl_unregister();
+#endif
        cleanup_ipv6_mibs();
        proto_unregister(&rawv6_prot);
        proto_unregister(&udplitev6_prot);