blob: 2b2bfe933ff14413aa4970391eb25d038ff3d90a [file] [log] [blame]
Vlad Yasevich60c778b2008-01-11 09:57:09 -05001/* SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * (C) Copyright IBM Corp. 2002, 2004
3 * Copyright (c) 2002 Intel Corp.
4 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -05005 * This file is part of the SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * Sysctl related interfaces for SCTP.
8 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -05009 * This SCTP implementation is free software;
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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)
13 * any later version.
14 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050015 * This SCTP implementation is distributed in the hope that it
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 * 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.
20 *
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.
25 *
26 * Please send any bug reports or fixes you make to the
27 * email address(es):
28 * lksctp developers <lksctp-developers@lists.sourceforge.net>
29 *
30 * Or submit a bug report through the following website:
31 * http://www.sf.net/projects/lksctp
32 *
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>
39 *
40 * Any bugs reported given to us we will try to fix... any fixes shared will
41 * be incorporated into the next SCTP release.
42 */
43
44#include <net/sctp/structs.h>
Adrian Bunk8c5955d2005-09-05 18:07:42 -070045#include <net/sctp/sctp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/sysctl.h>
47
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070048static int zero = 0;
49static int one = 1;
50static int timer_max = 86400000; /* ms in one day */
51static int int_max = INT_MAX;
Jean-Mickael Guerind48e0742009-05-13 00:03:20 +020052static int sack_timer_min = 1;
53static int sack_timer_max = 500;
Bhaskar Dutta72388432009-09-03 17:25:47 +053054static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
Vlad Yasevich90f2f532009-11-23 15:53:57 -050055static int rwnd_scale_max = 16;
Xi Wang2692ba62011-12-16 12:44:15 +000056static unsigned long max_autoclose_min = 0;
57static unsigned long max_autoclose_max =
58 (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
59 ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Eric Dumazet8d987e52010-11-09 23:24:26 +000061extern long sysctl_sctp_mem[3];
Vlad Yasevich007e3932007-09-16 16:04:37 -070062extern int sysctl_sctp_rmem[3];
63extern int sysctl_sctp_wmem[3];
Neil Horman4d93df02007-08-15 16:07:44 -070064
Linus Torvalds1da177e2005-04-16 15:20:36 -070065static ctl_table sctp_table[] = {
66 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 .procname = "rto_initial",
68 .data = &sctp_rto_initial,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070069 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080071 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070072 .extra1 = &one,
73 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 },
75 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 .procname = "rto_min",
77 .data = &sctp_rto_min,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070078 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080080 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070081 .extra1 = &one,
82 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 },
84 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 .procname = "rto_max",
86 .data = &sctp_rto_max,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070087 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080089 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070090 .extra1 = &one,
91 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 },
93 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 .procname = "valid_cookie_life",
95 .data = &sctp_valid_cookie_life,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070096 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080098 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070099 .extra1 = &one,
100 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 },
102 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 .procname = "max_burst",
104 .data = &sctp_max_burst,
105 .maxlen = sizeof(int),
106 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800107 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700108 .extra1 = &zero,
109 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 },
111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 .procname = "association_max_retrans",
113 .data = &sctp_max_retrans_association,
114 .maxlen = sizeof(int),
115 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800116 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700117 .extra1 = &one,
118 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 },
120 {
Neil Horman4eb701d2005-04-28 12:02:04 -0700121 .procname = "sndbuf_policy",
122 .data = &sctp_sndbuf_policy,
123 .maxlen = sizeof(int),
124 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800125 .proc_handler = proc_dointvec,
Neil Horman4eb701d2005-04-28 12:02:04 -0700126 },
127 {
Neil Horman049b3ff2005-11-11 16:08:24 -0800128 .procname = "rcvbuf_policy",
129 .data = &sctp_rcvbuf_policy,
130 .maxlen = sizeof(int),
131 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800132 .proc_handler = proc_dointvec,
Neil Horman049b3ff2005-11-11 16:08:24 -0800133 },
134 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 .procname = "path_max_retrans",
136 .data = &sctp_max_retrans_path,
137 .maxlen = sizeof(int),
138 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800139 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700140 .extra1 = &one,
141 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 },
143 {
Neil Horman5aa93bc2012-07-21 07:56:07 +0000144 .procname = "pf_retrans",
145 .data = &sctp_pf_retrans,
146 .maxlen = sizeof(int),
147 .mode = 0644,
148 .proc_handler = proc_dointvec_minmax,
149 .extra1 = &zero,
150 .extra2 = &int_max
151 },
152 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 .procname = "max_init_retransmits",
154 .data = &sctp_max_retrans_init,
155 .maxlen = sizeof(int),
156 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800157 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700158 .extra1 = &one,
159 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 },
161 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 .procname = "hb_interval",
163 .data = &sctp_hb_interval,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700164 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800166 .proc_handler = proc_dointvec_minmax,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700167 .extra1 = &one,
168 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 },
170 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 .procname = "cookie_preserve_enable",
172 .data = &sctp_cookie_preserve_enable,
Vlad Yasevich8116ffa2006-01-17 11:55:17 -0800173 .maxlen = sizeof(int),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800175 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 },
177 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 .procname = "rto_alpha_exp_divisor",
179 .data = &sctp_rto_alpha,
180 .maxlen = sizeof(int),
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700181 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800182 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 },
184 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 .procname = "rto_beta_exp_divisor",
186 .data = &sctp_rto_beta,
187 .maxlen = sizeof(int),
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700188 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800189 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 },
191 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 .procname = "addip_enable",
193 .data = &sctp_addip_enable,
194 .maxlen = sizeof(int),
195 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800196 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 },
198 {
Michio Hondadd51be02011-04-26 17:36:05 +0900199 .procname = "default_auto_asconf",
200 .data = &sctp_default_auto_asconf,
201 .maxlen = sizeof(int),
202 .mode = 0644,
203 .proc_handler = proc_dointvec,
204 },
205 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 .procname = "prsctp_enable",
207 .data = &sctp_prsctp_enable,
208 .maxlen = sizeof(int),
209 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800210 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 },
Vlad Yasevich2f85a422005-06-28 13:24:23 -0700212 {
Vlad Yasevich2f85a422005-06-28 13:24:23 -0700213 .procname = "sack_timeout",
214 .data = &sctp_sack_timeout,
Jean-Mickael Guerind48e0742009-05-13 00:03:20 +0200215 .maxlen = sizeof(int),
Vlad Yasevich2f85a422005-06-28 13:24:23 -0700216 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800217 .proc_handler = proc_dointvec_minmax,
Vlad Yasevich2f85a422005-06-28 13:24:23 -0700218 .extra1 = &sack_timer_min,
219 .extra2 = &sack_timer_max,
220 },
Neil Horman4d93df02007-08-15 16:07:44 -0700221 {
Neil Horman4d93df02007-08-15 16:07:44 -0700222 .procname = "sctp_mem",
223 .data = &sysctl_sctp_mem,
224 .maxlen = sizeof(sysctl_sctp_mem),
225 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000226 .proc_handler = proc_doulongvec_minmax
Neil Horman4d93df02007-08-15 16:07:44 -0700227 },
228 {
Neil Horman4d93df02007-08-15 16:07:44 -0700229 .procname = "sctp_rmem",
230 .data = &sysctl_sctp_rmem,
231 .maxlen = sizeof(sysctl_sctp_rmem),
232 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800233 .proc_handler = proc_dointvec,
Neil Horman4d93df02007-08-15 16:07:44 -0700234 },
235 {
Neil Horman4d93df02007-08-15 16:07:44 -0700236 .procname = "sctp_wmem",
237 .data = &sysctl_sctp_wmem,
238 .maxlen = sizeof(sysctl_sctp_wmem),
239 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800240 .proc_handler = proc_dointvec,
Neil Horman4d93df02007-08-15 16:07:44 -0700241 },
Vlad Yasevicha29a5bd2007-09-16 19:31:35 -0700242 {
Vlad Yasevicha29a5bd2007-09-16 19:31:35 -0700243 .procname = "auth_enable",
244 .data = &sctp_auth_enable,
245 .maxlen = sizeof(int),
246 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800247 .proc_handler = proc_dointvec,
Vlad Yasevicha29a5bd2007-09-16 19:31:35 -0700248 },
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400249 {
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400250 .procname = "addip_noauth_enable",
251 .data = &sctp_addip_noauth,
252 .maxlen = sizeof(int),
253 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800254 .proc_handler = proc_dointvec,
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400255 },
Bhaskar Dutta72388432009-09-03 17:25:47 +0530256 {
Bhaskar Dutta72388432009-09-03 17:25:47 +0530257 .procname = "addr_scope_policy",
258 .data = &sctp_scope_policy,
259 .maxlen = sizeof(int),
260 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800261 .proc_handler = proc_dointvec_minmax,
Bhaskar Dutta72388432009-09-03 17:25:47 +0530262 .extra1 = &zero,
263 .extra2 = &addr_scope_max,
264 },
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500265 {
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500266 .procname = "rwnd_update_shift",
267 .data = &sctp_rwnd_upd_shift,
268 .maxlen = sizeof(int),
269 .mode = 0644,
270 .proc_handler = &proc_dointvec_minmax,
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500271 .extra1 = &one,
272 .extra2 = &rwnd_scale_max,
273 },
Xi Wang2692ba62011-12-16 12:44:15 +0000274 {
275 .procname = "max_autoclose",
276 .data = &sctp_max_autoclose,
277 .maxlen = sizeof(unsigned long),
278 .mode = 0644,
279 .proc_handler = &proc_doulongvec_minmax,
280 .extra1 = &max_autoclose_min,
281 .extra2 = &max_autoclose_max,
282 },
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500283
Linus Torvaldsd7fc02c2009-12-08 07:55:01 -0800284 { /* sentinel */ }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285};
286
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287static struct ctl_table_header * sctp_sysctl_header;
288
289/* Sysctl registration. */
290void sctp_sysctl_register(void)
291{
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000292 sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293}
294
295/* Sysctl deregistration. */
296void sctp_sysctl_unregister(void)
297{
Eric W. Biederman5dd3df12012-04-19 13:24:33 +0000298 unregister_net_sysctl_table(sctp_sysctl_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299}