[SCTP]: Rewrite of sctp buffer management code
[linux-2.6.git] / net / sctp / sysctl.c
1 /* 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>
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 long sack_timer_min = 1;
53 static long sack_timer_max = 500;
54
55 int sysctl_sctp_mem[3];
56 int sysctl_sctp_rmem[3];
57 int sysctl_sctp_wmem[3];
58
59 /*
60  * per assoc memory limitationf for sends
61  */
62 int sysctl_sctp_wmem[3];
63
64 static ctl_table sctp_table[] = {
65         {
66                 .ctl_name       = NET_SCTP_RTO_INITIAL,
67                 .procname       = "rto_initial",
68                 .data           = &sctp_rto_initial,
69                 .maxlen         = sizeof(unsigned int),
70                 .mode           = 0644,
71                 .proc_handler   = &proc_dointvec_minmax,
72                 .strategy       = &sysctl_intvec,
73                 .extra1         = &one,
74                 .extra2         = &timer_max
75         },
76         {
77                 .ctl_name       = NET_SCTP_RTO_MIN,
78                 .procname       = "rto_min",
79                 .data           = &sctp_rto_min,
80                 .maxlen         = sizeof(unsigned int),
81                 .mode           = 0644,
82                 .proc_handler   = &proc_dointvec_minmax,
83                 .strategy       = &sysctl_intvec,
84                 .extra1         = &one,
85                 .extra2         = &timer_max
86         },
87         {
88                 .ctl_name       = NET_SCTP_RTO_MAX,
89                 .procname       = "rto_max",
90                 .data           = &sctp_rto_max,
91                 .maxlen         = sizeof(unsigned int),
92                 .mode           = 0644,
93                 .proc_handler   = &proc_dointvec_minmax,
94                 .strategy       = &sysctl_intvec,
95                 .extra1         = &one,
96                 .extra2         = &timer_max
97         },
98         {
99                 .ctl_name       = NET_SCTP_VALID_COOKIE_LIFE,
100                 .procname       = "valid_cookie_life",
101                 .data           = &sctp_valid_cookie_life,
102                 .maxlen         = sizeof(unsigned int),
103                 .mode           = 0644,
104                 .proc_handler   = &proc_dointvec_minmax,
105                 .strategy       = &sysctl_intvec,
106                 .extra1         = &one,
107                 .extra2         = &timer_max
108         },
109         {
110                 .ctl_name       = NET_SCTP_MAX_BURST,
111                 .procname       = "max_burst",
112                 .data           = &sctp_max_burst,
113                 .maxlen         = sizeof(int),
114                 .mode           = 0644,
115                 .proc_handler   = &proc_dointvec_minmax,
116                 .strategy       = &sysctl_intvec,
117                 .extra1         = &zero,
118                 .extra2         = &int_max
119         },
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,
126                 .proc_handler   = &proc_dointvec_minmax,
127                 .strategy       = &sysctl_intvec,
128                 .extra1         = &one,
129                 .extra2         = &int_max
130         },
131         {
132                 .ctl_name       = NET_SCTP_SNDBUF_POLICY,
133                 .procname       = "sndbuf_policy",
134                 .data           = &sctp_sndbuf_policy,
135                 .maxlen         = sizeof(int),
136                 .mode           = 0644,
137                 .proc_handler   = &proc_dointvec,
138                 .strategy       = &sysctl_intvec
139         },
140         {
141                 .ctl_name       = NET_SCTP_RCVBUF_POLICY,
142                 .procname       = "rcvbuf_policy",
143                 .data           = &sctp_rcvbuf_policy,
144                 .maxlen         = sizeof(int),
145                 .mode           = 0644,
146                 .proc_handler   = &proc_dointvec,
147                 .strategy       = &sysctl_intvec
148         },
149         {
150                 .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,
155                 .proc_handler   = &proc_dointvec_minmax,
156                 .strategy       = &sysctl_intvec,
157                 .extra1         = &one,
158                 .extra2         = &int_max
159         },
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,
166                 .proc_handler   = &proc_dointvec_minmax,
167                 .strategy       = &sysctl_intvec,
168                 .extra1         = &one,
169                 .extra2         = &int_max
170         },
171         {
172                 .ctl_name       = NET_SCTP_HB_INTERVAL,
173                 .procname       = "hb_interval",
174                 .data           = &sctp_hb_interval,
175                 .maxlen         = sizeof(unsigned int),
176                 .mode           = 0644,
177                 .proc_handler   = &proc_dointvec_minmax,
178                 .strategy       = &sysctl_intvec,
179                 .extra1         = &one,
180                 .extra2         = &timer_max
181         },
182         {
183                 .ctl_name       = NET_SCTP_PRESERVE_ENABLE,
184                 .procname       = "cookie_preserve_enable",
185                 .data           = &sctp_cookie_preserve_enable,
186                 .maxlen         = sizeof(int),
187                 .mode           = 0644,
188                 .proc_handler   = &proc_dointvec,
189                 .strategy       = &sysctl_intvec
190         },
191         {
192                 .ctl_name       = NET_SCTP_RTO_ALPHA,
193                 .procname       = "rto_alpha_exp_divisor",
194                 .data           = &sctp_rto_alpha,
195                 .maxlen         = sizeof(int),
196                 .mode           = 0444,
197                 .proc_handler   = &proc_dointvec,
198                 .strategy       = &sysctl_intvec
199         },
200         {
201                 .ctl_name       = NET_SCTP_RTO_BETA,
202                 .procname       = "rto_beta_exp_divisor",
203                 .data           = &sctp_rto_beta,
204                 .maxlen         = sizeof(int),
205                 .mode           = 0444,
206                 .proc_handler   = &proc_dointvec,
207                 .strategy       = &sysctl_intvec
208         },
209         {
210                 .ctl_name       = NET_SCTP_ADDIP_ENABLE,
211                 .procname       = "addip_enable",
212                 .data           = &sctp_addip_enable,
213                 .maxlen         = sizeof(int),
214                 .mode           = 0644,
215                 .proc_handler   = &proc_dointvec,
216                 .strategy       = &sysctl_intvec
217         },
218         {
219                 .ctl_name       = NET_SCTP_PRSCTP_ENABLE,
220                 .procname       = "prsctp_enable",
221                 .data           = &sctp_prsctp_enable,
222                 .maxlen         = sizeof(int),
223                 .mode           = 0644,
224                 .proc_handler   = &proc_dointvec,
225                 .strategy       = &sysctl_intvec
226         },
227         {
228                 .ctl_name       = NET_SCTP_SACK_TIMEOUT,
229                 .procname       = "sack_timeout",
230                 .data           = &sctp_sack_timeout,
231                 .maxlen         = sizeof(long),
232                 .mode           = 0644,
233                 .proc_handler   = &proc_dointvec_minmax,
234                 .strategy       = &sysctl_intvec,
235                 .extra1         = &sack_timer_min,
236                 .extra2         = &sack_timer_max,
237         },
238         {
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         },
262         { .ctl_name = 0 }
263 };
264
265 static 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
275 static 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
285 static struct ctl_table_header * sctp_sysctl_header;
286
287 /* Sysctl registration.  */
288 void sctp_sysctl_register(void)
289 {
290         sctp_sysctl_header = register_sysctl_table(sctp_root_table);
291 }
292
293 /* Sysctl deregistration.  */
294 void sctp_sysctl_unregister(void)
295 {
296         unregister_sysctl_table(sctp_sysctl_header);
297 }