1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com)
7 #include <linux/slab.h>
8 #include <linux/sysctl.h>
9 #include <linux/spinlock.h>
12 static int min_ipdefmode[1], max_ipdefmode[] = {1};
13 static int min_axdefmode[1], max_axdefmode[] = {1};
14 static int min_backoff[1], max_backoff[] = {2};
15 static int min_conmode[1], max_conmode[] = {2};
16 static int min_window[] = {1}, max_window[] = {7};
17 static int min_ewindow[] = {1}, max_ewindow[] = {63};
18 static int min_t1[] = {1}, max_t1[] = {30000};
19 static int min_t2[] = {1}, max_t2[] = {20000};
20 static int min_t3[1], max_t3[] = {3600000};
21 static int min_idle[1], max_idle[] = {65535000};
22 static int min_n2[] = {1}, max_n2[] = {31};
23 static int min_paclen[] = {1}, max_paclen[] = {512};
24 static int min_proto[1], max_proto[] = { AX25_PROTO_MAX };
25 #ifdef CONFIG_AX25_DAMA_SLAVE
26 static int min_ds_timeout[1], max_ds_timeout[] = {65535000};
29 static const struct ctl_table ax25_param_table[] = {
31 .procname = "ip_default_mode",
32 .maxlen = sizeof(int),
34 .proc_handler = proc_dointvec_minmax,
35 .extra1 = &min_ipdefmode,
36 .extra2 = &max_ipdefmode
39 .procname = "ax25_default_mode",
40 .maxlen = sizeof(int),
42 .proc_handler = proc_dointvec_minmax,
43 .extra1 = &min_axdefmode,
44 .extra2 = &max_axdefmode
47 .procname = "backoff_type",
48 .maxlen = sizeof(int),
50 .proc_handler = proc_dointvec_minmax,
51 .extra1 = &min_backoff,
52 .extra2 = &max_backoff
55 .procname = "connect_mode",
56 .maxlen = sizeof(int),
58 .proc_handler = proc_dointvec_minmax,
59 .extra1 = &min_conmode,
60 .extra2 = &max_conmode
63 .procname = "standard_window_size",
64 .maxlen = sizeof(int),
66 .proc_handler = proc_dointvec_minmax,
67 .extra1 = &min_window,
71 .procname = "extended_window_size",
72 .maxlen = sizeof(int),
74 .proc_handler = proc_dointvec_minmax,
75 .extra1 = &min_ewindow,
76 .extra2 = &max_ewindow
79 .procname = "t1_timeout",
80 .maxlen = sizeof(int),
82 .proc_handler = proc_dointvec_minmax,
87 .procname = "t2_timeout",
88 .maxlen = sizeof(int),
90 .proc_handler = proc_dointvec_minmax,
95 .procname = "t3_timeout",
96 .maxlen = sizeof(int),
98 .proc_handler = proc_dointvec_minmax,
103 .procname = "idle_timeout",
104 .maxlen = sizeof(int),
106 .proc_handler = proc_dointvec_minmax,
111 .procname = "maximum_retry_count",
112 .maxlen = sizeof(int),
114 .proc_handler = proc_dointvec_minmax,
119 .procname = "maximum_packet_length",
120 .maxlen = sizeof(int),
122 .proc_handler = proc_dointvec_minmax,
123 .extra1 = &min_paclen,
124 .extra2 = &max_paclen
127 .procname = "protocol",
128 .maxlen = sizeof(int),
130 .proc_handler = proc_dointvec_minmax,
131 .extra1 = &min_proto,
134 #ifdef CONFIG_AX25_DAMA_SLAVE
136 .procname = "dama_slave_timeout",
137 .maxlen = sizeof(int),
139 .proc_handler = proc_dointvec_minmax,
140 .extra1 = &min_ds_timeout,
141 .extra2 = &max_ds_timeout
145 { } /* that's all, folks! */
148 int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
150 char path[sizeof("net/ax25/") + IFNAMSIZ];
152 struct ctl_table *table;
154 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
158 for (k = 0; k < AX25_MAX_VALUES; k++)
159 table[k].data = &ax25_dev->values[k];
161 snprintf(path, sizeof(path), "net/ax25/%s", ax25_dev->dev->name);
162 ax25_dev->sysheader = register_net_sysctl(&init_net, path, table);
163 if (!ax25_dev->sysheader) {
170 void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev)
172 struct ctl_table_header *header = ax25_dev->sysheader;
173 struct ctl_table *table;
176 ax25_dev->sysheader = NULL;
177 table = header->ctl_table_arg;
178 unregister_net_sysctl_table(header);