blob: 70e3ba5cb50b319319e60c7bfa6fae69bc5c1fed [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 {
Neil Horman4d93df02007-08-15 16:07:44 -070067 .procname = "sctp_mem",
68 .data = &sysctl_sctp_mem,
69 .maxlen = sizeof(sysctl_sctp_mem),
70 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +000071 .proc_handler = proc_doulongvec_minmax
Neil Horman4d93df02007-08-15 16:07:44 -070072 },
73 {
Neil Horman4d93df02007-08-15 16:07:44 -070074 .procname = "sctp_rmem",
75 .data = &sysctl_sctp_rmem,
76 .maxlen = sizeof(sysctl_sctp_rmem),
77 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080078 .proc_handler = proc_dointvec,
Neil Horman4d93df02007-08-15 16:07:44 -070079 },
80 {
Neil Horman4d93df02007-08-15 16:07:44 -070081 .procname = "sctp_wmem",
82 .data = &sysctl_sctp_wmem,
83 .maxlen = sizeof(sysctl_sctp_wmem),
84 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080085 .proc_handler = proc_dointvec,
Neil Horman4d93df02007-08-15 16:07:44 -070086 },
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +000087
88 { /* sentinel */ }
89};
90
91static ctl_table sctp_net_table[] = {
Vlad Yasevicha29a5bd2007-09-16 19:31:35 -070092 {
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +000093 .procname = "rto_initial",
94 .data = &init_net.sctp.rto_initial,
95 .maxlen = sizeof(unsigned int),
96 .mode = 0644,
97 .proc_handler = proc_dointvec_minmax,
98 .extra1 = &one,
99 .extra2 = &timer_max
100 },
101 {
102 .procname = "rto_min",
103 .data = &init_net.sctp.rto_min,
104 .maxlen = sizeof(unsigned int),
105 .mode = 0644,
106 .proc_handler = proc_dointvec_minmax,
107 .extra1 = &one,
108 .extra2 = &timer_max
109 },
110 {
111 .procname = "rto_max",
112 .data = &init_net.sctp.rto_max,
113 .maxlen = sizeof(unsigned int),
114 .mode = 0644,
115 .proc_handler = proc_dointvec_minmax,
116 .extra1 = &one,
117 .extra2 = &timer_max
118 },
119 {
120 .procname = "rto_alpha_exp_divisor",
121 .data = &init_net.sctp.rto_alpha,
122 .maxlen = sizeof(int),
123 .mode = 0444,
124 .proc_handler = proc_dointvec,
125 },
126 {
127 .procname = "rto_beta_exp_divisor",
128 .data = &init_net.sctp.rto_beta,
129 .maxlen = sizeof(int),
130 .mode = 0444,
131 .proc_handler = proc_dointvec,
132 },
133 {
134 .procname = "max_burst",
135 .data = &init_net.sctp.max_burst,
136 .maxlen = sizeof(int),
137 .mode = 0644,
138 .proc_handler = proc_dointvec_minmax,
139 .extra1 = &zero,
140 .extra2 = &int_max
141 },
142 {
143 .procname = "cookie_preserve_enable",
144 .data = &init_net.sctp.cookie_preserve_enable,
145 .maxlen = sizeof(int),
146 .mode = 0644,
147 .proc_handler = proc_dointvec,
148 },
149 {
150 .procname = "valid_cookie_life",
151 .data = &init_net.sctp.valid_cookie_life,
152 .maxlen = sizeof(unsigned int),
153 .mode = 0644,
154 .proc_handler = proc_dointvec_minmax,
155 .extra1 = &one,
156 .extra2 = &timer_max
157 },
158 {
159 .procname = "sack_timeout",
160 .data = &init_net.sctp.sack_timeout,
161 .maxlen = sizeof(int),
162 .mode = 0644,
163 .proc_handler = proc_dointvec_minmax,
164 .extra1 = &sack_timer_min,
165 .extra2 = &sack_timer_max,
166 },
167 {
168 .procname = "hb_interval",
169 .data = &init_net.sctp.hb_interval,
170 .maxlen = sizeof(unsigned int),
171 .mode = 0644,
172 .proc_handler = proc_dointvec_minmax,
173 .extra1 = &one,
174 .extra2 = &timer_max
175 },
176 {
177 .procname = "association_max_retrans",
178 .data = &init_net.sctp.max_retrans_association,
179 .maxlen = sizeof(int),
180 .mode = 0644,
181 .proc_handler = proc_dointvec_minmax,
182 .extra1 = &one,
183 .extra2 = &int_max
184 },
185 {
186 .procname = "path_max_retrans",
187 .data = &init_net.sctp.max_retrans_path,
188 .maxlen = sizeof(int),
189 .mode = 0644,
190 .proc_handler = proc_dointvec_minmax,
191 .extra1 = &one,
192 .extra2 = &int_max
193 },
194 {
195 .procname = "max_init_retransmits",
196 .data = &init_net.sctp.max_retrans_init,
197 .maxlen = sizeof(int),
198 .mode = 0644,
199 .proc_handler = proc_dointvec_minmax,
200 .extra1 = &one,
201 .extra2 = &int_max
202 },
203 {
204 .procname = "pf_retrans",
205 .data = &init_net.sctp.pf_retrans,
206 .maxlen = sizeof(int),
207 .mode = 0644,
208 .proc_handler = proc_dointvec_minmax,
209 .extra1 = &zero,
210 .extra2 = &int_max
211 },
212 {
213 .procname = "sndbuf_policy",
214 .data = &init_net.sctp.sndbuf_policy,
215 .maxlen = sizeof(int),
216 .mode = 0644,
217 .proc_handler = proc_dointvec,
218 },
219 {
220 .procname = "rcvbuf_policy",
221 .data = &init_net.sctp.rcvbuf_policy,
222 .maxlen = sizeof(int),
223 .mode = 0644,
224 .proc_handler = proc_dointvec,
225 },
226 {
227 .procname = "default_auto_asconf",
228 .data = &init_net.sctp.default_auto_asconf,
229 .maxlen = sizeof(int),
230 .mode = 0644,
231 .proc_handler = proc_dointvec,
232 },
233 {
234 .procname = "addip_enable",
235 .data = &init_net.sctp.addip_enable,
Vlad Yasevicha29a5bd2007-09-16 19:31:35 -0700236 .maxlen = sizeof(int),
237 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800238 .proc_handler = proc_dointvec,
Vlad Yasevicha29a5bd2007-09-16 19:31:35 -0700239 },
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400240 {
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400241 .procname = "addip_noauth_enable",
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +0000242 .data = &init_net.sctp.addip_noauth,
243 .maxlen = sizeof(int),
244 .mode = 0644,
245 .proc_handler = proc_dointvec,
246 },
247 {
248 .procname = "prsctp_enable",
249 .data = &init_net.sctp.prsctp_enable,
250 .maxlen = sizeof(int),
251 .mode = 0644,
252 .proc_handler = proc_dointvec,
253 },
254 {
255 .procname = "auth_enable",
256 .data = &init_net.sctp.auth_enable,
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400257 .maxlen = sizeof(int),
258 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800259 .proc_handler = proc_dointvec,
Vlad Yasevich73d9c4f2007-10-24 17:24:26 -0400260 },
Bhaskar Dutta72388432009-09-03 17:25:47 +0530261 {
Bhaskar Dutta72388432009-09-03 17:25:47 +0530262 .procname = "addr_scope_policy",
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +0000263 .data = &init_net.sctp.scope_policy,
Bhaskar Dutta72388432009-09-03 17:25:47 +0530264 .maxlen = sizeof(int),
265 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800266 .proc_handler = proc_dointvec_minmax,
Bhaskar Dutta72388432009-09-03 17:25:47 +0530267 .extra1 = &zero,
268 .extra2 = &addr_scope_max,
269 },
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500270 {
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500271 .procname = "rwnd_update_shift",
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +0000272 .data = &init_net.sctp.rwnd_upd_shift,
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500273 .maxlen = sizeof(int),
274 .mode = 0644,
275 .proc_handler = &proc_dointvec_minmax,
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500276 .extra1 = &one,
277 .extra2 = &rwnd_scale_max,
278 },
Xi Wang2692ba62011-12-16 12:44:15 +0000279 {
280 .procname = "max_autoclose",
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +0000281 .data = &init_net.sctp.max_autoclose,
Xi Wang2692ba62011-12-16 12:44:15 +0000282 .maxlen = sizeof(unsigned long),
283 .mode = 0644,
284 .proc_handler = &proc_doulongvec_minmax,
285 .extra1 = &max_autoclose_min,
286 .extra2 = &max_autoclose_max,
287 },
Vlad Yasevich90f2f532009-11-23 15:53:57 -0500288
Linus Torvaldsd7fc02c2009-12-08 07:55:01 -0800289 { /* sentinel */ }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290};
291
Eric W. Biedermanebb7e952012-08-07 07:23:59 +0000292int sctp_sysctl_net_register(struct net *net)
293{
294 struct ctl_table *table;
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +0000295 int i;
Eric W. Biedermanebb7e952012-08-07 07:23:59 +0000296
297 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
298 if (!table)
299 return -ENOMEM;
300
Eric W. Biedermane1fc3b12012-08-07 07:29:57 +0000301 for (i = 0; table[i].data; i++)
302 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
303
Eric W. Biedermanebb7e952012-08-07 07:23:59 +0000304 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
305 return 0;
306}
307
308void sctp_sysctl_net_unregister(struct net *net)
309{
310 unregister_net_sysctl_table(net->sctp.sysctl_header);
311}
312
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313static struct ctl_table_header * sctp_sysctl_header;
314
315/* Sysctl registration. */
316void sctp_sysctl_register(void)
317{
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000318 sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319}
320
321/* Sysctl deregistration. */
322void sctp_sysctl_unregister(void)
323{
Eric W. Biederman5dd3df12012-04-19 13:24:33 +0000324 unregister_net_sysctl_table(sctp_sysctl_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325}