x86/xen: resume timer irqs early
[linux/fpc-iii.git] / net / sctp / sysctl.c
blob968355f0de60c5733e5b2ffb5ae1d1ad5acfed81
1 /* SCTP kernel implementation
2 * (C) Copyright IBM Corp. 2002, 2004
3 * Copyright (c) 2002 Intel Corp.
5 * This file is part of the SCTP kernel implementation
7 * Sysctl related interfaces for SCTP.
9 * This SCTP implementation is free software;
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.
15 * This SCTP implementation is distributed in the hope that it
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.
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.
26 * Please send any bug reports or fixes you make to the
27 * email address(es):
28 * lksctp developers <linux-sctp@vger.kernel.org>
30 * Written or modified by:
31 * Mingqin Liu <liuming@us.ibm.com>
32 * Jon Grimm <jgrimm@us.ibm.com>
33 * Ardelle Fan <ardelle.fan@intel.com>
34 * Ryan Layer <rmlayer@us.ibm.com>
35 * Sridhar Samudrala <sri@us.ibm.com>
38 #include <net/sctp/structs.h>
39 #include <net/sctp/sctp.h>
40 #include <linux/sysctl.h>
42 static int zero = 0;
43 static int one = 1;
44 static int timer_max = 86400000; /* ms in one day */
45 static int int_max = INT_MAX;
46 static int sack_timer_min = 1;
47 static int sack_timer_max = 500;
48 static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
49 static int rwnd_scale_max = 16;
50 static unsigned long max_autoclose_min = 0;
51 static unsigned long max_autoclose_max =
52 (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
53 ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
55 extern long sysctl_sctp_mem[3];
56 extern int sysctl_sctp_rmem[3];
57 extern int sysctl_sctp_wmem[3];
59 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
60 int write,
61 void __user *buffer, size_t *lenp,
62 loff_t *ppos);
63 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
64 void __user *buffer, size_t *lenp,
65 loff_t *ppos);
67 static struct ctl_table sctp_table[] = {
69 .procname = "sctp_mem",
70 .data = &sysctl_sctp_mem,
71 .maxlen = sizeof(sysctl_sctp_mem),
72 .mode = 0644,
73 .proc_handler = proc_doulongvec_minmax
76 .procname = "sctp_rmem",
77 .data = &sysctl_sctp_rmem,
78 .maxlen = sizeof(sysctl_sctp_rmem),
79 .mode = 0644,
80 .proc_handler = proc_dointvec,
83 .procname = "sctp_wmem",
84 .data = &sysctl_sctp_wmem,
85 .maxlen = sizeof(sysctl_sctp_wmem),
86 .mode = 0644,
87 .proc_handler = proc_dointvec,
90 { /* sentinel */ }
93 static struct ctl_table sctp_net_table[] = {
95 .procname = "rto_initial",
96 .data = &init_net.sctp.rto_initial,
97 .maxlen = sizeof(unsigned int),
98 .mode = 0644,
99 .proc_handler = proc_dointvec_minmax,
100 .extra1 = &one,
101 .extra2 = &timer_max
104 .procname = "rto_min",
105 .data = &init_net.sctp.rto_min,
106 .maxlen = sizeof(unsigned int),
107 .mode = 0644,
108 .proc_handler = proc_dointvec_minmax,
109 .extra1 = &one,
110 .extra2 = &timer_max
113 .procname = "rto_max",
114 .data = &init_net.sctp.rto_max,
115 .maxlen = sizeof(unsigned int),
116 .mode = 0644,
117 .proc_handler = proc_dointvec_minmax,
118 .extra1 = &one,
119 .extra2 = &timer_max
122 .procname = "rto_alpha_exp_divisor",
123 .data = &init_net.sctp.rto_alpha,
124 .maxlen = sizeof(int),
125 .mode = 0444,
126 .proc_handler = proc_dointvec,
129 .procname = "rto_beta_exp_divisor",
130 .data = &init_net.sctp.rto_beta,
131 .maxlen = sizeof(int),
132 .mode = 0444,
133 .proc_handler = proc_dointvec,
136 .procname = "max_burst",
137 .data = &init_net.sctp.max_burst,
138 .maxlen = sizeof(int),
139 .mode = 0644,
140 .proc_handler = proc_dointvec_minmax,
141 .extra1 = &zero,
142 .extra2 = &int_max
145 .procname = "cookie_preserve_enable",
146 .data = &init_net.sctp.cookie_preserve_enable,
147 .maxlen = sizeof(int),
148 .mode = 0644,
149 .proc_handler = proc_dointvec,
152 .procname = "cookie_hmac_alg",
153 .maxlen = 8,
154 .mode = 0644,
155 .proc_handler = proc_sctp_do_hmac_alg,
158 .procname = "valid_cookie_life",
159 .data = &init_net.sctp.valid_cookie_life,
160 .maxlen = sizeof(unsigned int),
161 .mode = 0644,
162 .proc_handler = proc_dointvec_minmax,
163 .extra1 = &one,
164 .extra2 = &timer_max
167 .procname = "sack_timeout",
168 .data = &init_net.sctp.sack_timeout,
169 .maxlen = sizeof(int),
170 .mode = 0644,
171 .proc_handler = proc_dointvec_minmax,
172 .extra1 = &sack_timer_min,
173 .extra2 = &sack_timer_max,
176 .procname = "hb_interval",
177 .data = &init_net.sctp.hb_interval,
178 .maxlen = sizeof(unsigned int),
179 .mode = 0644,
180 .proc_handler = proc_dointvec_minmax,
181 .extra1 = &one,
182 .extra2 = &timer_max
185 .procname = "association_max_retrans",
186 .data = &init_net.sctp.max_retrans_association,
187 .maxlen = sizeof(int),
188 .mode = 0644,
189 .proc_handler = proc_dointvec_minmax,
190 .extra1 = &one,
191 .extra2 = &int_max
194 .procname = "path_max_retrans",
195 .data = &init_net.sctp.max_retrans_path,
196 .maxlen = sizeof(int),
197 .mode = 0644,
198 .proc_handler = proc_dointvec_minmax,
199 .extra1 = &one,
200 .extra2 = &int_max
203 .procname = "max_init_retransmits",
204 .data = &init_net.sctp.max_retrans_init,
205 .maxlen = sizeof(int),
206 .mode = 0644,
207 .proc_handler = proc_dointvec_minmax,
208 .extra1 = &one,
209 .extra2 = &int_max
212 .procname = "pf_retrans",
213 .data = &init_net.sctp.pf_retrans,
214 .maxlen = sizeof(int),
215 .mode = 0644,
216 .proc_handler = proc_dointvec_minmax,
217 .extra1 = &zero,
218 .extra2 = &int_max
221 .procname = "sndbuf_policy",
222 .data = &init_net.sctp.sndbuf_policy,
223 .maxlen = sizeof(int),
224 .mode = 0644,
225 .proc_handler = proc_dointvec,
228 .procname = "rcvbuf_policy",
229 .data = &init_net.sctp.rcvbuf_policy,
230 .maxlen = sizeof(int),
231 .mode = 0644,
232 .proc_handler = proc_dointvec,
235 .procname = "default_auto_asconf",
236 .data = &init_net.sctp.default_auto_asconf,
237 .maxlen = sizeof(int),
238 .mode = 0644,
239 .proc_handler = proc_dointvec,
242 .procname = "addip_enable",
243 .data = &init_net.sctp.addip_enable,
244 .maxlen = sizeof(int),
245 .mode = 0644,
246 .proc_handler = proc_dointvec,
249 .procname = "addip_noauth_enable",
250 .data = &init_net.sctp.addip_noauth,
251 .maxlen = sizeof(int),
252 .mode = 0644,
253 .proc_handler = proc_dointvec,
256 .procname = "prsctp_enable",
257 .data = &init_net.sctp.prsctp_enable,
258 .maxlen = sizeof(int),
259 .mode = 0644,
260 .proc_handler = proc_dointvec,
263 .procname = "auth_enable",
264 .data = &init_net.sctp.auth_enable,
265 .maxlen = sizeof(int),
266 .mode = 0644,
267 .proc_handler = proc_sctp_do_auth,
270 .procname = "addr_scope_policy",
271 .data = &init_net.sctp.scope_policy,
272 .maxlen = sizeof(int),
273 .mode = 0644,
274 .proc_handler = proc_dointvec_minmax,
275 .extra1 = &zero,
276 .extra2 = &addr_scope_max,
279 .procname = "rwnd_update_shift",
280 .data = &init_net.sctp.rwnd_upd_shift,
281 .maxlen = sizeof(int),
282 .mode = 0644,
283 .proc_handler = &proc_dointvec_minmax,
284 .extra1 = &one,
285 .extra2 = &rwnd_scale_max,
288 .procname = "max_autoclose",
289 .data = &init_net.sctp.max_autoclose,
290 .maxlen = sizeof(unsigned long),
291 .mode = 0644,
292 .proc_handler = &proc_doulongvec_minmax,
293 .extra1 = &max_autoclose_min,
294 .extra2 = &max_autoclose_max,
297 { /* sentinel */ }
300 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
301 int write,
302 void __user *buffer, size_t *lenp,
303 loff_t *ppos)
305 struct net *net = current->nsproxy->net_ns;
306 struct ctl_table tbl;
307 bool changed = false;
308 char *none = "none";
309 char tmp[8];
310 int ret;
312 memset(&tbl, 0, sizeof(struct ctl_table));
314 if (write) {
315 tbl.data = tmp;
316 tbl.maxlen = sizeof(tmp);
317 } else {
318 tbl.data = net->sctp.sctp_hmac_alg ? : none;
319 tbl.maxlen = strlen(tbl.data);
322 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
323 if (write && ret == 0) {
324 #ifdef CONFIG_CRYPTO_MD5
325 if (!strncmp(tmp, "md5", 3)) {
326 net->sctp.sctp_hmac_alg = "md5";
327 changed = true;
329 #endif
330 #ifdef CONFIG_CRYPTO_SHA1
331 if (!strncmp(tmp, "sha1", 4)) {
332 net->sctp.sctp_hmac_alg = "sha1";
333 changed = true;
335 #endif
336 if (!strncmp(tmp, "none", 4)) {
337 net->sctp.sctp_hmac_alg = NULL;
338 changed = true;
340 if (!changed)
341 ret = -EINVAL;
344 return ret;
347 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
348 void __user *buffer, size_t *lenp,
349 loff_t *ppos)
351 struct net *net = current->nsproxy->net_ns;
352 struct ctl_table tbl;
353 int new_value, ret;
355 memset(&tbl, 0, sizeof(struct ctl_table));
356 tbl.maxlen = sizeof(unsigned int);
358 if (write)
359 tbl.data = &new_value;
360 else
361 tbl.data = &net->sctp.auth_enable;
363 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
364 if (write && ret == 0) {
365 struct sock *sk = net->sctp.ctl_sock;
367 net->sctp.auth_enable = new_value;
368 /* Update the value in the control socket */
369 lock_sock(sk);
370 sctp_sk(sk)->ep->auth_enable = new_value;
371 release_sock(sk);
374 return ret;
377 int sctp_sysctl_net_register(struct net *net)
379 struct ctl_table *table;
380 int i;
382 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
383 if (!table)
384 return -ENOMEM;
386 for (i = 0; table[i].data; i++)
387 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
389 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
390 return 0;
393 void sctp_sysctl_net_unregister(struct net *net)
395 struct ctl_table *table;
397 table = net->sctp.sysctl_header->ctl_table_arg;
398 unregister_net_sysctl_table(net->sctp.sysctl_header);
399 kfree(table);
402 static struct ctl_table_header * sctp_sysctl_header;
404 /* Sysctl registration. */
405 void sctp_sysctl_register(void)
407 sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
410 /* Sysctl deregistration. */
411 void sctp_sysctl_unregister(void)
413 unregister_net_sysctl_table(sctp_sysctl_header);