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,
61 void __user *buffer, size_t *lenp,
64 static struct ctl_table sctp_table[] = {
66 .procname = "sctp_mem",
67 .data = &sysctl_sctp_mem,
68 .maxlen = sizeof(sysctl_sctp_mem),
70 .proc_handler = proc_doulongvec_minmax
73 .procname = "sctp_rmem",
74 .data = &sysctl_sctp_rmem,
75 .maxlen = sizeof(sysctl_sctp_rmem),
77 .proc_handler = proc_dointvec,
80 .procname = "sctp_wmem",
81 .data = &sysctl_sctp_wmem,
82 .maxlen = sizeof(sysctl_sctp_wmem),
84 .proc_handler = proc_dointvec,
90 static struct ctl_table sctp_net_table[] = {
92 .procname = "rto_initial",
93 .data = &init_net.sctp.rto_initial,
94 .maxlen = sizeof(unsigned int),
96 .proc_handler = proc_dointvec_minmax,
101 .procname = "rto_min",
102 .data = &init_net.sctp.rto_min,
103 .maxlen = sizeof(unsigned int),
105 .proc_handler = proc_dointvec_minmax,
110 .procname = "rto_max",
111 .data = &init_net.sctp.rto_max,
112 .maxlen = sizeof(unsigned int),
114 .proc_handler = proc_dointvec_minmax,
119 .procname = "rto_alpha_exp_divisor",
120 .data = &init_net.sctp.rto_alpha,
121 .maxlen = sizeof(int),
123 .proc_handler = proc_dointvec,
126 .procname = "rto_beta_exp_divisor",
127 .data = &init_net.sctp.rto_beta,
128 .maxlen = sizeof(int),
130 .proc_handler = proc_dointvec,
133 .procname = "max_burst",
134 .data = &init_net.sctp.max_burst,
135 .maxlen = sizeof(int),
137 .proc_handler = proc_dointvec_minmax,
142 .procname = "cookie_preserve_enable",
143 .data = &init_net.sctp.cookie_preserve_enable,
144 .maxlen = sizeof(int),
146 .proc_handler = proc_dointvec,
149 .procname = "cookie_hmac_alg",
152 .proc_handler = proc_sctp_do_hmac_alg,
155 .procname = "valid_cookie_life",
156 .data = &init_net.sctp.valid_cookie_life,
157 .maxlen = sizeof(unsigned int),
159 .proc_handler = proc_dointvec_minmax,
164 .procname = "sack_timeout",
165 .data = &init_net.sctp.sack_timeout,
166 .maxlen = sizeof(int),
168 .proc_handler = proc_dointvec_minmax,
169 .extra1 = &sack_timer_min,
170 .extra2 = &sack_timer_max,
173 .procname = "hb_interval",
174 .data = &init_net.sctp.hb_interval,
175 .maxlen = sizeof(unsigned int),
177 .proc_handler = proc_dointvec_minmax,
182 .procname = "association_max_retrans",
183 .data = &init_net.sctp.max_retrans_association,
184 .maxlen = sizeof(int),
186 .proc_handler = proc_dointvec_minmax,
191 .procname = "path_max_retrans",
192 .data = &init_net.sctp.max_retrans_path,
193 .maxlen = sizeof(int),
195 .proc_handler = proc_dointvec_minmax,
200 .procname = "max_init_retransmits",
201 .data = &init_net.sctp.max_retrans_init,
202 .maxlen = sizeof(int),
204 .proc_handler = proc_dointvec_minmax,
209 .procname = "pf_retrans",
210 .data = &init_net.sctp.pf_retrans,
211 .maxlen = sizeof(int),
213 .proc_handler = proc_dointvec_minmax,
218 .procname = "sndbuf_policy",
219 .data = &init_net.sctp.sndbuf_policy,
220 .maxlen = sizeof(int),
222 .proc_handler = proc_dointvec,
225 .procname = "rcvbuf_policy",
226 .data = &init_net.sctp.rcvbuf_policy,
227 .maxlen = sizeof(int),
229 .proc_handler = proc_dointvec,
232 .procname = "default_auto_asconf",
233 .data = &init_net.sctp.default_auto_asconf,
234 .maxlen = sizeof(int),
236 .proc_handler = proc_dointvec,
239 .procname = "addip_enable",
240 .data = &init_net.sctp.addip_enable,
241 .maxlen = sizeof(int),
243 .proc_handler = proc_dointvec,
246 .procname = "addip_noauth_enable",
247 .data = &init_net.sctp.addip_noauth,
248 .maxlen = sizeof(int),
250 .proc_handler = proc_dointvec,
253 .procname = "prsctp_enable",
254 .data = &init_net.sctp.prsctp_enable,
255 .maxlen = sizeof(int),
257 .proc_handler = proc_dointvec,
260 .procname = "auth_enable",
261 .data = &init_net.sctp.auth_enable,
262 .maxlen = sizeof(int),
264 .proc_handler = proc_dointvec,
267 .procname = "addr_scope_policy",
268 .data = &init_net.sctp.scope_policy,
269 .maxlen = sizeof(int),
271 .proc_handler = proc_dointvec_minmax,
273 .extra2 = &addr_scope_max,
276 .procname = "rwnd_update_shift",
277 .data = &init_net.sctp.rwnd_upd_shift,
278 .maxlen = sizeof(int),
280 .proc_handler = &proc_dointvec_minmax,
282 .extra2 = &rwnd_scale_max,
285 .procname = "max_autoclose",
286 .data = &init_net.sctp.max_autoclose,
287 .maxlen = sizeof(unsigned long),
289 .proc_handler = &proc_doulongvec_minmax,
290 .extra1 = &max_autoclose_min,
291 .extra2 = &max_autoclose_max,
297 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
299 void __user *buffer, size_t *lenp,
302 struct net *net = current->nsproxy->net_ns;
304 struct ctl_table tbl;
309 memset(&tbl, 0, sizeof(struct ctl_table));
315 tbl.data = net->sctp.sctp_hmac_alg ? : none;
316 tbl.maxlen = strlen(tbl.data);
318 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
321 #ifdef CONFIG_CRYPTO_MD5
322 if (!strncmp(tmp, "md5", 3)) {
323 net->sctp.sctp_hmac_alg = "md5";
327 #ifdef CONFIG_CRYPTO_SHA1
328 if (!strncmp(tmp, "sha1", 4)) {
329 net->sctp.sctp_hmac_alg = "sha1";
333 if (!strncmp(tmp, "none", 4)) {
334 net->sctp.sctp_hmac_alg = NULL;
345 int sctp_sysctl_net_register(struct net *net)
347 struct ctl_table *table;
350 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
354 for (i = 0; table[i].data; i++)
355 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
357 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
361 void sctp_sysctl_net_unregister(struct net *net)
363 struct ctl_table *table;
365 table = net->sctp.sysctl_header->ctl_table_arg;
366 unregister_net_sysctl_table(net->sctp.sysctl_header);
370 static struct ctl_table_header * sctp_sysctl_header;
372 /* Sysctl registration. */
373 void sctp_sysctl_register(void)
375 sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
378 /* Sysctl deregistration. */
379 void sctp_sysctl_unregister(void)
381 unregister_net_sysctl_table(sctp_sysctl_header);