hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
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 {
....@@ -100,32 +79,60 @@
10079 { /* sentinel */ }
10180 };
10281
82
+/* The following index defines are used in sctp_sysctl_net_register().
83
+ * If you add new items to the sctp_net_table, please ensure that
84
+ * the index values of these defines hold the same meaning indicated by
85
+ * their macro names when they appear in sctp_net_table.
86
+ */
87
+#define SCTP_RTO_MIN_IDX 0
88
+#define SCTP_RTO_MAX_IDX 1
89
+#define SCTP_PF_RETRANS_IDX 2
90
+#define SCTP_PS_RETRANS_IDX 3
91
+
10392 static struct ctl_table sctp_net_table[] = {
104
- {
105
- .procname = "rto_initial",
106
- .data = &init_net.sctp.rto_initial,
107
- .maxlen = sizeof(unsigned int),
108
- .mode = 0644,
109
- .proc_handler = proc_dointvec_minmax,
110
- .extra1 = &one,
111
- .extra2 = &timer_max
112
- },
113
- {
93
+ [SCTP_RTO_MIN_IDX] = {
11494 .procname = "rto_min",
11595 .data = &init_net.sctp.rto_min,
11696 .maxlen = sizeof(unsigned int),
11797 .mode = 0644,
11898 .proc_handler = proc_sctp_do_rto_min,
119
- .extra1 = &one,
99
+ .extra1 = SYSCTL_ONE,
120100 .extra2 = &init_net.sctp.rto_max
121101 },
122
- {
102
+ [SCTP_RTO_MAX_IDX] = {
123103 .procname = "rto_max",
124104 .data = &init_net.sctp.rto_max,
125105 .maxlen = sizeof(unsigned int),
126106 .mode = 0644,
127107 .proc_handler = proc_sctp_do_rto_max,
128108 .extra1 = &init_net.sctp.rto_min,
109
+ .extra2 = &timer_max
110
+ },
111
+ [SCTP_PF_RETRANS_IDX] = {
112
+ .procname = "pf_retrans",
113
+ .data = &init_net.sctp.pf_retrans,
114
+ .maxlen = sizeof(int),
115
+ .mode = 0644,
116
+ .proc_handler = proc_dointvec_minmax,
117
+ .extra1 = SYSCTL_ZERO,
118
+ .extra2 = &init_net.sctp.ps_retrans,
119
+ },
120
+ [SCTP_PS_RETRANS_IDX] = {
121
+ .procname = "ps_retrans",
122
+ .data = &init_net.sctp.ps_retrans,
123
+ .maxlen = sizeof(int),
124
+ .mode = 0644,
125
+ .proc_handler = proc_dointvec_minmax,
126
+ .extra1 = &init_net.sctp.pf_retrans,
127
+ .extra2 = &ps_retrans_max,
128
+ },
129
+ {
130
+ .procname = "rto_initial",
131
+ .data = &init_net.sctp.rto_initial,
132
+ .maxlen = sizeof(unsigned int),
133
+ .mode = 0644,
134
+ .proc_handler = proc_dointvec_minmax,
135
+ .extra1 = SYSCTL_ONE,
129136 .extra2 = &timer_max
130137 },
131138 {
....@@ -152,8 +159,8 @@
152159 .maxlen = sizeof(int),
153160 .mode = 0644,
154161 .proc_handler = proc_dointvec_minmax,
155
- .extra1 = &zero,
156
- .extra2 = &int_max
162
+ .extra1 = SYSCTL_ZERO,
163
+ .extra2 = SYSCTL_INT_MAX,
157164 },
158165 {
159166 .procname = "cookie_preserve_enable",
....@@ -175,7 +182,7 @@
175182 .maxlen = sizeof(unsigned int),
176183 .mode = 0644,
177184 .proc_handler = proc_dointvec_minmax,
178
- .extra1 = &one,
185
+ .extra1 = SYSCTL_ONE,
179186 .extra2 = &timer_max
180187 },
181188 {
....@@ -193,7 +200,7 @@
193200 .maxlen = sizeof(unsigned int),
194201 .mode = 0644,
195202 .proc_handler = proc_dointvec_minmax,
196
- .extra1 = &one,
203
+ .extra1 = SYSCTL_ONE,
197204 .extra2 = &timer_max
198205 },
199206 {
....@@ -202,8 +209,8 @@
202209 .maxlen = sizeof(int),
203210 .mode = 0644,
204211 .proc_handler = proc_dointvec_minmax,
205
- .extra1 = &one,
206
- .extra2 = &int_max
212
+ .extra1 = SYSCTL_ONE,
213
+ .extra2 = SYSCTL_INT_MAX,
207214 },
208215 {
209216 .procname = "path_max_retrans",
....@@ -211,8 +218,8 @@
211218 .maxlen = sizeof(int),
212219 .mode = 0644,
213220 .proc_handler = proc_dointvec_minmax,
214
- .extra1 = &one,
215
- .extra2 = &int_max
221
+ .extra1 = SYSCTL_ONE,
222
+ .extra2 = SYSCTL_INT_MAX,
216223 },
217224 {
218225 .procname = "max_init_retransmits",
....@@ -220,17 +227,8 @@
220227 .maxlen = sizeof(int),
221228 .mode = 0644,
222229 .proc_handler = proc_dointvec_minmax,
223
- .extra1 = &one,
224
- .extra2 = &int_max
225
- },
226
- {
227
- .procname = "pf_retrans",
228
- .data = &init_net.sctp.pf_retrans,
229
- .maxlen = sizeof(int),
230
- .mode = 0644,
231
- .proc_handler = proc_dointvec_minmax,
232
- .extra1 = &zero,
233
- .extra2 = &int_max
230
+ .extra1 = SYSCTL_ONE,
231
+ .extra2 = SYSCTL_INT_MAX,
234232 },
235233 {
236234 .procname = "sndbuf_policy",
....@@ -296,12 +294,19 @@
296294 .proc_handler = proc_dointvec,
297295 },
298296 {
297
+ .procname = "ecn_enable",
298
+ .data = &init_net.sctp.ecn_enable,
299
+ .maxlen = sizeof(int),
300
+ .mode = 0644,
301
+ .proc_handler = proc_dointvec,
302
+ },
303
+ {
299304 .procname = "addr_scope_policy",
300305 .data = &init_net.sctp.scope_policy,
301306 .maxlen = sizeof(int),
302307 .mode = 0644,
303308 .proc_handler = proc_dointvec_minmax,
304
- .extra1 = &zero,
309
+ .extra1 = SYSCTL_ZERO,
305310 .extra2 = &addr_scope_max,
306311 },
307312 {
....@@ -310,7 +315,7 @@
310315 .maxlen = sizeof(int),
311316 .mode = 0644,
312317 .proc_handler = &proc_dointvec_minmax,
313
- .extra1 = &one,
318
+ .extra1 = SYSCTL_ONE,
314319 .extra2 = &rwnd_scale_max,
315320 },
316321 {
....@@ -329,13 +334,21 @@
329334 .mode = 0644,
330335 .proc_handler = proc_dointvec,
331336 },
337
+ {
338
+ .procname = "pf_expose",
339
+ .data = &init_net.sctp.pf_expose,
340
+ .maxlen = sizeof(int),
341
+ .mode = 0644,
342
+ .proc_handler = proc_dointvec_minmax,
343
+ .extra1 = SYSCTL_ZERO,
344
+ .extra2 = &pf_expose_max,
345
+ },
332346
333347 { /* sentinel */ }
334348 };
335349
336350 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
337
- void __user *buffer, size_t *lenp,
338
- loff_t *ppos)
351
+ void *buffer, size_t *lenp, loff_t *ppos)
339352 {
340353 struct net *net = current->nsproxy->net_ns;
341354 struct ctl_table tbl;
....@@ -380,8 +393,7 @@
380393 }
381394
382395 static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
383
- void __user *buffer, size_t *lenp,
384
- loff_t *ppos)
396
+ void *buffer, size_t *lenp, loff_t *ppos)
385397 {
386398 struct net *net = current->nsproxy->net_ns;
387399 unsigned int min = *(unsigned int *) ctl->extra1;
....@@ -409,8 +421,7 @@
409421 }
410422
411423 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
412
- void __user *buffer, size_t *lenp,
413
- loff_t *ppos)
424
+ void *buffer, size_t *lenp, loff_t *ppos)
414425 {
415426 struct net *net = current->nsproxy->net_ns;
416427 unsigned int min = *(unsigned int *) ctl->extra1;
....@@ -438,8 +449,7 @@
438449 }
439450
440451 static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
441
- void __user *buffer, size_t *lenp,
442
- loff_t *ppos)
452
+ void *buffer, size_t *lenp, loff_t *ppos)
443453 {
444454 if (write)
445455 pr_warn_once("Changing rto_alpha or rto_beta may lead to "
....@@ -449,8 +459,7 @@
449459 }
450460
451461 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
452
- void __user *buffer, size_t *lenp,
453
- loff_t *ppos)
462
+ void *buffer, size_t *lenp, loff_t *ppos)
454463 {
455464 struct net *net = current->nsproxy->net_ns;
456465 struct ctl_table tbl;
....@@ -490,6 +499,11 @@
490499 for (i = 0; table[i].data; i++)
491500 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
492501
502
+ table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max;
503
+ table[SCTP_RTO_MAX_IDX].extra1 = &net->sctp.rto_min;
504
+ table[SCTP_PF_RETRANS_IDX].extra2 = &net->sctp.ps_retrans;
505
+ table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans;
506
+
493507 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
494508 if (net->sctp.sysctl_header == NULL) {
495509 kfree(table);