1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds *
41da177e4SLinus Torvalds * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com)
51da177e4SLinus Torvalds */
61da177e4SLinus Torvalds #include <linux/mm.h>
71da177e4SLinus Torvalds #include <linux/sysctl.h>
81da177e4SLinus Torvalds #include <linux/init.h>
91da177e4SLinus Torvalds #include <net/ax25.h>
101da177e4SLinus Torvalds #include <net/netrom.h>
111da177e4SLinus Torvalds
121da177e4SLinus Torvalds /*
131da177e4SLinus Torvalds * Values taken from NET/ROM documentation.
141da177e4SLinus Torvalds */
151da177e4SLinus Torvalds static int min_quality[] = {0}, max_quality[] = {255};
161da177e4SLinus Torvalds static int min_obs[] = {0}, max_obs[] = {255};
171da177e4SLinus Torvalds static int min_ttl[] = {0}, max_ttl[] = {255};
181da177e4SLinus Torvalds static int min_t1[] = {5 * HZ};
191da177e4SLinus Torvalds static int max_t1[] = {600 * HZ};
201da177e4SLinus Torvalds static int min_n2[] = {2}, max_n2[] = {127};
211da177e4SLinus Torvalds static int min_t2[] = {1 * HZ};
221da177e4SLinus Torvalds static int max_t2[] = {60 * HZ};
231da177e4SLinus Torvalds static int min_t4[] = {1 * HZ};
241da177e4SLinus Torvalds static int max_t4[] = {1000 * HZ};
251da177e4SLinus Torvalds static int min_window[] = {1}, max_window[] = {127};
261da177e4SLinus Torvalds static int min_idle[] = {0 * HZ};
271da177e4SLinus Torvalds static int max_idle[] = {65535 * HZ};
281da177e4SLinus Torvalds static int min_route[] = {0}, max_route[] = {1};
291da177e4SLinus Torvalds static int min_fails[] = {1}, max_fails[] = {10};
30e21ce8c7SRalf Baechle static int min_reset[] = {0}, max_reset[] = {1};
311da177e4SLinus Torvalds
321da177e4SLinus Torvalds static struct ctl_table_header *nr_table_header;
331da177e4SLinus Torvalds
34fe2c6338SJoe Perches static struct ctl_table nr_table[] = {
351da177e4SLinus Torvalds {
361da177e4SLinus Torvalds .procname = "default_path_quality",
371da177e4SLinus Torvalds .data = &sysctl_netrom_default_path_quality,
381da177e4SLinus Torvalds .maxlen = sizeof(int),
391da177e4SLinus Torvalds .mode = 0644,
406d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
411da177e4SLinus Torvalds .extra1 = &min_quality,
421da177e4SLinus Torvalds .extra2 = &max_quality
431da177e4SLinus Torvalds },
441da177e4SLinus Torvalds {
451da177e4SLinus Torvalds .procname = "obsolescence_count_initialiser",
461da177e4SLinus Torvalds .data = &sysctl_netrom_obsolescence_count_initialiser,
471da177e4SLinus Torvalds .maxlen = sizeof(int),
481da177e4SLinus Torvalds .mode = 0644,
496d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
501da177e4SLinus Torvalds .extra1 = &min_obs,
511da177e4SLinus Torvalds .extra2 = &max_obs
521da177e4SLinus Torvalds },
531da177e4SLinus Torvalds {
541da177e4SLinus Torvalds .procname = "network_ttl_initialiser",
551da177e4SLinus Torvalds .data = &sysctl_netrom_network_ttl_initialiser,
561da177e4SLinus Torvalds .maxlen = sizeof(int),
571da177e4SLinus Torvalds .mode = 0644,
586d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
591da177e4SLinus Torvalds .extra1 = &min_ttl,
601da177e4SLinus Torvalds .extra2 = &max_ttl
611da177e4SLinus Torvalds },
621da177e4SLinus Torvalds {
631da177e4SLinus Torvalds .procname = "transport_timeout",
641da177e4SLinus Torvalds .data = &sysctl_netrom_transport_timeout,
651da177e4SLinus Torvalds .maxlen = sizeof(int),
661da177e4SLinus Torvalds .mode = 0644,
676d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
681da177e4SLinus Torvalds .extra1 = &min_t1,
691da177e4SLinus Torvalds .extra2 = &max_t1
701da177e4SLinus Torvalds },
711da177e4SLinus Torvalds {
721da177e4SLinus Torvalds .procname = "transport_maximum_tries",
731da177e4SLinus Torvalds .data = &sysctl_netrom_transport_maximum_tries,
741da177e4SLinus Torvalds .maxlen = sizeof(int),
751da177e4SLinus Torvalds .mode = 0644,
766d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
771da177e4SLinus Torvalds .extra1 = &min_n2,
781da177e4SLinus Torvalds .extra2 = &max_n2
791da177e4SLinus Torvalds },
801da177e4SLinus Torvalds {
811da177e4SLinus Torvalds .procname = "transport_acknowledge_delay",
821da177e4SLinus Torvalds .data = &sysctl_netrom_transport_acknowledge_delay,
831da177e4SLinus Torvalds .maxlen = sizeof(int),
841da177e4SLinus Torvalds .mode = 0644,
856d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
861da177e4SLinus Torvalds .extra1 = &min_t2,
871da177e4SLinus Torvalds .extra2 = &max_t2
881da177e4SLinus Torvalds },
891da177e4SLinus Torvalds {
901da177e4SLinus Torvalds .procname = "transport_busy_delay",
911da177e4SLinus Torvalds .data = &sysctl_netrom_transport_busy_delay,
921da177e4SLinus Torvalds .maxlen = sizeof(int),
931da177e4SLinus Torvalds .mode = 0644,
946d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
951da177e4SLinus Torvalds .extra1 = &min_t4,
961da177e4SLinus Torvalds .extra2 = &max_t4
971da177e4SLinus Torvalds },
981da177e4SLinus Torvalds {
991da177e4SLinus Torvalds .procname = "transport_requested_window_size",
1001da177e4SLinus Torvalds .data = &sysctl_netrom_transport_requested_window_size,
1011da177e4SLinus Torvalds .maxlen = sizeof(int),
1021da177e4SLinus Torvalds .mode = 0644,
1036d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
1041da177e4SLinus Torvalds .extra1 = &min_window,
1051da177e4SLinus Torvalds .extra2 = &max_window
1061da177e4SLinus Torvalds },
1071da177e4SLinus Torvalds {
1081da177e4SLinus Torvalds .procname = "transport_no_activity_timeout",
1091da177e4SLinus Torvalds .data = &sysctl_netrom_transport_no_activity_timeout,
1101da177e4SLinus Torvalds .maxlen = sizeof(int),
1111da177e4SLinus Torvalds .mode = 0644,
1126d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
1131da177e4SLinus Torvalds .extra1 = &min_idle,
1141da177e4SLinus Torvalds .extra2 = &max_idle
1151da177e4SLinus Torvalds },
1161da177e4SLinus Torvalds {
1171da177e4SLinus Torvalds .procname = "routing_control",
1181da177e4SLinus Torvalds .data = &sysctl_netrom_routing_control,
1191da177e4SLinus Torvalds .maxlen = sizeof(int),
1201da177e4SLinus Torvalds .mode = 0644,
1216d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
1221da177e4SLinus Torvalds .extra1 = &min_route,
1231da177e4SLinus Torvalds .extra2 = &max_route
1241da177e4SLinus Torvalds },
1251da177e4SLinus Torvalds {
1261da177e4SLinus Torvalds .procname = "link_fails_count",
1271da177e4SLinus Torvalds .data = &sysctl_netrom_link_fails_count,
1281da177e4SLinus Torvalds .maxlen = sizeof(int),
1291da177e4SLinus Torvalds .mode = 0644,
1306d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
1311da177e4SLinus Torvalds .extra1 = &min_fails,
1321da177e4SLinus Torvalds .extra2 = &max_fails
1331da177e4SLinus Torvalds },
134e21ce8c7SRalf Baechle {
135e21ce8c7SRalf Baechle .procname = "reset",
136e21ce8c7SRalf Baechle .data = &sysctl_netrom_reset_circuit,
137e21ce8c7SRalf Baechle .maxlen = sizeof(int),
138e21ce8c7SRalf Baechle .mode = 0644,
1396d9f239aSAlexey Dobriyan .proc_handler = proc_dointvec_minmax,
140e21ce8c7SRalf Baechle .extra1 = &min_reset,
141e21ce8c7SRalf Baechle .extra2 = &max_reset
142e21ce8c7SRalf Baechle },
1431da177e4SLinus Torvalds };
1441da177e4SLinus Torvalds
nr_register_sysctl(void)145d3706566SYueHaibing int __init nr_register_sysctl(void)
1461da177e4SLinus Torvalds {
147ec8f23ceSEric W. Biederman nr_table_header = register_net_sysctl(&init_net, "net/netrom", nr_table);
148d3706566SYueHaibing if (!nr_table_header)
149d3706566SYueHaibing return -ENOMEM;
150d3706566SYueHaibing return 0;
1511da177e4SLinus Torvalds }
1521da177e4SLinus Torvalds
nr_unregister_sysctl(void)1531da177e4SLinus Torvalds void nr_unregister_sysctl(void)
1541da177e4SLinus Torvalds {
1555dd3df10SEric W. Biederman unregister_net_sysctl_table(nr_table_header);
1561da177e4SLinus Torvalds }
157