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
,
69 static int proc_sctp_do_auth(struct ctl_table
*ctl
, int write
,
70 void __user
*buffer
, size_t *lenp
,
73 static ctl_table sctp_table
[] = {
75 .procname
= "sctp_mem",
76 .data
= &sysctl_sctp_mem
,
77 .maxlen
= sizeof(sysctl_sctp_mem
),
79 .proc_handler
= proc_doulongvec_minmax
82 .procname
= "sctp_rmem",
83 .data
= &sysctl_sctp_rmem
,
84 .maxlen
= sizeof(sysctl_sctp_rmem
),
86 .proc_handler
= proc_dointvec
,
89 .procname
= "sctp_wmem",
90 .data
= &sysctl_sctp_wmem
,
91 .maxlen
= sizeof(sysctl_sctp_wmem
),
93 .proc_handler
= proc_dointvec
,
99 static ctl_table sctp_net_table
[] = {
101 .procname
= "rto_initial",
102 .data
= &init_net
.sctp
.rto_initial
,
103 .maxlen
= sizeof(unsigned int),
105 .proc_handler
= proc_dointvec_minmax
,
110 .procname
= "rto_min",
111 .data
= &init_net
.sctp
.rto_min
,
112 .maxlen
= sizeof(unsigned int),
114 .proc_handler
= proc_dointvec_minmax
,
119 .procname
= "rto_max",
120 .data
= &init_net
.sctp
.rto_max
,
121 .maxlen
= sizeof(unsigned int),
123 .proc_handler
= proc_dointvec_minmax
,
128 .procname
= "rto_alpha_exp_divisor",
129 .data
= &init_net
.sctp
.rto_alpha
,
130 .maxlen
= sizeof(int),
132 .proc_handler
= proc_dointvec
,
135 .procname
= "rto_beta_exp_divisor",
136 .data
= &init_net
.sctp
.rto_beta
,
137 .maxlen
= sizeof(int),
139 .proc_handler
= proc_dointvec
,
142 .procname
= "max_burst",
143 .data
= &init_net
.sctp
.max_burst
,
144 .maxlen
= sizeof(int),
146 .proc_handler
= proc_dointvec_minmax
,
151 .procname
= "cookie_preserve_enable",
152 .data
= &init_net
.sctp
.cookie_preserve_enable
,
153 .maxlen
= sizeof(int),
155 .proc_handler
= proc_dointvec
,
158 .procname
= "cookie_hmac_alg",
161 .proc_handler
= proc_sctp_do_hmac_alg
,
164 .procname
= "valid_cookie_life",
165 .data
= &init_net
.sctp
.valid_cookie_life
,
166 .maxlen
= sizeof(unsigned int),
168 .proc_handler
= proc_dointvec_minmax
,
173 .procname
= "sack_timeout",
174 .data
= &init_net
.sctp
.sack_timeout
,
175 .maxlen
= sizeof(int),
177 .proc_handler
= proc_dointvec_minmax
,
178 .extra1
= &sack_timer_min
,
179 .extra2
= &sack_timer_max
,
182 .procname
= "hb_interval",
183 .data
= &init_net
.sctp
.hb_interval
,
184 .maxlen
= sizeof(unsigned int),
186 .proc_handler
= proc_dointvec_minmax
,
191 .procname
= "association_max_retrans",
192 .data
= &init_net
.sctp
.max_retrans_association
,
193 .maxlen
= sizeof(int),
195 .proc_handler
= proc_dointvec_minmax
,
200 .procname
= "path_max_retrans",
201 .data
= &init_net
.sctp
.max_retrans_path
,
202 .maxlen
= sizeof(int),
204 .proc_handler
= proc_dointvec_minmax
,
209 .procname
= "max_init_retransmits",
210 .data
= &init_net
.sctp
.max_retrans_init
,
211 .maxlen
= sizeof(int),
213 .proc_handler
= proc_dointvec_minmax
,
218 .procname
= "pf_retrans",
219 .data
= &init_net
.sctp
.pf_retrans
,
220 .maxlen
= sizeof(int),
222 .proc_handler
= proc_dointvec_minmax
,
227 .procname
= "sndbuf_policy",
228 .data
= &init_net
.sctp
.sndbuf_policy
,
229 .maxlen
= sizeof(int),
231 .proc_handler
= proc_dointvec
,
234 .procname
= "rcvbuf_policy",
235 .data
= &init_net
.sctp
.rcvbuf_policy
,
236 .maxlen
= sizeof(int),
238 .proc_handler
= proc_dointvec
,
241 .procname
= "default_auto_asconf",
242 .data
= &init_net
.sctp
.default_auto_asconf
,
243 .maxlen
= sizeof(int),
245 .proc_handler
= proc_dointvec
,
248 .procname
= "addip_enable",
249 .data
= &init_net
.sctp
.addip_enable
,
250 .maxlen
= sizeof(int),
252 .proc_handler
= proc_dointvec
,
255 .procname
= "addip_noauth_enable",
256 .data
= &init_net
.sctp
.addip_noauth
,
257 .maxlen
= sizeof(int),
259 .proc_handler
= proc_dointvec
,
262 .procname
= "prsctp_enable",
263 .data
= &init_net
.sctp
.prsctp_enable
,
264 .maxlen
= sizeof(int),
266 .proc_handler
= proc_dointvec
,
269 .procname
= "auth_enable",
270 .data
= &init_net
.sctp
.auth_enable
,
271 .maxlen
= sizeof(int),
273 .proc_handler
= proc_sctp_do_auth
,
276 .procname
= "addr_scope_policy",
277 .data
= &init_net
.sctp
.scope_policy
,
278 .maxlen
= sizeof(int),
280 .proc_handler
= proc_dointvec_minmax
,
282 .extra2
= &addr_scope_max
,
285 .procname
= "rwnd_update_shift",
286 .data
= &init_net
.sctp
.rwnd_upd_shift
,
287 .maxlen
= sizeof(int),
289 .proc_handler
= &proc_dointvec_minmax
,
291 .extra2
= &rwnd_scale_max
,
294 .procname
= "max_autoclose",
295 .data
= &init_net
.sctp
.max_autoclose
,
296 .maxlen
= sizeof(unsigned long),
298 .proc_handler
= &proc_doulongvec_minmax
,
299 .extra1
= &max_autoclose_min
,
300 .extra2
= &max_autoclose_max
,
306 static int proc_sctp_do_hmac_alg(ctl_table
*ctl
,
308 void __user
*buffer
, size_t *lenp
,
311 struct net
*net
= current
->nsproxy
->net_ns
;
318 memset(&tbl
, 0, sizeof(struct ctl_table
));
324 tbl
.data
= net
->sctp
.sctp_hmac_alg
? : none
;
325 tbl
.maxlen
= strlen(tbl
.data
);
327 ret
= proc_dostring(&tbl
, write
, buffer
, lenp
, ppos
);
330 #ifdef CONFIG_CRYPTO_MD5
331 if (!strncmp(tmp
, "md5", 3)) {
332 net
->sctp
.sctp_hmac_alg
= "md5";
336 #ifdef CONFIG_CRYPTO_SHA1
337 if (!strncmp(tmp
, "sha1", 4)) {
338 net
->sctp
.sctp_hmac_alg
= "sha1";
342 if (!strncmp(tmp
, "none", 4)) {
343 net
->sctp
.sctp_hmac_alg
= NULL
;
354 static int proc_sctp_do_auth(struct ctl_table
*ctl
, int write
,
355 void __user
*buffer
, size_t *lenp
,
358 struct net
*net
= current
->nsproxy
->net_ns
;
359 struct ctl_table tbl
;
362 memset(&tbl
, 0, sizeof(struct ctl_table
));
363 tbl
.maxlen
= sizeof(unsigned int);
366 tbl
.data
= &new_value
;
368 tbl
.data
= &net
->sctp
.auth_enable
;
370 ret
= proc_dointvec(&tbl
, write
, buffer
, lenp
, ppos
);
371 if (write
&& ret
== 0) {
372 struct sock
*sk
= net
->sctp
.ctl_sock
;
374 net
->sctp
.auth_enable
= new_value
;
375 /* Update the value in the control socket */
377 sctp_sk(sk
)->ep
->auth_enable
= new_value
;
384 int sctp_sysctl_net_register(struct net
*net
)
386 struct ctl_table
*table
;
389 table
= kmemdup(sctp_net_table
, sizeof(sctp_net_table
), GFP_KERNEL
);
393 for (i
= 0; table
[i
].data
; i
++)
394 table
[i
].data
+= (char *)(&net
->sctp
) - (char *)&init_net
.sctp
;
396 net
->sctp
.sysctl_header
= register_net_sysctl(net
, "net/sctp", table
);
400 void sctp_sysctl_net_unregister(struct net
*net
)
402 struct ctl_table
*table
;
404 table
= net
->sctp
.sysctl_header
->ctl_table_arg
;
405 unregister_net_sysctl_table(net
->sctp
.sysctl_header
);
409 static struct ctl_table_header
* sctp_sysctl_header
;
411 /* Sysctl registration. */
412 void sctp_sysctl_register(void)
414 sctp_sysctl_header
= register_net_sysctl(&init_net
, "net/sctp", sctp_table
);
417 /* Sysctl deregistration. */
418 void sctp_sysctl_unregister(void)
420 unregister_net_sysctl_table(sctp_sysctl_header
);