forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/net/sctp/sysctl.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* SCTP kernel implementation
23 * (C) Copyright IBM Corp. 2002, 2004
34 * Copyright (c) 2002 Intel Corp.
....@@ -5,22 +6,6 @@
56 * This file is part of the SCTP kernel implementation
67 *
78 * Sysctl related interfaces for SCTP.
8
- *
9
- * This SCTP 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
- * This SCTP 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, see
23
- * <http://www.gnu.org/licenses/>.
249 *
2510 * Please send any bug reports or fixes you make to the
2611 * email address(es):
....@@ -40,10 +25,7 @@
4025 #include <net/sctp/sctp.h>
4126 #include <linux/sysctl.h>
4227
43
-static int zero = 0;
44
-static int one = 1;
4528 static int timer_max = 86400000; /* ms in one day */
46
-static int int_max = INT_MAX;
4729 static int sack_timer_min = 1;
4830 static int sack_timer_max = 500;
4931 static int addr_scope_max = SCTP_SCOPE_POLICY_MAX;
....@@ -52,6 +34,8 @@
5234 static int rto_beta_min = 0;
5335 static int rto_alpha_max = 1000;
5436 static int rto_beta_max = 1000;
37
+static int pf_expose_max = SCTP_PF_EXPOSE_MAX;
38
+static int ps_retrans_max = SCTP_PS_RETRANS_MAX;
5539
5640 static unsigned long max_autoclose_min = 0;
5741 static unsigned long max_autoclose_max =
....@@ -59,20 +43,15 @@
5943 ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
6044
6145 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
62
- void __user *buffer, size_t *lenp,
63
- loff_t *ppos);
46
+ void *buffer, size_t *lenp, loff_t *ppos);
6447 static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
65
- void __user *buffer, size_t *lenp,
66
- loff_t *ppos);
67
-static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
68
- void __user *buffer, size_t *lenp,
69
- loff_t *ppos);
48
+ void *buffer, size_t *lenp, loff_t *ppos);
49
+static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, void *buffer,
50
+ size_t *lenp, loff_t *ppos);
7051 static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
71
- void __user *buffer, size_t *lenp,
72
- loff_t *ppos);
52
+ void *buffer, size_t *lenp, loff_t *ppos);
7353 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
74
- void __user *buffer, size_t *lenp,
75
- loff_t *ppos);
54
+ void *buffer, size_t *lenp, loff_t *ppos);
7655
7756 static struct ctl_table sctp_table[] = {
7857 {
....@@ -107,7 +86,7 @@
10786 .maxlen = sizeof(unsigned int),
10887 .mode = 0644,
10988 .proc_handler = proc_dointvec_minmax,
110
- .extra1 = &one,
89
+ .extra1 = SYSCTL_ONE,
11190 .extra2 = &timer_max
11291 },
11392 {
....@@ -116,7 +95,7 @@
11695 .maxlen = sizeof(unsigned int),
11796 .mode = 0644,
11897 .proc_handler = proc_sctp_do_rto_min,
119
- .extra1 = &one,
98
+ .extra1 = SYSCTL_ONE,
12099 .extra2 = &init_net.sctp.rto_max
121100 },
122101 {
....@@ -152,8 +131,8 @@
152131 .maxlen = sizeof(int),
153132 .mode = 0644,
154133 .proc_handler = proc_dointvec_minmax,
155
- .extra1 = &zero,
156
- .extra2 = &int_max
134
+ .extra1 = SYSCTL_ZERO,
135
+ .extra2 = SYSCTL_INT_MAX,
157136 },
158137 {
159138 .procname = "cookie_preserve_enable",
....@@ -175,7 +154,7 @@
175154 .maxlen = sizeof(unsigned int),
176155 .mode = 0644,
177156 .proc_handler = proc_dointvec_minmax,
178
- .extra1 = &one,
157
+ .extra1 = SYSCTL_ONE,
179158 .extra2 = &timer_max
180159 },
181160 {
....@@ -193,7 +172,7 @@
193172 .maxlen = sizeof(unsigned int),
194173 .mode = 0644,
195174 .proc_handler = proc_dointvec_minmax,
196
- .extra1 = &one,
175
+ .extra1 = SYSCTL_ONE,
197176 .extra2 = &timer_max
198177 },
199178 {
....@@ -202,8 +181,8 @@
202181 .maxlen = sizeof(int),
203182 .mode = 0644,
204183 .proc_handler = proc_dointvec_minmax,
205
- .extra1 = &one,
206
- .extra2 = &int_max
184
+ .extra1 = SYSCTL_ONE,
185
+ .extra2 = SYSCTL_INT_MAX,
207186 },
208187 {
209188 .procname = "path_max_retrans",
....@@ -211,8 +190,8 @@
211190 .maxlen = sizeof(int),
212191 .mode = 0644,
213192 .proc_handler = proc_dointvec_minmax,
214
- .extra1 = &one,
215
- .extra2 = &int_max
193
+ .extra1 = SYSCTL_ONE,
194
+ .extra2 = SYSCTL_INT_MAX,
216195 },
217196 {
218197 .procname = "max_init_retransmits",
....@@ -220,8 +199,8 @@
220199 .maxlen = sizeof(int),
221200 .mode = 0644,
222201 .proc_handler = proc_dointvec_minmax,
223
- .extra1 = &one,
224
- .extra2 = &int_max
202
+ .extra1 = SYSCTL_ONE,
203
+ .extra2 = SYSCTL_INT_MAX,
225204 },
226205 {
227206 .procname = "pf_retrans",
....@@ -229,8 +208,17 @@
229208 .maxlen = sizeof(int),
230209 .mode = 0644,
231210 .proc_handler = proc_dointvec_minmax,
232
- .extra1 = &zero,
233
- .extra2 = &int_max
211
+ .extra1 = SYSCTL_ZERO,
212
+ .extra2 = &init_net.sctp.ps_retrans,
213
+ },
214
+ {
215
+ .procname = "ps_retrans",
216
+ .data = &init_net.sctp.ps_retrans,
217
+ .maxlen = sizeof(int),
218
+ .mode = 0644,
219
+ .proc_handler = proc_dointvec_minmax,
220
+ .extra1 = &init_net.sctp.pf_retrans,
221
+ .extra2 = &ps_retrans_max,
234222 },
235223 {
236224 .procname = "sndbuf_policy",
....@@ -296,12 +284,19 @@
296284 .proc_handler = proc_dointvec,
297285 },
298286 {
287
+ .procname = "ecn_enable",
288
+ .data = &init_net.sctp.ecn_enable,
289
+ .maxlen = sizeof(int),
290
+ .mode = 0644,
291
+ .proc_handler = proc_dointvec,
292
+ },
293
+ {
299294 .procname = "addr_scope_policy",
300295 .data = &init_net.sctp.scope_policy,
301296 .maxlen = sizeof(int),
302297 .mode = 0644,
303298 .proc_handler = proc_dointvec_minmax,
304
- .extra1 = &zero,
299
+ .extra1 = SYSCTL_ZERO,
305300 .extra2 = &addr_scope_max,
306301 },
307302 {
....@@ -310,7 +305,7 @@
310305 .maxlen = sizeof(int),
311306 .mode = 0644,
312307 .proc_handler = &proc_dointvec_minmax,
313
- .extra1 = &one,
308
+ .extra1 = SYSCTL_ONE,
314309 .extra2 = &rwnd_scale_max,
315310 },
316311 {
....@@ -329,13 +324,21 @@
329324 .mode = 0644,
330325 .proc_handler = proc_dointvec,
331326 },
327
+ {
328
+ .procname = "pf_expose",
329
+ .data = &init_net.sctp.pf_expose,
330
+ .maxlen = sizeof(int),
331
+ .mode = 0644,
332
+ .proc_handler = proc_dointvec_minmax,
333
+ .extra1 = SYSCTL_ZERO,
334
+ .extra2 = &pf_expose_max,
335
+ },
332336
333337 { /* sentinel */ }
334338 };
335339
336340 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
337
- void __user *buffer, size_t *lenp,
338
- loff_t *ppos)
341
+ void *buffer, size_t *lenp, loff_t *ppos)
339342 {
340343 struct net *net = current->nsproxy->net_ns;
341344 struct ctl_table tbl;
....@@ -380,8 +383,7 @@
380383 }
381384
382385 static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
383
- void __user *buffer, size_t *lenp,
384
- loff_t *ppos)
386
+ void *buffer, size_t *lenp, loff_t *ppos)
385387 {
386388 struct net *net = current->nsproxy->net_ns;
387389 unsigned int min = *(unsigned int *) ctl->extra1;
....@@ -409,8 +411,7 @@
409411 }
410412
411413 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
412
- void __user *buffer, size_t *lenp,
413
- loff_t *ppos)
414
+ void *buffer, size_t *lenp, loff_t *ppos)
414415 {
415416 struct net *net = current->nsproxy->net_ns;
416417 unsigned int min = *(unsigned int *) ctl->extra1;
....@@ -438,8 +439,7 @@
438439 }
439440
440441 static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
441
- void __user *buffer, size_t *lenp,
442
- loff_t *ppos)
442
+ void *buffer, size_t *lenp, loff_t *ppos)
443443 {
444444 if (write)
445445 pr_warn_once("Changing rto_alpha or rto_beta may lead to "
....@@ -449,8 +449,7 @@
449449 }
450450
451451 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
452
- void __user *buffer, size_t *lenp,
453
- loff_t *ppos)
452
+ void *buffer, size_t *lenp, loff_t *ppos)
454453 {
455454 struct net *net = current->nsproxy->net_ns;
456455 struct ctl_table tbl;