~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/sctp/sysctl.c

Version: ~ [ linux-5.8-rc5 ] ~ [ linux-5.7.8 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.51 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.132 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.188 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.230 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.230 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SCTP kernel implementation
  2  * (C) Copyright IBM Corp. 2002, 2004
  3  * Copyright (c) 2002 Intel Corp.
  4  *
  5  * This file is part of the SCTP kernel implementation
  6  *
  7  * 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, write to
 23  * the Free Software Foundation, 59 Temple Place - Suite 330,
 24  * Boston, MA 02111-1307, USA.
 25  *
 26  * Please send any bug reports or fixes you make to the
 27  * email address(es):
 28  *    lksctp developers <linux-sctp@vger.kernel.org>
 29  *
 30  * Written or modified by:
 31  *    Mingqin Liu           <liuming@us.ibm.com>
 32  *    Jon Grimm             <jgrimm@us.ibm.com>
 33  *    Ardelle Fan           <ardelle.fan@intel.com>
 34  *    Ryan Layer            <rmlayer@us.ibm.com>
 35  *    Sridhar Samudrala     <sri@us.ibm.com>
 36  */
 37 
 38 #include <net/sctp/structs.h>
 39 #include <net/sctp/sctp.h>
 40 #include <linux/sysctl.h>
 41 
 42 static int zero = 0;
 43 static int one = 1;
 44 static int timer_max = 86400000; /* ms in one day */
 45 static int int_max = INT_MAX;
 46 static int sack_timer_min = 1;
 47 static int sack_timer_max = 500;
 48 static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
 49 static int rwnd_scale_max = 16;
 50 static unsigned long max_autoclose_min = 0;
 51 static unsigned long max_autoclose_max =
 52         (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
 53         ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
 54 
 55 extern long sysctl_sctp_mem[3];
 56 extern int sysctl_sctp_rmem[3];
 57 extern int sysctl_sctp_wmem[3];
 58 
 59 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
 60                                 int write,
 61                                 void __user *buffer, size_t *lenp,
 62                                 loff_t *ppos);
 63 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
 64                              void __user *buffer, size_t *lenp,
 65                              loff_t *ppos);
 66 
 67 static struct ctl_table sctp_table[] = {
 68         {
 69                 .procname       = "sctp_mem",
 70                 .data           = &sysctl_sctp_mem,
 71                 .maxlen         = sizeof(sysctl_sctp_mem),
 72                 .mode           = 0644,
 73                 .proc_handler   = proc_doulongvec_minmax
 74         },
 75         {
 76                 .procname       = "sctp_rmem",
 77                 .data           = &sysctl_sctp_rmem,
 78                 .maxlen         = sizeof(sysctl_sctp_rmem),
 79                 .mode           = 0644,
 80                 .proc_handler   = proc_dointvec,
 81         },
 82         {
 83                 .procname       = "sctp_wmem",
 84                 .data           = &sysctl_sctp_wmem,
 85                 .maxlen         = sizeof(sysctl_sctp_wmem),
 86                 .mode           = 0644,
 87                 .proc_handler   = proc_dointvec,
 88         },
 89 
 90         { /* sentinel */ }
 91 };
 92 
 93 static struct ctl_table sctp_net_table[] = {
 94         {
 95                 .procname       = "rto_initial",
 96                 .data           = &init_net.sctp.rto_initial,
 97                 .maxlen         = sizeof(unsigned int),
 98                 .mode           = 0644,
 99                 .proc_handler   = proc_dointvec_minmax,
100                 .extra1         = &one,
101                 .extra2         = &timer_max
102         },
103         {
104                 .procname       = "rto_min",
105                 .data           = &init_net.sctp.rto_min,
106                 .maxlen         = sizeof(unsigned int),
107                 .mode           = 0644,
108                 .proc_handler   = proc_dointvec_minmax,
109                 .extra1         = &one,
110                 .extra2         = &timer_max
111         },
112         {
113                 .procname       = "rto_max",
114                 .data           = &init_net.sctp.rto_max,
115                 .maxlen         = sizeof(unsigned int),
116                 .mode           = 0644,
117                 .proc_handler   = proc_dointvec_minmax,
118                 .extra1         = &one,
119                 .extra2         = &timer_max
120         },
121         {
122                 .procname       = "rto_alpha_exp_divisor",
123                 .data           = &init_net.sctp.rto_alpha,
124                 .maxlen         = sizeof(int),
125                 .mode           = 0444,
126                 .proc_handler   = proc_dointvec,
127         },
128         {
129                 .procname       = "rto_beta_exp_divisor",
130                 .data           = &init_net.sctp.rto_beta,
131                 .maxlen         = sizeof(int),
132                 .mode           = 0444,
133                 .proc_handler   = proc_dointvec,
134         },
135         {
136                 .procname       = "max_burst",
137                 .data           = &init_net.sctp.max_burst,
138                 .maxlen         = sizeof(int),
139                 .mode           = 0644,
140                 .proc_handler   = proc_dointvec_minmax,
141                 .extra1         = &zero,
142                 .extra2         = &int_max
143         },
144         {
145                 .procname       = "cookie_preserve_enable",
146                 .data           = &init_net.sctp.cookie_preserve_enable,
147                 .maxlen         = sizeof(int),
148                 .mode           = 0644,
149                 .proc_handler   = proc_dointvec,
150         },
151         {
152                 .procname       = "cookie_hmac_alg",
153                 .maxlen         = 8,
154                 .mode           = 0644,
155                 .proc_handler   = proc_sctp_do_hmac_alg,
156         },
157         {
158                 .procname       = "valid_cookie_life",
159                 .data           = &init_net.sctp.valid_cookie_life,
160                 .maxlen         = sizeof(unsigned int),
161                 .mode           = 0644,
162                 .proc_handler   = proc_dointvec_minmax,
163                 .extra1         = &one,
164                 .extra2         = &timer_max
165         },
166         {
167                 .procname       = "sack_timeout",
168                 .data           = &init_net.sctp.sack_timeout,
169                 .maxlen         = sizeof(int),
170                 .mode           = 0644,
171                 .proc_handler   = proc_dointvec_minmax,
172                 .extra1         = &sack_timer_min,
173                 .extra2         = &sack_timer_max,
174         },
175         {
176                 .procname       = "hb_interval",
177                 .data           = &init_net.sctp.hb_interval,
178                 .maxlen         = sizeof(unsigned int),
179                 .mode           = 0644,
180                 .proc_handler   = proc_dointvec_minmax,
181                 .extra1         = &one,
182                 .extra2         = &timer_max
183         },
184         {
185                 .procname       = "association_max_retrans",
186                 .data           = &init_net.sctp.max_retrans_association,
187                 .maxlen         = sizeof(int),
188                 .mode           = 0644,
189                 .proc_handler   = proc_dointvec_minmax,
190                 .extra1         = &one,
191                 .extra2         = &int_max
192         },
193         {
194                 .procname       = "path_max_retrans",
195                 .data           = &init_net.sctp.max_retrans_path,
196                 .maxlen         = sizeof(int),
197                 .mode           = 0644,
198                 .proc_handler   = proc_dointvec_minmax,
199                 .extra1         = &one,
200                 .extra2         = &int_max
201         },
202         {
203                 .procname       = "max_init_retransmits",
204                 .data           = &init_net.sctp.max_retrans_init,
205                 .maxlen         = sizeof(int),
206                 .mode           = 0644,
207                 .proc_handler   = proc_dointvec_minmax,
208                 .extra1         = &one,
209                 .extra2         = &int_max
210         },
211         {
212                 .procname       = "pf_retrans",
213                 .data           = &init_net.sctp.pf_retrans,
214                 .maxlen         = sizeof(int),
215                 .mode           = 0644,
216                 .proc_handler   = proc_dointvec_minmax,
217                 .extra1         = &zero,
218                 .extra2         = &int_max
219         },
220         {
221                 .procname       = "sndbuf_policy",
222                 .data           = &init_net.sctp.sndbuf_policy,
223                 .maxlen         = sizeof(int),
224                 .mode           = 0644,
225                 .proc_handler   = proc_dointvec,
226         },
227         {
228                 .procname       = "rcvbuf_policy",
229                 .data           = &init_net.sctp.rcvbuf_policy,
230                 .maxlen         = sizeof(int),
231                 .mode           = 0644,
232                 .proc_handler   = proc_dointvec,
233         },
234         {
235                 .procname       = "default_auto_asconf",
236                 .data           = &init_net.sctp.default_auto_asconf,
237                 .maxlen         = sizeof(int),
238                 .mode           = 0644,
239                 .proc_handler   = proc_dointvec,
240         },
241         {
242                 .procname       = "addip_enable",
243                 .data           = &init_net.sctp.addip_enable,
244                 .maxlen         = sizeof(int),
245                 .mode           = 0644,
246                 .proc_handler   = proc_dointvec,
247         },
248         {
249                 .procname       = "addip_noauth_enable",
250                 .data           = &init_net.sctp.addip_noauth,
251                 .maxlen         = sizeof(int),
252                 .mode           = 0644,
253                 .proc_handler   = proc_dointvec,
254         },
255         {
256                 .procname       = "prsctp_enable",
257                 .data           = &init_net.sctp.prsctp_enable,
258                 .maxlen         = sizeof(int),
259                 .mode           = 0644,
260                 .proc_handler   = proc_dointvec,
261         },
262         {
263                 .procname       = "auth_enable",
264                 .data           = &init_net.sctp.auth_enable,
265                 .maxlen         = sizeof(int),
266                 .mode           = 0644,
267                 .proc_handler   = proc_sctp_do_auth,
268         },
269         {
270                 .procname       = "addr_scope_policy",
271                 .data           = &init_net.sctp.scope_policy,
272                 .maxlen         = sizeof(int),
273                 .mode           = 0644,
274                 .proc_handler   = proc_dointvec_minmax,
275                 .extra1         = &zero,
276                 .extra2         = &addr_scope_max,
277         },
278         {
279                 .procname       = "rwnd_update_shift",
280                 .data           = &init_net.sctp.rwnd_upd_shift,
281                 .maxlen         = sizeof(int),
282                 .mode           = 0644,
283                 .proc_handler   = &proc_dointvec_minmax,
284                 .extra1         = &one,
285                 .extra2         = &rwnd_scale_max,
286         },
287         {
288                 .procname       = "max_autoclose",
289                 .data           = &init_net.sctp.max_autoclose,
290                 .maxlen         = sizeof(unsigned long),
291                 .mode           = 0644,
292                 .proc_handler   = &proc_doulongvec_minmax,
293                 .extra1         = &max_autoclose_min,
294                 .extra2         = &max_autoclose_max,
295         },
296 
297         { /* sentinel */ }
298 };
299 
300 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
301                                 int write,
302                                 void __user *buffer, size_t *lenp,
303                                 loff_t *ppos)
304 {
305         struct net *net = current->nsproxy->net_ns;
306         struct ctl_table tbl;
307         bool changed = false;
308         char *none = "none";
309         char tmp[8] = {0};
310         int ret;
311 
312         memset(&tbl, 0, sizeof(struct ctl_table));
313 
314         if (write) {
315                 tbl.data = tmp;
316                 tbl.maxlen = sizeof(tmp);
317         } else {
318                 tbl.data = net->sctp.sctp_hmac_alg ? : none;
319                 tbl.maxlen = strlen(tbl.data);
320         }
321 
322         ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
323         if (write && ret == 0) {
324 #ifdef CONFIG_CRYPTO_MD5
325                 if (!strncmp(tmp, "md5", 3)) {
326                         net->sctp.sctp_hmac_alg = "md5";
327                         changed = true;
328                 }
329 #endif
330 #ifdef CONFIG_CRYPTO_SHA1
331                 if (!strncmp(tmp, "sha1", 4)) {
332                         net->sctp.sctp_hmac_alg = "sha1";
333                         changed = true;
334                 }
335 #endif
336                 if (!strncmp(tmp, "none", 4)) {
337                         net->sctp.sctp_hmac_alg = NULL;
338                         changed = true;
339                 }
340                 if (!changed)
341                         ret = -EINVAL;
342         }
343 
344         return ret;
345 }
346 
347 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
348                              void __user *buffer, size_t *lenp,
349                              loff_t *ppos)
350 {
351         struct net *net = current->nsproxy->net_ns;
352         struct ctl_table tbl;
353         int new_value, ret;
354 
355         memset(&tbl, 0, sizeof(struct ctl_table));
356         tbl.maxlen = sizeof(unsigned int);
357 
358         if (write)
359                 tbl.data = &new_value;
360         else
361                 tbl.data = &net->sctp.auth_enable;
362 
363         ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
364         if (write && ret == 0) {
365                 struct sock *sk = net->sctp.ctl_sock;
366 
367                 net->sctp.auth_enable = new_value;
368                 /* Update the value in the control socket */
369                 lock_sock(sk);
370                 sctp_sk(sk)->ep->auth_enable = new_value;
371                 release_sock(sk);
372         }
373 
374         return ret;
375 }
376 
377 int sctp_sysctl_net_register(struct net *net)
378 {
379         struct ctl_table *table;
380         int i;
381 
382         table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
383         if (!table)
384                 return -ENOMEM;
385 
386         for (i = 0; table[i].data; i++)
387                 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
388 
389         net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
390         return 0;
391 }
392 
393 void sctp_sysctl_net_unregister(struct net *net)
394 {
395         struct ctl_table *table;
396 
397         table = net->sctp.sysctl_header->ctl_table_arg;
398         unregister_net_sysctl_table(net->sctp.sysctl_header);
399         kfree(table);
400 }
401 
402 static struct ctl_table_header * sctp_sysctl_header;
403 
404 /* Sysctl registration.  */
405 void sctp_sysctl_register(void)
406 {
407         sctp_sysctl_header = register_net_sysctl(&init_net, "net/sctp", sctp_table);
408 }
409 
410 /* Sysctl deregistration.  */
411 void sctp_sysctl_unregister(void)
412 {
413         unregister_net_sysctl_table(sctp_sysctl_header);
414 }
415 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp