blob: ba75ef4669e35d9e8d279ff37b8aeabb03be4a84 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* SCTP kernel reference Implementation
2 * (C) Copyright IBM Corp. 2002, 2004
3 * Copyright (c) 2002 Intel Corp.
4 *
5 * This file is part of the SCTP kernel reference Implementation
6 *
7 * Sysctl related interfaces for SCTP.
8 *
9 * The SCTP reference 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)
13 * any later version.
14 *
15 * The SCTP reference 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.
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;
Vlad Yasevich2f85a422005-06-28 13:24:23 -070052static long sack_timer_min = 1;
53static long sack_timer_max = 500;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Neil Horman4d93df02007-08-15 16:07:44 -070055int sysctl_sctp_mem[3];
56int sysctl_sctp_rmem[3];
57int sysctl_sctp_wmem[3];
58
59/*
60 * per assoc memory limitationf for sends
61 */
62int sysctl_sctp_wmem[3];
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064static ctl_table sctp_table[] = {
65 {
66 .ctl_name = NET_SCTP_RTO_INITIAL,
67 .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,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070071 .proc_handler = &proc_dointvec_minmax,
72 .strategy = &sysctl_intvec,
73 .extra1 = &one,
74 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 },
76 {
77 .ctl_name = NET_SCTP_RTO_MIN,
78 .procname = "rto_min",
79 .data = &sctp_rto_min,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070080 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070082 .proc_handler = &proc_dointvec_minmax,
83 .strategy = &sysctl_intvec,
84 .extra1 = &one,
85 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 },
87 {
88 .ctl_name = NET_SCTP_RTO_MAX,
89 .procname = "rto_max",
90 .data = &sctp_rto_max,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070091 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -070093 .proc_handler = &proc_dointvec_minmax,
94 .strategy = &sysctl_intvec,
95 .extra1 = &one,
96 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 },
98 {
99 .ctl_name = NET_SCTP_VALID_COOKIE_LIFE,
100 .procname = "valid_cookie_life",
101 .data = &sctp_valid_cookie_life,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700102 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700104 .proc_handler = &proc_dointvec_minmax,
105 .strategy = &sysctl_intvec,
106 .extra1 = &one,
107 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 },
109 {
110 .ctl_name = NET_SCTP_MAX_BURST,
111 .procname = "max_burst",
112 .data = &sctp_max_burst,
113 .maxlen = sizeof(int),
114 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700115 .proc_handler = &proc_dointvec_minmax,
116 .strategy = &sysctl_intvec,
117 .extra1 = &zero,
118 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 },
120 {
121 .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS,
122 .procname = "association_max_retrans",
123 .data = &sctp_max_retrans_association,
124 .maxlen = sizeof(int),
125 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700126 .proc_handler = &proc_dointvec_minmax,
127 .strategy = &sysctl_intvec,
128 .extra1 = &one,
129 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 },
131 {
Neil Horman4eb701d2005-04-28 12:02:04 -0700132 .ctl_name = NET_SCTP_SNDBUF_POLICY,
133 .procname = "sndbuf_policy",
134 .data = &sctp_sndbuf_policy,
135 .maxlen = sizeof(int),
136 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700137 .proc_handler = &proc_dointvec,
138 .strategy = &sysctl_intvec
Neil Horman4eb701d2005-04-28 12:02:04 -0700139 },
140 {
Neil Horman049b3ff2005-11-11 16:08:24 -0800141 .ctl_name = NET_SCTP_RCVBUF_POLICY,
142 .procname = "rcvbuf_policy",
143 .data = &sctp_rcvbuf_policy,
144 .maxlen = sizeof(int),
145 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700146 .proc_handler = &proc_dointvec,
147 .strategy = &sysctl_intvec
Neil Horman049b3ff2005-11-11 16:08:24 -0800148 },
149 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
151 .procname = "path_max_retrans",
152 .data = &sctp_max_retrans_path,
153 .maxlen = sizeof(int),
154 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700155 .proc_handler = &proc_dointvec_minmax,
156 .strategy = &sysctl_intvec,
157 .extra1 = &one,
158 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 },
160 {
161 .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS,
162 .procname = "max_init_retransmits",
163 .data = &sctp_max_retrans_init,
164 .maxlen = sizeof(int),
165 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700166 .proc_handler = &proc_dointvec_minmax,
167 .strategy = &sysctl_intvec,
168 .extra1 = &one,
169 .extra2 = &int_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 },
171 {
172 .ctl_name = NET_SCTP_HB_INTERVAL,
173 .procname = "hb_interval",
174 .data = &sctp_hb_interval,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700175 .maxlen = sizeof(unsigned int),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700177 .proc_handler = &proc_dointvec_minmax,
178 .strategy = &sysctl_intvec,
179 .extra1 = &one,
180 .extra2 = &timer_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 },
182 {
183 .ctl_name = NET_SCTP_PRESERVE_ENABLE,
184 .procname = "cookie_preserve_enable",
185 .data = &sctp_cookie_preserve_enable,
Vlad Yasevich8116ffa2006-01-17 11:55:17 -0800186 .maxlen = sizeof(int),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700188 .proc_handler = &proc_dointvec,
189 .strategy = &sysctl_intvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 },
191 {
192 .ctl_name = NET_SCTP_RTO_ALPHA,
193 .procname = "rto_alpha_exp_divisor",
194 .data = &sctp_rto_alpha,
195 .maxlen = sizeof(int),
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700196 .mode = 0444,
197 .proc_handler = &proc_dointvec,
198 .strategy = &sysctl_intvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 },
200 {
201 .ctl_name = NET_SCTP_RTO_BETA,
202 .procname = "rto_beta_exp_divisor",
203 .data = &sctp_rto_beta,
204 .maxlen = sizeof(int),
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700205 .mode = 0444,
206 .proc_handler = &proc_dointvec,
207 .strategy = &sysctl_intvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 },
209 {
210 .ctl_name = NET_SCTP_ADDIP_ENABLE,
211 .procname = "addip_enable",
212 .data = &sctp_addip_enable,
213 .maxlen = sizeof(int),
214 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700215 .proc_handler = &proc_dointvec,
216 .strategy = &sysctl_intvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 },
218 {
219 .ctl_name = NET_SCTP_PRSCTP_ENABLE,
220 .procname = "prsctp_enable",
221 .data = &sctp_prsctp_enable,
222 .maxlen = sizeof(int),
223 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700224 .proc_handler = &proc_dointvec,
225 .strategy = &sysctl_intvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 },
Vlad Yasevich2f85a422005-06-28 13:24:23 -0700227 {
228 .ctl_name = NET_SCTP_SACK_TIMEOUT,
229 .procname = "sack_timeout",
230 .data = &sctp_sack_timeout,
231 .maxlen = sizeof(long),
232 .mode = 0644,
Vladislav Yasevich3fd091e2006-08-22 13:29:17 -0700233 .proc_handler = &proc_dointvec_minmax,
234 .strategy = &sysctl_intvec,
Vlad Yasevich2f85a422005-06-28 13:24:23 -0700235 .extra1 = &sack_timer_min,
236 .extra2 = &sack_timer_max,
237 },
Neil Horman4d93df02007-08-15 16:07:44 -0700238 {
239 .ctl_name = CTL_UNNUMBERED,
240 .procname = "sctp_mem",
241 .data = &sysctl_sctp_mem,
242 .maxlen = sizeof(sysctl_sctp_mem),
243 .mode = 0644,
244 .proc_handler = &proc_dointvec,
245 },
246 {
247 .ctl_name = CTL_UNNUMBERED,
248 .procname = "sctp_rmem",
249 .data = &sysctl_sctp_rmem,
250 .maxlen = sizeof(sysctl_sctp_rmem),
251 .mode = 0644,
252 .proc_handler = &proc_dointvec,
253 },
254 {
255 .ctl_name = CTL_UNNUMBERED,
256 .procname = "sctp_wmem",
257 .data = &sysctl_sctp_wmem,
258 .maxlen = sizeof(sysctl_sctp_wmem),
259 .mode = 0644,
260 .proc_handler = &proc_dointvec,
261 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 { .ctl_name = 0 }
263};
264
265static ctl_table sctp_net_table[] = {
266 {
267 .ctl_name = NET_SCTP,
268 .procname = "sctp",
269 .mode = 0555,
270 .child = sctp_table
271 },
272 { .ctl_name = 0 }
273};
274
275static ctl_table sctp_root_table[] = {
276 {
277 .ctl_name = CTL_NET,
278 .procname = "net",
279 .mode = 0555,
280 .child = sctp_net_table
281 },
282 { .ctl_name = 0 }
283};
284
285static struct ctl_table_header * sctp_sysctl_header;
286
287/* Sysctl registration. */
288void sctp_sysctl_register(void)
289{
Eric W. Biederman0b4d4142007-02-14 00:34:09 -0800290 sctp_sysctl_header = register_sysctl_table(sctp_root_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291}
292
293/* Sysctl deregistration. */
294void sctp_sysctl_unregister(void)
295{
296 unregister_sysctl_table(sctp_sysctl_header);
297}