Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com) |
| 5 | */ |
| 6 | #include <linux/mm.h> |
| 7 | #include <linux/sysctl.h> |
| 8 | #include <linux/init.h> |
| 9 | #include <net/ax25.h> |
| 10 | #include <net/netrom.h> |
| 11 | |
| 12 | /* |
| 13 | * Values taken from NET/ROM documentation. |
| 14 | */ |
| 15 | static int min_quality[] = {0}, max_quality[] = {255}; |
| 16 | static int min_obs[] = {0}, max_obs[] = {255}; |
| 17 | static int min_ttl[] = {0}, max_ttl[] = {255}; |
| 18 | static int min_t1[] = {5 * HZ}; |
| 19 | static int max_t1[] = {600 * HZ}; |
| 20 | static int min_n2[] = {2}, max_n2[] = {127}; |
| 21 | static int min_t2[] = {1 * HZ}; |
| 22 | static int max_t2[] = {60 * HZ}; |
| 23 | static int min_t4[] = {1 * HZ}; |
| 24 | static int max_t4[] = {1000 * HZ}; |
| 25 | static int min_window[] = {1}, max_window[] = {127}; |
| 26 | static int min_idle[] = {0 * HZ}; |
| 27 | static int max_idle[] = {65535 * HZ}; |
| 28 | static int min_route[] = {0}, max_route[] = {1}; |
| 29 | static int min_fails[] = {1}, max_fails[] = {10}; |
Ralf Baechle | e21ce8c | 2005-09-12 14:27:37 -0700 | [diff] [blame] | 30 | static int min_reset[] = {0}, max_reset[] = {1}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | static struct ctl_table_header *nr_table_header; |
| 33 | |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 34 | static struct ctl_table nr_table[] = { |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 35 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | .procname = "default_path_quality", |
| 37 | .data = &sysctl_netrom_default_path_quality, |
| 38 | .maxlen = sizeof(int), |
| 39 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 40 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | .extra1 = &min_quality, |
| 42 | .extra2 = &max_quality |
| 43 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 44 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | .procname = "obsolescence_count_initialiser", |
| 46 | .data = &sysctl_netrom_obsolescence_count_initialiser, |
| 47 | .maxlen = sizeof(int), |
| 48 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 49 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | .extra1 = &min_obs, |
| 51 | .extra2 = &max_obs |
| 52 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 53 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | .procname = "network_ttl_initialiser", |
| 55 | .data = &sysctl_netrom_network_ttl_initialiser, |
| 56 | .maxlen = sizeof(int), |
| 57 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 58 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | .extra1 = &min_ttl, |
| 60 | .extra2 = &max_ttl |
| 61 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 62 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | .procname = "transport_timeout", |
| 64 | .data = &sysctl_netrom_transport_timeout, |
| 65 | .maxlen = sizeof(int), |
| 66 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 67 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | .extra1 = &min_t1, |
| 69 | .extra2 = &max_t1 |
| 70 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 71 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | .procname = "transport_maximum_tries", |
| 73 | .data = &sysctl_netrom_transport_maximum_tries, |
| 74 | .maxlen = sizeof(int), |
| 75 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 76 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | .extra1 = &min_n2, |
| 78 | .extra2 = &max_n2 |
| 79 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 80 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | .procname = "transport_acknowledge_delay", |
| 82 | .data = &sysctl_netrom_transport_acknowledge_delay, |
| 83 | .maxlen = sizeof(int), |
| 84 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 85 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | .extra1 = &min_t2, |
| 87 | .extra2 = &max_t2 |
| 88 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 89 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | .procname = "transport_busy_delay", |
| 91 | .data = &sysctl_netrom_transport_busy_delay, |
| 92 | .maxlen = sizeof(int), |
| 93 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 94 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | .extra1 = &min_t4, |
| 96 | .extra2 = &max_t4 |
| 97 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 98 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | .procname = "transport_requested_window_size", |
| 100 | .data = &sysctl_netrom_transport_requested_window_size, |
| 101 | .maxlen = sizeof(int), |
| 102 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 103 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | .extra1 = &min_window, |
| 105 | .extra2 = &max_window |
| 106 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 107 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | .procname = "transport_no_activity_timeout", |
| 109 | .data = &sysctl_netrom_transport_no_activity_timeout, |
| 110 | .maxlen = sizeof(int), |
| 111 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 112 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | .extra1 = &min_idle, |
| 114 | .extra2 = &max_idle |
| 115 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 116 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | .procname = "routing_control", |
| 118 | .data = &sysctl_netrom_routing_control, |
| 119 | .maxlen = sizeof(int), |
| 120 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 121 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | .extra1 = &min_route, |
| 123 | .extra2 = &max_route |
| 124 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 125 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | .procname = "link_fails_count", |
| 127 | .data = &sysctl_netrom_link_fails_count, |
| 128 | .maxlen = sizeof(int), |
| 129 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 130 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | .extra1 = &min_fails, |
| 132 | .extra2 = &max_fails |
| 133 | }, |
YOSHIFUJI Hideaki | 5f8f59d | 2007-02-09 23:25:09 +0900 | [diff] [blame] | 134 | { |
Ralf Baechle | e21ce8c | 2005-09-12 14:27:37 -0700 | [diff] [blame] | 135 | .procname = "reset", |
| 136 | .data = &sysctl_netrom_reset_circuit, |
| 137 | .maxlen = sizeof(int), |
| 138 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 139 | .proc_handler = proc_dointvec_minmax, |
Ralf Baechle | e21ce8c | 2005-09-12 14:27:37 -0700 | [diff] [blame] | 140 | .extra1 = &min_reset, |
| 141 | .extra2 = &max_reset |
| 142 | }, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 143 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
YueHaibing | d370656 | 2019-04-09 19:53:55 +0800 | [diff] [blame] | 146 | int __init nr_register_sysctl(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
Eric W. Biederman | ec8f23c | 2012-04-19 13:44:49 +0000 | [diff] [blame] | 148 | nr_table_header = register_net_sysctl(&init_net, "net/netrom", nr_table); |
YueHaibing | d370656 | 2019-04-09 19:53:55 +0800 | [diff] [blame] | 149 | if (!nr_table_header) |
| 150 | return -ENOMEM; |
| 151 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | void nr_unregister_sysctl(void) |
| 155 | { |
Eric W. Biederman | 5dd3df1 | 2012-04-19 13:24:33 +0000 | [diff] [blame] | 156 | unregister_net_sysctl_table(nr_table_header); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |