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]
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>
15 #include <linux/slab.h>
20 static struct ctl_table net_core_table[] = {
23 .procname = "wmem_max",
24 .data = &sysctl_wmem_max,
25 .maxlen = sizeof(int),
27 .proc_handler = proc_dointvec
30 .procname = "rmem_max",
31 .data = &sysctl_rmem_max,
32 .maxlen = sizeof(int),
34 .proc_handler = proc_dointvec
37 .procname = "wmem_default",
38 .data = &sysctl_wmem_default,
39 .maxlen = sizeof(int),
41 .proc_handler = proc_dointvec
44 .procname = "rmem_default",
45 .data = &sysctl_rmem_default,
46 .maxlen = sizeof(int),
48 .proc_handler = proc_dointvec
51 .procname = "dev_weight",
53 .maxlen = sizeof(int),
55 .proc_handler = proc_dointvec
58 .procname = "netdev_max_backlog",
59 .data = &netdev_max_backlog,
60 .maxlen = sizeof(int),
62 .proc_handler = proc_dointvec
65 .procname = "message_cost",
66 .data = &net_ratelimit_state.interval,
67 .maxlen = sizeof(int),
69 .proc_handler = proc_dointvec_jiffies,
72 .procname = "message_burst",
73 .data = &net_ratelimit_state.burst,
74 .maxlen = sizeof(int),
76 .proc_handler = proc_dointvec,
79 .procname = "optmem_max",
80 .data = &sysctl_optmem_max,
81 .maxlen = sizeof(int),
83 .proc_handler = proc_dointvec
85 #endif /* CONFIG_NET */
87 .procname = "netdev_budget",
88 .data = &netdev_budget,
89 .maxlen = sizeof(int),
91 .proc_handler = proc_dointvec
94 .procname = "warnings",
95 .data = &net_msg_warn,
96 .maxlen = sizeof(int),
98 .proc_handler = proc_dointvec
103 static struct ctl_table netns_core_table[] = {
105 .procname = "somaxconn",
106 .data = &init_net.core.sysctl_somaxconn,
107 .maxlen = sizeof(int),
109 .proc_handler = proc_dointvec
114 __net_initdata struct ctl_path net_core_path[] = {
115 { .procname = "net", },
116 { .procname = "core", },
120 static __net_init int sysctl_core_net_init(struct net *net)
122 struct ctl_table *tbl;
124 net->core.sysctl_somaxconn = SOMAXCONN;
126 tbl = netns_core_table;
127 if (!net_eq(net, &init_net)) {
128 tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
132 tbl[0].data = &net->core.sysctl_somaxconn;
135 net->core.sysctl_hdr = register_net_sysctl_table(net,
137 if (net->core.sysctl_hdr == NULL)
143 if (tbl != netns_core_table)
149 static __net_exit void sysctl_core_net_exit(struct net *net)
151 struct ctl_table *tbl;
153 tbl = net->core.sysctl_hdr->ctl_table_arg;
154 unregister_net_sysctl_table(net->core.sysctl_hdr);
155 BUG_ON(tbl == netns_core_table);
159 static __net_initdata struct pernet_operations sysctl_core_ops = {
160 .init = sysctl_core_net_init,
161 .exit = sysctl_core_net_exit,
164 static __init int sysctl_core_init(void)
166 static struct ctl_table empty[1];
168 register_sysctl_paths(net_core_path, empty);
169 register_net_sysctl_rotable(net_core_path, net_core_table);
170 return register_pernet_subsys(&sysctl_core_ops);
173 fs_initcall(sysctl_core_init);