e2c679baf912ad35662837d4a6447057053218be
[linux-3.10.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 static ctl_table sctp_table[] = {
56         {
57                 .ctl_name       = NET_SCTP_RTO_INITIAL,
58                 .procname       = "rto_initial",
59                 .data           = &sctp_rto_initial,
60                 .maxlen         = sizeof(unsigned int),
61                 .mode           = 0644,
62                 .proc_handler   = &proc_dointvec_minmax,
63                 .strategy       = &sysctl_intvec,
64                 .extra1         = &one,
65                 .extra2         = &timer_max
66         },
67         {
68                 .ctl_name       = NET_SCTP_RTO_MIN,
69                 .procname       = "rto_min",
70                 .data           = &sctp_rto_min,
71                 .maxlen         = sizeof(unsigned int),
72                 .mode           = 0644,
73                 .proc_handler   = &proc_dointvec_minmax,
74                 .strategy       = &sysctl_intvec,
75                 .extra1         = &one,
76                 .extra2         = &timer_max
77         },
78         {
79                 .ctl_name       = NET_SCTP_RTO_MAX,
80                 .procname       = "rto_max",
81                 .data           = &sctp_rto_max,
82                 .maxlen         = sizeof(unsigned int),
83                 .mode           = 0644,
84                 .proc_handler   = &proc_dointvec_minmax,
85                 .strategy       = &sysctl_intvec,
86                 .extra1         = &one,
87                 .extra2         = &timer_max
88         },
89         {
90                 .ctl_name       = NET_SCTP_VALID_COOKIE_LIFE,
91                 .procname       = "valid_cookie_life",
92                 .data           = &sctp_valid_cookie_life,
93                 .maxlen         = sizeof(unsigned int),
94                 .mode           = 0644,
95                 .proc_handler   = &proc_dointvec_minmax,
96                 .strategy       = &sysctl_intvec,
97                 .extra1         = &one,
98                 .extra2         = &timer_max
99         },
100         {
101                 .ctl_name       = NET_SCTP_MAX_BURST,
102                 .procname       = "max_burst",
103                 .data           = &sctp_max_burst,
104                 .maxlen         = sizeof(int),
105                 .mode           = 0644,
106                 .proc_handler   = &proc_dointvec_minmax,
107                 .strategy       = &sysctl_intvec,
108                 .extra1         = &zero,
109                 .extra2         = &int_max
110         },
111         {
112                 .ctl_name       = NET_SCTP_ASSOCIATION_MAX_RETRANS,
113                 .procname       = "association_max_retrans",
114                 .data           = &sctp_max_retrans_association,
115                 .maxlen         = sizeof(int),
116                 .mode           = 0644,
117                 .proc_handler   = &proc_dointvec_minmax,
118                 .strategy       = &sysctl_intvec,
119                 .extra1         = &one,
120                 .extra2         = &int_max
121         },
122         {
123                 .ctl_name       = NET_SCTP_SNDBUF_POLICY,
124                 .procname       = "sndbuf_policy",
125                 .data           = &sctp_sndbuf_policy,
126                 .maxlen         = sizeof(int),
127                 .mode           = 0644,
128                 .proc_handler   = &proc_dointvec,
129                 .strategy       = &sysctl_intvec
130         },
131         {
132                 .ctl_name       = NET_SCTP_RCVBUF_POLICY,
133                 .procname       = "rcvbuf_policy",
134                 .data           = &sctp_rcvbuf_policy,
135                 .maxlen         = sizeof(int),
136                 .mode           = 0644,
137                 .proc_handler   = &proc_dointvec,
138                 .strategy       = &sysctl_intvec
139         },
140         {
141                 .ctl_name       = NET_SCTP_PATH_MAX_RETRANS,
142                 .procname       = "path_max_retrans",
143                 .data           = &sctp_max_retrans_path,
144                 .maxlen         = sizeof(int),
145                 .mode           = 0644,
146                 .proc_handler   = &proc_dointvec_minmax,
147                 .strategy       = &sysctl_intvec,
148                 .extra1         = &one,
149                 .extra2         = &int_max
150         },
151         {
152                 .ctl_name       = NET_SCTP_MAX_INIT_RETRANSMITS,
153                 .procname       = "max_init_retransmits",
154                 .data           = &sctp_max_retrans_init,
155                 .maxlen         = sizeof(int),
156                 .mode           = 0644,
157                 .proc_handler   = &proc_dointvec_minmax,
158                 .strategy       = &sysctl_intvec,
159                 .extra1         = &one,
160                 .extra2         = &int_max
161         },
162         {
163                 .ctl_name       = NET_SCTP_HB_INTERVAL,
164                 .procname       = "hb_interval",
165                 .data           = &sctp_hb_interval,
166                 .maxlen         = sizeof(unsigned int),
167                 .mode           = 0644,
168                 .proc_handler   = &proc_dointvec_minmax,
169                 .strategy       = &sysctl_intvec,
170                 .extra1         = &one,
171                 .extra2         = &timer_max
172         },
173         {
174                 .ctl_name       = NET_SCTP_PRESERVE_ENABLE,
175                 .procname       = "cookie_preserve_enable",
176                 .data           = &sctp_cookie_preserve_enable,
177                 .maxlen         = sizeof(int),
178                 .mode           = 0644,
179                 .proc_handler   = &proc_dointvec,
180                 .strategy       = &sysctl_intvec
181         },
182         {
183                 .ctl_name       = NET_SCTP_RTO_ALPHA,
184                 .procname       = "rto_alpha_exp_divisor",
185                 .data           = &sctp_rto_alpha,
186                 .maxlen         = sizeof(int),
187                 .mode           = 0444,
188                 .proc_handler   = &proc_dointvec,
189                 .strategy       = &sysctl_intvec
190         },
191         {
192                 .ctl_name       = NET_SCTP_RTO_BETA,
193                 .procname       = "rto_beta_exp_divisor",
194                 .data           = &sctp_rto_beta,
195                 .maxlen         = sizeof(int),
196                 .mode           = 0444,
197                 .proc_handler   = &proc_dointvec,
198                 .strategy       = &sysctl_intvec
199         },
200         {
201                 .ctl_name       = NET_SCTP_ADDIP_ENABLE,
202                 .procname       = "addip_enable",
203                 .data           = &sctp_addip_enable,
204                 .maxlen         = sizeof(int),
205                 .mode           = 0644,
206                 .proc_handler   = &proc_dointvec,
207                 .strategy       = &sysctl_intvec
208         },
209         {
210                 .ctl_name       = NET_SCTP_PRSCTP_ENABLE,
211                 .procname       = "prsctp_enable",
212                 .data           = &sctp_prsctp_enable,
213                 .maxlen         = sizeof(int),
214                 .mode           = 0644,
215                 .proc_handler   = &proc_dointvec,
216                 .strategy       = &sysctl_intvec
217         },
218         {
219                 .ctl_name       = NET_SCTP_SACK_TIMEOUT,
220                 .procname       = "sack_timeout",
221                 .data           = &sctp_sack_timeout,
222                 .maxlen         = sizeof(long),
223                 .mode           = 0644,
224                 .proc_handler   = &proc_dointvec_minmax,
225                 .strategy       = &sysctl_intvec,
226                 .extra1         = &sack_timer_min,
227                 .extra2         = &sack_timer_max,
228         },
229         { .ctl_name = 0 }
230 };
231
232 static ctl_table sctp_net_table[] = {
233         {
234                 .ctl_name       = NET_SCTP,
235                 .procname       = "sctp",
236                 .mode           = 0555,
237                 .child          = sctp_table
238         },
239         { .ctl_name = 0 }
240 };
241
242 static ctl_table sctp_root_table[] = {
243         {
244                 .ctl_name       = CTL_NET,
245                 .procname       = "net",
246                 .mode           = 0555,
247                 .child          = sctp_net_table
248         },
249         { .ctl_name = 0 }
250 };
251
252 static struct ctl_table_header * sctp_sysctl_header;
253
254 /* Sysctl registration.  */
255 void sctp_sysctl_register(void)
256 {
257         sctp_sysctl_header = register_sysctl_table(sctp_root_table);
258 }
259
260 /* Sysctl deregistration.  */
261 void sctp_sysctl_unregister(void)
262 {
263         unregister_sysctl_table(sctp_sysctl_header);
264 }