USB: serial: remove recourse to generic method
[wandboard.git] / net / core / sysctl_net_core.c
blob83d3398559ea80d3823140856b375dd5c2419927
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/init.h>
14 #include <net/sock.h>
16 static struct ctl_table net_core_table[] = {
17 #ifdef CONFIG_NET
19 .ctl_name = NET_CORE_WMEM_MAX,
20 .procname = "wmem_max",
21 .data = &sysctl_wmem_max,
22 .maxlen = sizeof(int),
23 .mode = 0644,
24 .proc_handler = proc_dointvec
27 .ctl_name = NET_CORE_RMEM_MAX,
28 .procname = "rmem_max",
29 .data = &sysctl_rmem_max,
30 .maxlen = sizeof(int),
31 .mode = 0644,
32 .proc_handler = proc_dointvec
35 .ctl_name = NET_CORE_WMEM_DEFAULT,
36 .procname = "wmem_default",
37 .data = &sysctl_wmem_default,
38 .maxlen = sizeof(int),
39 .mode = 0644,
40 .proc_handler = proc_dointvec
43 .ctl_name = NET_CORE_RMEM_DEFAULT,
44 .procname = "rmem_default",
45 .data = &sysctl_rmem_default,
46 .maxlen = sizeof(int),
47 .mode = 0644,
48 .proc_handler = proc_dointvec
51 .ctl_name = NET_CORE_DEV_WEIGHT,
52 .procname = "dev_weight",
53 .data = &weight_p,
54 .maxlen = sizeof(int),
55 .mode = 0644,
56 .proc_handler = proc_dointvec
59 .ctl_name = NET_CORE_MAX_BACKLOG,
60 .procname = "netdev_max_backlog",
61 .data = &netdev_max_backlog,
62 .maxlen = sizeof(int),
63 .mode = 0644,
64 .proc_handler = proc_dointvec
67 .ctl_name = NET_CORE_MSG_COST,
68 .procname = "message_cost",
69 .data = &net_ratelimit_state.interval,
70 .maxlen = sizeof(int),
71 .mode = 0644,
72 .proc_handler = proc_dointvec_jiffies,
73 .strategy = sysctl_jiffies,
76 .ctl_name = NET_CORE_MSG_BURST,
77 .procname = "message_burst",
78 .data = &net_ratelimit_state.burst,
79 .maxlen = sizeof(int),
80 .mode = 0644,
81 .proc_handler = proc_dointvec,
84 .ctl_name = NET_CORE_OPTMEM_MAX,
85 .procname = "optmem_max",
86 .data = &sysctl_optmem_max,
87 .maxlen = sizeof(int),
88 .mode = 0644,
89 .proc_handler = proc_dointvec
91 #endif /* CONFIG_NET */
93 .ctl_name = NET_CORE_BUDGET,
94 .procname = "netdev_budget",
95 .data = &netdev_budget,
96 .maxlen = sizeof(int),
97 .mode = 0644,
98 .proc_handler = proc_dointvec
101 .ctl_name = NET_CORE_WARNINGS,
102 .procname = "warnings",
103 .data = &net_msg_warn,
104 .maxlen = sizeof(int),
105 .mode = 0644,
106 .proc_handler = proc_dointvec
108 { .ctl_name = 0 }
111 static struct ctl_table netns_core_table[] = {
113 .ctl_name = NET_CORE_SOMAXCONN,
114 .procname = "somaxconn",
115 .data = &init_net.core.sysctl_somaxconn,
116 .maxlen = sizeof(int),
117 .mode = 0644,
118 .proc_handler = proc_dointvec
120 { .ctl_name = 0 }
123 __net_initdata struct ctl_path net_core_path[] = {
124 { .procname = "net", .ctl_name = CTL_NET, },
125 { .procname = "core", .ctl_name = NET_CORE, },
126 { },
129 static __net_init int sysctl_core_net_init(struct net *net)
131 struct ctl_table *tbl;
133 net->core.sysctl_somaxconn = SOMAXCONN;
135 tbl = netns_core_table;
136 if (net != &init_net) {
137 tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
138 if (tbl == NULL)
139 goto err_dup;
141 tbl[0].data = &net->core.sysctl_somaxconn;
144 net->core.sysctl_hdr = register_net_sysctl_table(net,
145 net_core_path, tbl);
146 if (net->core.sysctl_hdr == NULL)
147 goto err_reg;
149 return 0;
151 err_reg:
152 if (tbl != netns_core_table)
153 kfree(tbl);
154 err_dup:
155 return -ENOMEM;
158 static __net_exit void sysctl_core_net_exit(struct net *net)
160 struct ctl_table *tbl;
162 tbl = net->core.sysctl_hdr->ctl_table_arg;
163 unregister_net_sysctl_table(net->core.sysctl_hdr);
164 BUG_ON(tbl == netns_core_table);
165 kfree(tbl);
168 static __net_initdata struct pernet_operations sysctl_core_ops = {
169 .init = sysctl_core_net_init,
170 .exit = sysctl_core_net_exit,
173 static __init int sysctl_core_init(void)
175 static struct ctl_table empty[1];
177 register_sysctl_paths(net_core_path, empty);
178 register_net_sysctl_rotable(net_core_path, net_core_table);
179 return register_pernet_subsys(&sysctl_core_ops);
182 fs_initcall(sysctl_core_init);