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>
19 static struct ctl_table net_core_table
[] = {
22 .ctl_name
= NET_CORE_WMEM_MAX
,
23 .procname
= "wmem_max",
24 .data
= &sysctl_wmem_max
,
25 .maxlen
= sizeof(int),
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),
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),
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),
51 .proc_handler
= proc_dointvec
54 .ctl_name
= NET_CORE_DEV_WEIGHT
,
55 .procname
= "dev_weight",
57 .maxlen
= sizeof(int),
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),
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),
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),
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),
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),
101 .proc_handler
= proc_dointvec
104 .ctl_name
= NET_CORE_WARNINGS
,
105 .procname
= "warnings",
106 .data
= &net_msg_warn
,
107 .maxlen
= sizeof(int),
109 .proc_handler
= proc_dointvec
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),
121 .proc_handler
= proc_dointvec
126 __net_initdata
struct ctl_path net_core_path
[] = {
127 { .procname
= "net", .ctl_name
= CTL_NET
, },
128 { .procname
= "core", .ctl_name
= NET_CORE
, },
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
);
144 tbl
[0].data
= &net
->core
.sysctl_somaxconn
;
147 net
->core
.sysctl_hdr
= register_net_sysctl_table(net
,
149 if (net
->core
.sysctl_hdr
== NULL
)
155 if (tbl
!= netns_core_table
)
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
);
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
);