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 <linux/sysctl.h>
47 static ctl_handler sctp_sysctl_jiffies_ms;
48 static long rto_timer_min = 1;
49 static long rto_timer_max = 86400000; /* One day */
51 static ctl_table sctp_table[] = {
53 .ctl_name = NET_SCTP_RTO_INITIAL,
54 .procname = "rto_initial",
55 .data = &sctp_rto_initial,
56 .maxlen = sizeof(long),
58 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
59 .strategy = &sctp_sysctl_jiffies_ms,
60 .extra1 = &rto_timer_min,
61 .extra2 = &rto_timer_max
64 .ctl_name = NET_SCTP_RTO_MIN,
65 .procname = "rto_min",
66 .data = &sctp_rto_min,
67 .maxlen = sizeof(long),
69 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
70 .strategy = &sctp_sysctl_jiffies_ms,
71 .extra1 = &rto_timer_min,
72 .extra2 = &rto_timer_max
75 .ctl_name = NET_SCTP_RTO_MAX,
76 .procname = "rto_max",
77 .data = &sctp_rto_max,
78 .maxlen = sizeof(long),
80 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
81 .strategy = &sctp_sysctl_jiffies_ms,
82 .extra1 = &rto_timer_min,
83 .extra2 = &rto_timer_max
86 .ctl_name = NET_SCTP_VALID_COOKIE_LIFE,
87 .procname = "valid_cookie_life",
88 .data = &sctp_valid_cookie_life,
89 .maxlen = sizeof(long),
91 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
92 .strategy = &sctp_sysctl_jiffies_ms,
93 .extra1 = &rto_timer_min,
94 .extra2 = &rto_timer_max
97 .ctl_name = NET_SCTP_MAX_BURST,
98 .procname = "max_burst",
99 .data = &sctp_max_burst,
100 .maxlen = sizeof(int),
102 .proc_handler = &proc_dointvec
105 .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS,
106 .procname = "association_max_retrans",
107 .data = &sctp_max_retrans_association,
108 .maxlen = sizeof(int),
110 .proc_handler = &proc_dointvec
113 .ctl_name = NET_SCTP_SNDBUF_POLICY,
114 .procname = "sndbuf_policy",
115 .data = &sctp_sndbuf_policy,
116 .maxlen = sizeof(int),
118 .proc_handler = &proc_dointvec
121 .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
122 .procname = "path_max_retrans",
123 .data = &sctp_max_retrans_path,
124 .maxlen = sizeof(int),
126 .proc_handler = &proc_dointvec
129 .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS,
130 .procname = "max_init_retransmits",
131 .data = &sctp_max_retrans_init,
132 .maxlen = sizeof(int),
134 .proc_handler = &proc_dointvec
137 .ctl_name = NET_SCTP_HB_INTERVAL,
138 .procname = "hb_interval",
139 .data = &sctp_hb_interval,
140 .maxlen = sizeof(long),
142 .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
143 .strategy = &sctp_sysctl_jiffies_ms,
144 .extra1 = &rto_timer_min,
145 .extra2 = &rto_timer_max
148 .ctl_name = NET_SCTP_PRESERVE_ENABLE,
149 .procname = "cookie_preserve_enable",
150 .data = &sctp_cookie_preserve_enable,
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_RTO_ALPHA,
160 .procname = "rto_alpha_exp_divisor",
161 .data = &sctp_rto_alpha,
162 .maxlen = sizeof(int),
164 .proc_handler = &proc_dointvec
167 .ctl_name = NET_SCTP_RTO_BETA,
168 .procname = "rto_beta_exp_divisor",
169 .data = &sctp_rto_beta,
170 .maxlen = sizeof(int),
172 .proc_handler = &proc_dointvec
175 .ctl_name = NET_SCTP_ADDIP_ENABLE,
176 .procname = "addip_enable",
177 .data = &sctp_addip_enable,
178 .maxlen = sizeof(int),
180 .proc_handler = &proc_dointvec
183 .ctl_name = NET_SCTP_PRSCTP_ENABLE,
184 .procname = "prsctp_enable",
185 .data = &sctp_prsctp_enable,
186 .maxlen = sizeof(int),
188 .proc_handler = &proc_dointvec
193 static ctl_table sctp_net_table[] = {
195 .ctl_name = NET_SCTP,
203 static ctl_table sctp_root_table[] = {
208 .child = sctp_net_table
213 static struct ctl_table_header * sctp_sysctl_header;
215 /* Sysctl registration. */
216 void sctp_sysctl_register(void)
218 sctp_sysctl_header = register_sysctl_table(sctp_root_table, 0);
221 /* Sysctl deregistration. */
222 void sctp_sysctl_unregister(void)
224 unregister_sysctl_table(sctp_sysctl_header);
227 /* Strategy function to convert jiffies to milliseconds. */
228 static int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen,
229 void __user *oldval, size_t __user *oldlenp,
230 void __user *newval, size_t newlen, void **context) {
236 if (get_user(olen, oldlenp))
239 if (olen != sizeof (int))
242 if (put_user((*(int *)(table->data) * 1000) / HZ,
243 (int __user *)oldval) ||
244 (oldlenp && put_user(sizeof (int), oldlenp)))
247 if (newval && newlen) {
250 if (newlen != sizeof (int))
253 if (get_user(new, (int __user *)newval))
256 *(int *)(table->data) = (new * HZ) / 1000;