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 <lksctp-developers@lists.sourceforge.net>
30 * Or submit a bug report through the following website:
31 * http://www.sf.net/projects/lksctp
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>
40 * Any bugs reported given to us we will try to fix... any fixes shared will
41 * be incorporated into the next SCTP release.
44 #include <net/sctp/structs.h>
45 #include <net/sctp/sctp.h>
46 #include <linux/sysctl.h>
50 static int timer_max
= 86400000; /* ms in one day */
51 static int int_max
= INT_MAX
;
52 static int sack_timer_min
= 1;
53 static int sack_timer_max
= 500;
54 static int addr_scope_max
= 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
55 static int rwnd_scale_max
= 16;
56 static unsigned long max_autoclose_min
= 0;
57 static unsigned long max_autoclose_max
=
58 (MAX_SCHEDULE_TIMEOUT
/ HZ
> UINT_MAX
)
59 ? UINT_MAX
: MAX_SCHEDULE_TIMEOUT
/ HZ
;
61 extern long sysctl_sctp_mem
[3];
62 extern int sysctl_sctp_rmem
[3];
63 extern int sysctl_sctp_wmem
[3];
65 static int proc_sctp_do_hmac_alg(ctl_table
*ctl
,
67 void __user
*buffer
, size_t *lenp
,
70 static ctl_table sctp_table
[] = {
72 .procname
= "sctp_mem",
73 .data
= &sysctl_sctp_mem
,
74 .maxlen
= sizeof(sysctl_sctp_mem
),
76 .proc_handler
= proc_doulongvec_minmax
79 .procname
= "sctp_rmem",
80 .data
= &sysctl_sctp_rmem
,
81 .maxlen
= sizeof(sysctl_sctp_rmem
),
83 .proc_handler
= proc_dointvec
,
86 .procname
= "sctp_wmem",
87 .data
= &sysctl_sctp_wmem
,
88 .maxlen
= sizeof(sysctl_sctp_wmem
),
90 .proc_handler
= proc_dointvec
,
96 static ctl_table sctp_net_table
[] = {
98 .procname
= "rto_initial",
99 .data
= &init_net
.sctp
.rto_initial
,
100 .maxlen
= sizeof(unsigned int),
102 .proc_handler
= proc_dointvec_minmax
,
107 .procname
= "rto_min",
108 .data
= &init_net
.sctp
.rto_min
,
109 .maxlen
= sizeof(unsigned int),
111 .proc_handler
= proc_dointvec_minmax
,
116 .procname
= "rto_max",
117 .data
= &init_net
.sctp
.rto_max
,
118 .maxlen
= sizeof(unsigned int),
120 .proc_handler
= proc_dointvec_minmax
,
125 .procname
= "rto_alpha_exp_divisor",
126 .data
= &init_net
.sctp
.rto_alpha
,
127 .maxlen
= sizeof(int),
129 .proc_handler
= proc_dointvec
,
132 .procname
= "rto_beta_exp_divisor",
133 .data
= &init_net
.sctp
.rto_beta
,
134 .maxlen
= sizeof(int),
136 .proc_handler
= proc_dointvec
,
139 .procname
= "max_burst",
140 .data
= &init_net
.sctp
.max_burst
,
141 .maxlen
= sizeof(int),
143 .proc_handler
= proc_dointvec_minmax
,
148 .procname
= "cookie_preserve_enable",
149 .data
= &init_net
.sctp
.cookie_preserve_enable
,
150 .maxlen
= sizeof(int),
152 .proc_handler
= proc_dointvec
,
155 .procname
= "cookie_hmac_alg",
158 .proc_handler
= proc_sctp_do_hmac_alg
,
161 .procname
= "valid_cookie_life",
162 .data
= &init_net
.sctp
.valid_cookie_life
,
163 .maxlen
= sizeof(unsigned int),
165 .proc_handler
= proc_dointvec_minmax
,
170 .procname
= "sack_timeout",
171 .data
= &init_net
.sctp
.sack_timeout
,
172 .maxlen
= sizeof(int),
174 .proc_handler
= proc_dointvec_minmax
,
175 .extra1
= &sack_timer_min
,
176 .extra2
= &sack_timer_max
,
179 .procname
= "hb_interval",
180 .data
= &init_net
.sctp
.hb_interval
,
181 .maxlen
= sizeof(unsigned int),
183 .proc_handler
= proc_dointvec_minmax
,
188 .procname
= "association_max_retrans",
189 .data
= &init_net
.sctp
.max_retrans_association
,
190 .maxlen
= sizeof(int),
192 .proc_handler
= proc_dointvec_minmax
,
197 .procname
= "path_max_retrans",
198 .data
= &init_net
.sctp
.max_retrans_path
,
199 .maxlen
= sizeof(int),
201 .proc_handler
= proc_dointvec_minmax
,
206 .procname
= "max_init_retransmits",
207 .data
= &init_net
.sctp
.max_retrans_init
,
208 .maxlen
= sizeof(int),
210 .proc_handler
= proc_dointvec_minmax
,
215 .procname
= "pf_retrans",
216 .data
= &init_net
.sctp
.pf_retrans
,
217 .maxlen
= sizeof(int),
219 .proc_handler
= proc_dointvec_minmax
,
224 .procname
= "sndbuf_policy",
225 .data
= &init_net
.sctp
.sndbuf_policy
,
226 .maxlen
= sizeof(int),
228 .proc_handler
= proc_dointvec
,
231 .procname
= "rcvbuf_policy",
232 .data
= &init_net
.sctp
.rcvbuf_policy
,
233 .maxlen
= sizeof(int),
235 .proc_handler
= proc_dointvec
,
238 .procname
= "default_auto_asconf",
239 .data
= &init_net
.sctp
.default_auto_asconf
,
240 .maxlen
= sizeof(int),
242 .proc_handler
= proc_dointvec
,
245 .procname
= "addip_enable",
246 .data
= &init_net
.sctp
.addip_enable
,
247 .maxlen
= sizeof(int),
249 .proc_handler
= proc_dointvec
,
252 .procname
= "addip_noauth_enable",
253 .data
= &init_net
.sctp
.addip_noauth
,
254 .maxlen
= sizeof(int),
256 .proc_handler
= proc_dointvec
,
259 .procname
= "prsctp_enable",
260 .data
= &init_net
.sctp
.prsctp_enable
,
261 .maxlen
= sizeof(int),
263 .proc_handler
= proc_dointvec
,
266 .procname
= "auth_enable",
267 .data
= &init_net
.sctp
.auth_enable
,
268 .maxlen
= sizeof(int),
270 .proc_handler
= proc_dointvec
,
273 .procname
= "addr_scope_policy",
274 .data
= &init_net
.sctp
.scope_policy
,
275 .maxlen
= sizeof(int),
277 .proc_handler
= proc_dointvec_minmax
,
279 .extra2
= &addr_scope_max
,
282 .procname
= "rwnd_update_shift",
283 .data
= &init_net
.sctp
.rwnd_upd_shift
,
284 .maxlen
= sizeof(int),
286 .proc_handler
= &proc_dointvec_minmax
,
288 .extra2
= &rwnd_scale_max
,
291 .procname
= "max_autoclose",
292 .data
= &init_net
.sctp
.max_autoclose
,
293 .maxlen
= sizeof(unsigned long),
295 .proc_handler
= &proc_doulongvec_minmax
,
296 .extra1
= &max_autoclose_min
,
297 .extra2
= &max_autoclose_max
,
303 static int proc_sctp_do_hmac_alg(ctl_table
*ctl
,
305 void __user
*buffer
, size_t *lenp
,
308 struct net
*net
= current
->nsproxy
->net_ns
;
315 memset(&tbl
, 0, sizeof(struct ctl_table
));
321 tbl
.data
= net
->sctp
.sctp_hmac_alg
? : none
;
322 tbl
.maxlen
= strlen(tbl
.data
);
324 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
327 #ifdef CONFIG_CRYPTO_MD5
328 if (!strncmp(tmp
, "md5", 3)) {
329 net
->sctp
.sctp_hmac_alg
= "md5";
333 #ifdef CONFIG_CRYPTO_SHA1
334 if (!strncmp(tmp
, "sha1", 4)) {
335 net
->sctp
.sctp_hmac_alg
= "sha1";
339 if (!strncmp(tmp
, "none", 4)) {
340 net
->sctp
.sctp_hmac_alg
= NULL
;
351 int sctp_sysctl_net_register(struct net
*net
)
353 struct ctl_table
*table
;
356 table
= kmemdup(sctp_net_table
, sizeof(sctp_net_table
), GFP_KERNEL
);
360 for (i
= 0; table
[i
].data
; i
++)
361 table
[i
].data
+= (char *)(&net
->sctp
) - (char *)&init_net
.sctp
;
363 net
->sctp
.sysctl_header
= register_net_sysctl(net
, "net/sctp", table
);
367 void sctp_sysctl_net_unregister(struct net
*net
)
369 struct ctl_table
*table
;
371 table
= net
->sctp
.sysctl_header
->ctl_table_arg
;
372 unregister_net_sysctl_table(net
->sctp
.sysctl_header
);
376 static struct ctl_table_header
* sctp_sysctl_header
;
378 /* Sysctl registration. */
379 void sctp_sysctl_register(void)
381 sctp_sysctl_header
= register_net_sysctl(&init_net
, "net/sctp", sctp_table
);
384 /* Sysctl deregistration. */
385 void sctp_sysctl_unregister(void)
387 unregister_net_sysctl_table(sctp_sysctl_header
);