mm-only debug patch...
[mmotm.git] / net / core / sysctl_net_core.c
blob887c03c4e3c6d8078265c4e6ad69256dd77f0e58
1 /* -*- linux-c -*-
2 * sysctl_net_core.c: sysctl interface to net core subsystem.
4 * Begun April 1, 1996, Mike Shaver.
5 * Added /proc/sys/net/core directory entry (empty =) ). [MS]
6 */
8 #include <linux/mm.h>
9 #include <linux/sysctl.h>
10 #include <linux/module.h>
11 #include <linux/socket.h>
12 #include <linux/netdevice.h>
13 #include <linux/ratelimit.h>
14 #include <linux/init.h>
16 #include <net/ip.h>
17 #include <net/sock.h>
19 static struct ctl_table net_core_table[] = {
20 #ifdef CONFIG_NET
22 .ctl_name = NET_CORE_WMEM_MAX,
23 .procname = "wmem_max",
24 .data = &sysctl_wmem_max,
25 .maxlen = sizeof(int),
26 .mode = 0644,
27 .proc_handler = proc_dointvec
30 .ctl_name = NET_CORE_RMEM_MAX,
31 .procname = "rmem_max",
32 .data = &sysctl_rmem_max,
33 .maxlen = sizeof(int),
34 .mode = 0644,
35 .proc_handler = proc_dointvec
38 .ctl_name = NET_CORE_WMEM_DEFAULT,
39 .procname = "wmem_default",
40 .data = &sysctl_wmem_default,
41 .maxlen = sizeof(int),
42 .mode = 0644,
43 .proc_handler = proc_dointvec
46 .ctl_name = NET_CORE_RMEM_DEFAULT,
47 .procname = "rmem_default",
48 .data = &sysctl_rmem_default,
49 .maxlen = sizeof(int),
50 .mode = 0644,
51 .proc_handler = proc_dointvec
54 .ctl_name = NET_CORE_DEV_WEIGHT,
55 .procname = "dev_weight",
56 .data = &weight_p,
57 .maxlen = sizeof(int),
58 .mode = 0644,
59 .proc_handler = proc_dointvec
62 .ctl_name = NET_CORE_MAX_BACKLOG,
63 .procname = "netdev_max_backlog",
64 .data = &netdev_max_backlog,
65 .maxlen = sizeof(int),
66 .mode = 0644,
67 .proc_handler = proc_dointvec
70 .ctl_name = NET_CORE_MSG_COST,
71 .procname = "message_cost",
72 .data = &net_ratelimit_state.interval,
73 .maxlen = sizeof(int),
74 .mode = 0644,
75 .proc_handler = proc_dointvec_jiffies,
76 .strategy = sysctl_jiffies,
79 .ctl_name = NET_CORE_MSG_BURST,
80 .procname = "message_burst",
81 .data = &net_ratelimit_state.burst,
82 .maxlen = sizeof(int),
83 .mode = 0644,
84 .proc_handler = proc_dointvec,
87 .ctl_name = NET_CORE_OPTMEM_MAX,
88 .procname = "optmem_max",
89 .data = &sysctl_optmem_max,
90 .maxlen = sizeof(int),
91 .mode = 0644,
92 .proc_handler = proc_dointvec
94 #endif /* CONFIG_NET */
96 .ctl_name = NET_CORE_BUDGET,
97 .procname = "netdev_budget",
98 .data = &netdev_budget,
99 .maxlen = sizeof(int),
100 .mode = 0644,
101 .proc_handler = proc_dointvec
104 .ctl_name = NET_CORE_WARNINGS,
105 .procname = "warnings",
106 .data = &net_msg_warn,
107 .maxlen = sizeof(int),
108 .mode = 0644,
109 .proc_handler = proc_dointvec
111 { .ctl_name = 0 }
114 static struct ctl_table netns_core_table[] = {
116 .ctl_name = NET_CORE_SOMAXCONN,
117 .procname = "somaxconn",
118 .data = &init_net.core.sysctl_somaxconn,
119 .maxlen = sizeof(int),
120 .mode = 0644,
121 .proc_handler = proc_dointvec
123 { .ctl_name = 0 }
126 __net_initdata struct ctl_path net_core_path[] = {
127 { .procname = "net", .ctl_name = CTL_NET, },
128 { .procname = "core", .ctl_name = NET_CORE, },
129 { },
132 static __net_init int sysctl_core_net_init(struct net *net)
134 struct ctl_table *tbl;
136 net->core.sysctl_somaxconn = SOMAXCONN;
138 tbl = netns_core_table;
139 if (net != &init_net) {
140 tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
141 if (tbl == NULL)
142 goto err_dup;
144 tbl[0].data = &net->core.sysctl_somaxconn;
147 net->core.sysctl_hdr = register_net_sysctl_table(net,
148 net_core_path, tbl);
149 if (net->core.sysctl_hdr == NULL)
150 goto err_reg;
152 return 0;
154 err_reg:
155 if (tbl != netns_core_table)
156 kfree(tbl);
157 err_dup:
158 return -ENOMEM;
161 static __net_exit void sysctl_core_net_exit(struct net *net)
163 struct ctl_table *tbl;
165 tbl = net->core.sysctl_hdr->ctl_table_arg;
166 unregister_net_sysctl_table(net->core.sysctl_hdr);
167 BUG_ON(tbl == netns_core_table);
168 kfree(tbl);
171 static __net_initdata struct pernet_operations sysctl_core_ops = {
172 .init = sysctl_core_net_init,
173 .exit = sysctl_core_net_exit,
176 static __init int sysctl_core_init(void)
178 static struct ctl_table empty[1];
180 register_sysctl_paths(net_core_path, empty);
181 register_net_sysctl_rotable(net_core_path, net_core_table);
182 return register_pernet_subsys(&sysctl_core_ops);
185 fs_initcall(sysctl_core_init);