blob: 79fb2d3f477b52762707c32fb77e3975c26cfb90 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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 */
15static int min_quality[] = {0}, max_quality[] = {255};
16static int min_obs[] = {0}, max_obs[] = {255};
17static int min_ttl[] = {0}, max_ttl[] = {255};
18static int min_t1[] = {5 * HZ};
19static int max_t1[] = {600 * HZ};
20static int min_n2[] = {2}, max_n2[] = {127};
21static int min_t2[] = {1 * HZ};
22static int max_t2[] = {60 * HZ};
23static int min_t4[] = {1 * HZ};
24static int max_t4[] = {1000 * HZ};
25static int min_window[] = {1}, max_window[] = {127};
26static int min_idle[] = {0 * HZ};
27static int max_idle[] = {65535 * HZ};
28static int min_route[] = {0}, max_route[] = {1};
29static int min_fails[] = {1}, max_fails[] = {10};
Ralf Baechlee21ce8c2005-09-12 14:27:37 -070030static int min_reset[] = {0}, max_reset[] = {1};
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32static struct ctl_table_header *nr_table_header;
33
Joe Perchesfe2c6332013-06-11 23:04:25 -070034static struct ctl_table nr_table[] = {
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090035 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 .procname = "default_path_quality",
37 .data = &sysctl_netrom_default_path_quality,
38 .maxlen = sizeof(int),
39 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080040 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 .extra1 = &min_quality,
42 .extra2 = &max_quality
43 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090044 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 .procname = "obsolescence_count_initialiser",
46 .data = &sysctl_netrom_obsolescence_count_initialiser,
47 .maxlen = sizeof(int),
48 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080049 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 .extra1 = &min_obs,
51 .extra2 = &max_obs
52 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090053 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 .procname = "network_ttl_initialiser",
55 .data = &sysctl_netrom_network_ttl_initialiser,
56 .maxlen = sizeof(int),
57 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080058 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 .extra1 = &min_ttl,
60 .extra2 = &max_ttl
61 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090062 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 .procname = "transport_timeout",
64 .data = &sysctl_netrom_transport_timeout,
65 .maxlen = sizeof(int),
66 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080067 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 .extra1 = &min_t1,
69 .extra2 = &max_t1
70 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090071 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 .procname = "transport_maximum_tries",
73 .data = &sysctl_netrom_transport_maximum_tries,
74 .maxlen = sizeof(int),
75 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080076 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 .extra1 = &min_n2,
78 .extra2 = &max_n2
79 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090080 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 .procname = "transport_acknowledge_delay",
82 .data = &sysctl_netrom_transport_acknowledge_delay,
83 .maxlen = sizeof(int),
84 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080085 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 .extra1 = &min_t2,
87 .extra2 = &max_t2
88 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090089 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 .procname = "transport_busy_delay",
91 .data = &sysctl_netrom_transport_busy_delay,
92 .maxlen = sizeof(int),
93 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -080094 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 .extra1 = &min_t4,
96 .extra2 = &max_t4
97 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +090098 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 .procname = "transport_requested_window_size",
100 .data = &sysctl_netrom_transport_requested_window_size,
101 .maxlen = sizeof(int),
102 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800103 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 .extra1 = &min_window,
105 .extra2 = &max_window
106 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +0900107 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 .procname = "transport_no_activity_timeout",
109 .data = &sysctl_netrom_transport_no_activity_timeout,
110 .maxlen = sizeof(int),
111 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800112 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 .extra1 = &min_idle,
114 .extra2 = &max_idle
115 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +0900116 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 .procname = "routing_control",
118 .data = &sysctl_netrom_routing_control,
119 .maxlen = sizeof(int),
120 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800121 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 .extra1 = &min_route,
123 .extra2 = &max_route
124 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +0900125 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 .procname = "link_fails_count",
127 .data = &sysctl_netrom_link_fails_count,
128 .maxlen = sizeof(int),
129 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800130 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 .extra1 = &min_fails,
132 .extra2 = &max_fails
133 },
YOSHIFUJI Hideaki5f8f59d2007-02-09 23:25:09 +0900134 {
Ralf Baechlee21ce8c2005-09-12 14:27:37 -0700135 .procname = "reset",
136 .data = &sysctl_netrom_reset_circuit,
137 .maxlen = sizeof(int),
138 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800139 .proc_handler = proc_dointvec_minmax,
Ralf Baechlee21ce8c2005-09-12 14:27:37 -0700140 .extra1 = &min_reset,
141 .extra2 = &max_reset
142 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800143 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144};
145
YueHaibingd3706562019-04-09 19:53:55 +0800146int __init nr_register_sysctl(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000148 nr_table_header = register_net_sysctl(&init_net, "net/netrom", nr_table);
YueHaibingd3706562019-04-09 19:53:55 +0800149 if (!nr_table_header)
150 return -ENOMEM;
151 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152}
153
154void nr_unregister_sysctl(void)
155{
Eric W. Biederman5dd3df12012-04-19 13:24:33 +0000156 unregister_net_sysctl_table(nr_table_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157}