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 .procname
= "wmem_max",
23 .data
= &sysctl_wmem_max
,
24 .maxlen
= sizeof(int),
26 .proc_handler
= proc_dointvec
29 .procname
= "rmem_max",
30 .data
= &sysctl_rmem_max
,
31 .maxlen
= sizeof(int),
33 .proc_handler
= proc_dointvec
36 .procname
= "wmem_default",
37 .data
= &sysctl_wmem_default
,
38 .maxlen
= sizeof(int),
40 .proc_handler
= proc_dointvec
43 .procname
= "rmem_default",
44 .data
= &sysctl_rmem_default
,
45 .maxlen
= sizeof(int),
47 .proc_handler
= proc_dointvec
50 .procname
= "dev_weight",
52 .maxlen
= sizeof(int),
54 .proc_handler
= proc_dointvec
57 .procname
= "netdev_max_backlog",
58 .data
= &netdev_max_backlog
,
59 .maxlen
= sizeof(int),
61 .proc_handler
= proc_dointvec
64 .procname
= "message_cost",
65 .data
= &net_ratelimit_state
.interval
,
66 .maxlen
= sizeof(int),
68 .proc_handler
= proc_dointvec_jiffies
,
71 .procname
= "message_burst",
72 .data
= &net_ratelimit_state
.burst
,
73 .maxlen
= sizeof(int),
75 .proc_handler
= proc_dointvec
,
78 .procname
= "optmem_max",
79 .data
= &sysctl_optmem_max
,
80 .maxlen
= sizeof(int),
82 .proc_handler
= proc_dointvec
84 #endif /* CONFIG_NET */
86 .procname
= "netdev_budget",
87 .data
= &netdev_budget
,
88 .maxlen
= sizeof(int),
90 .proc_handler
= proc_dointvec
93 .procname
= "warnings",
94 .data
= &net_msg_warn
,
95 .maxlen
= sizeof(int),
97 .proc_handler
= proc_dointvec
102 static struct ctl_table netns_core_table
[] = {
104 .procname
= "somaxconn",
105 .data
= &init_net
.core
.sysctl_somaxconn
,
106 .maxlen
= sizeof(int),
108 .proc_handler
= proc_dointvec
113 __net_initdata
struct ctl_path net_core_path
[] = {
114 { .procname
= "net", },
115 { .procname
= "core", },
119 static __net_init
int sysctl_core_net_init(struct net
*net
)
121 struct ctl_table
*tbl
;
123 net
->core
.sysctl_somaxconn
= SOMAXCONN
;
125 tbl
= netns_core_table
;
126 if (net
!= &init_net
) {
127 tbl
= kmemdup(tbl
, sizeof(netns_core_table
), GFP_KERNEL
);
131 tbl
[0].data
= &net
->core
.sysctl_somaxconn
;
134 net
->core
.sysctl_hdr
= register_net_sysctl_table(net
,
136 if (net
->core
.sysctl_hdr
== NULL
)
142 if (tbl
!= netns_core_table
)
148 static __net_exit
void sysctl_core_net_exit(struct net
*net
)
150 struct ctl_table
*tbl
;
152 tbl
= net
->core
.sysctl_hdr
->ctl_table_arg
;
153 unregister_net_sysctl_table(net
->core
.sysctl_hdr
);
154 BUG_ON(tbl
== netns_core_table
);
158 static __net_initdata
struct pernet_operations sysctl_core_ops
= {
159 .init
= sysctl_core_net_init
,
160 .exit
= sysctl_core_net_exit
,
163 static __init
int sysctl_core_init(void)
165 static struct ctl_table empty
[1];
167 register_sysctl_paths(net_core_path
, empty
);
168 register_net_sysctl_rotable(net_core_path
, net_core_table
);
169 return register_pernet_subsys(&sysctl_core_ops
);
172 fs_initcall(sysctl_core_init
);