Merge branch 'pandora-27-omap1' into rev2
[pandora-kernel.git] / net / core / sysctl_net_core.c
index 113cc72..f686467 100644 (file)
 #include <linux/module.h>
 #include <linux/socket.h>
 #include <linux/netdevice.h>
+#include <linux/init.h>
 #include <net/sock.h>
 #include <net/xfrm.h>
 
-#ifdef CONFIG_SYSCTL
-
-ctl_table core_table[] = {
+static struct ctl_table net_core_table[] = {
 #ifdef CONFIG_NET
        {
                .ctl_name       = NET_CORE_WMEM_MAX,
@@ -68,7 +67,7 @@ ctl_table core_table[] = {
        {
                .ctl_name       = NET_CORE_MSG_COST,
                .procname       = "message_cost",
-               .data           = &net_msg_cost,
+               .data           = &net_ratelimit_state.interval,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
@@ -77,7 +76,7 @@ ctl_table core_table[] = {
        {
                .ctl_name       = NET_CORE_MSG_BURST,
                .procname       = "message_burst",
-               .data           = &net_msg_burst,
+               .data           = &net_ratelimit_state.burst,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
@@ -125,14 +124,6 @@ ctl_table core_table[] = {
        },
 #endif /* CONFIG_XFRM */
 #endif /* CONFIG_NET */
-       {
-               .ctl_name       = NET_CORE_SOMAXCONN,
-               .procname       = "somaxconn",
-               .data           = &sysctl_somaxconn,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
        {
                .ctl_name       = NET_CORE_BUDGET,
                .procname       = "netdev_budget",
@@ -152,4 +143,72 @@ ctl_table core_table[] = {
        { .ctl_name = 0 }
 };
 
-#endif
+static struct ctl_table netns_core_table[] = {
+       {
+               .ctl_name       = NET_CORE_SOMAXCONN,
+               .procname       = "somaxconn",
+               .data           = &init_net.core.sysctl_somaxconn,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       { .ctl_name = 0 }
+};
+
+static __net_initdata struct ctl_path net_core_path[] = {
+       { .procname = "net", .ctl_name = CTL_NET, },
+       { .procname = "core", .ctl_name = NET_CORE, },
+       { },
+};
+
+static __net_init int sysctl_core_net_init(struct net *net)
+{
+       struct ctl_table *tbl;
+
+       net->core.sysctl_somaxconn = SOMAXCONN;
+
+       tbl = netns_core_table;
+       if (net != &init_net) {
+               tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
+               if (tbl == NULL)
+                       goto err_dup;
+
+               tbl[0].data = &net->core.sysctl_somaxconn;
+       }
+
+       net->core.sysctl_hdr = register_net_sysctl_table(net,
+                       net_core_path, tbl);
+       if (net->core.sysctl_hdr == NULL)
+               goto err_reg;
+
+       return 0;
+
+err_reg:
+       if (tbl != netns_core_table)
+               kfree(tbl);
+err_dup:
+       return -ENOMEM;
+}
+
+static __net_exit void sysctl_core_net_exit(struct net *net)
+{
+       struct ctl_table *tbl;
+
+       tbl = net->core.sysctl_hdr->ctl_table_arg;
+       unregister_net_sysctl_table(net->core.sysctl_hdr);
+       BUG_ON(tbl == netns_core_table);
+       kfree(tbl);
+}
+
+static __net_initdata struct pernet_operations sysctl_core_ops = {
+       .init = sysctl_core_net_init,
+       .exit = sysctl_core_net_exit,
+};
+
+static __init int sysctl_core_init(void)
+{
+       register_net_sysctl_rotable(net_core_path, net_core_table);
+       return register_pernet_subsys(&sysctl_core_ops);
+}
+
+__initcall(sysctl_core_init);