1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* sysctls for configuring RxRPC operating parameters
3 *
4 * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells ([email protected])
6 */
7
8 #include <linux/sysctl.h>
9 #include <net/sock.h>
10 #include <net/af_rxrpc.h>
11 #include "ar-internal.h"
12
13 static struct ctl_table_header *rxrpc_sysctl_reg_table;
14 static const unsigned int rxrpc_rx_mtu_min = 500;
15 static const unsigned int rxrpc_jumbo_max = RXRPC_MAX_NR_JUMBO;
16 static const unsigned int four = 4;
17 static const unsigned int max_backlog = RXRPC_BACKLOG_MAX - 1;
18 static const unsigned int n_65535 = 65535;
19 static const unsigned int n_max_acks = 255;
20 static const unsigned long one_ms = 1;
21 static const unsigned long max_ms = 1000;
22 static const unsigned long one_jiffy = 1;
23 static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
24 #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
25 static const unsigned long max_500 = 500;
26 #endif
27
28 /*
29 * RxRPC operating parameters.
30 *
31 * See Documentation/networking/rxrpc.rst and the variable definitions for more
32 * information on the individual parameters.
33 */
34 static struct ctl_table rxrpc_sysctl_table[] = {
35 /* Values measured in milliseconds */
36 {
37 .procname = "soft_ack_delay",
38 .data = &rxrpc_soft_ack_delay,
39 .maxlen = sizeof(unsigned long),
40 .mode = 0644,
41 .proc_handler = proc_doulongvec_minmax,
42 .extra1 = (void *)&one_ms,
43 .extra2 = (void *)&max_ms,
44 },
45 {
46 .procname = "idle_ack_delay",
47 .data = &rxrpc_idle_ack_delay,
48 .maxlen = sizeof(unsigned long),
49 .mode = 0644,
50 .proc_handler = proc_doulongvec_minmax,
51 .extra1 = (void *)&one_ms,
52 .extra2 = (void *)&max_ms,
53 },
54 {
55 .procname = "idle_conn_expiry",
56 .data = &rxrpc_conn_idle_client_expiry,
57 .maxlen = sizeof(unsigned long),
58 .mode = 0644,
59 .proc_handler = proc_doulongvec_ms_jiffies_minmax,
60 .extra1 = (void *)&one_jiffy,
61 .extra2 = (void *)&max_jiffies,
62 },
63 {
64 .procname = "idle_conn_fast_expiry",
65 .data = &rxrpc_conn_idle_client_fast_expiry,
66 .maxlen = sizeof(unsigned long),
67 .mode = 0644,
68 .proc_handler = proc_doulongvec_ms_jiffies_minmax,
69 .extra1 = (void *)&one_jiffy,
70 .extra2 = (void *)&max_jiffies,
71 },
72
73 /* Values used in milliseconds */
74 #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
75 {
76 .procname = "inject_rx_delay",
77 .data = &rxrpc_inject_rx_delay,
78 .maxlen = sizeof(unsigned long),
79 .mode = 0644,
80 .proc_handler = proc_doulongvec_minmax,
81 .extra1 = (void *)SYSCTL_LONG_ZERO,
82 .extra2 = (void *)&max_500,
83 },
84 #endif
85
86 /* Non-time values */
87 {
88 .procname = "reap_client_conns",
89 .data = &rxrpc_reap_client_connections,
90 .maxlen = sizeof(unsigned int),
91 .mode = 0644,
92 .proc_handler = proc_dointvec_minmax,
93 .extra1 = (void *)SYSCTL_ONE,
94 .extra2 = (void *)&n_65535,
95 },
96 {
97 .procname = "max_backlog",
98 .data = &rxrpc_max_backlog,
99 .maxlen = sizeof(unsigned int),
100 .mode = 0644,
101 .proc_handler = proc_dointvec_minmax,
102 .extra1 = (void *)&four,
103 .extra2 = (void *)&max_backlog,
104 },
105 {
106 .procname = "rx_window_size",
107 .data = &rxrpc_rx_window_size,
108 .maxlen = sizeof(unsigned int),
109 .mode = 0644,
110 .proc_handler = proc_dointvec_minmax,
111 .extra1 = (void *)SYSCTL_ONE,
112 .extra2 = (void *)&n_max_acks,
113 },
114 {
115 .procname = "rx_mtu",
116 .data = &rxrpc_rx_mtu,
117 .maxlen = sizeof(unsigned int),
118 .mode = 0644,
119 .proc_handler = proc_dointvec_minmax,
120 .extra1 = (void *)&rxrpc_rx_mtu_min,
121 .extra2 = (void *)&n_65535,
122 },
123 {
124 .procname = "rx_jumbo_max",
125 .data = &rxrpc_rx_jumbo_max,
126 .maxlen = sizeof(unsigned int),
127 .mode = 0644,
128 .proc_handler = proc_dointvec_minmax,
129 .extra1 = (void *)SYSCTL_ONE,
130 .extra2 = (void *)&rxrpc_jumbo_max,
131 },
132 };
133
rxrpc_sysctl_init(void)134 int __init rxrpc_sysctl_init(void)
135 {
136 rxrpc_sysctl_reg_table = register_net_sysctl(&init_net, "net/rxrpc",
137 rxrpc_sysctl_table);
138 if (!rxrpc_sysctl_reg_table)
139 return -ENOMEM;
140 return 0;
141 }
142
rxrpc_sysctl_exit(void)143 void rxrpc_sysctl_exit(void)
144 {
145 if (rxrpc_sysctl_reg_table)
146 unregister_net_sysctl_table(rxrpc_sysctl_reg_table);
147 }
148