Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / sctp / sysctl.c
CommitLineData
60c778b2 1/* SCTP kernel implementation
1da177e4
LT
2 * (C) Copyright IBM Corp. 2002, 2004
3 * Copyright (c) 2002 Intel Corp.
4 *
60c778b2 5 * This file is part of the SCTP kernel implementation
1da177e4
LT
6 *
7 * Sysctl related interfaces for SCTP.
8 *
60c778b2 9 * This SCTP implementation is free software;
1da177e4
LT
10 * you can redistribute it and/or modify it under the terms of
11 * the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
60c778b2 15 * This SCTP implementation is distributed in the hope that it
1da177e4
LT
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * ************************
18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GNU CC; see the file COPYING. If not, write to
23 * the Free Software Foundation, 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
25 *
26 * Please send any bug reports or fixes you make to the
27 * email address(es):
28 * lksctp developers <lksctp-developers@lists.sourceforge.net>
29 *
30 * Or submit a bug report through the following website:
31 * http://www.sf.net/projects/lksctp
32 *
33 * Written or modified by:
34 * Mingqin Liu <liuming@us.ibm.com>
35 * Jon Grimm <jgrimm@us.ibm.com>
36 * Ardelle Fan <ardelle.fan@intel.com>
37 * Ryan Layer <rmlayer@us.ibm.com>
38 * Sridhar Samudrala <sri@us.ibm.com>
39 *
40 * Any bugs reported given to us we will try to fix... any fixes shared will
41 * be incorporated into the next SCTP release.
42 */
43
44#include <net/sctp/structs.h>
8c5955d8 45#include <net/sctp/sctp.h>
1da177e4
LT
46#include <linux/sysctl.h>
47
3fd091e7
VY
48static int zero = 0;
49static int one = 1;
50static int timer_max = 86400000; /* ms in one day */
51static int int_max = INT_MAX;
d48e074d
JMG
52static int sack_timer_min = 1;
53static int sack_timer_max = 500;
72388433 54static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
90f2f531 55static int rwnd_scale_max = 16;
2692ba61
XW
56static unsigned long max_autoclose_min = 0;
57static unsigned long max_autoclose_max =
58 (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
59 ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
1da177e4 60
8d987e5c 61extern long sysctl_sctp_mem[3];
007e3936
VY
62extern int sysctl_sctp_rmem[3];
63extern int sysctl_sctp_wmem[3];
4d93df0a 64
1da177e4 65static ctl_table sctp_table[] = {
e1fc3b14
EB
66 {
67 .procname = "sctp_mem",
68 .data = &sysctl_sctp_mem,
69 .maxlen = sizeof(sysctl_sctp_mem),
70 .mode = 0644,
71 .proc_handler = proc_doulongvec_minmax
72 },
73 {
74 .procname = "sctp_rmem",
75 .data = &sysctl_sctp_rmem,
76 .maxlen = sizeof(sysctl_sctp_rmem),
77 .mode = 0644,
78 .proc_handler = proc_dointvec,
79 },
80 {
81 .procname = "sctp_wmem",
82 .data = &sysctl_sctp_wmem,
83 .maxlen = sizeof(sysctl_sctp_wmem),
84 .mode = 0644,
85 .proc_handler = proc_dointvec,
86 },
87
88 { /* sentinel */ }
89};
90
91static ctl_table sctp_net_table[] = {
1da177e4 92 {
1da177e4 93 .procname = "rto_initial",
e1fc3b14 94 .data = &init_net.sctp.rto_initial,
3fd091e7 95 .maxlen = sizeof(unsigned int),
1da177e4 96 .mode = 0644,
6d9f239a 97 .proc_handler = proc_dointvec_minmax,
3fd091e7
VY
98 .extra1 = &one,
99 .extra2 = &timer_max
1da177e4
LT
100 },
101 {
1da177e4 102 .procname = "rto_min",
e1fc3b14 103 .data = &init_net.sctp.rto_min,
3fd091e7 104 .maxlen = sizeof(unsigned int),
1da177e4 105 .mode = 0644,
6d9f239a 106 .proc_handler = proc_dointvec_minmax,
3fd091e7
VY
107 .extra1 = &one,
108 .extra2 = &timer_max
1da177e4
LT
109 },
110 {
1da177e4 111 .procname = "rto_max",
e1fc3b14 112 .data = &init_net.sctp.rto_max,
3fd091e7 113 .maxlen = sizeof(unsigned int),
1da177e4 114 .mode = 0644,
6d9f239a 115 .proc_handler = proc_dointvec_minmax,
3fd091e7
VY
116 .extra1 = &one,
117 .extra2 = &timer_max
1da177e4
LT
118 },
119 {
e1fc3b14
EB
120 .procname = "rto_alpha_exp_divisor",
121 .data = &init_net.sctp.rto_alpha,
122 .maxlen = sizeof(int),
123 .mode = 0444,
124 .proc_handler = proc_dointvec,
125 },
126 {
127 .procname = "rto_beta_exp_divisor",
128 .data = &init_net.sctp.rto_beta,
129 .maxlen = sizeof(int),
130 .mode = 0444,
131 .proc_handler = proc_dointvec,
1da177e4
LT
132 },
133 {
1da177e4 134 .procname = "max_burst",
e1fc3b14 135 .data = &init_net.sctp.max_burst,
1da177e4
LT
136 .maxlen = sizeof(int),
137 .mode = 0644,
6d9f239a 138 .proc_handler = proc_dointvec_minmax,
3fd091e7
VY
139 .extra1 = &zero,
140 .extra2 = &int_max
1da177e4
LT
141 },
142 {
e1fc3b14
EB
143 .procname = "cookie_preserve_enable",
144 .data = &init_net.sctp.cookie_preserve_enable,
1da177e4
LT
145 .maxlen = sizeof(int),
146 .mode = 0644,
e1fc3b14
EB
147 .proc_handler = proc_dointvec,
148 },
149 {
150 .procname = "valid_cookie_life",
151 .data = &init_net.sctp.valid_cookie_life,
152 .maxlen = sizeof(unsigned int),
153 .mode = 0644,
6d9f239a 154 .proc_handler = proc_dointvec_minmax,
e1fc3b14
EB
155 .extra1 = &one,
156 .extra2 = &timer_max
1da177e4 157 },
4eb701df 158 {
e1fc3b14
EB
159 .procname = "sack_timeout",
160 .data = &init_net.sctp.sack_timeout,
4eb701df
NH
161 .maxlen = sizeof(int),
162 .mode = 0644,
e1fc3b14
EB
163 .proc_handler = proc_dointvec_minmax,
164 .extra1 = &sack_timer_min,
165 .extra2 = &sack_timer_max,
4eb701df 166 },
049b3ff5 167 {
e1fc3b14
EB
168 .procname = "hb_interval",
169 .data = &init_net.sctp.hb_interval,
170 .maxlen = sizeof(unsigned int),
049b3ff5 171 .mode = 0644,
e1fc3b14
EB
172 .proc_handler = proc_dointvec_minmax,
173 .extra1 = &one,
174 .extra2 = &timer_max
049b3ff5 175 },
1da177e4 176 {
e1fc3b14
EB
177 .procname = "association_max_retrans",
178 .data = &init_net.sctp.max_retrans_association,
1da177e4
LT
179 .maxlen = sizeof(int),
180 .mode = 0644,
6d9f239a 181 .proc_handler = proc_dointvec_minmax,
3fd091e7
VY
182 .extra1 = &one,
183 .extra2 = &int_max
1da177e4 184 },
5aa93bcf 185 {
e1fc3b14
EB
186 .procname = "path_max_retrans",
187 .data = &init_net.sctp.max_retrans_path,
5aa93bcf
NH
188 .maxlen = sizeof(int),
189 .mode = 0644,
190 .proc_handler = proc_dointvec_minmax,
e1fc3b14 191 .extra1 = &one,
5aa93bcf
NH
192 .extra2 = &int_max
193 },
1da177e4 194 {
1da177e4 195 .procname = "max_init_retransmits",
e1fc3b14 196 .data = &init_net.sctp.max_retrans_init,
1da177e4
LT
197 .maxlen = sizeof(int),
198 .mode = 0644,
6d9f239a 199 .proc_handler = proc_dointvec_minmax,
3fd091e7
VY
200 .extra1 = &one,
201 .extra2 = &int_max
1da177e4
LT
202 },
203 {
e1fc3b14
EB
204 .procname = "pf_retrans",
205 .data = &init_net.sctp.pf_retrans,
206 .maxlen = sizeof(int),
1da177e4 207 .mode = 0644,
6d9f239a 208 .proc_handler = proc_dointvec_minmax,
e1fc3b14
EB
209 .extra1 = &zero,
210 .extra2 = &int_max
1da177e4
LT
211 },
212 {
e1fc3b14
EB
213 .procname = "sndbuf_policy",
214 .data = &init_net.sctp.sndbuf_policy,
8116ffad 215 .maxlen = sizeof(int),
1da177e4 216 .mode = 0644,
6d9f239a 217 .proc_handler = proc_dointvec,
1da177e4
LT
218 },
219 {
e1fc3b14
EB
220 .procname = "rcvbuf_policy",
221 .data = &init_net.sctp.rcvbuf_policy,
dd51be0f
MH
222 .maxlen = sizeof(int),
223 .mode = 0644,
224 .proc_handler = proc_dointvec,
225 },
226 {
227 .procname = "default_auto_asconf",
e1fc3b14 228 .data = &init_net.sctp.default_auto_asconf,
1da177e4
LT
229 .maxlen = sizeof(int),
230 .mode = 0644,
6d9f239a 231 .proc_handler = proc_dointvec,
1da177e4
LT
232 },
233 {
e1fc3b14
EB
234 .procname = "addip_enable",
235 .data = &init_net.sctp.addip_enable,
1da177e4
LT
236 .maxlen = sizeof(int),
237 .mode = 0644,
6d9f239a 238 .proc_handler = proc_dointvec,
1da177e4 239 },
2f85a429 240 {
e1fc3b14
EB
241 .procname = "addip_noauth_enable",
242 .data = &init_net.sctp.addip_noauth,
d48e074d 243 .maxlen = sizeof(int),
2f85a429 244 .mode = 0644,
6d9f239a 245 .proc_handler = proc_dointvec,
4d93df0a
NH
246 },
247 {
e1fc3b14
EB
248 .procname = "prsctp_enable",
249 .data = &init_net.sctp.prsctp_enable,
a29a5bd4
VY
250 .maxlen = sizeof(int),
251 .mode = 0644,
6d9f239a 252 .proc_handler = proc_dointvec,
a29a5bd4 253 },
73d9c4fd 254 {
e1fc3b14
EB
255 .procname = "auth_enable",
256 .data = &init_net.sctp.auth_enable,
73d9c4fd
VY
257 .maxlen = sizeof(int),
258 .mode = 0644,
6d9f239a 259 .proc_handler = proc_dointvec,
73d9c4fd 260 },
72388433 261 {
72388433 262 .procname = "addr_scope_policy",
e1fc3b14 263 .data = &init_net.sctp.scope_policy,
72388433
BD
264 .maxlen = sizeof(int),
265 .mode = 0644,
6d456111 266 .proc_handler = proc_dointvec_minmax,
72388433
BD
267 .extra1 = &zero,
268 .extra2 = &addr_scope_max,
269 },
90f2f531 270 {
90f2f531 271 .procname = "rwnd_update_shift",
e1fc3b14 272 .data = &init_net.sctp.rwnd_upd_shift,
90f2f531
VY
273 .maxlen = sizeof(int),
274 .mode = 0644,
275 .proc_handler = &proc_dointvec_minmax,
90f2f531
VY
276 .extra1 = &one,
277 .extra2 = &rwnd_scale_max,
278 },
2692ba61
XW
279 {
280 .procname = "max_autoclose",
e1fc3b14 281 .data = &init_net.sctp.max_autoclose,
2692ba61
XW
282 .maxlen = sizeof(unsigned long),
283 .mode = 0644,
284 .proc_handler = &proc_doulongvec_minmax,
285 .extra1 = &max_autoclose_min,
286 .extra2 = &max_autoclose_max,
287 },
90f2f531 288
d7fc02c7 289 { /* sentinel */ }
1da177e4
LT
290};
291
ebb7e95d
EB
292int sctp_sysctl_net_register(struct net *net)
293{
294 struct ctl_table *table;
e1fc3b14 295 int i;
ebb7e95d
EB
296
297 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
298 if (!table)
299 return -ENOMEM;
300
e1fc3b14
EB
301 for (i = 0; table[i].data; i++)
302 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
303
ebb7e95d
EB
304 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
305 return 0;
306}
307
308void sctp_sysctl_net_unregister(struct net *net)
309{
310 unregister_net_sysctl_table(net->sctp.sysctl_header);
311}
312
1da177e4
LT
313static struct ctl_table_header * sctp_sysctl_header;
314
315/* Sysctl registration. */
316void sctp_sysctl_register(void)
317{
ec8f23ce 318 sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
1da177e4
LT
319}
320
321/* Sysctl deregistration. */
322void sctp_sysctl_unregister(void)
323{
5dd3df10 324 unregister_net_sysctl_table(sctp_sysctl_header);
1da177e4 325}