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)
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
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>
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, int write,
60 void __user *buffer, size_t *lenp,
62 static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
63 void __user *buffer, size_t *lenp,
65 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
66 void __user *buffer, size_t *lenp,
69 static struct ctl_table sctp_table[] = {
71 .procname = "sctp_mem",
72 .data = &sysctl_sctp_mem,
73 .maxlen = sizeof(sysctl_sctp_mem),
75 .proc_handler = proc_doulongvec_minmax
78 .procname = "sctp_rmem",
79 .data = &sysctl_sctp_rmem,
80 .maxlen = sizeof(sysctl_sctp_rmem),
82 .proc_handler = proc_dointvec,
85 .procname = "sctp_wmem",
86 .data = &sysctl_sctp_wmem,
87 .maxlen = sizeof(sysctl_sctp_wmem),
89 .proc_handler = proc_dointvec,
95 static struct ctl_table sctp_net_table[] = {
97 .procname = "rto_initial",
98 .data = &init_net.sctp.rto_initial,
99 .maxlen = sizeof(unsigned int),
101 .proc_handler = proc_dointvec_minmax,
106 .procname = "rto_min",
107 .data = &init_net.sctp.rto_min,
108 .maxlen = sizeof(unsigned int),
110 .proc_handler = proc_sctp_do_rto_min,
112 .extra2 = &init_net.sctp.rto_max
115 .procname = "rto_max",
116 .data = &init_net.sctp.rto_max,
117 .maxlen = sizeof(unsigned int),
119 .proc_handler = proc_sctp_do_rto_max,
120 .extra1 = &init_net.sctp.rto_min,
124 .procname = "rto_alpha_exp_divisor",
125 .data = &init_net.sctp.rto_alpha,
126 .maxlen = sizeof(int),
128 .proc_handler = proc_dointvec,
131 .procname = "rto_beta_exp_divisor",
132 .data = &init_net.sctp.rto_beta,
133 .maxlen = sizeof(int),
135 .proc_handler = proc_dointvec,
138 .procname = "max_burst",
139 .data = &init_net.sctp.max_burst,
140 .maxlen = sizeof(int),
142 .proc_handler = proc_dointvec_minmax,
147 .procname = "cookie_preserve_enable",
148 .data = &init_net.sctp.cookie_preserve_enable,
149 .maxlen = sizeof(int),
151 .proc_handler = proc_dointvec,
154 .procname = "cookie_hmac_alg",
157 .proc_handler = proc_sctp_do_hmac_alg,
160 .procname = "valid_cookie_life",
161 .data = &init_net.sctp.valid_cookie_life,
162 .maxlen = sizeof(unsigned int),
164 .proc_handler = proc_dointvec_minmax,
169 .procname = "sack_timeout",
170 .data = &init_net.sctp.sack_timeout,
171 .maxlen = sizeof(int),
173 .proc_handler = proc_dointvec_minmax,
174 .extra1 = &sack_timer_min,
175 .extra2 = &sack_timer_max,
178 .procname = "hb_interval",
179 .data = &init_net.sctp.hb_interval,
180 .maxlen = sizeof(unsigned int),
182 .proc_handler = proc_dointvec_minmax,
187 .procname = "association_max_retrans",
188 .data = &init_net.sctp.max_retrans_association,
189 .maxlen = sizeof(int),
191 .proc_handler = proc_dointvec_minmax,
196 .procname = "path_max_retrans",
197 .data = &init_net.sctp.max_retrans_path,
198 .maxlen = sizeof(int),
200 .proc_handler = proc_dointvec_minmax,
205 .procname = "max_init_retransmits",
206 .data = &init_net.sctp.max_retrans_init,
207 .maxlen = sizeof(int),
209 .proc_handler = proc_dointvec_minmax,
214 .procname = "pf_retrans",
215 .data = &init_net.sctp.pf_retrans,
216 .maxlen = sizeof(int),
218 .proc_handler = proc_dointvec_minmax,
223 .procname = "sndbuf_policy",
224 .data = &init_net.sctp.sndbuf_policy,
225 .maxlen = sizeof(int),
227 .proc_handler = proc_dointvec,
230 .procname = "rcvbuf_policy",
231 .data = &init_net.sctp.rcvbuf_policy,
232 .maxlen = sizeof(int),
234 .proc_handler = proc_dointvec,
237 .procname = "default_auto_asconf",
238 .data = &init_net.sctp.default_auto_asconf,
239 .maxlen = sizeof(int),
241 .proc_handler = proc_dointvec,
244 .procname = "addip_enable",
245 .data = &init_net.sctp.addip_enable,
246 .maxlen = sizeof(int),
248 .proc_handler = proc_dointvec,
251 .procname = "addip_noauth_enable",
252 .data = &init_net.sctp.addip_noauth,
253 .maxlen = sizeof(int),
255 .proc_handler = proc_dointvec,
258 .procname = "prsctp_enable",
259 .data = &init_net.sctp.prsctp_enable,
260 .maxlen = sizeof(int),
262 .proc_handler = proc_dointvec,
265 .procname = "auth_enable",
266 .data = &init_net.sctp.auth_enable,
267 .maxlen = sizeof(int),
269 .proc_handler = proc_dointvec,
272 .procname = "addr_scope_policy",
273 .data = &init_net.sctp.scope_policy,
274 .maxlen = sizeof(int),
276 .proc_handler = proc_dointvec_minmax,
278 .extra2 = &addr_scope_max,
281 .procname = "rwnd_update_shift",
282 .data = &init_net.sctp.rwnd_upd_shift,
283 .maxlen = sizeof(int),
285 .proc_handler = &proc_dointvec_minmax,
287 .extra2 = &rwnd_scale_max,
290 .procname = "max_autoclose",
291 .data = &init_net.sctp.max_autoclose,
292 .maxlen = sizeof(unsigned long),
294 .proc_handler = &proc_doulongvec_minmax,
295 .extra1 = &max_autoclose_min,
296 .extra2 = &max_autoclose_max,
302 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
303 void __user *buffer, size_t *lenp,
306 struct net *net = current->nsproxy->net_ns;
308 struct ctl_table tbl;
313 memset(&tbl, 0, sizeof(struct ctl_table));
319 tbl.data = net->sctp.sctp_hmac_alg ? : none;
320 tbl.maxlen = strlen(tbl.data);
322 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
325 #ifdef CONFIG_CRYPTO_MD5
326 if (!strncmp(tmp, "md5", 3)) {
327 net->sctp.sctp_hmac_alg = "md5";
331 #ifdef CONFIG_CRYPTO_SHA1
332 if (!strncmp(tmp, "sha1", 4)) {
333 net->sctp.sctp_hmac_alg = "sha1";
337 if (!strncmp(tmp, "none", 4)) {
338 net->sctp.sctp_hmac_alg = NULL;
349 static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
350 void __user *buffer, size_t *lenp,
353 struct net *net = current->nsproxy->net_ns;
355 struct ctl_table tbl;
356 unsigned int min = *(unsigned int *) ctl->extra1;
357 unsigned int max = *(unsigned int *) ctl->extra2;
360 memset(&tbl, 0, sizeof(struct ctl_table));
361 tbl.maxlen = sizeof(unsigned int);
364 tbl.data = &new_value;
366 tbl.data = &net->sctp.rto_min;
367 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
369 if (ret || new_value > max || new_value < min)
371 net->sctp.rto_min = new_value;
376 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
377 void __user *buffer, size_t *lenp,
380 struct net *net = current->nsproxy->net_ns;
382 struct ctl_table tbl;
383 unsigned int min = *(unsigned int *) ctl->extra1;
384 unsigned int max = *(unsigned int *) ctl->extra2;
387 memset(&tbl, 0, sizeof(struct ctl_table));
388 tbl.maxlen = sizeof(unsigned int);
391 tbl.data = &new_value;
393 tbl.data = &net->sctp.rto_max;
394 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
396 if (ret || new_value > max || new_value < min)
398 net->sctp.rto_max = new_value;
403 int sctp_sysctl_net_register(struct net *net)
405 struct ctl_table *table;
408 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
412 for (i = 0; table[i].data; i++)
413 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
415 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
419 void sctp_sysctl_net_unregister(struct net *net)
421 struct ctl_table *table;
423 table = net->sctp.sysctl_header->ctl_table_arg;
424 unregister_net_sysctl_table(net->sctp.sysctl_header);
428 static struct ctl_table_header * sctp_sysctl_header;
430 /* Sysctl registration. */
431 void sctp_sysctl_register(void)
433 sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
436 /* Sysctl deregistration. */
437 void sctp_sysctl_unregister(void)
439 unregister_net_sysctl_table(sctp_sysctl_header);