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
,
63 static int proc_sctp_do_auth(struct ctl_table
*ctl
, int write
,
64 void __user
*buffer
, size_t *lenp
,
67 static struct ctl_table sctp_table
[] = {
69 .procname
= "sctp_mem",
70 .data
= &sysctl_sctp_mem
,
71 .maxlen
= sizeof(sysctl_sctp_mem
),
73 .proc_handler
= proc_doulongvec_minmax
76 .procname
= "sctp_rmem",
77 .data
= &sysctl_sctp_rmem
,
78 .maxlen
= sizeof(sysctl_sctp_rmem
),
80 .proc_handler
= proc_dointvec
,
83 .procname
= "sctp_wmem",
84 .data
= &sysctl_sctp_wmem
,
85 .maxlen
= sizeof(sysctl_sctp_wmem
),
87 .proc_handler
= proc_dointvec
,
93 static struct ctl_table sctp_net_table
[] = {
95 .procname
= "rto_initial",
96 .data
= &init_net
.sctp
.rto_initial
,
97 .maxlen
= sizeof(unsigned int),
99 .proc_handler
= proc_dointvec_minmax
,
104 .procname
= "rto_min",
105 .data
= &init_net
.sctp
.rto_min
,
106 .maxlen
= sizeof(unsigned int),
108 .proc_handler
= proc_dointvec_minmax
,
113 .procname
= "rto_max",
114 .data
= &init_net
.sctp
.rto_max
,
115 .maxlen
= sizeof(unsigned int),
117 .proc_handler
= proc_dointvec_minmax
,
122 .procname
= "rto_alpha_exp_divisor",
123 .data
= &init_net
.sctp
.rto_alpha
,
124 .maxlen
= sizeof(int),
126 .proc_handler
= proc_dointvec
,
129 .procname
= "rto_beta_exp_divisor",
130 .data
= &init_net
.sctp
.rto_beta
,
131 .maxlen
= sizeof(int),
133 .proc_handler
= proc_dointvec
,
136 .procname
= "max_burst",
137 .data
= &init_net
.sctp
.max_burst
,
138 .maxlen
= sizeof(int),
140 .proc_handler
= proc_dointvec_minmax
,
145 .procname
= "cookie_preserve_enable",
146 .data
= &init_net
.sctp
.cookie_preserve_enable
,
147 .maxlen
= sizeof(int),
149 .proc_handler
= proc_dointvec
,
152 .procname
= "cookie_hmac_alg",
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),
162 .proc_handler
= proc_dointvec_minmax
,
167 .procname
= "sack_timeout",
168 .data
= &init_net
.sctp
.sack_timeout
,
169 .maxlen
= sizeof(int),
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),
180 .proc_handler
= proc_dointvec_minmax
,
185 .procname
= "association_max_retrans",
186 .data
= &init_net
.sctp
.max_retrans_association
,
187 .maxlen
= sizeof(int),
189 .proc_handler
= proc_dointvec_minmax
,
194 .procname
= "path_max_retrans",
195 .data
= &init_net
.sctp
.max_retrans_path
,
196 .maxlen
= sizeof(int),
198 .proc_handler
= proc_dointvec_minmax
,
203 .procname
= "max_init_retransmits",
204 .data
= &init_net
.sctp
.max_retrans_init
,
205 .maxlen
= sizeof(int),
207 .proc_handler
= proc_dointvec_minmax
,
212 .procname
= "pf_retrans",
213 .data
= &init_net
.sctp
.pf_retrans
,
214 .maxlen
= sizeof(int),
216 .proc_handler
= proc_dointvec_minmax
,
221 .procname
= "sndbuf_policy",
222 .data
= &init_net
.sctp
.sndbuf_policy
,
223 .maxlen
= sizeof(int),
225 .proc_handler
= proc_dointvec
,
228 .procname
= "rcvbuf_policy",
229 .data
= &init_net
.sctp
.rcvbuf_policy
,
230 .maxlen
= sizeof(int),
232 .proc_handler
= proc_dointvec
,
235 .procname
= "default_auto_asconf",
236 .data
= &init_net
.sctp
.default_auto_asconf
,
237 .maxlen
= sizeof(int),
239 .proc_handler
= proc_dointvec
,
242 .procname
= "addip_enable",
243 .data
= &init_net
.sctp
.addip_enable
,
244 .maxlen
= sizeof(int),
246 .proc_handler
= proc_dointvec
,
249 .procname
= "addip_noauth_enable",
250 .data
= &init_net
.sctp
.addip_noauth
,
251 .maxlen
= sizeof(int),
253 .proc_handler
= proc_dointvec
,
256 .procname
= "prsctp_enable",
257 .data
= &init_net
.sctp
.prsctp_enable
,
258 .maxlen
= sizeof(int),
260 .proc_handler
= proc_dointvec
,
263 .procname
= "auth_enable",
264 .data
= &init_net
.sctp
.auth_enable
,
265 .maxlen
= sizeof(int),
267 .proc_handler
= proc_sctp_do_auth
,
270 .procname
= "addr_scope_policy",
271 .data
= &init_net
.sctp
.scope_policy
,
272 .maxlen
= sizeof(int),
274 .proc_handler
= proc_dointvec_minmax
,
276 .extra2
= &addr_scope_max
,
279 .procname
= "rwnd_update_shift",
280 .data
= &init_net
.sctp
.rwnd_upd_shift
,
281 .maxlen
= sizeof(int),
283 .proc_handler
= &proc_dointvec_minmax
,
285 .extra2
= &rwnd_scale_max
,
288 .procname
= "max_autoclose",
289 .data
= &init_net
.sctp
.max_autoclose
,
290 .maxlen
= sizeof(unsigned long),
292 .proc_handler
= &proc_doulongvec_minmax
,
293 .extra1
= &max_autoclose_min
,
294 .extra2
= &max_autoclose_max
,
300 static int proc_sctp_do_hmac_alg(struct ctl_table
*ctl
,
302 void __user
*buffer
, size_t *lenp
,
305 struct net
*net
= current
->nsproxy
->net_ns
;
306 struct ctl_table tbl
;
307 bool changed
= false;
312 memset(&tbl
, 0, sizeof(struct ctl_table
));
316 tbl
.maxlen
= sizeof(tmp
);
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";
330 #ifdef CONFIG_CRYPTO_SHA1
331 if (!strncmp(tmp
, "sha1", 4)) {
332 net
->sctp
.sctp_hmac_alg
= "sha1";
336 if (!strncmp(tmp
, "none", 4)) {
337 net
->sctp
.sctp_hmac_alg
= NULL
;
347 static int proc_sctp_do_auth(struct ctl_table
*ctl
, int write
,
348 void __user
*buffer
, size_t *lenp
,
351 struct net
*net
= current
->nsproxy
->net_ns
;
352 struct ctl_table tbl
;
355 memset(&tbl
, 0, sizeof(struct ctl_table
));
356 tbl
.maxlen
= sizeof(unsigned int);
359 tbl
.data
= &new_value
;
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 */
370 sctp_sk(sk
)->ep
->auth_enable
= new_value
;
377 int sctp_sysctl_net_register(struct net
*net
)
379 struct ctl_table
*table
;
382 table
= kmemdup(sctp_net_table
, sizeof(sctp_net_table
), GFP_KERNEL
);
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
);
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
);
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
);