sysctl.c 8.2 KB
Newer Older
1
/* SCTP kernel implementation
L
Linus Torvalds 已提交
2 3 4
 * (C) Copyright IBM Corp. 2002, 2004
 * Copyright (c) 2002 Intel Corp.
 *
5
 * This file is part of the SCTP kernel implementation
L
Linus Torvalds 已提交
6 7 8
 *
 * Sysctl related interfaces for SCTP.
 *
9
 * This SCTP implementation is free software;
L
Linus Torvalds 已提交
10 11 12 13 14
 * you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
15
 * This SCTP implementation is distributed in the hope that it
L
Linus Torvalds 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 *                 ************************
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU CC; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Please send any bug reports or fixes you make to the
 * email address(es):
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 *
 * Or submit a bug report through the following website:
 *    http://www.sf.net/projects/lksctp
 *
 * Written or modified by:
 *    Mingqin Liu           <liuming@us.ibm.com>
 *    Jon Grimm             <jgrimm@us.ibm.com>
 *    Ardelle Fan           <ardelle.fan@intel.com>
 *    Ryan Layer            <rmlayer@us.ibm.com>
 *    Sridhar Samudrala     <sri@us.ibm.com>
 *
 * Any bugs reported given to us we will try to fix... any fixes shared will
 * be incorporated into the next SCTP release.
 */

#include <net/sctp/structs.h>
45
#include <net/sctp/sctp.h>
L
Linus Torvalds 已提交
46 47
#include <linux/sysctl.h>

48 49 50 51
static int zero = 0;
static int one = 1;
static int timer_max = 86400000; /* ms in one day */
static int int_max = INT_MAX;
52 53
static int sack_timer_min = 1;
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
static int rwnd_scale_max = 16;
56 57 58 59
static unsigned long max_autoclose_min = 0;
static unsigned long max_autoclose_max =
	(MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
	? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
L
Linus Torvalds 已提交
60

E
Eric Dumazet 已提交
61
extern long sysctl_sctp_mem[3];
62 63
extern int sysctl_sctp_rmem[3];
extern int sysctl_sctp_wmem[3];
64

L
Linus Torvalds 已提交
65
static ctl_table sctp_table[] = {
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
	{
		.procname	= "sctp_mem",
		.data		= &sysctl_sctp_mem,
		.maxlen		= sizeof(sysctl_sctp_mem),
		.mode		= 0644,
		.proc_handler	= proc_doulongvec_minmax
	},
	{
		.procname	= "sctp_rmem",
		.data		= &sysctl_sctp_rmem,
		.maxlen		= sizeof(sysctl_sctp_rmem),
		.mode		= 0644,
		.proc_handler	= proc_dointvec,
	},
	{
		.procname	= "sctp_wmem",
		.data		= &sysctl_sctp_wmem,
		.maxlen		= sizeof(sysctl_sctp_wmem),
		.mode		= 0644,
		.proc_handler	= proc_dointvec,
	},

	{ /* sentinel */ }
};

static ctl_table sctp_net_table[] = {
L
Linus Torvalds 已提交
92 93
	{
		.procname	= "rto_initial",
94
		.data		= &init_net.sctp.rto_initial,
95
		.maxlen		= sizeof(unsigned int),
L
Linus Torvalds 已提交
96
		.mode		= 0644,
A
Alexey Dobriyan 已提交
97
		.proc_handler	= proc_dointvec_minmax,
98 99
		.extra1         = &one,
		.extra2         = &timer_max
L
Linus Torvalds 已提交
100 101 102
	},
	{
		.procname	= "rto_min",
103
		.data		= &init_net.sctp.rto_min,
104
		.maxlen		= sizeof(unsigned int),
L
Linus Torvalds 已提交
105
		.mode		= 0644,
A
Alexey Dobriyan 已提交
106
		.proc_handler	= proc_dointvec_minmax,
107 108
		.extra1         = &one,
		.extra2         = &timer_max
L
Linus Torvalds 已提交
109 110 111
	},
	{
		.procname	= "rto_max",
112
		.data		= &init_net.sctp.rto_max,
113
		.maxlen		= sizeof(unsigned int),
L
Linus Torvalds 已提交
114
		.mode		= 0644,
A
Alexey Dobriyan 已提交
115
		.proc_handler	= proc_dointvec_minmax,
116 117
		.extra1         = &one,
		.extra2         = &timer_max
L
Linus Torvalds 已提交
118 119
	},
	{
120 121 122 123 124 125 126 127 128 129 130 131
		.procname	= "rto_alpha_exp_divisor",
		.data		= &init_net.sctp.rto_alpha,
		.maxlen		= sizeof(int),
		.mode		= 0444,
		.proc_handler	= proc_dointvec,
	},
	{
		.procname	= "rto_beta_exp_divisor",
		.data		= &init_net.sctp.rto_beta,
		.maxlen		= sizeof(int),
		.mode		= 0444,
		.proc_handler	= proc_dointvec,
L
Linus Torvalds 已提交
132 133 134
	},
	{
		.procname	= "max_burst",
135
		.data		= &init_net.sctp.max_burst,
L
Linus Torvalds 已提交
136 137
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
138
		.proc_handler	= proc_dointvec_minmax,
139 140
		.extra1		= &zero,
		.extra2		= &int_max
L
Linus Torvalds 已提交
141 142
	},
	{
143 144
		.procname	= "cookie_preserve_enable",
		.data		= &init_net.sctp.cookie_preserve_enable,
L
Linus Torvalds 已提交
145 146
		.maxlen		= sizeof(int),
		.mode		= 0644,
147 148 149 150 151 152 153
		.proc_handler	= proc_dointvec,
	},
	{
		.procname	= "valid_cookie_life",
		.data		= &init_net.sctp.valid_cookie_life,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
154
		.proc_handler	= proc_dointvec_minmax,
155 156
		.extra1         = &one,
		.extra2         = &timer_max
L
Linus Torvalds 已提交
157
	},
158
	{
159 160
		.procname	= "sack_timeout",
		.data		= &init_net.sctp.sack_timeout,
161 162
		.maxlen		= sizeof(int),
		.mode		= 0644,
163 164 165
		.proc_handler	= proc_dointvec_minmax,
		.extra1         = &sack_timer_min,
		.extra2         = &sack_timer_max,
166
	},
167
	{
168 169 170
		.procname	= "hb_interval",
		.data		= &init_net.sctp.hb_interval,
		.maxlen		= sizeof(unsigned int),
171
		.mode		= 0644,
172 173 174
		.proc_handler	= proc_dointvec_minmax,
		.extra1         = &one,
		.extra2         = &timer_max
175
	},
L
Linus Torvalds 已提交
176
	{
177 178
		.procname	= "association_max_retrans",
		.data		= &init_net.sctp.max_retrans_association,
L
Linus Torvalds 已提交
179 180
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
181
		.proc_handler	= proc_dointvec_minmax,
182 183
		.extra1		= &one,
		.extra2		= &int_max
L
Linus Torvalds 已提交
184
	},
185
	{
186 187
		.procname	= "path_max_retrans",
		.data		= &init_net.sctp.max_retrans_path,
188 189 190
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= proc_dointvec_minmax,
191
		.extra1		= &one,
192 193
		.extra2		= &int_max
	},
L
Linus Torvalds 已提交
194 195
	{
		.procname	= "max_init_retransmits",
196
		.data		= &init_net.sctp.max_retrans_init,
L
Linus Torvalds 已提交
197 198
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
199
		.proc_handler	= proc_dointvec_minmax,
200 201
		.extra1		= &one,
		.extra2		= &int_max
L
Linus Torvalds 已提交
202 203
	},
	{
204 205 206
		.procname	= "pf_retrans",
		.data		= &init_net.sctp.pf_retrans,
		.maxlen		= sizeof(int),
L
Linus Torvalds 已提交
207
		.mode		= 0644,
A
Alexey Dobriyan 已提交
208
		.proc_handler	= proc_dointvec_minmax,
209 210
		.extra1		= &zero,
		.extra2		= &int_max
L
Linus Torvalds 已提交
211 212
	},
	{
213 214
		.procname	= "sndbuf_policy",
		.data		= &init_net.sctp.sndbuf_policy,
215
		.maxlen		= sizeof(int),
L
Linus Torvalds 已提交
216
		.mode		= 0644,
A
Alexey Dobriyan 已提交
217
		.proc_handler	= proc_dointvec,
L
Linus Torvalds 已提交
218 219
	},
	{
220 221
		.procname	= "rcvbuf_policy",
		.data		= &init_net.sctp.rcvbuf_policy,
222 223 224 225 226 227
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= proc_dointvec,
	},
	{
		.procname	= "default_auto_asconf",
228
		.data		= &init_net.sctp.default_auto_asconf,
L
Linus Torvalds 已提交
229 230
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
231
		.proc_handler	= proc_dointvec,
L
Linus Torvalds 已提交
232 233
	},
	{
234 235
		.procname	= "addip_enable",
		.data		= &init_net.sctp.addip_enable,
L
Linus Torvalds 已提交
236 237
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
238
		.proc_handler	= proc_dointvec,
L
Linus Torvalds 已提交
239
	},
240
	{
241 242
		.procname	= "addip_noauth_enable",
		.data		= &init_net.sctp.addip_noauth,
243
		.maxlen		= sizeof(int),
244
		.mode		= 0644,
A
Alexey Dobriyan 已提交
245
		.proc_handler	= proc_dointvec,
246 247
	},
	{
248 249
		.procname	= "prsctp_enable",
		.data		= &init_net.sctp.prsctp_enable,
250 251
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
252
		.proc_handler	= proc_dointvec,
253
	},
254
	{
255 256
		.procname	= "auth_enable",
		.data		= &init_net.sctp.auth_enable,
257 258
		.maxlen		= sizeof(int),
		.mode		= 0644,
A
Alexey Dobriyan 已提交
259
		.proc_handler	= proc_dointvec,
260
	},
261 262
	{
		.procname	= "addr_scope_policy",
263
		.data		= &init_net.sctp.scope_policy,
264 265
		.maxlen		= sizeof(int),
		.mode		= 0644,
266
		.proc_handler	= proc_dointvec_minmax,
267 268 269
		.extra1		= &zero,
		.extra2		= &addr_scope_max,
	},
270 271
	{
		.procname	= "rwnd_update_shift",
272
		.data		= &init_net.sctp.rwnd_upd_shift,
273 274 275 276 277 278
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= &proc_dointvec_minmax,
		.extra1		= &one,
		.extra2		= &rwnd_scale_max,
	},
279 280
	{
		.procname	= "max_autoclose",
281
		.data		= &init_net.sctp.max_autoclose,
282 283 284 285 286 287
		.maxlen		= sizeof(unsigned long),
		.mode		= 0644,
		.proc_handler	= &proc_doulongvec_minmax,
		.extra1		= &max_autoclose_min,
		.extra2		= &max_autoclose_max,
	},
288

289
	{ /* sentinel */ }
L
Linus Torvalds 已提交
290 291
};

292 293 294
int sctp_sysctl_net_register(struct net *net)
{
	struct ctl_table *table;
295
	int i;
296 297 298 299 300

	table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
	if (!table)
		return -ENOMEM;

301 302 303
	for (i = 0; table[i].data; i++)
		table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;

304 305 306 307 308 309 310 311 312
	net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
	return 0;
}

void sctp_sysctl_net_unregister(struct net *net)
{
	unregister_net_sysctl_table(net->sctp.sysctl_header);
}

L
Linus Torvalds 已提交
313 314 315 316 317
static struct ctl_table_header * sctp_sysctl_header;

/* Sysctl registration.  */
void sctp_sysctl_register(void)
{
318
	sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
L
Linus Torvalds 已提交
319 320 321 322 323
}

/* Sysctl deregistration.  */
void sctp_sysctl_unregister(void)
{
324
	unregister_net_sysctl_table(sctp_sysctl_header);
L
Linus Torvalds 已提交
325
}