xref: /linux/net/dccp/sysctl.c (revision a954e5fb4bc2d401b8fc3b4c7cd316497ff80225)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  net/dccp/sysctl.c
4  *
5  *  An implementation of the DCCP protocol
6  *  Arnaldo Carvalho de Melo <acme@mandriva.com>
7  */
8 
9 #include <linux/mm.h>
10 #include <linux/sysctl.h>
11 #include "dccp.h"
12 #include "feat.h"
13 
14 #ifndef CONFIG_SYSCTL
15 #error This file should not be compiled without CONFIG_SYSCTL defined
16 #endif
17 
18 /* Boundary values */
19 static int		zero     = 0,
20 			one      = 1,
21 			u8_max   = 0xFF;
22 static unsigned long	seqw_min = DCCPF_SEQ_WMIN,
23 			seqw_max = 0xFFFFFFFF;		/* maximum on 32 bit */
24 
25 static struct ctl_table dccp_default_table[] = {
26 	{
27 		.procname	= "seq_window",
28 		.data		= &sysctl_dccp_sequence_window,
29 		.maxlen		= sizeof(sysctl_dccp_sequence_window),
30 		.mode		= 0644,
31 		.proc_handler	= proc_doulongvec_minmax,
32 		.extra1		= &seqw_min,		/* RFC 4340, 7.5.2 */
33 		.extra2		= &seqw_max,
34 	},
35 	{
36 		.procname	= "rx_ccid",
37 		.data		= &sysctl_dccp_rx_ccid,
38 		.maxlen		= sizeof(sysctl_dccp_rx_ccid),
39 		.mode		= 0644,
40 		.proc_handler	= proc_dointvec_minmax,
41 		.extra1		= &zero,
42 		.extra2		= &u8_max,		/* RFC 4340, 10. */
43 	},
44 	{
45 		.procname	= "tx_ccid",
46 		.data		= &sysctl_dccp_tx_ccid,
47 		.maxlen		= sizeof(sysctl_dccp_tx_ccid),
48 		.mode		= 0644,
49 		.proc_handler	= proc_dointvec_minmax,
50 		.extra1		= &zero,
51 		.extra2		= &u8_max,		/* RFC 4340, 10. */
52 	},
53 	{
54 		.procname	= "request_retries",
55 		.data		= &sysctl_dccp_request_retries,
56 		.maxlen		= sizeof(sysctl_dccp_request_retries),
57 		.mode		= 0644,
58 		.proc_handler	= proc_dointvec_minmax,
59 		.extra1		= &one,
60 		.extra2		= &u8_max,
61 	},
62 	{
63 		.procname	= "retries1",
64 		.data		= &sysctl_dccp_retries1,
65 		.maxlen		= sizeof(sysctl_dccp_retries1),
66 		.mode		= 0644,
67 		.proc_handler	= proc_dointvec_minmax,
68 		.extra1		= &zero,
69 		.extra2		= &u8_max,
70 	},
71 	{
72 		.procname	= "retries2",
73 		.data		= &sysctl_dccp_retries2,
74 		.maxlen		= sizeof(sysctl_dccp_retries2),
75 		.mode		= 0644,
76 		.proc_handler	= proc_dointvec_minmax,
77 		.extra1		= &zero,
78 		.extra2		= &u8_max,
79 	},
80 	{
81 		.procname	= "tx_qlen",
82 		.data		= &sysctl_dccp_tx_qlen,
83 		.maxlen		= sizeof(sysctl_dccp_tx_qlen),
84 		.mode		= 0644,
85 		.proc_handler	= proc_dointvec_minmax,
86 		.extra1		= &zero,
87 	},
88 	{
89 		.procname	= "sync_ratelimit",
90 		.data		= &sysctl_dccp_sync_ratelimit,
91 		.maxlen		= sizeof(sysctl_dccp_sync_ratelimit),
92 		.mode		= 0644,
93 		.proc_handler	= proc_dointvec_ms_jiffies,
94 	},
95 
96 	{ }
97 };
98 
99 static struct ctl_table_header *dccp_table_header;
100 
101 int __init dccp_sysctl_init(void)
102 {
103 	dccp_table_header = register_net_sysctl(&init_net, "net/dccp/default",
104 			dccp_default_table);
105 
106 	return dccp_table_header != NULL ? 0 : -ENOMEM;
107 }
108 
109 void dccp_sysctl_exit(void)
110 {
111 	if (dccp_table_header != NULL) {
112 		unregister_net_sysctl_table(dccp_table_header);
113 		dccp_table_header = NULL;
114 	}
115 }
116