GNU Linux-libre 4.19.264-gnu1
[releases.git] / net / rxrpc / sysctl.c
1 /* sysctls for configuring RxRPC operating parameters
2  *
3  * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public Licence
8  * as published by the Free Software Foundation; either version
9  * 2 of the Licence, or (at your option) any later version.
10  */
11
12 #include <linux/sysctl.h>
13 #include <net/sock.h>
14 #include <net/af_rxrpc.h>
15 #include "ar-internal.h"
16
17 static struct ctl_table_header *rxrpc_sysctl_reg_table;
18 static const unsigned int one = 1;
19 static const unsigned int four = 4;
20 static const unsigned int max_backlog = RXRPC_BACKLOG_MAX - 1;
21 static const unsigned int n_65535 = 65535;
22 static const unsigned int n_max_acks = RXRPC_RXTX_BUFF_SIZE - 1;
23 static const unsigned long one_jiffy = 1;
24 static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
25
26 /*
27  * RxRPC operating parameters.
28  *
29  * See Documentation/networking/rxrpc.txt and the variable definitions for more
30  * information on the individual parameters.
31  */
32 static struct ctl_table rxrpc_sysctl_table[] = {
33         /* Values measured in milliseconds but used in jiffies */
34         {
35                 .procname       = "req_ack_delay",
36                 .data           = &rxrpc_requested_ack_delay,
37                 .maxlen         = sizeof(unsigned long),
38                 .mode           = 0644,
39                 .proc_handler   = proc_doulongvec_ms_jiffies_minmax,
40                 .extra1         = (void *)&one_jiffy,
41                 .extra2         = (void *)&max_jiffies,
42         },
43         {
44                 .procname       = "soft_ack_delay",
45                 .data           = &rxrpc_soft_ack_delay,
46                 .maxlen         = sizeof(unsigned long),
47                 .mode           = 0644,
48                 .proc_handler   = proc_doulongvec_ms_jiffies_minmax,
49                 .extra1         = (void *)&one_jiffy,
50                 .extra2         = (void *)&max_jiffies,
51         },
52         {
53                 .procname       = "idle_ack_delay",
54                 .data           = &rxrpc_idle_ack_delay,
55                 .maxlen         = sizeof(unsigned long),
56                 .mode           = 0644,
57                 .proc_handler   = proc_doulongvec_ms_jiffies_minmax,
58                 .extra1         = (void *)&one_jiffy,
59                 .extra2         = (void *)&max_jiffies,
60         },
61         {
62                 .procname       = "idle_conn_expiry",
63                 .data           = &rxrpc_conn_idle_client_expiry,
64                 .maxlen         = sizeof(unsigned long),
65                 .mode           = 0644,
66                 .proc_handler   = proc_doulongvec_ms_jiffies_minmax,
67                 .extra1         = (void *)&one_jiffy,
68                 .extra2         = (void *)&max_jiffies,
69         },
70         {
71                 .procname       = "idle_conn_fast_expiry",
72                 .data           = &rxrpc_conn_idle_client_fast_expiry,
73                 .maxlen         = sizeof(unsigned long),
74                 .mode           = 0644,
75                 .proc_handler   = proc_doulongvec_ms_jiffies_minmax,
76                 .extra1         = (void *)&one_jiffy,
77                 .extra2         = (void *)&max_jiffies,
78         },
79         {
80                 .procname       = "resend_timeout",
81                 .data           = &rxrpc_resend_timeout,
82                 .maxlen         = sizeof(unsigned long),
83                 .mode           = 0644,
84                 .proc_handler   = proc_doulongvec_ms_jiffies_minmax,
85                 .extra1         = (void *)&one_jiffy,
86                 .extra2         = (void *)&max_jiffies,
87         },
88
89         /* Non-time values */
90         {
91                 .procname       = "max_client_conns",
92                 .data           = &rxrpc_max_client_connections,
93                 .maxlen         = sizeof(unsigned int),
94                 .mode           = 0644,
95                 .proc_handler   = proc_dointvec_minmax,
96                 .extra1         = (void *)&rxrpc_reap_client_connections,
97         },
98         {
99                 .procname       = "reap_client_conns",
100                 .data           = &rxrpc_reap_client_connections,
101                 .maxlen         = sizeof(unsigned int),
102                 .mode           = 0644,
103                 .proc_handler   = proc_dointvec_minmax,
104                 .extra1         = (void *)&one,
105                 .extra2         = (void *)&rxrpc_max_client_connections,
106         },
107         {
108                 .procname       = "max_backlog",
109                 .data           = &rxrpc_max_backlog,
110                 .maxlen         = sizeof(unsigned int),
111                 .mode           = 0644,
112                 .proc_handler   = proc_dointvec_minmax,
113                 .extra1         = (void *)&four,
114                 .extra2         = (void *)&max_backlog,
115         },
116         {
117                 .procname       = "rx_window_size",
118                 .data           = &rxrpc_rx_window_size,
119                 .maxlen         = sizeof(unsigned int),
120                 .mode           = 0644,
121                 .proc_handler   = proc_dointvec_minmax,
122                 .extra1         = (void *)&one,
123                 .extra2         = (void *)&n_max_acks,
124         },
125         {
126                 .procname       = "rx_mtu",
127                 .data           = &rxrpc_rx_mtu,
128                 .maxlen         = sizeof(unsigned int),
129                 .mode           = 0644,
130                 .proc_handler   = proc_dointvec_minmax,
131                 .extra1         = (void *)&one,
132                 .extra2         = (void *)&n_65535,
133         },
134         {
135                 .procname       = "rx_jumbo_max",
136                 .data           = &rxrpc_rx_jumbo_max,
137                 .maxlen         = sizeof(unsigned int),
138                 .mode           = 0644,
139                 .proc_handler   = proc_dointvec_minmax,
140                 .extra1         = (void *)&one,
141                 .extra2         = (void *)&four,
142         },
143
144         { }
145 };
146
147 int __init rxrpc_sysctl_init(void)
148 {
149         rxrpc_sysctl_reg_table = register_net_sysctl(&init_net, "net/rxrpc",
150                                                      rxrpc_sysctl_table);
151         if (!rxrpc_sysctl_reg_table)
152                 return -ENOMEM;
153         return 0;
154 }
155
156 void rxrpc_sysctl_exit(void)
157 {
158         if (rxrpc_sysctl_reg_table)
159                 unregister_net_sysctl_table(rxrpc_sysctl_reg_table);
160 }