2 * DECnet An implementation of the DECnet protocol suite for the LINUX
3 * operating system. DECnet is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * DECnet sysctl support functions
8 * Author: Steve Whitehouse <SteveW@ACM.org>
12 * Steve Whitehouse - C99 changes and default device handling
13 * Steve Whitehouse - Memory buffer settings, like the tcp ones
17 #include <linux/sysctl.h>
19 #include <linux/netdevice.h>
20 #include <linux/string.h>
21 #include <net/neighbour.h>
25 #include <asm/uaccess.h>
28 #include <net/dn_dev.h>
29 #include <net/dn_route.h>
32 int decnet_debug_level
;
33 int decnet_time_wait
= 30;
34 int decnet_dn_count
= 1;
35 int decnet_di_count
= 3;
36 int decnet_dr_count
= 3;
37 int decnet_log_martians
= 1;
38 int decnet_no_fc_max_cwnd
= NSP_MIN_WINDOW
;
40 /* Reasonable defaults, I hope, based on tcp's defaults */
41 long sysctl_decnet_mem
[3] = { 768 << 3, 1024 << 3, 1536 << 3 };
42 int sysctl_decnet_wmem
[3] = { 4 * 1024, 16 * 1024, 128 * 1024 };
43 int sysctl_decnet_rmem
[3] = { 4 * 1024, 87380, 87380 * 2 };
46 extern int decnet_dst_gc_interval
;
47 static int min_decnet_time_wait
[] = { 5 };
48 static int max_decnet_time_wait
[] = { 600 };
49 static int min_state_count
[] = { 1 };
50 static int max_state_count
[] = { NSP_MAXRXTSHIFT
};
51 static int min_decnet_dst_gc_interval
[] = { 1 };
52 static int max_decnet_dst_gc_interval
[] = { 60 };
53 static int min_decnet_no_fc_max_cwnd
[] = { NSP_MIN_WINDOW
};
54 static int max_decnet_no_fc_max_cwnd
[] = { NSP_MAX_WINDOW
};
55 static char node_name
[7] = "???";
57 static struct ctl_table_header
*dn_table_header
= NULL
;
62 #define ISNUM(x) (((x) >= '0') && ((x) <= '9'))
63 #define ISLOWER(x) (((x) >= 'a') && ((x) <= 'z'))
64 #define ISUPPER(x) (((x) >= 'A') && ((x) <= 'Z'))
65 #define ISALPHA(x) (ISLOWER(x) || ISUPPER(x))
66 #define INVALID_END_CHAR(x) (ISNUM(x) || ISALPHA(x))
68 static void strip_it(char *str
)
86 * Simple routine to parse an ascii DECnet address
87 * into a network order address.
89 static int parse_addr(__le16
*addr
, char *str
)
93 while(*str
&& !ISNUM(*str
)) str
++;
98 area
= (*str
++ - '0');
101 area
+= (*str
++ - '0');
113 node
+= (*str
++ - '0');
117 node
+= (*str
++ - '0');
121 node
+= (*str
++ - '0');
124 if ((node
> 1023) || (area
> 63))
127 if (INVALID_END_CHAR(*str
))
130 *addr
= cpu_to_le16((area
<< 10) | node
);
135 static int dn_node_address_handler(ctl_table
*table
, int write
,
137 size_t *lenp
, loff_t
*ppos
)
139 char addr
[DN_ASCBUF_LEN
];
143 if (!*lenp
|| (*ppos
&& !write
)) {
149 len
= (*lenp
< DN_ASCBUF_LEN
) ? *lenp
: (DN_ASCBUF_LEN
-1);
151 if (copy_from_user(addr
, buffer
, len
))
157 if (parse_addr(&dnaddr
, addr
))
160 dn_dev_devices_off();
162 decnet_address
= dnaddr
;
171 dn_addr2asc(le16_to_cpu(decnet_address
), addr
);
175 if (len
> *lenp
) len
= *lenp
;
177 if (copy_to_user(buffer
, addr
, len
))
186 static int dn_def_dev_handler(ctl_table
*table
, int write
,
188 size_t *lenp
, loff_t
*ppos
)
191 struct net_device
*dev
;
194 if (!*lenp
|| (*ppos
&& !write
)) {
203 if (copy_from_user(devname
, buffer
, *lenp
))
209 dev
= dev_get_by_name(&init_net
, devname
);
213 if (dev
->dn_ptr
== NULL
) {
218 if (dn_dev_set_default(dev
, 1)) {
227 dev
= dn_dev_get_default();
233 strcpy(devname
, dev
->name
);
235 len
= strlen(devname
);
236 devname
[len
++] = '\n';
238 if (len
> *lenp
) len
= *lenp
;
240 if (copy_to_user(buffer
, devname
, len
))
249 static ctl_table dn_table
[] = {
251 .procname
= "node_address",
254 .proc_handler
= dn_node_address_handler
,
257 .procname
= "node_name",
261 .proc_handler
= proc_dostring
,
264 .procname
= "default_device",
267 .proc_handler
= dn_def_dev_handler
,
270 .procname
= "time_wait",
271 .data
= &decnet_time_wait
,
272 .maxlen
= sizeof(int),
274 .proc_handler
= proc_dointvec_minmax
,
275 .extra1
= &min_decnet_time_wait
,
276 .extra2
= &max_decnet_time_wait
279 .procname
= "dn_count",
280 .data
= &decnet_dn_count
,
281 .maxlen
= sizeof(int),
283 .proc_handler
= proc_dointvec_minmax
,
284 .extra1
= &min_state_count
,
285 .extra2
= &max_state_count
288 .procname
= "di_count",
289 .data
= &decnet_di_count
,
290 .maxlen
= sizeof(int),
292 .proc_handler
= proc_dointvec_minmax
,
293 .extra1
= &min_state_count
,
294 .extra2
= &max_state_count
297 .procname
= "dr_count",
298 .data
= &decnet_dr_count
,
299 .maxlen
= sizeof(int),
301 .proc_handler
= proc_dointvec_minmax
,
302 .extra1
= &min_state_count
,
303 .extra2
= &max_state_count
306 .procname
= "dst_gc_interval",
307 .data
= &decnet_dst_gc_interval
,
308 .maxlen
= sizeof(int),
310 .proc_handler
= proc_dointvec_minmax
,
311 .extra1
= &min_decnet_dst_gc_interval
,
312 .extra2
= &max_decnet_dst_gc_interval
315 .procname
= "no_fc_max_cwnd",
316 .data
= &decnet_no_fc_max_cwnd
,
317 .maxlen
= sizeof(int),
319 .proc_handler
= proc_dointvec_minmax
,
320 .extra1
= &min_decnet_no_fc_max_cwnd
,
321 .extra2
= &max_decnet_no_fc_max_cwnd
324 .procname
= "decnet_mem",
325 .data
= &sysctl_decnet_mem
,
326 .maxlen
= sizeof(sysctl_decnet_mem
),
328 .proc_handler
= proc_doulongvec_minmax
331 .procname
= "decnet_rmem",
332 .data
= &sysctl_decnet_rmem
,
333 .maxlen
= sizeof(sysctl_decnet_rmem
),
335 .proc_handler
= proc_dointvec
,
338 .procname
= "decnet_wmem",
339 .data
= &sysctl_decnet_wmem
,
340 .maxlen
= sizeof(sysctl_decnet_wmem
),
342 .proc_handler
= proc_dointvec
,
346 .data
= &decnet_debug_level
,
347 .maxlen
= sizeof(int),
349 .proc_handler
= proc_dointvec
,
354 static struct ctl_path dn_path
[] = {
355 { .procname
= "net", },
356 { .procname
= "decnet", },
360 void dn_register_sysctl(void)
362 dn_table_header
= register_sysctl_paths(dn_path
, dn_table
);
365 void dn_unregister_sysctl(void)
367 unregister_sysctl_table(dn_table_header
);
370 #else /* CONFIG_SYSCTL */
371 void dn_unregister_sysctl(void)
374 void dn_register_sysctl(void)