1 /* SCTP kernel reference Implementation
2 * (C) Copyright IBM Corp. 2002, 2004
3 * Copyright (c) 2002 Intel Corp.
5 * This file is part of the SCTP kernel reference Implementation
7 * Sysctl related interfaces for SCTP.
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)
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.
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.
26 * Please send any bug reports or fixes you make to the
28 * lksctp developers <lksctp-developers@lists.sourceforge.net>
30 * Or submit a bug report through the following website:
31 * http://www.sf.net/projects/lksctp
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>
40 * Any bugs reported given to us we will try to fix... any fixes shared will
41 * be incorporated into the next SCTP release.
44 #include <net/sctp/structs.h>
45 #include <net/sctp/sctp.h>
46 #include <linux/sysctl.h>
48 static ctl_handler sctp_sysctl_jiffies_ms;
49 static long rto_timer_min = 1;
50 static long rto_timer_max = 86400000; /* One day */
51 static long sack_timer_min = 1;
52 static long sack_timer_max = 500;
54 static ctl_table sctp_table[] = {
56 .ctl_name = NET_SCTP_RTO_INITIAL,
57 .procname = "rto_initial",
58 .data = &sctp_rto_initial,
59 .maxlen = sizeof(long),
61 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
62 .strategy = &sctp_sysctl_jiffies_ms,
63 .extra1 = &rto_timer_min,
64 .extra2 = &rto_timer_max
67 .ctl_name = NET_SCTP_RTO_MIN,
68 .procname = "rto_min",
69 .data = &sctp_rto_min,
70 .maxlen = sizeof(long),
72 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
73 .strategy = &sctp_sysctl_jiffies_ms,
74 .extra1 = &rto_timer_min,
75 .extra2 = &rto_timer_max
78 .ctl_name = NET_SCTP_RTO_MAX,
79 .procname = "rto_max",
80 .data = &sctp_rto_max,
81 .maxlen = sizeof(long),
83 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
84 .strategy = &sctp_sysctl_jiffies_ms,
85 .extra1 = &rto_timer_min,
86 .extra2 = &rto_timer_max
89 .ctl_name = NET_SCTP_VALID_COOKIE_LIFE,
90 .procname = "valid_cookie_life",
91 .data = &sctp_valid_cookie_life,
92 .maxlen = sizeof(long),
94 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
95 .strategy = &sctp_sysctl_jiffies_ms,
96 .extra1 = &rto_timer_min,
97 .extra2 = &rto_timer_max
100 .ctl_name = NET_SCTP_MAX_BURST,
101 .procname = "max_burst",
102 .data = &sctp_max_burst,
103 .maxlen = sizeof(int),
105 .proc_handler = &proc_dointvec
108 .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS,
109 .procname = "association_max_retrans",
110 .data = &sctp_max_retrans_association,
111 .maxlen = sizeof(int),
113 .proc_handler = &proc_dointvec
116 .ctl_name = NET_SCTP_SNDBUF_POLICY,
117 .procname = "sndbuf_policy",
118 .data = &sctp_sndbuf_policy,
119 .maxlen = sizeof(int),
121 .proc_handler = &proc_dointvec
124 .ctl_name = NET_SCTP_RCVBUF_POLICY,
125 .procname = "rcvbuf_policy",
126 .data = &sctp_rcvbuf_policy,
127 .maxlen = sizeof(int),
129 .proc_handler = &proc_dointvec
132 .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
133 .procname = "path_max_retrans",
134 .data = &sctp_max_retrans_path,
135 .maxlen = sizeof(int),
137 .proc_handler = &proc_dointvec
140 .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS,
141 .procname = "max_init_retransmits",
142 .data = &sctp_max_retrans_init,
143 .maxlen = sizeof(int),
145 .proc_handler = &proc_dointvec
148 .ctl_name = NET_SCTP_HB_INTERVAL,
149 .procname = "hb_interval",
150 .data = &sctp_hb_interval,
151 .maxlen = sizeof(long),
153 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
154 .strategy = &sctp_sysctl_jiffies_ms,
155 .extra1 = &rto_timer_min,
156 .extra2 = &rto_timer_max
159 .ctl_name = NET_SCTP_PRESERVE_ENABLE,
160 .procname = "cookie_preserve_enable",
161 .data = &sctp_cookie_preserve_enable,
162 .maxlen = sizeof(long),
164 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
165 .strategy = &sctp_sysctl_jiffies_ms,
166 .extra1 = &rto_timer_min,
167 .extra2 = &rto_timer_max
170 .ctl_name = NET_SCTP_RTO_ALPHA,
171 .procname = "rto_alpha_exp_divisor",
172 .data = &sctp_rto_alpha,
173 .maxlen = sizeof(int),
175 .proc_handler = &proc_dointvec
178 .ctl_name = NET_SCTP_RTO_BETA,
179 .procname = "rto_beta_exp_divisor",
180 .data = &sctp_rto_beta,
181 .maxlen = sizeof(int),
183 .proc_handler = &proc_dointvec
186 .ctl_name = NET_SCTP_ADDIP_ENABLE,
187 .procname = "addip_enable",
188 .data = &sctp_addip_enable,
189 .maxlen = sizeof(int),
191 .proc_handler = &proc_dointvec
194 .ctl_name = NET_SCTP_PRSCTP_ENABLE,
195 .procname = "prsctp_enable",
196 .data = &sctp_prsctp_enable,
197 .maxlen = sizeof(int),
199 .proc_handler = &proc_dointvec
202 .ctl_name = NET_SCTP_SACK_TIMEOUT,
203 .procname = "sack_timeout",
204 .data = &sctp_sack_timeout,
205 .maxlen = sizeof(long),
207 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
208 .strategy = &sctp_sysctl_jiffies_ms,
209 .extra1 = &sack_timer_min,
210 .extra2 = &sack_timer_max,
215 static ctl_table sctp_net_table[] = {
217 .ctl_name = NET_SCTP,
225 static ctl_table sctp_root_table[] = {
230 .child = sctp_net_table
235 static struct ctl_table_header * sctp_sysctl_header;
237 /* Sysctl registration. */
238 void sctp_sysctl_register(void)
240 sctp_sysctl_header = register_sysctl_table(sctp_root_table, 0);
243 /* Sysctl deregistration. */
244 void sctp_sysctl_unregister(void)
246 unregister_sysctl_table(sctp_sysctl_header);
249 /* Strategy function to convert jiffies to milliseconds. */
250 static int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen,
251 void __user *oldval, size_t __user *oldlenp,
252 void __user *newval, size_t newlen, void **context) {
258 if (get_user(olen, oldlenp))
261 if (olen != sizeof (int))
264 if (put_user((*(int *)(table->data) * 1000) / HZ,
265 (int __user *)oldval) ||
266 (oldlenp && put_user(sizeof (int), oldlenp)))
269 if (newval && newlen) {
272 if (newlen != sizeof (int))
275 if (get_user(new, (int __user *)newval))
278 *(int *)(table->data) = (new * HZ) / 1000;