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