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/init.h>
16 static struct ctl_table net_core_table[] = {
19 .ctl_name = NET_CORE_WMEM_MAX,
20 .procname = "wmem_max",
21 .data = &sysctl_wmem_max,
22 .maxlen = sizeof(int),
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),
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),
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),
48 .proc_handler = proc_dointvec
51 .ctl_name = NET_CORE_DEV_WEIGHT,
52 .procname = "dev_weight",
54 .maxlen = sizeof(int),
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),
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),
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),
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),
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),
98 .proc_handler = proc_dointvec
101 .ctl_name = NET_CORE_WARNINGS,
102 .procname = "warnings",
103 .data = &net_msg_warn,
104 .maxlen = sizeof(int),
106 .proc_handler = proc_dointvec
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),
118 .proc_handler = proc_dointvec
123 __net_initdata struct ctl_path net_core_path[] = {
124 { .procname = "net", .ctl_name = CTL_NET, },
125 { .procname = "core", .ctl_name = NET_CORE, },
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);
141 tbl[0].data = &net->core.sysctl_somaxconn;
144 net->core.sysctl_hdr = register_net_sysctl_table(net,
146 if (net->core.sysctl_hdr == NULL)
152 if (tbl != netns_core_table)
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);
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);