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 (dhowells@redhat.com)
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 four = 4;
15 static const unsigned int thirtytwo = 32;
16 static const unsigned int n_65535 = 65535;
17 static const unsigned int n_max_acks = RXRPC_RXTX_BUFF_SIZE - 1;
18 static const unsigned long one_jiffy = 1;
19 static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
20 
21 /*
22  * RxRPC operating parameters.
23  *
24  * See Documentation/networking/rxrpc.rst and the variable definitions for more
25  * information on the individual parameters.
26  */
27 static struct ctl_table rxrpc_sysctl_table[] = {
28 	/* Values measured in milliseconds but used in jiffies */
29 	{
30 		.procname	= "req_ack_delay",
31 		.data		= &rxrpc_requested_ack_delay,
32 		.maxlen		= sizeof(unsigned long),
33 		.mode		= 0644,
34 		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
35 		.extra1		= (void *)&one_jiffy,
36 		.extra2		= (void *)&max_jiffies,
37 	},
38 	{
39 		.procname	= "soft_ack_delay",
40 		.data		= &rxrpc_soft_ack_delay,
41 		.maxlen		= sizeof(unsigned long),
42 		.mode		= 0644,
43 		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
44 		.extra1		= (void *)&one_jiffy,
45 		.extra2		= (void *)&max_jiffies,
46 	},
47 	{
48 		.procname	= "idle_ack_delay",
49 		.data		= &rxrpc_idle_ack_delay,
50 		.maxlen		= sizeof(unsigned long),
51 		.mode		= 0644,
52 		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
53 		.extra1		= (void *)&one_jiffy,
54 		.extra2		= (void *)&max_jiffies,
55 	},
56 	{
57 		.procname	= "idle_conn_expiry",
58 		.data		= &rxrpc_conn_idle_client_expiry,
59 		.maxlen		= sizeof(unsigned long),
60 		.mode		= 0644,
61 		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
62 		.extra1		= (void *)&one_jiffy,
63 		.extra2		= (void *)&max_jiffies,
64 	},
65 	{
66 		.procname	= "idle_conn_fast_expiry",
67 		.data		= &rxrpc_conn_idle_client_fast_expiry,
68 		.maxlen		= sizeof(unsigned long),
69 		.mode		= 0644,
70 		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
71 		.extra1		= (void *)&one_jiffy,
72 		.extra2		= (void *)&max_jiffies,
73 	},
74 
75 	/* Non-time values */
76 	{
77 		.procname	= "reap_client_conns",
78 		.data		= &rxrpc_reap_client_connections,
79 		.maxlen		= sizeof(unsigned int),
80 		.mode		= 0644,
81 		.proc_handler	= proc_dointvec_minmax,
82 		.extra1		= (void *)SYSCTL_ONE,
83 		.extra2		= (void *)&n_65535,
84 	},
85 	{
86 		.procname	= "max_backlog",
87 		.data		= &rxrpc_max_backlog,
88 		.maxlen		= sizeof(unsigned int),
89 		.mode		= 0644,
90 		.proc_handler	= proc_dointvec_minmax,
91 		.extra1		= (void *)&four,
92 		.extra2		= (void *)&thirtytwo,
93 	},
94 	{
95 		.procname	= "rx_window_size",
96 		.data		= &rxrpc_rx_window_size,
97 		.maxlen		= sizeof(unsigned int),
98 		.mode		= 0644,
99 		.proc_handler	= proc_dointvec_minmax,
100 		.extra1		= (void *)SYSCTL_ONE,
101 		.extra2		= (void *)&n_max_acks,
102 	},
103 	{
104 		.procname	= "rx_mtu",
105 		.data		= &rxrpc_rx_mtu,
106 		.maxlen		= sizeof(unsigned int),
107 		.mode		= 0644,
108 		.proc_handler	= proc_dointvec_minmax,
109 		.extra1		= (void *)SYSCTL_ONE,
110 		.extra2		= (void *)&n_65535,
111 	},
112 	{
113 		.procname	= "rx_jumbo_max",
114 		.data		= &rxrpc_rx_jumbo_max,
115 		.maxlen		= sizeof(unsigned int),
116 		.mode		= 0644,
117 		.proc_handler	= proc_dointvec_minmax,
118 		.extra1		= (void *)SYSCTL_ONE,
119 		.extra2		= (void *)&four,
120 	},
121 
122 	{ }
123 };
124 
rxrpc_sysctl_init(void)125 int __init rxrpc_sysctl_init(void)
126 {
127 	rxrpc_sysctl_reg_table = register_net_sysctl(&init_net, "net/rxrpc",
128 						     rxrpc_sysctl_table);
129 	if (!rxrpc_sysctl_reg_table)
130 		return -ENOMEM;
131 	return 0;
132 }
133 
rxrpc_sysctl_exit(void)134 void rxrpc_sysctl_exit(void)
135 {
136 	if (rxrpc_sysctl_reg_table)
137 		unregister_net_sysctl_table(rxrpc_sysctl_reg_table);
138 }
139