]>
Commit | Line | Data |
---|---|---|
60c778b2 | 1 | /* SCTP kernel implementation |
1da177e4 LT |
2 | * (C) Copyright IBM Corp. 2002, 2004 |
3 | * Copyright (c) 2002 Intel Corp. | |
4 | * | |
60c778b2 | 5 | * This file is part of the SCTP kernel implementation |
1da177e4 LT |
6 | * |
7 | * Sysctl related interfaces for SCTP. | |
8 | * | |
60c778b2 | 9 | * This SCTP implementation is free software; |
1da177e4 LT |
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) | |
13 | * any later version. | |
14 | * | |
60c778b2 | 15 | * This SCTP implementation is distributed in the hope that it |
1da177e4 LT |
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. | |
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): | |
91705c61 | 28 | * lksctp developers <[email protected]> |
1da177e4 | 29 | * |
1da177e4 LT |
30 | * Written or modified by: |
31 | * Mingqin Liu <[email protected]> | |
32 | * Jon Grimm <[email protected]> | |
33 | * Ardelle Fan <[email protected]> | |
34 | * Ryan Layer <[email protected]> | |
35 | * Sridhar Samudrala <[email protected]> | |
1da177e4 LT |
36 | */ |
37 | ||
38 | #include <net/sctp/structs.h> | |
8c5955d8 | 39 | #include <net/sctp/sctp.h> |
1da177e4 LT |
40 | #include <linux/sysctl.h> |
41 | ||
3fd091e7 VY |
42 | static int zero = 0; |
43 | static int one = 1; | |
44 | static int timer_max = 86400000; /* ms in one day */ | |
45 | static int int_max = INT_MAX; | |
d48e074d JMG |
46 | static int sack_timer_min = 1; |
47 | static int sack_timer_max = 500; | |
72388433 | 48 | static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ |
90f2f531 | 49 | static int rwnd_scale_max = 16; |
2692ba61 XW |
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; | |
1da177e4 | 54 | |
8d987e5c | 55 | extern long sysctl_sctp_mem[3]; |
007e3936 VY |
56 | extern int sysctl_sctp_rmem[3]; |
57 | extern int sysctl_sctp_wmem[3]; | |
4d93df0a | 58 | |
fe2c6338 | 59 | static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, |
3c68198e NH |
60 | int write, |
61 | void __user *buffer, size_t *lenp, | |
62 | ||
63 | loff_t *ppos); | |
fe2c6338 | 64 | static struct ctl_table sctp_table[] = { |
e1fc3b14 EB |
65 | { |
66 | .procname = "sctp_mem", | |
67 | .data = &sysctl_sctp_mem, | |
68 | .maxlen = sizeof(sysctl_sctp_mem), | |
69 | .mode = 0644, | |
70 | .proc_handler = proc_doulongvec_minmax | |
71 | }, | |
72 | { | |
73 | .procname = "sctp_rmem", | |
74 | .data = &sysctl_sctp_rmem, | |
75 | .maxlen = sizeof(sysctl_sctp_rmem), | |
76 | .mode = 0644, | |
77 | .proc_handler = proc_dointvec, | |
78 | }, | |
79 | { | |
80 | .procname = "sctp_wmem", | |
81 | .data = &sysctl_sctp_wmem, | |
82 | .maxlen = sizeof(sysctl_sctp_wmem), | |
83 | .mode = 0644, | |
84 | .proc_handler = proc_dointvec, | |
85 | }, | |
86 | ||
87 | { /* sentinel */ } | |
88 | }; | |
89 | ||
fe2c6338 | 90 | static struct ctl_table sctp_net_table[] = { |
1da177e4 | 91 | { |
1da177e4 | 92 | .procname = "rto_initial", |
e1fc3b14 | 93 | .data = &init_net.sctp.rto_initial, |
3fd091e7 | 94 | .maxlen = sizeof(unsigned int), |
1da177e4 | 95 | .mode = 0644, |
6d9f239a | 96 | .proc_handler = proc_dointvec_minmax, |
3fd091e7 VY |
97 | .extra1 = &one, |
98 | .extra2 = &timer_max | |
1da177e4 LT |
99 | }, |
100 | { | |
1da177e4 | 101 | .procname = "rto_min", |
e1fc3b14 | 102 | .data = &init_net.sctp.rto_min, |
3fd091e7 | 103 | .maxlen = sizeof(unsigned int), |
1da177e4 | 104 | .mode = 0644, |
6d9f239a | 105 | .proc_handler = proc_dointvec_minmax, |
3fd091e7 VY |
106 | .extra1 = &one, |
107 | .extra2 = &timer_max | |
1da177e4 LT |
108 | }, |
109 | { | |
1da177e4 | 110 | .procname = "rto_max", |
e1fc3b14 | 111 | .data = &init_net.sctp.rto_max, |
3fd091e7 | 112 | .maxlen = sizeof(unsigned int), |
1da177e4 | 113 | .mode = 0644, |
6d9f239a | 114 | .proc_handler = proc_dointvec_minmax, |
3fd091e7 VY |
115 | .extra1 = &one, |
116 | .extra2 = &timer_max | |
1da177e4 LT |
117 | }, |
118 | { | |
e1fc3b14 EB |
119 | .procname = "rto_alpha_exp_divisor", |
120 | .data = &init_net.sctp.rto_alpha, | |
121 | .maxlen = sizeof(int), | |
122 | .mode = 0444, | |
123 | .proc_handler = proc_dointvec, | |
124 | }, | |
125 | { | |
126 | .procname = "rto_beta_exp_divisor", | |
127 | .data = &init_net.sctp.rto_beta, | |
128 | .maxlen = sizeof(int), | |
129 | .mode = 0444, | |
130 | .proc_handler = proc_dointvec, | |
1da177e4 LT |
131 | }, |
132 | { | |
1da177e4 | 133 | .procname = "max_burst", |
e1fc3b14 | 134 | .data = &init_net.sctp.max_burst, |
1da177e4 LT |
135 | .maxlen = sizeof(int), |
136 | .mode = 0644, | |
6d9f239a | 137 | .proc_handler = proc_dointvec_minmax, |
3fd091e7 VY |
138 | .extra1 = &zero, |
139 | .extra2 = &int_max | |
1da177e4 LT |
140 | }, |
141 | { | |
e1fc3b14 EB |
142 | .procname = "cookie_preserve_enable", |
143 | .data = &init_net.sctp.cookie_preserve_enable, | |
1da177e4 LT |
144 | .maxlen = sizeof(int), |
145 | .mode = 0644, | |
e1fc3b14 EB |
146 | .proc_handler = proc_dointvec, |
147 | }, | |
3c68198e NH |
148 | { |
149 | .procname = "cookie_hmac_alg", | |
150 | .maxlen = 8, | |
151 | .mode = 0644, | |
152 | .proc_handler = proc_sctp_do_hmac_alg, | |
153 | }, | |
e1fc3b14 EB |
154 | { |
155 | .procname = "valid_cookie_life", | |
156 | .data = &init_net.sctp.valid_cookie_life, | |
157 | .maxlen = sizeof(unsigned int), | |
158 | .mode = 0644, | |
6d9f239a | 159 | .proc_handler = proc_dointvec_minmax, |
e1fc3b14 EB |
160 | .extra1 = &one, |
161 | .extra2 = &timer_max | |
1da177e4 | 162 | }, |
4eb701df | 163 | { |
e1fc3b14 EB |
164 | .procname = "sack_timeout", |
165 | .data = &init_net.sctp.sack_timeout, | |
4eb701df NH |
166 | .maxlen = sizeof(int), |
167 | .mode = 0644, | |
e1fc3b14 EB |
168 | .proc_handler = proc_dointvec_minmax, |
169 | .extra1 = &sack_timer_min, | |
170 | .extra2 = &sack_timer_max, | |
4eb701df | 171 | }, |
049b3ff5 | 172 | { |
e1fc3b14 EB |
173 | .procname = "hb_interval", |
174 | .data = &init_net.sctp.hb_interval, | |
175 | .maxlen = sizeof(unsigned int), | |
049b3ff5 | 176 | .mode = 0644, |
e1fc3b14 EB |
177 | .proc_handler = proc_dointvec_minmax, |
178 | .extra1 = &one, | |
179 | .extra2 = &timer_max | |
049b3ff5 | 180 | }, |
1da177e4 | 181 | { |
e1fc3b14 EB |
182 | .procname = "association_max_retrans", |
183 | .data = &init_net.sctp.max_retrans_association, | |
1da177e4 LT |
184 | .maxlen = sizeof(int), |
185 | .mode = 0644, | |
6d9f239a | 186 | .proc_handler = proc_dointvec_minmax, |
3fd091e7 VY |
187 | .extra1 = &one, |
188 | .extra2 = &int_max | |
1da177e4 | 189 | }, |
5aa93bcf | 190 | { |
e1fc3b14 EB |
191 | .procname = "path_max_retrans", |
192 | .data = &init_net.sctp.max_retrans_path, | |
5aa93bcf NH |
193 | .maxlen = sizeof(int), |
194 | .mode = 0644, | |
195 | .proc_handler = proc_dointvec_minmax, | |
e1fc3b14 | 196 | .extra1 = &one, |
5aa93bcf NH |
197 | .extra2 = &int_max |
198 | }, | |
1da177e4 | 199 | { |
1da177e4 | 200 | .procname = "max_init_retransmits", |
e1fc3b14 | 201 | .data = &init_net.sctp.max_retrans_init, |
1da177e4 LT |
202 | .maxlen = sizeof(int), |
203 | .mode = 0644, | |
6d9f239a | 204 | .proc_handler = proc_dointvec_minmax, |
3fd091e7 VY |
205 | .extra1 = &one, |
206 | .extra2 = &int_max | |
1da177e4 LT |
207 | }, |
208 | { | |
e1fc3b14 EB |
209 | .procname = "pf_retrans", |
210 | .data = &init_net.sctp.pf_retrans, | |
211 | .maxlen = sizeof(int), | |
1da177e4 | 212 | .mode = 0644, |
6d9f239a | 213 | .proc_handler = proc_dointvec_minmax, |
e1fc3b14 EB |
214 | .extra1 = &zero, |
215 | .extra2 = &int_max | |
1da177e4 LT |
216 | }, |
217 | { | |
e1fc3b14 EB |
218 | .procname = "sndbuf_policy", |
219 | .data = &init_net.sctp.sndbuf_policy, | |
8116ffad | 220 | .maxlen = sizeof(int), |
1da177e4 | 221 | .mode = 0644, |
6d9f239a | 222 | .proc_handler = proc_dointvec, |
1da177e4 LT |
223 | }, |
224 | { | |
e1fc3b14 EB |
225 | .procname = "rcvbuf_policy", |
226 | .data = &init_net.sctp.rcvbuf_policy, | |
dd51be0f MH |
227 | .maxlen = sizeof(int), |
228 | .mode = 0644, | |
229 | .proc_handler = proc_dointvec, | |
230 | }, | |
231 | { | |
232 | .procname = "default_auto_asconf", | |
e1fc3b14 | 233 | .data = &init_net.sctp.default_auto_asconf, |
1da177e4 LT |
234 | .maxlen = sizeof(int), |
235 | .mode = 0644, | |
6d9f239a | 236 | .proc_handler = proc_dointvec, |
1da177e4 LT |
237 | }, |
238 | { | |
e1fc3b14 EB |
239 | .procname = "addip_enable", |
240 | .data = &init_net.sctp.addip_enable, | |
1da177e4 LT |
241 | .maxlen = sizeof(int), |
242 | .mode = 0644, | |
6d9f239a | 243 | .proc_handler = proc_dointvec, |
1da177e4 | 244 | }, |
2f85a429 | 245 | { |
e1fc3b14 EB |
246 | .procname = "addip_noauth_enable", |
247 | .data = &init_net.sctp.addip_noauth, | |
d48e074d | 248 | .maxlen = sizeof(int), |
2f85a429 | 249 | .mode = 0644, |
6d9f239a | 250 | .proc_handler = proc_dointvec, |
4d93df0a NH |
251 | }, |
252 | { | |
e1fc3b14 EB |
253 | .procname = "prsctp_enable", |
254 | .data = &init_net.sctp.prsctp_enable, | |
a29a5bd4 VY |
255 | .maxlen = sizeof(int), |
256 | .mode = 0644, | |
6d9f239a | 257 | .proc_handler = proc_dointvec, |
a29a5bd4 | 258 | }, |
73d9c4fd | 259 | { |
e1fc3b14 EB |
260 | .procname = "auth_enable", |
261 | .data = &init_net.sctp.auth_enable, | |
73d9c4fd VY |
262 | .maxlen = sizeof(int), |
263 | .mode = 0644, | |
6d9f239a | 264 | .proc_handler = proc_dointvec, |
73d9c4fd | 265 | }, |
72388433 | 266 | { |
72388433 | 267 | .procname = "addr_scope_policy", |
e1fc3b14 | 268 | .data = &init_net.sctp.scope_policy, |
72388433 BD |
269 | .maxlen = sizeof(int), |
270 | .mode = 0644, | |
6d456111 | 271 | .proc_handler = proc_dointvec_minmax, |
72388433 BD |
272 | .extra1 = &zero, |
273 | .extra2 = &addr_scope_max, | |
274 | }, | |
90f2f531 | 275 | { |
90f2f531 | 276 | .procname = "rwnd_update_shift", |
e1fc3b14 | 277 | .data = &init_net.sctp.rwnd_upd_shift, |
90f2f531 VY |
278 | .maxlen = sizeof(int), |
279 | .mode = 0644, | |
280 | .proc_handler = &proc_dointvec_minmax, | |
90f2f531 VY |
281 | .extra1 = &one, |
282 | .extra2 = &rwnd_scale_max, | |
283 | }, | |
2692ba61 XW |
284 | { |
285 | .procname = "max_autoclose", | |
e1fc3b14 | 286 | .data = &init_net.sctp.max_autoclose, |
2692ba61 XW |
287 | .maxlen = sizeof(unsigned long), |
288 | .mode = 0644, | |
289 | .proc_handler = &proc_doulongvec_minmax, | |
290 | .extra1 = &max_autoclose_min, | |
291 | .extra2 = &max_autoclose_max, | |
292 | }, | |
71acc0dd | 293 | |
d7fc02c7 | 294 | { /* sentinel */ } |
1da177e4 LT |
295 | }; |
296 | ||
fe2c6338 | 297 | static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, |
3c68198e NH |
298 | int write, |
299 | void __user *buffer, size_t *lenp, | |
300 | loff_t *ppos) | |
301 | { | |
302 | struct net *net = current->nsproxy->net_ns; | |
303 | char tmp[8]; | |
fe2c6338 | 304 | struct ctl_table tbl; |
3c68198e NH |
305 | int ret; |
306 | int changed = 0; | |
307 | char *none = "none"; | |
308 | ||
309 | memset(&tbl, 0, sizeof(struct ctl_table)); | |
310 | ||
311 | if (write) { | |
312 | tbl.data = tmp; | |
313 | tbl.maxlen = 8; | |
314 | } else { | |
315 | tbl.data = net->sctp.sctp_hmac_alg ? : none; | |
316 | tbl.maxlen = strlen(tbl.data); | |
317 | } | |
318 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); | |
319 | ||
320 | if (write) { | |
321 | #ifdef CONFIG_CRYPTO_MD5 | |
322 | if (!strncmp(tmp, "md5", 3)) { | |
323 | net->sctp.sctp_hmac_alg = "md5"; | |
324 | changed = 1; | |
325 | } | |
326 | #endif | |
327 | #ifdef CONFIG_CRYPTO_SHA1 | |
328 | if (!strncmp(tmp, "sha1", 4)) { | |
329 | net->sctp.sctp_hmac_alg = "sha1"; | |
330 | changed = 1; | |
331 | } | |
332 | #endif | |
333 | if (!strncmp(tmp, "none", 4)) { | |
334 | net->sctp.sctp_hmac_alg = NULL; | |
335 | changed = 1; | |
336 | } | |
337 | ||
338 | if (!changed) | |
339 | ret = -EINVAL; | |
340 | } | |
341 | ||
342 | return ret; | |
343 | } | |
344 | ||
ebb7e95d EB |
345 | int sctp_sysctl_net_register(struct net *net) |
346 | { | |
347 | struct ctl_table *table; | |
e1fc3b14 | 348 | int i; |
ebb7e95d EB |
349 | |
350 | table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); | |
351 | if (!table) | |
352 | return -ENOMEM; | |
353 | ||
e1fc3b14 EB |
354 | for (i = 0; table[i].data; i++) |
355 | table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; | |
356 | ||
ebb7e95d EB |
357 | net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); |
358 | return 0; | |
359 | } | |
360 | ||
361 | void sctp_sysctl_net_unregister(struct net *net) | |
362 | { | |
5f19d121 VY |
363 | struct ctl_table *table; |
364 | ||
365 | table = net->sctp.sysctl_header->ctl_table_arg; | |
ebb7e95d | 366 | unregister_net_sysctl_table(net->sctp.sysctl_header); |
5f19d121 | 367 | kfree(table); |
ebb7e95d EB |
368 | } |
369 | ||
1da177e4 LT |
370 | static struct ctl_table_header * sctp_sysctl_header; |
371 | ||
372 | /* Sysctl registration. */ | |
373 | void sctp_sysctl_register(void) | |
374 | { | |
ec8f23ce | 375 | sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table); |
1da177e4 LT |
376 | } |
377 | ||
378 | /* Sysctl deregistration. */ | |
379 | void sctp_sysctl_unregister(void) | |
380 | { | |
5dd3df10 | 381 | unregister_net_sysctl_table(sctp_sysctl_header); |
1da177e4 | 382 | } |