xref: /linux/net/sctp/sysctl.c (revision 6d4561110a3e9fa742aeec6717248a491dfb1878)
1 /* SCTP kernel implementation
2  * (C) Copyright IBM Corp. 2002, 2004
3  * Copyright (c) 2002 Intel Corp.
4  *
5  * This file is part of the SCTP kernel implementation
6  *
7  * Sysctl related interfaces for SCTP.
8  *
9  * This SCTP 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  * This SCTP 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>
45 #include <net/sctp/sctp.h>
46 #include <linux/sysctl.h>
47 
48 static int zero = 0;
49 static int one = 1;
50 static int timer_max = 86400000; /* ms in one day */
51 static int int_max = INT_MAX;
52 static int sack_timer_min = 1;
53 static int sack_timer_max = 500;
54 static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
55 
56 extern int sysctl_sctp_mem[3];
57 extern int sysctl_sctp_rmem[3];
58 extern int sysctl_sctp_wmem[3];
59 
60 static ctl_table sctp_table[] = {
61 	{
62 		.procname	= "rto_initial",
63 		.data		= &sctp_rto_initial,
64 		.maxlen		= sizeof(unsigned int),
65 		.mode		= 0644,
66 		.proc_handler	= proc_dointvec_minmax,
67 		.extra1         = &one,
68 		.extra2         = &timer_max
69 	},
70 	{
71 		.procname	= "rto_min",
72 		.data		= &sctp_rto_min,
73 		.maxlen		= sizeof(unsigned int),
74 		.mode		= 0644,
75 		.proc_handler	= proc_dointvec_minmax,
76 		.extra1         = &one,
77 		.extra2         = &timer_max
78 	},
79 	{
80 		.procname	= "rto_max",
81 		.data		= &sctp_rto_max,
82 		.maxlen		= sizeof(unsigned int),
83 		.mode		= 0644,
84 		.proc_handler	= proc_dointvec_minmax,
85 		.extra1         = &one,
86 		.extra2         = &timer_max
87 	},
88 	{
89 		.procname	= "valid_cookie_life",
90 		.data		= &sctp_valid_cookie_life,
91 		.maxlen		= sizeof(unsigned int),
92 		.mode		= 0644,
93 		.proc_handler	= proc_dointvec_minmax,
94 		.extra1         = &one,
95 		.extra2         = &timer_max
96 	},
97 	{
98 		.procname	= "max_burst",
99 		.data		= &sctp_max_burst,
100 		.maxlen		= sizeof(int),
101 		.mode		= 0644,
102 		.proc_handler	= proc_dointvec_minmax,
103 		.extra1		= &zero,
104 		.extra2		= &int_max
105 	},
106 	{
107 		.procname	= "association_max_retrans",
108 		.data		= &sctp_max_retrans_association,
109 		.maxlen		= sizeof(int),
110 		.mode		= 0644,
111 		.proc_handler	= proc_dointvec_minmax,
112 		.extra1		= &one,
113 		.extra2		= &int_max
114 	},
115 	{
116 		.procname	= "sndbuf_policy",
117 		.data		= &sctp_sndbuf_policy,
118 		.maxlen		= sizeof(int),
119 		.mode		= 0644,
120 		.proc_handler	= proc_dointvec,
121 	},
122 	{
123 		.procname	= "rcvbuf_policy",
124 		.data		= &sctp_rcvbuf_policy,
125 		.maxlen		= sizeof(int),
126 		.mode		= 0644,
127 		.proc_handler	= proc_dointvec,
128 	},
129 	{
130 		.procname	= "path_max_retrans",
131 		.data		= &sctp_max_retrans_path,
132 		.maxlen		= sizeof(int),
133 		.mode		= 0644,
134 		.proc_handler	= proc_dointvec_minmax,
135 		.extra1		= &one,
136 		.extra2		= &int_max
137 	},
138 	{
139 		.procname	= "max_init_retransmits",
140 		.data		= &sctp_max_retrans_init,
141 		.maxlen		= sizeof(int),
142 		.mode		= 0644,
143 		.proc_handler	= proc_dointvec_minmax,
144 		.extra1		= &one,
145 		.extra2		= &int_max
146 	},
147 	{
148 		.procname	= "hb_interval",
149 		.data		= &sctp_hb_interval,
150 		.maxlen		= sizeof(unsigned int),
151 		.mode		= 0644,
152 		.proc_handler	= proc_dointvec_minmax,
153 		.extra1         = &one,
154 		.extra2         = &timer_max
155 	},
156 	{
157 		.procname	= "cookie_preserve_enable",
158 		.data		= &sctp_cookie_preserve_enable,
159 		.maxlen		= sizeof(int),
160 		.mode		= 0644,
161 		.proc_handler	= proc_dointvec,
162 	},
163 	{
164 		.procname	= "rto_alpha_exp_divisor",
165 		.data		= &sctp_rto_alpha,
166 		.maxlen		= sizeof(int),
167 		.mode		= 0444,
168 		.proc_handler	= proc_dointvec,
169 	},
170 	{
171 		.procname	= "rto_beta_exp_divisor",
172 		.data		= &sctp_rto_beta,
173 		.maxlen		= sizeof(int),
174 		.mode		= 0444,
175 		.proc_handler	= proc_dointvec,
176 	},
177 	{
178 		.procname	= "addip_enable",
179 		.data		= &sctp_addip_enable,
180 		.maxlen		= sizeof(int),
181 		.mode		= 0644,
182 		.proc_handler	= proc_dointvec,
183 	},
184 	{
185 		.procname	= "prsctp_enable",
186 		.data		= &sctp_prsctp_enable,
187 		.maxlen		= sizeof(int),
188 		.mode		= 0644,
189 		.proc_handler	= proc_dointvec,
190 	},
191 	{
192 		.procname	= "sack_timeout",
193 		.data		= &sctp_sack_timeout,
194 		.maxlen		= sizeof(int),
195 		.mode		= 0644,
196 		.proc_handler	= proc_dointvec_minmax,
197 		.extra1         = &sack_timer_min,
198 		.extra2         = &sack_timer_max,
199 	},
200 	{
201 		.procname	= "sctp_mem",
202 		.data		= &sysctl_sctp_mem,
203 		.maxlen		= sizeof(sysctl_sctp_mem),
204 		.mode		= 0644,
205 		.proc_handler	= proc_dointvec,
206 	},
207 	{
208 		.procname	= "sctp_rmem",
209 		.data		= &sysctl_sctp_rmem,
210 		.maxlen		= sizeof(sysctl_sctp_rmem),
211 		.mode		= 0644,
212 		.proc_handler	= proc_dointvec,
213 	},
214 	{
215 		.procname	= "sctp_wmem",
216 		.data		= &sysctl_sctp_wmem,
217 		.maxlen		= sizeof(sysctl_sctp_wmem),
218 		.mode		= 0644,
219 		.proc_handler	= proc_dointvec,
220 	},
221 	{
222 		.procname	= "auth_enable",
223 		.data		= &sctp_auth_enable,
224 		.maxlen		= sizeof(int),
225 		.mode		= 0644,
226 		.proc_handler	= proc_dointvec,
227 	},
228 	{
229 		.procname	= "addip_noauth_enable",
230 		.data		= &sctp_addip_noauth,
231 		.maxlen		= sizeof(int),
232 		.mode		= 0644,
233 		.proc_handler	= proc_dointvec,
234 	},
235 	{
236 		.procname	= "addr_scope_policy",
237 		.data		= &sctp_scope_policy,
238 		.maxlen		= sizeof(int),
239 		.mode		= 0644,
240 		.proc_handler	= proc_dointvec_minmax,
241 		.extra1		= &zero,
242 		.extra2		= &addr_scope_max,
243 	},
244 	{ }
245 };
246 
247 static struct ctl_path sctp_path[] = {
248 	{ .procname = "net", },
249 	{ .procname = "sctp", },
250 	{ }
251 };
252 
253 static struct ctl_table_header * sctp_sysctl_header;
254 
255 /* Sysctl registration.  */
256 void sctp_sysctl_register(void)
257 {
258 	sctp_sysctl_header = register_sysctl_paths(sctp_path, sctp_table);
259 }
260 
261 /* Sysctl deregistration.  */
262 void sctp_sysctl_unregister(void)
263 {
264 	unregister_sysctl_table(sctp_sysctl_header);
265 }
266