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