Blame view

net/sctp/sysctl.c 12.2 KB
47505b8bc   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
2
  /* SCTP kernel implementation
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
5
   * (C) Copyright IBM Corp. 2002, 2004
   * Copyright (c) 2002 Intel Corp.
   *
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
6
   * This file is part of the SCTP kernel implementation
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
   *
   * Sysctl related interfaces for SCTP.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
   * Please send any bug reports or fixes you make to the
   * email address(es):
91705c61b   Daniel Borkmann   net: sctp: trivia...
12
   *    lksctp developers <linux-sctp@vger.kernel.org>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
17
18
19
   * 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>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
   */
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
21
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
  #include <net/sctp/structs.h>
8c5955d83   Adrian Bunk   [SCTP]: net/sctp/...
23
  #include <net/sctp/sctp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
  #include <linux/sysctl.h>
3fd091e73   Vladislav Yasevich   [SCTP]: Remove mu...
25
  static int timer_max = 86400000; /* ms in one day */
d48e074df   Jean-Mickael Guerin   sctp: fix sack_ti...
26
27
  static int sack_timer_min = 1;
  static int sack_timer_max = 500;
701ef3e6c   Xin Long   sctp: remove the ...
28
  static int addr_scope_max = SCTP_SCOPE_POLICY_MAX;
90f2f5318   Vlad Yasevich   sctp: Update SWS ...
29
  static int rwnd_scale_max = 16;
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
30
31
32
33
  static int rto_alpha_min = 0;
  static int rto_beta_min = 0;
  static int rto_alpha_max = 1000;
  static int rto_beta_max = 1000;
2692ba61a   Xi Wang   sctp: fix incorre...
34
35
36
37
  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;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38

b486b2289   wangweidong   sctp: fix up a sp...
39
  static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
3c68198e7   Neil Horman   sctp: Make hmac a...
40
  				void __user *buffer, size_t *lenp,
3c68198e7   Neil Horman   sctp: Make hmac a...
41
  				loff_t *ppos);
4f3fdf3bc   wangweidong   sctp: add check r...
42
43
44
45
  static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
  				void __user *buffer, size_t *lenp,
  				loff_t *ppos);
  static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
3c68198e7   Neil Horman   sctp: Make hmac a...
46
  				void __user *buffer, size_t *lenp,
3c68198e7   Neil Horman   sctp: Make hmac a...
47
  				loff_t *ppos);
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
48
49
50
  static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
  				   void __user *buffer, size_t *lenp,
  				   loff_t *ppos);
b14878ccb   Vlad Yasevich   net: sctp: cache ...
51
52
53
  static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
  			     void __user *buffer, size_t *lenp,
  			     loff_t *ppos);
4f3fdf3bc   wangweidong   sctp: add check r...
54

fe2c6338f   Joe Perches   net: Convert uses...
55
  static struct ctl_table sctp_table[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  		.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 */ }
  };
fe2c6338f   Joe Perches   net: Convert uses...
80
  static struct ctl_table sctp_net_table[] = {
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
81
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
  		.procname	= "rto_initial",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
83
  		.data		= &init_net.sctp.rto_initial,
3fd091e73   Vladislav Yasevich   [SCTP]: Remove mu...
84
  		.maxlen		= sizeof(unsigned int),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
86
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
87
  		.extra1         = SYSCTL_ONE,
3fd091e73   Vladislav Yasevich   [SCTP]: Remove mu...
88
  		.extra2         = &timer_max
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
90
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
  		.procname	= "rto_min",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
92
  		.data		= &init_net.sctp.rto_min,
3fd091e73   Vladislav Yasevich   [SCTP]: Remove mu...
93
  		.maxlen		= sizeof(unsigned int),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94
  		.mode		= 0644,
4f3fdf3bc   wangweidong   sctp: add check r...
95
  		.proc_handler	= proc_sctp_do_rto_min,
eec4844fa   Matteo Croce   proc/sysctl: add ...
96
  		.extra1         = SYSCTL_ONE,
4f3fdf3bc   wangweidong   sctp: add check r...
97
  		.extra2         = &init_net.sctp.rto_max
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
  		.procname	= "rto_max",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
101
  		.data		= &init_net.sctp.rto_max,
3fd091e73   Vladislav Yasevich   [SCTP]: Remove mu...
102
  		.maxlen		= sizeof(unsigned int),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
103
  		.mode		= 0644,
4f3fdf3bc   wangweidong   sctp: add check r...
104
105
  		.proc_handler	= proc_sctp_do_rto_max,
  		.extra1         = &init_net.sctp.rto_min,
3fd091e73   Vladislav Yasevich   [SCTP]: Remove mu...
106
  		.extra2         = &timer_max
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
109
110
111
  		.procname	= "rto_alpha_exp_divisor",
  		.data		= &init_net.sctp.rto_alpha,
  		.maxlen		= sizeof(int),
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
112
113
114
115
  		.mode		= 0644,
  		.proc_handler	= proc_sctp_do_alpha_beta,
  		.extra1		= &rto_alpha_min,
  		.extra2		= &rto_alpha_max,
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
116
117
118
119
120
  	},
  	{
  		.procname	= "rto_beta_exp_divisor",
  		.data		= &init_net.sctp.rto_beta,
  		.maxlen		= sizeof(int),
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
121
122
123
124
  		.mode		= 0644,
  		.proc_handler	= proc_sctp_do_alpha_beta,
  		.extra1		= &rto_beta_min,
  		.extra2		= &rto_beta_max,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
125
126
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
  		.procname	= "max_burst",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
128
  		.data		= &init_net.sctp.max_burst,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
129
130
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
131
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
132
133
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_INT_MAX,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
135
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
136
137
  		.procname	= "cookie_preserve_enable",
  		.data		= &init_net.sctp.cookie_preserve_enable,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
139
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
140
141
142
  		.proc_handler	= proc_dointvec,
  	},
  	{
3c68198e7   Neil Horman   sctp: Make hmac a...
143
  		.procname	= "cookie_hmac_alg",
22a1f5140   wangweidong   sctp: fix a misse...
144
  		.data		= &init_net.sctp.sctp_hmac_alg,
3c68198e7   Neil Horman   sctp: Make hmac a...
145
146
147
148
149
  		.maxlen		= 8,
  		.mode		= 0644,
  		.proc_handler	= proc_sctp_do_hmac_alg,
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
150
151
152
153
  		.procname	= "valid_cookie_life",
  		.data		= &init_net.sctp.valid_cookie_life,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
154
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
155
  		.extra1         = SYSCTL_ONE,
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
156
  		.extra2         = &timer_max
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
159
160
  		.procname	= "sack_timeout",
  		.data		= &init_net.sctp.sack_timeout,
4eb701dfc   Neil Horman   [SCTP] Fix SCTP s...
161
162
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
163
164
165
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1         = &sack_timer_min,
  		.extra2         = &sack_timer_max,
4eb701dfc   Neil Horman   [SCTP] Fix SCTP s...
166
167
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
168
169
170
  		.procname	= "hb_interval",
  		.data		= &init_net.sctp.hb_interval,
  		.maxlen		= sizeof(unsigned int),
049b3ff5a   Neil Horman   [SCTP]: Include u...
171
  		.mode		= 0644,
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
172
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
173
  		.extra1         = SYSCTL_ONE,
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
174
  		.extra2         = &timer_max
049b3ff5a   Neil Horman   [SCTP]: Include u...
175
176
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
177
178
  		.procname	= "association_max_retrans",
  		.data		= &init_net.sctp.max_retrans_association,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179
180
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
181
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
182
183
  		.extra1		= SYSCTL_ONE,
  		.extra2		= SYSCTL_INT_MAX,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
185
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
186
187
  		.procname	= "path_max_retrans",
  		.data		= &init_net.sctp.max_retrans_path,
5aa93bcf6   Neil Horman   sctp: Implement q...
188
189
190
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
191
192
  		.extra1		= SYSCTL_ONE,
  		.extra2		= SYSCTL_INT_MAX,
5aa93bcf6   Neil Horman   sctp: Implement q...
193
194
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
195
  		.procname	= "max_init_retransmits",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
196
  		.data		= &init_net.sctp.max_retrans_init,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
197
198
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
199
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
200
201
  		.extra1		= SYSCTL_ONE,
  		.extra2		= SYSCTL_INT_MAX,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
202
203
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
204
205
206
  		.procname	= "pf_retrans",
  		.data		= &init_net.sctp.pf_retrans,
  		.maxlen		= sizeof(int),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
207
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
208
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
209
210
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_INT_MAX,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
211
212
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
213
214
  		.procname	= "sndbuf_policy",
  		.data		= &init_net.sctp.sndbuf_policy,
8116ffad4   Vlad Yasevich   [SCTP]: Fix bad s...
215
  		.maxlen		= sizeof(int),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
217
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
218
219
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
220
221
  		.procname	= "rcvbuf_policy",
  		.data		= &init_net.sctp.rcvbuf_policy,
dd51be0f5   Michio Honda   sctp: Add sysctl ...
222
223
224
225
226
227
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
  	{
  		.procname	= "default_auto_asconf",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
228
  		.data		= &init_net.sctp.default_auto_asconf,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
229
230
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
231
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
232
233
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
234
235
  		.procname	= "addip_enable",
  		.data		= &init_net.sctp.addip_enable,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
236
237
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
238
  		.proc_handler	= proc_dointvec,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
239
  	},
2f85a4296   Vlad Yasevich   [SCTP] Make init ...
240
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
241
242
  		.procname	= "addip_noauth_enable",
  		.data		= &init_net.sctp.addip_noauth,
d48e074df   Jean-Mickael Guerin   sctp: fix sack_ti...
243
  		.maxlen		= sizeof(int),
2f85a4296   Vlad Yasevich   [SCTP] Make init ...
244
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
245
  		.proc_handler	= proc_dointvec,
4d93df0ab   Neil Horman   [SCTP]: Rewrite o...
246
247
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
248
249
  		.procname	= "prsctp_enable",
  		.data		= &init_net.sctp.prsctp_enable,
a29a5bd4f   Vlad Yasevich   [SCTP]: Implement...
250
251
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
252
  		.proc_handler	= proc_dointvec,
a29a5bd4f   Vlad Yasevich   [SCTP]: Implement...
253
  	},
73d9c4fd1   Vlad Yasevich   SCTP: Allow ADD_I...
254
  	{
c0d8bab6a   Xin Long   sctp: add get and...
255
256
257
258
259
260
261
  		.procname	= "reconf_enable",
  		.data		= &init_net.sctp.reconf_enable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
  	{
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
262
263
  		.procname	= "auth_enable",
  		.data		= &init_net.sctp.auth_enable,
73d9c4fd1   Vlad Yasevich   SCTP: Allow ADD_I...
264
265
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
b14878ccb   Vlad Yasevich   net: sctp: cache ...
266
  		.proc_handler	= proc_sctp_do_auth,
73d9c4fd1   Vlad Yasevich   SCTP: Allow ADD_I...
267
  	},
723884339   Bhaskar Dutta   sctp: Sysctl conf...
268
  	{
463118c34   Xin Long   sctp: support sys...
269
270
271
272
273
274
  		.procname	= "intl_enable",
  		.data		= &init_net.sctp.intl_enable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
2f5268a92   Xin Long   sctp: allow users...
275
276
277
278
279
280
281
  	{
  		.procname	= "ecn_enable",
  		.data		= &init_net.sctp.ecn_enable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
463118c34   Xin Long   sctp: support sys...
282
  	{
723884339   Bhaskar Dutta   sctp: Sysctl conf...
283
  		.procname	= "addr_scope_policy",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
284
  		.data		= &init_net.sctp.scope_policy,
723884339   Bhaskar Dutta   sctp: Sysctl conf...
285
286
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d4561110   Eric W. Biederman   sysctl: Drop & in...
287
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
288
  		.extra1		= SYSCTL_ZERO,
723884339   Bhaskar Dutta   sctp: Sysctl conf...
289
290
  		.extra2		= &addr_scope_max,
  	},
90f2f5318   Vlad Yasevich   sctp: Update SWS ...
291
  	{
90f2f5318   Vlad Yasevich   sctp: Update SWS ...
292
  		.procname	= "rwnd_update_shift",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
293
  		.data		= &init_net.sctp.rwnd_upd_shift,
90f2f5318   Vlad Yasevich   sctp: Update SWS ...
294
295
296
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= &proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
297
  		.extra1		= SYSCTL_ONE,
90f2f5318   Vlad Yasevich   sctp: Update SWS ...
298
299
  		.extra2		= &rwnd_scale_max,
  	},
2692ba61a   Xi Wang   sctp: fix incorre...
300
301
  	{
  		.procname	= "max_autoclose",
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
302
  		.data		= &init_net.sctp.max_autoclose,
2692ba61a   Xi Wang   sctp: fix incorre...
303
304
305
306
307
308
  		.maxlen		= sizeof(unsigned long),
  		.mode		= 0644,
  		.proc_handler	= &proc_doulongvec_minmax,
  		.extra1		= &max_autoclose_min,
  		.extra2		= &max_autoclose_max,
  	},
566178f85   Zhu Yanjun   net: sctp: dynami...
309
310
311
312
313
314
315
  	{
  		.procname	= "pf_enable",
  		.data		= &init_net.sctp.pf_enable,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
71acc0ddd   David S. Miller   Revert "net: sctp...
316

d7fc02c7b   Linus Torvalds   Merge git://git.k...
317
  	{ /* sentinel */ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
318
  };
b486b2289   wangweidong   sctp: fix up a sp...
319
  static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
3c68198e7   Neil Horman   sctp: Make hmac a...
320
321
322
323
  				void __user *buffer, size_t *lenp,
  				loff_t *ppos)
  {
  	struct net *net = current->nsproxy->net_ns;
fe2c6338f   Joe Perches   net: Convert uses...
324
  	struct ctl_table tbl;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
325
  	bool changed = false;
3c68198e7   Neil Horman   sctp: Make hmac a...
326
  	char *none = "none";
320f1a4a1   Sasha Levin   net: sctp: preven...
327
  	char tmp[8] = {0};
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
328
  	int ret;
3c68198e7   Neil Horman   sctp: Make hmac a...
329
330
331
332
333
  
  	memset(&tbl, 0, sizeof(struct ctl_table));
  
  	if (write) {
  		tbl.data = tmp;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
334
  		tbl.maxlen = sizeof(tmp);
3c68198e7   Neil Horman   sctp: Make hmac a...
335
336
337
338
  	} else {
  		tbl.data = net->sctp.sctp_hmac_alg ? : none;
  		tbl.maxlen = strlen(tbl.data);
  	}
3c68198e7   Neil Horman   sctp: Make hmac a...
339

ff5e92c1a   Daniel Borkmann   net: sctp: propag...
340
341
  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  	if (write && ret == 0) {
3c68198e7   Neil Horman   sctp: Make hmac a...
342
343
344
  #ifdef CONFIG_CRYPTO_MD5
  		if (!strncmp(tmp, "md5", 3)) {
  			net->sctp.sctp_hmac_alg = "md5";
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
345
  			changed = true;
3c68198e7   Neil Horman   sctp: Make hmac a...
346
347
348
349
350
  		}
  #endif
  #ifdef CONFIG_CRYPTO_SHA1
  		if (!strncmp(tmp, "sha1", 4)) {
  			net->sctp.sctp_hmac_alg = "sha1";
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
351
  			changed = true;
3c68198e7   Neil Horman   sctp: Make hmac a...
352
353
354
355
  		}
  #endif
  		if (!strncmp(tmp, "none", 4)) {
  			net->sctp.sctp_hmac_alg = NULL;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
356
  			changed = true;
3c68198e7   Neil Horman   sctp: Make hmac a...
357
  		}
3c68198e7   Neil Horman   sctp: Make hmac a...
358
359
360
361
362
363
  		if (!changed)
  			ret = -EINVAL;
  	}
  
  	return ret;
  }
4f3fdf3bc   wangweidong   sctp: add check r...
364
365
366
367
368
  static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
  				void __user *buffer, size_t *lenp,
  				loff_t *ppos)
  {
  	struct net *net = current->nsproxy->net_ns;
4f3fdf3bc   wangweidong   sctp: add check r...
369
370
  	unsigned int min = *(unsigned int *) ctl->extra1;
  	unsigned int max = *(unsigned int *) ctl->extra2;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
371
372
  	struct ctl_table tbl;
  	int ret, new_value;
4f3fdf3bc   wangweidong   sctp: add check r...
373
374
375
376
377
378
379
380
  
  	memset(&tbl, 0, sizeof(struct ctl_table));
  	tbl.maxlen = sizeof(unsigned int);
  
  	if (write)
  		tbl.data = &new_value;
  	else
  		tbl.data = &net->sctp.rto_min;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
381

4f3fdf3bc   wangweidong   sctp: add check r...
382
  	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
383
384
  	if (write && ret == 0) {
  		if (new_value > max || new_value < min)
4f3fdf3bc   wangweidong   sctp: add check r...
385
  			return -EINVAL;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
386

4f3fdf3bc   wangweidong   sctp: add check r...
387
388
  		net->sctp.rto_min = new_value;
  	}
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
389

4f3fdf3bc   wangweidong   sctp: add check r...
390
391
392
393
394
395
396
397
  	return ret;
  }
  
  static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
  				void __user *buffer, size_t *lenp,
  				loff_t *ppos)
  {
  	struct net *net = current->nsproxy->net_ns;
4f3fdf3bc   wangweidong   sctp: add check r...
398
399
  	unsigned int min = *(unsigned int *) ctl->extra1;
  	unsigned int max = *(unsigned int *) ctl->extra2;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
400
401
  	struct ctl_table tbl;
  	int ret, new_value;
4f3fdf3bc   wangweidong   sctp: add check r...
402
403
404
405
406
407
408
409
  
  	memset(&tbl, 0, sizeof(struct ctl_table));
  	tbl.maxlen = sizeof(unsigned int);
  
  	if (write)
  		tbl.data = &new_value;
  	else
  		tbl.data = &net->sctp.rto_max;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
410

4f3fdf3bc   wangweidong   sctp: add check r...
411
  	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
412
413
  	if (write && ret == 0) {
  		if (new_value > max || new_value < min)
4f3fdf3bc   wangweidong   sctp: add check r...
414
  			return -EINVAL;
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
415

4f3fdf3bc   wangweidong   sctp: add check r...
416
417
  		net->sctp.rto_max = new_value;
  	}
ff5e92c1a   Daniel Borkmann   net: sctp: propag...
418

4f3fdf3bc   wangweidong   sctp: add check r...
419
420
  	return ret;
  }
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
421
422
423
424
  static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
  				   void __user *buffer, size_t *lenp,
  				   loff_t *ppos)
  {
eaea2da72   Daniel Borkmann   net: sctp: only w...
425
426
427
428
  	if (write)
  		pr_warn_once("Changing rto_alpha or rto_beta may lead to "
  			     "suboptimal rtt/srtt estimations!
  ");
b58537a1f   Daniel Borkmann   net: sctp: fix pe...
429
430
431
  
  	return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  }
b14878ccb   Vlad Yasevich   net: sctp: cache ...
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
  static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
  			     void __user *buffer, size_t *lenp,
  			     loff_t *ppos)
  {
  	struct net *net = current->nsproxy->net_ns;
  	struct ctl_table tbl;
  	int new_value, ret;
  
  	memset(&tbl, 0, sizeof(struct ctl_table));
  	tbl.maxlen = sizeof(unsigned int);
  
  	if (write)
  		tbl.data = &new_value;
  	else
  		tbl.data = &net->sctp.auth_enable;
  
  	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
24599e61b   Daniel Borkmann   net: sctp: check ...
449
  	if (write && ret == 0) {
b14878ccb   Vlad Yasevich   net: sctp: cache ...
450
451
452
453
454
455
456
457
458
459
460
  		struct sock *sk = net->sctp.ctl_sock;
  
  		net->sctp.auth_enable = new_value;
  		/* Update the value in the control socket */
  		lock_sock(sk);
  		sctp_sk(sk)->ep->auth_enable = new_value;
  		release_sock(sk);
  	}
  
  	return ret;
  }
ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
461
462
  int sctp_sysctl_net_register(struct net *net)
  {
eb9f37053   wangweidong   Revert "sctp: opt...
463
464
  	struct ctl_table *table;
  	int i;
ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
465

eb9f37053   wangweidong   Revert "sctp: opt...
466
467
468
  	table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
  	if (!table)
  		return -ENOMEM;
ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
469

eb9f37053   wangweidong   Revert "sctp: opt...
470
471
  	for (i = 0; table[i].data; i++)
  		table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
e1fc3b14f   Eric W. Biederman   sctp: Make sysctl...
472

ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
473
  	net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
f66138c84   wangweidong   sctp: add a check...
474
475
476
477
  	if (net->sctp.sysctl_header == NULL) {
  		kfree(table);
  		return -ENOMEM;
  	}
ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
478
479
480
481
482
  	return 0;
  }
  
  void sctp_sysctl_net_unregister(struct net *net)
  {
5f19d1219   Vlad Yasevich   SCTP: Free the pe...
483
484
485
  	struct ctl_table *table;
  
  	table = net->sctp.sysctl_header->ctl_table_arg;
ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
486
  	unregister_net_sysctl_table(net->sctp.sysctl_header);
5f19d1219   Vlad Yasevich   SCTP: Free the pe...
487
  	kfree(table);
ebb7e95d9   Eric W. Biederman   sctp: Add infrast...
488
  }
26ac8e5fe   wangweidong   sctp: fix checkpa...
489
  static struct ctl_table_header *sctp_sysctl_header;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
490
491
492
493
  
  /* Sysctl registration.  */
  void sctp_sysctl_register(void)
  {
ec8f23ce0   Eric W. Biederman   net: Convert all ...
494
  	sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
495
496
497
498
499
  }
  
  /* Sysctl deregistration.  */
  void sctp_sysctl_unregister(void)
  {
5dd3df105   Eric W. Biederman   net: Move all of ...
500
  	unregister_net_sysctl_table(sctp_sysctl_header);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
501
  }