]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | /* |
3 | * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem. | |
4 | * | |
1da177e4 LT |
5 | * Begun April 1, 1996, Mike Shaver. |
6 | * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS] | |
7 | */ | |
8 | ||
9 | #include <linux/mm.h> | |
10 | #include <linux/module.h> | |
11 | #include <linux/sysctl.h> | |
20380731 | 12 | #include <linux/igmp.h> |
14c85021 | 13 | #include <linux/inetdevice.h> |
227b60f5 | 14 | #include <linux/seqlock.h> |
3e37c3f9 | 15 | #include <linux/init.h> |
5a0e3ad6 | 16 | #include <linux/slab.h> |
c319b4d7 | 17 | #include <linux/nsproxy.h> |
3dc43e3e | 18 | #include <linux/swap.h> |
1da177e4 | 19 | #include <net/snmp.h> |
20380731 | 20 | #include <net/icmp.h> |
1da177e4 LT |
21 | #include <net/ip.h> |
22 | #include <net/route.h> | |
23 | #include <net/tcp.h> | |
95766fff | 24 | #include <net/udp.h> |
446fda4f | 25 | #include <net/cipso_ipv4.h> |
04128f23 | 26 | #include <net/inet_frag.h> |
c319b4d7 | 27 | #include <net/ping.h> |
dddb64bc | 28 | #include <net/protocol.h> |
3ae6ec08 | 29 | #include <net/netevent.h> |
1da177e4 | 30 | |
89cee8b1 | 31 | static int zero; |
cdda8891 | 32 | static int one = 1; |
79e9fed4 | 33 | static int two = 2; |
6ba8a3b1 | 34 | static int four = 4; |
43e122b0 | 35 | static int thousand = 1000; |
95bd09eb | 36 | static int gso_max_segs = GSO_MAX_SEGS; |
e905a9ed | 37 | static int tcp_retr1_max = 255; |
1da177e4 LT |
38 | static int ip_local_port_range_min[] = { 1, 1 }; |
39 | static int ip_local_port_range_max[] = { 65535, 65535 }; | |
0147fc05 AD |
40 | static int tcp_adv_win_scale_min = -31; |
41 | static int tcp_adv_win_scale_max = 31; | |
4548b683 KJ |
42 | static int ip_privileged_port_min; |
43 | static int ip_privileged_port_max = 65535; | |
249fab77 ED |
44 | static int ip_ttl_min = 1; |
45 | static int ip_ttl_max = 255; | |
651e9271 MT |
46 | static int tcp_syn_retries_min = 1; |
47 | static int tcp_syn_retries_max = MAX_TCP_SYNCNT; | |
c319b4d7 VK |
48 | static int ip_ping_group_range_min[] = { 0, 0 }; |
49 | static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; | |
9c21d2fc | 50 | static int comp_sack_nr_max = 255; |
1da177e4 | 51 | |
b6690b14 FW |
52 | /* obsolete */ |
53 | static int sysctl_tcp_low_latency __read_mostly; | |
54 | ||
227b60f5 | 55 | /* Update system visible IP port range */ |
0bbf87d8 | 56 | static void set_local_port_range(struct net *net, int range[2]) |
227b60f5 | 57 | { |
ed2dfd90 ED |
58 | bool same_parity = !((range[0] ^ range[1]) & 1); |
59 | ||
4ee3bd4a | 60 | write_seqlock_bh(&net->ipv4.ip_local_ports.lock); |
ed2dfd90 ED |
61 | if (same_parity && !net->ipv4.ip_local_ports.warned) { |
62 | net->ipv4.ip_local_ports.warned = true; | |
63 | pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n"); | |
64 | } | |
c9d8f1a6 CW |
65 | net->ipv4.ip_local_ports.range[0] = range[0]; |
66 | net->ipv4.ip_local_ports.range[1] = range[1]; | |
4ee3bd4a | 67 | write_sequnlock_bh(&net->ipv4.ip_local_ports.lock); |
227b60f5 SH |
68 | } |
69 | ||
70 | /* Validate changes from /proc interface. */ | |
fe2c6338 | 71 | static int ipv4_local_port_range(struct ctl_table *table, int write, |
227b60f5 SH |
72 | void __user *buffer, |
73 | size_t *lenp, loff_t *ppos) | |
74 | { | |
0bbf87d8 | 75 | struct net *net = |
c9d8f1a6 | 76 | container_of(table->data, struct net, ipv4.ip_local_ports.range); |
227b60f5 | 77 | int ret; |
3c689b73 | 78 | int range[2]; |
fe2c6338 | 79 | struct ctl_table tmp = { |
227b60f5 SH |
80 | .data = &range, |
81 | .maxlen = sizeof(range), | |
82 | .mode = table->mode, | |
83 | .extra1 = &ip_local_port_range_min, | |
84 | .extra2 = &ip_local_port_range_max, | |
85 | }; | |
86 | ||
0bbf87d8 EB |
87 | inet_get_local_port_range(net, &range[0], &range[1]); |
88 | ||
8d65af78 | 89 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
227b60f5 SH |
90 | |
91 | if (write && ret == 0) { | |
4548b683 KJ |
92 | /* Ensure that the upper limit is not smaller than the lower, |
93 | * and that the lower does not encroach upon the privileged | |
94 | * port limit. | |
95 | */ | |
96 | if ((range[1] < range[0]) || | |
97 | (range[0] < net->ipv4.sysctl_ip_prot_sock)) | |
227b60f5 SH |
98 | ret = -EINVAL; |
99 | else | |
0bbf87d8 | 100 | set_local_port_range(net, range); |
227b60f5 SH |
101 | } |
102 | ||
103 | return ret; | |
104 | } | |
105 | ||
4548b683 KJ |
106 | /* Validate changes from /proc interface. */ |
107 | static int ipv4_privileged_ports(struct ctl_table *table, int write, | |
108 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
109 | { | |
110 | struct net *net = container_of(table->data, struct net, | |
111 | ipv4.sysctl_ip_prot_sock); | |
112 | int ret; | |
113 | int pports; | |
114 | int range[2]; | |
115 | struct ctl_table tmp = { | |
116 | .data = &pports, | |
117 | .maxlen = sizeof(pports), | |
118 | .mode = table->mode, | |
119 | .extra1 = &ip_privileged_port_min, | |
120 | .extra2 = &ip_privileged_port_max, | |
121 | }; | |
122 | ||
123 | pports = net->ipv4.sysctl_ip_prot_sock; | |
124 | ||
125 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); | |
126 | ||
127 | if (write && ret == 0) { | |
128 | inet_get_local_port_range(net, &range[0], &range[1]); | |
129 | /* Ensure that the local port range doesn't overlap with the | |
130 | * privileged port range. | |
131 | */ | |
132 | if (range[0] < pports) | |
133 | ret = -EINVAL; | |
134 | else | |
135 | net->ipv4.sysctl_ip_prot_sock = pports; | |
136 | } | |
137 | ||
138 | return ret; | |
139 | } | |
c319b4d7 | 140 | |
7064d16e | 141 | static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high) |
c319b4d7 | 142 | { |
7064d16e | 143 | kgid_t *data = table->data; |
0bbf87d8 | 144 | struct net *net = |
ba6b918a | 145 | container_of(table->data, struct net, ipv4.ping_group_range.range); |
95c96174 | 146 | unsigned int seq; |
c319b4d7 | 147 | do { |
396a30cc | 148 | seq = read_seqbegin(&net->ipv4.ping_group_range.lock); |
c319b4d7 VK |
149 | |
150 | *low = data[0]; | |
151 | *high = data[1]; | |
396a30cc | 152 | } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq)); |
c319b4d7 VK |
153 | } |
154 | ||
155 | /* Update system visible IP port range */ | |
7064d16e | 156 | static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high) |
c319b4d7 | 157 | { |
7064d16e | 158 | kgid_t *data = table->data; |
0bbf87d8 | 159 | struct net *net = |
ba6b918a | 160 | container_of(table->data, struct net, ipv4.ping_group_range.range); |
396a30cc | 161 | write_seqlock(&net->ipv4.ping_group_range.lock); |
7064d16e EB |
162 | data[0] = low; |
163 | data[1] = high; | |
396a30cc | 164 | write_sequnlock(&net->ipv4.ping_group_range.lock); |
c319b4d7 VK |
165 | } |
166 | ||
167 | /* Validate changes from /proc interface. */ | |
fe2c6338 | 168 | static int ipv4_ping_group_range(struct ctl_table *table, int write, |
c319b4d7 VK |
169 | void __user *buffer, |
170 | size_t *lenp, loff_t *ppos) | |
171 | { | |
7064d16e | 172 | struct user_namespace *user_ns = current_user_ns(); |
c319b4d7 | 173 | int ret; |
7064d16e EB |
174 | gid_t urange[2]; |
175 | kgid_t low, high; | |
fe2c6338 | 176 | struct ctl_table tmp = { |
7064d16e EB |
177 | .data = &urange, |
178 | .maxlen = sizeof(urange), | |
c319b4d7 VK |
179 | .mode = table->mode, |
180 | .extra1 = &ip_ping_group_range_min, | |
181 | .extra2 = &ip_ping_group_range_max, | |
182 | }; | |
183 | ||
7064d16e EB |
184 | inet_get_ping_group_range_table(table, &low, &high); |
185 | urange[0] = from_kgid_munged(user_ns, low); | |
186 | urange[1] = from_kgid_munged(user_ns, high); | |
c319b4d7 VK |
187 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
188 | ||
7064d16e EB |
189 | if (write && ret == 0) { |
190 | low = make_kgid(user_ns, urange[0]); | |
191 | high = make_kgid(user_ns, urange[1]); | |
70ba5b6d TH |
192 | if (!gid_valid(low) || !gid_valid(high)) |
193 | return -EINVAL; | |
194 | if (urange[1] < urange[0] || gid_lt(high, low)) { | |
7064d16e EB |
195 | low = make_kgid(&init_user_ns, 1); |
196 | high = make_kgid(&init_user_ns, 0); | |
197 | } | |
198 | set_ping_group_range(table, low, high); | |
199 | } | |
c319b4d7 VK |
200 | |
201 | return ret; | |
202 | } | |
203 | ||
fe2c6338 | 204 | static int proc_tcp_congestion_control(struct ctl_table *ctl, int write, |
317a76f9 SH |
205 | void __user *buffer, size_t *lenp, loff_t *ppos) |
206 | { | |
6670e152 SH |
207 | struct net *net = container_of(ctl->data, struct net, |
208 | ipv4.tcp_congestion_control); | |
317a76f9 | 209 | char val[TCP_CA_NAME_MAX]; |
fe2c6338 | 210 | struct ctl_table tbl = { |
317a76f9 SH |
211 | .data = val, |
212 | .maxlen = TCP_CA_NAME_MAX, | |
213 | }; | |
214 | int ret; | |
215 | ||
6670e152 | 216 | tcp_get_default_congestion_control(net, val); |
317a76f9 | 217 | |
8d65af78 | 218 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
317a76f9 | 219 | if (write && ret == 0) |
6670e152 | 220 | ret = tcp_set_default_congestion_control(net, val); |
317a76f9 SH |
221 | return ret; |
222 | } | |
223 | ||
fe2c6338 | 224 | static int proc_tcp_available_congestion_control(struct ctl_table *ctl, |
8d65af78 | 225 | int write, |
3ff825b2 SH |
226 | void __user *buffer, size_t *lenp, |
227 | loff_t *ppos) | |
228 | { | |
fe2c6338 | 229 | struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, }; |
3ff825b2 SH |
230 | int ret; |
231 | ||
232 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); | |
233 | if (!tbl.data) | |
234 | return -ENOMEM; | |
235 | tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX); | |
8d65af78 | 236 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
3ff825b2 SH |
237 | kfree(tbl.data); |
238 | return ret; | |
239 | } | |
240 | ||
fe2c6338 | 241 | static int proc_allowed_congestion_control(struct ctl_table *ctl, |
8d65af78 | 242 | int write, |
ce7bc3bf SH |
243 | void __user *buffer, size_t *lenp, |
244 | loff_t *ppos) | |
245 | { | |
fe2c6338 | 246 | struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX }; |
ce7bc3bf SH |
247 | int ret; |
248 | ||
249 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); | |
250 | if (!tbl.data) | |
251 | return -ENOMEM; | |
252 | ||
253 | tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen); | |
8d65af78 | 254 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
ce7bc3bf SH |
255 | if (write && ret == 0) |
256 | ret = tcp_set_allowed_congestion_control(tbl.data); | |
257 | kfree(tbl.data); | |
258 | return ret; | |
259 | } | |
260 | ||
43713848 | 261 | static int proc_tcp_fastopen_key(struct ctl_table *table, int write, |
fe2c6338 JP |
262 | void __user *buffer, size_t *lenp, |
263 | loff_t *ppos) | |
10467163 | 264 | { |
43713848 HY |
265 | struct net *net = container_of(table->data, struct net, |
266 | ipv4.sysctl_tcp_fastopen); | |
fe2c6338 | 267 | struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) }; |
10467163 | 268 | struct tcp_fastopen_context *ctxt; |
10467163 | 269 | u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */ |
c860e997 YC |
270 | __le32 key[4]; |
271 | int ret, i; | |
10467163 JC |
272 | |
273 | tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL); | |
274 | if (!tbl.data) | |
275 | return -ENOMEM; | |
276 | ||
277 | rcu_read_lock(); | |
43713848 | 278 | ctxt = rcu_dereference(net->ipv4.tcp_fastopen_ctx); |
10467163 | 279 | if (ctxt) |
c860e997 | 280 | memcpy(key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH); |
0e24c4fc | 281 | else |
c860e997 | 282 | memset(key, 0, sizeof(key)); |
10467163 JC |
283 | rcu_read_unlock(); |
284 | ||
c860e997 YC |
285 | for (i = 0; i < ARRAY_SIZE(key); i++) |
286 | user_key[i] = le32_to_cpu(key[i]); | |
287 | ||
10467163 JC |
288 | snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x", |
289 | user_key[0], user_key[1], user_key[2], user_key[3]); | |
290 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); | |
291 | ||
292 | if (write && ret == 0) { | |
293 | if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1, | |
294 | user_key + 2, user_key + 3) != 4) { | |
295 | ret = -EINVAL; | |
296 | goto bad_key; | |
297 | } | |
c860e997 YC |
298 | |
299 | for (i = 0; i < ARRAY_SIZE(user_key); i++) | |
300 | key[i] = cpu_to_le32(user_key[i]); | |
301 | ||
302 | tcp_fastopen_reset_cipher(net, NULL, key, | |
1fba70e5 | 303 | TCP_FASTOPEN_KEY_LENGTH); |
10467163 JC |
304 | } |
305 | ||
306 | bad_key: | |
307 | pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n", | |
c860e997 | 308 | user_key[0], user_key[1], user_key[2], user_key[3], |
10467163 JC |
309 | (char *)tbl.data, ret); |
310 | kfree(tbl.data); | |
311 | return ret; | |
312 | } | |
313 | ||
dddb64bc SAK |
314 | static void proc_configure_early_demux(int enabled, int protocol) |
315 | { | |
316 | struct net_protocol *ipprot; | |
317 | #if IS_ENABLED(CONFIG_IPV6) | |
318 | struct inet6_protocol *ip6prot; | |
319 | #endif | |
320 | ||
58c4c6a3 DA |
321 | rcu_read_lock(); |
322 | ||
dddb64bc SAK |
323 | ipprot = rcu_dereference(inet_protos[protocol]); |
324 | if (ipprot) | |
325 | ipprot->early_demux = enabled ? ipprot->early_demux_handler : | |
326 | NULL; | |
327 | ||
328 | #if IS_ENABLED(CONFIG_IPV6) | |
329 | ip6prot = rcu_dereference(inet6_protos[protocol]); | |
330 | if (ip6prot) | |
331 | ip6prot->early_demux = enabled ? ip6prot->early_demux_handler : | |
332 | NULL; | |
333 | #endif | |
58c4c6a3 | 334 | rcu_read_unlock(); |
dddb64bc SAK |
335 | } |
336 | ||
337 | static int proc_tcp_early_demux(struct ctl_table *table, int write, | |
338 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
339 | { | |
340 | int ret = 0; | |
341 | ||
342 | ret = proc_dointvec(table, write, buffer, lenp, ppos); | |
343 | ||
344 | if (write && !ret) { | |
345 | int enabled = init_net.ipv4.sysctl_tcp_early_demux; | |
346 | ||
347 | proc_configure_early_demux(enabled, IPPROTO_TCP); | |
348 | } | |
349 | ||
350 | return ret; | |
351 | } | |
352 | ||
353 | static int proc_udp_early_demux(struct ctl_table *table, int write, | |
354 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
355 | { | |
356 | int ret = 0; | |
357 | ||
358 | ret = proc_dointvec(table, write, buffer, lenp, ppos); | |
359 | ||
360 | if (write && !ret) { | |
361 | int enabled = init_net.ipv4.sysctl_udp_early_demux; | |
362 | ||
363 | proc_configure_early_demux(enabled, IPPROTO_UDP); | |
364 | } | |
365 | ||
366 | return ret; | |
367 | } | |
368 | ||
cf1ef3f0 WW |
369 | static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table, |
370 | int write, | |
371 | void __user *buffer, | |
372 | size_t *lenp, loff_t *ppos) | |
373 | { | |
3733be14 HY |
374 | struct net *net = container_of(table->data, struct net, |
375 | ipv4.sysctl_tcp_fastopen_blackhole_timeout); | |
cf1ef3f0 WW |
376 | int ret; |
377 | ||
378 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | |
379 | if (write && ret == 0) | |
3733be14 | 380 | atomic_set(&net->ipv4.tfo_active_disable_times, 0); |
734942cc DW |
381 | |
382 | return ret; | |
383 | } | |
384 | ||
385 | static int proc_tcp_available_ulp(struct ctl_table *ctl, | |
386 | int write, | |
387 | void __user *buffer, size_t *lenp, | |
388 | loff_t *ppos) | |
389 | { | |
390 | struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, }; | |
391 | int ret; | |
392 | ||
393 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); | |
394 | if (!tbl.data) | |
395 | return -ENOMEM; | |
396 | tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX); | |
397 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); | |
398 | kfree(tbl.data); | |
399 | ||
cf1ef3f0 WW |
400 | return ret; |
401 | } | |
402 | ||
3ae6ec08 IS |
403 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
404 | static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write, | |
405 | void __user *buffer, size_t *lenp, | |
406 | loff_t *ppos) | |
407 | { | |
408 | struct net *net = container_of(table->data, struct net, | |
409 | ipv4.sysctl_fib_multipath_hash_policy); | |
410 | int ret; | |
411 | ||
412 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | |
413 | if (write && ret == 0) | |
3192dac6 | 414 | call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net); |
3ae6ec08 IS |
415 | |
416 | return ret; | |
417 | } | |
418 | #endif | |
419 | ||
3e37c3f9 | 420 | static struct ctl_table ipv4_table[] = { |
1da177e4 | 421 | { |
1da177e4 LT |
422 | .procname = "tcp_max_orphans", |
423 | .data = &sysctl_tcp_max_orphans, | |
424 | .maxlen = sizeof(int), | |
425 | .mode = 0644, | |
6d9f239a | 426 | .proc_handler = proc_dointvec |
1da177e4 | 427 | }, |
1da177e4 | 428 | { |
1da177e4 LT |
429 | .procname = "inet_peer_threshold", |
430 | .data = &inet_peer_threshold, | |
431 | .maxlen = sizeof(int), | |
432 | .mode = 0644, | |
6d9f239a | 433 | .proc_handler = proc_dointvec |
1da177e4 LT |
434 | }, |
435 | { | |
1da177e4 LT |
436 | .procname = "inet_peer_minttl", |
437 | .data = &inet_peer_minttl, | |
438 | .maxlen = sizeof(int), | |
439 | .mode = 0644, | |
6d9f239a | 440 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 LT |
441 | }, |
442 | { | |
1da177e4 LT |
443 | .procname = "inet_peer_maxttl", |
444 | .data = &inet_peer_maxttl, | |
445 | .maxlen = sizeof(int), | |
446 | .mode = 0644, | |
6d9f239a | 447 | .proc_handler = proc_dointvec_jiffies, |
1da177e4 | 448 | }, |
a4fe34bf EB |
449 | { |
450 | .procname = "tcp_mem", | |
451 | .maxlen = sizeof(sysctl_tcp_mem), | |
452 | .data = &sysctl_tcp_mem, | |
453 | .mode = 0644, | |
454 | .proc_handler = proc_doulongvec_minmax, | |
455 | }, | |
1da177e4 | 456 | { |
1da177e4 LT |
457 | .procname = "tcp_low_latency", |
458 | .data = &sysctl_tcp_low_latency, | |
459 | .maxlen = sizeof(int), | |
460 | .mode = 0644, | |
6d9f239a | 461 | .proc_handler = proc_dointvec |
1da177e4 | 462 | }, |
446fda4f PM |
463 | #ifdef CONFIG_NETLABEL |
464 | { | |
446fda4f PM |
465 | .procname = "cipso_cache_enable", |
466 | .data = &cipso_v4_cache_enabled, | |
467 | .maxlen = sizeof(int), | |
468 | .mode = 0644, | |
6d9f239a | 469 | .proc_handler = proc_dointvec, |
446fda4f PM |
470 | }, |
471 | { | |
446fda4f PM |
472 | .procname = "cipso_cache_bucket_size", |
473 | .data = &cipso_v4_cache_bucketsize, | |
474 | .maxlen = sizeof(int), | |
475 | .mode = 0644, | |
6d9f239a | 476 | .proc_handler = proc_dointvec, |
446fda4f PM |
477 | }, |
478 | { | |
446fda4f PM |
479 | .procname = "cipso_rbm_optfmt", |
480 | .data = &cipso_v4_rbm_optfmt, | |
481 | .maxlen = sizeof(int), | |
482 | .mode = 0644, | |
6d9f239a | 483 | .proc_handler = proc_dointvec, |
446fda4f PM |
484 | }, |
485 | { | |
446fda4f PM |
486 | .procname = "cipso_rbm_strictvalid", |
487 | .data = &cipso_v4_rbm_strictvalid, | |
488 | .maxlen = sizeof(int), | |
489 | .mode = 0644, | |
6d9f239a | 490 | .proc_handler = proc_dointvec, |
446fda4f PM |
491 | }, |
492 | #endif /* CONFIG_NETLABEL */ | |
3ff825b2 | 493 | { |
3ff825b2 SH |
494 | .procname = "tcp_available_congestion_control", |
495 | .maxlen = TCP_CA_BUF_MAX, | |
496 | .mode = 0444, | |
6d9f239a | 497 | .proc_handler = proc_tcp_available_congestion_control, |
3ff825b2 | 498 | }, |
ce7bc3bf | 499 | { |
ce7bc3bf SH |
500 | .procname = "tcp_allowed_congestion_control", |
501 | .maxlen = TCP_CA_BUF_MAX, | |
502 | .mode = 0644, | |
6d9f239a | 503 | .proc_handler = proc_allowed_congestion_control, |
ce7bc3bf | 504 | }, |
734942cc DW |
505 | { |
506 | .procname = "tcp_available_ulp", | |
507 | .maxlen = TCP_ULP_BUF_MAX, | |
508 | .mode = 0444, | |
509 | .proc_handler = proc_tcp_available_ulp, | |
510 | }, | |
4cdf507d ED |
511 | { |
512 | .procname = "icmp_msgs_per_sec", | |
513 | .data = &sysctl_icmp_msgs_per_sec, | |
514 | .maxlen = sizeof(int), | |
515 | .mode = 0644, | |
516 | .proc_handler = proc_dointvec_minmax, | |
517 | .extra1 = &zero, | |
518 | }, | |
519 | { | |
520 | .procname = "icmp_msgs_burst", | |
521 | .data = &sysctl_icmp_msgs_burst, | |
522 | .maxlen = sizeof(int), | |
523 | .mode = 0644, | |
524 | .proc_handler = proc_dointvec_minmax, | |
525 | .extra1 = &zero, | |
526 | }, | |
95766fff | 527 | { |
95766fff HA |
528 | .procname = "udp_mem", |
529 | .data = &sysctl_udp_mem, | |
530 | .maxlen = sizeof(sysctl_udp_mem), | |
531 | .mode = 0644, | |
8d987e5c | 532 | .proc_handler = proc_doulongvec_minmax, |
95766fff | 533 | }, |
f8572d8f | 534 | { } |
1da177e4 | 535 | }; |
3e37c3f9 | 536 | |
68528f09 PE |
537 | static struct ctl_table ipv4_net_table[] = { |
538 | { | |
68528f09 PE |
539 | .procname = "icmp_echo_ignore_all", |
540 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, | |
541 | .maxlen = sizeof(int), | |
542 | .mode = 0644, | |
6d9f239a | 543 | .proc_handler = proc_dointvec |
68528f09 PE |
544 | }, |
545 | { | |
68528f09 PE |
546 | .procname = "icmp_echo_ignore_broadcasts", |
547 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, | |
548 | .maxlen = sizeof(int), | |
549 | .mode = 0644, | |
6d9f239a | 550 | .proc_handler = proc_dointvec |
68528f09 PE |
551 | }, |
552 | { | |
68528f09 PE |
553 | .procname = "icmp_ignore_bogus_error_responses", |
554 | .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, | |
555 | .maxlen = sizeof(int), | |
556 | .mode = 0644, | |
6d9f239a | 557 | .proc_handler = proc_dointvec |
68528f09 PE |
558 | }, |
559 | { | |
68528f09 PE |
560 | .procname = "icmp_errors_use_inbound_ifaddr", |
561 | .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, | |
562 | .maxlen = sizeof(int), | |
563 | .mode = 0644, | |
6d9f239a | 564 | .proc_handler = proc_dointvec |
68528f09 PE |
565 | }, |
566 | { | |
68528f09 PE |
567 | .procname = "icmp_ratelimit", |
568 | .data = &init_net.ipv4.sysctl_icmp_ratelimit, | |
569 | .maxlen = sizeof(int), | |
570 | .mode = 0644, | |
6d9f239a | 571 | .proc_handler = proc_dointvec_ms_jiffies, |
68528f09 PE |
572 | }, |
573 | { | |
68528f09 PE |
574 | .procname = "icmp_ratemask", |
575 | .data = &init_net.ipv4.sysctl_icmp_ratemask, | |
576 | .maxlen = sizeof(int), | |
577 | .mode = 0644, | |
6d9f239a | 578 | .proc_handler = proc_dointvec |
68528f09 | 579 | }, |
c319b4d7 VK |
580 | { |
581 | .procname = "ping_group_range", | |
ba6b918a | 582 | .data = &init_net.ipv4.ping_group_range.range, |
7064d16e | 583 | .maxlen = sizeof(gid_t)*2, |
c319b4d7 VK |
584 | .mode = 0644, |
585 | .proc_handler = ipv4_ping_group_range, | |
586 | }, | |
5d134f1c HFS |
587 | { |
588 | .procname = "tcp_ecn", | |
589 | .data = &init_net.ipv4.sysctl_tcp_ecn, | |
590 | .maxlen = sizeof(int), | |
591 | .mode = 0644, | |
592 | .proc_handler = proc_dointvec | |
593 | }, | |
49213555 DB |
594 | { |
595 | .procname = "tcp_ecn_fallback", | |
596 | .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, | |
597 | .maxlen = sizeof(int), | |
598 | .mode = 0644, | |
599 | .proc_handler = proc_dointvec | |
600 | }, | |
287b7f38 NB |
601 | { |
602 | .procname = "ip_dynaddr", | |
603 | .data = &init_net.ipv4.sysctl_ip_dynaddr, | |
604 | .maxlen = sizeof(int), | |
605 | .mode = 0644, | |
606 | .proc_handler = proc_dointvec | |
607 | }, | |
e21145a9 NB |
608 | { |
609 | .procname = "ip_early_demux", | |
610 | .data = &init_net.ipv4.sysctl_ip_early_demux, | |
611 | .maxlen = sizeof(int), | |
612 | .mode = 0644, | |
613 | .proc_handler = proc_dointvec | |
614 | }, | |
dddb64bc SAK |
615 | { |
616 | .procname = "udp_early_demux", | |
617 | .data = &init_net.ipv4.sysctl_udp_early_demux, | |
618 | .maxlen = sizeof(int), | |
619 | .mode = 0644, | |
620 | .proc_handler = proc_udp_early_demux | |
621 | }, | |
622 | { | |
623 | .procname = "tcp_early_demux", | |
624 | .data = &init_net.ipv4.sysctl_tcp_early_demux, | |
625 | .maxlen = sizeof(int), | |
626 | .mode = 0644, | |
627 | .proc_handler = proc_tcp_early_demux | |
628 | }, | |
fa50d974 NB |
629 | { |
630 | .procname = "ip_default_ttl", | |
631 | .data = &init_net.ipv4.sysctl_ip_default_ttl, | |
632 | .maxlen = sizeof(int), | |
633 | .mode = 0644, | |
634 | .proc_handler = proc_dointvec_minmax, | |
635 | .extra1 = &ip_ttl_min, | |
636 | .extra2 = &ip_ttl_max, | |
637 | }, | |
0bbf87d8 EB |
638 | { |
639 | .procname = "ip_local_port_range", | |
c9d8f1a6 CW |
640 | .maxlen = sizeof(init_net.ipv4.ip_local_ports.range), |
641 | .data = &init_net.ipv4.ip_local_ports.range, | |
0bbf87d8 EB |
642 | .mode = 0644, |
643 | .proc_handler = ipv4_local_port_range, | |
644 | }, | |
122ff243 WC |
645 | { |
646 | .procname = "ip_local_reserved_ports", | |
647 | .data = &init_net.ipv4.sysctl_local_reserved_ports, | |
648 | .maxlen = 65536, | |
649 | .mode = 0644, | |
650 | .proc_handler = proc_do_large_bitmap, | |
651 | }, | |
974eda11 HFS |
652 | { |
653 | .procname = "ip_no_pmtu_disc", | |
654 | .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc, | |
655 | .maxlen = sizeof(int), | |
656 | .mode = 0644, | |
657 | .proc_handler = proc_dointvec | |
658 | }, | |
f87c10a8 HFS |
659 | { |
660 | .procname = "ip_forward_use_pmtu", | |
661 | .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu, | |
662 | .maxlen = sizeof(int), | |
663 | .mode = 0644, | |
664 | .proc_handler = proc_dointvec, | |
665 | }, | |
432e05d3 PM |
666 | { |
667 | .procname = "ip_forward_update_priority", | |
668 | .data = &init_net.ipv4.sysctl_ip_fwd_update_priority, | |
669 | .maxlen = sizeof(int), | |
670 | .mode = 0644, | |
671 | .proc_handler = proc_dointvec_minmax, | |
672 | .extra1 = &zero, | |
673 | .extra2 = &one, | |
674 | }, | |
49a60158 VB |
675 | { |
676 | .procname = "ip_nonlocal_bind", | |
677 | .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, | |
678 | .maxlen = sizeof(int), | |
679 | .mode = 0644, | |
680 | .proc_handler = proc_dointvec | |
681 | }, | |
e110861f LC |
682 | { |
683 | .procname = "fwmark_reflect", | |
684 | .data = &init_net.ipv4.sysctl_fwmark_reflect, | |
685 | .maxlen = sizeof(int), | |
686 | .mode = 0644, | |
687 | .proc_handler = proc_dointvec, | |
688 | }, | |
84f39b08 LC |
689 | { |
690 | .procname = "tcp_fwmark_accept", | |
691 | .data = &init_net.ipv4.sysctl_tcp_fwmark_accept, | |
692 | .maxlen = sizeof(int), | |
693 | .mode = 0644, | |
694 | .proc_handler = proc_dointvec, | |
695 | }, | |
6dd9a14e DA |
696 | #ifdef CONFIG_NET_L3_MASTER_DEV |
697 | { | |
698 | .procname = "tcp_l3mdev_accept", | |
699 | .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept, | |
700 | .maxlen = sizeof(int), | |
701 | .mode = 0644, | |
702 | .proc_handler = proc_dointvec_minmax, | |
703 | .extra1 = &zero, | |
704 | .extra2 = &one, | |
705 | }, | |
706 | #endif | |
b0f9ca53 FD |
707 | { |
708 | .procname = "tcp_mtu_probing", | |
709 | .data = &init_net.ipv4.sysctl_tcp_mtu_probing, | |
710 | .maxlen = sizeof(int), | |
711 | .mode = 0644, | |
712 | .proc_handler = proc_dointvec, | |
713 | }, | |
714 | { | |
715 | .procname = "tcp_base_mss", | |
716 | .data = &init_net.ipv4.sysctl_tcp_base_mss, | |
717 | .maxlen = sizeof(int), | |
718 | .mode = 0644, | |
719 | .proc_handler = proc_dointvec, | |
720 | }, | |
6b58e0a5 FD |
721 | { |
722 | .procname = "tcp_probe_threshold", | |
723 | .data = &init_net.ipv4.sysctl_tcp_probe_threshold, | |
724 | .maxlen = sizeof(int), | |
725 | .mode = 0644, | |
726 | .proc_handler = proc_dointvec, | |
727 | }, | |
05cbc0db FD |
728 | { |
729 | .procname = "tcp_probe_interval", | |
730 | .data = &init_net.ipv4.sysctl_tcp_probe_interval, | |
731 | .maxlen = sizeof(int), | |
732 | .mode = 0644, | |
733 | .proc_handler = proc_dointvec, | |
734 | }, | |
df2cf4a7 PD |
735 | { |
736 | .procname = "igmp_link_local_mcast_reports", | |
87a8a2ae | 737 | .data = &init_net.ipv4.sysctl_igmp_llm_reports, |
df2cf4a7 PD |
738 | .maxlen = sizeof(int), |
739 | .mode = 0644, | |
740 | .proc_handler = proc_dointvec | |
741 | }, | |
815c5270 NB |
742 | { |
743 | .procname = "igmp_max_memberships", | |
744 | .data = &init_net.ipv4.sysctl_igmp_max_memberships, | |
745 | .maxlen = sizeof(int), | |
746 | .mode = 0644, | |
747 | .proc_handler = proc_dointvec | |
748 | }, | |
166b6b2d NB |
749 | { |
750 | .procname = "igmp_max_msf", | |
751 | .data = &init_net.ipv4.sysctl_igmp_max_msf, | |
752 | .maxlen = sizeof(int), | |
753 | .mode = 0644, | |
754 | .proc_handler = proc_dointvec | |
755 | }, | |
165094af NB |
756 | #ifdef CONFIG_IP_MULTICAST |
757 | { | |
758 | .procname = "igmp_qrv", | |
759 | .data = &init_net.ipv4.sysctl_igmp_qrv, | |
760 | .maxlen = sizeof(int), | |
761 | .mode = 0644, | |
762 | .proc_handler = proc_dointvec_minmax, | |
763 | .extra1 = &one | |
764 | }, | |
765 | #endif | |
6670e152 SH |
766 | { |
767 | .procname = "tcp_congestion_control", | |
768 | .data = &init_net.ipv4.tcp_congestion_control, | |
769 | .mode = 0644, | |
770 | .maxlen = TCP_CA_NAME_MAX, | |
771 | .proc_handler = proc_tcp_congestion_control, | |
772 | }, | |
13b287e8 NB |
773 | { |
774 | .procname = "tcp_keepalive_time", | |
775 | .data = &init_net.ipv4.sysctl_tcp_keepalive_time, | |
776 | .maxlen = sizeof(int), | |
777 | .mode = 0644, | |
778 | .proc_handler = proc_dointvec_jiffies, | |
779 | }, | |
9bd6861b NB |
780 | { |
781 | .procname = "tcp_keepalive_probes", | |
782 | .data = &init_net.ipv4.sysctl_tcp_keepalive_probes, | |
783 | .maxlen = sizeof(int), | |
784 | .mode = 0644, | |
785 | .proc_handler = proc_dointvec | |
786 | }, | |
b840d15d NB |
787 | { |
788 | .procname = "tcp_keepalive_intvl", | |
789 | .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl, | |
790 | .maxlen = sizeof(int), | |
791 | .mode = 0644, | |
792 | .proc_handler = proc_dointvec_jiffies, | |
793 | }, | |
6fa25166 NB |
794 | { |
795 | .procname = "tcp_syn_retries", | |
796 | .data = &init_net.ipv4.sysctl_tcp_syn_retries, | |
797 | .maxlen = sizeof(int), | |
798 | .mode = 0644, | |
799 | .proc_handler = proc_dointvec_minmax, | |
800 | .extra1 = &tcp_syn_retries_min, | |
801 | .extra2 = &tcp_syn_retries_max | |
802 | }, | |
7c083ecb NB |
803 | { |
804 | .procname = "tcp_synack_retries", | |
805 | .data = &init_net.ipv4.sysctl_tcp_synack_retries, | |
806 | .maxlen = sizeof(int), | |
807 | .mode = 0644, | |
808 | .proc_handler = proc_dointvec | |
809 | }, | |
12ed8244 NB |
810 | #ifdef CONFIG_SYN_COOKIES |
811 | { | |
812 | .procname = "tcp_syncookies", | |
813 | .data = &init_net.ipv4.sysctl_tcp_syncookies, | |
814 | .maxlen = sizeof(int), | |
815 | .mode = 0644, | |
816 | .proc_handler = proc_dointvec | |
817 | }, | |
818 | #endif | |
1043e25f NB |
819 | { |
820 | .procname = "tcp_reordering", | |
821 | .data = &init_net.ipv4.sysctl_tcp_reordering, | |
822 | .maxlen = sizeof(int), | |
823 | .mode = 0644, | |
824 | .proc_handler = proc_dointvec | |
825 | }, | |
ae5c3f40 NB |
826 | { |
827 | .procname = "tcp_retries1", | |
828 | .data = &init_net.ipv4.sysctl_tcp_retries1, | |
829 | .maxlen = sizeof(int), | |
830 | .mode = 0644, | |
831 | .proc_handler = proc_dointvec_minmax, | |
832 | .extra2 = &tcp_retr1_max | |
833 | }, | |
c6214a97 NB |
834 | { |
835 | .procname = "tcp_retries2", | |
836 | .data = &init_net.ipv4.sysctl_tcp_retries2, | |
837 | .maxlen = sizeof(int), | |
838 | .mode = 0644, | |
839 | .proc_handler = proc_dointvec | |
840 | }, | |
c402d9be NB |
841 | { |
842 | .procname = "tcp_orphan_retries", | |
843 | .data = &init_net.ipv4.sysctl_tcp_orphan_retries, | |
844 | .maxlen = sizeof(int), | |
845 | .mode = 0644, | |
846 | .proc_handler = proc_dointvec | |
847 | }, | |
1e579caa NB |
848 | { |
849 | .procname = "tcp_fin_timeout", | |
850 | .data = &init_net.ipv4.sysctl_tcp_fin_timeout, | |
851 | .maxlen = sizeof(int), | |
852 | .mode = 0644, | |
853 | .proc_handler = proc_dointvec_jiffies, | |
854 | }, | |
4979f2d9 NB |
855 | { |
856 | .procname = "tcp_notsent_lowat", | |
857 | .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, | |
858 | .maxlen = sizeof(unsigned int), | |
859 | .mode = 0644, | |
b007f090 | 860 | .proc_handler = proc_douintvec, |
4979f2d9 | 861 | }, |
56ab6b93 HY |
862 | { |
863 | .procname = "tcp_tw_reuse", | |
864 | .data = &init_net.ipv4.sysctl_tcp_tw_reuse, | |
865 | .maxlen = sizeof(int), | |
866 | .mode = 0644, | |
79e9fed4 MŻ |
867 | .proc_handler = proc_dointvec_minmax, |
868 | .extra1 = &zero, | |
869 | .extra2 = &two, | |
56ab6b93 | 870 | }, |
1946e672 HY |
871 | { |
872 | .procname = "tcp_max_tw_buckets", | |
873 | .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets, | |
874 | .maxlen = sizeof(int), | |
875 | .mode = 0644, | |
876 | .proc_handler = proc_dointvec | |
877 | }, | |
fee83d09 HY |
878 | { |
879 | .procname = "tcp_max_syn_backlog", | |
880 | .data = &init_net.ipv4.sysctl_max_syn_backlog, | |
881 | .maxlen = sizeof(int), | |
882 | .mode = 0644, | |
883 | .proc_handler = proc_dointvec | |
884 | }, | |
e1cfcbe8 HY |
885 | { |
886 | .procname = "tcp_fastopen", | |
887 | .data = &init_net.ipv4.sysctl_tcp_fastopen, | |
888 | .maxlen = sizeof(int), | |
889 | .mode = 0644, | |
890 | .proc_handler = proc_dointvec, | |
891 | }, | |
43713848 HY |
892 | { |
893 | .procname = "tcp_fastopen_key", | |
894 | .mode = 0600, | |
895 | .data = &init_net.ipv4.sysctl_tcp_fastopen, | |
896 | .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10), | |
897 | .proc_handler = proc_tcp_fastopen_key, | |
898 | }, | |
3733be14 HY |
899 | { |
900 | .procname = "tcp_fastopen_blackhole_timeout_sec", | |
901 | .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout, | |
902 | .maxlen = sizeof(int), | |
903 | .mode = 0644, | |
904 | .proc_handler = proc_tfo_blackhole_detect_timeout, | |
905 | .extra1 = &zero, | |
906 | }, | |
a6db4494 DA |
907 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
908 | { | |
909 | .procname = "fib_multipath_use_neigh", | |
910 | .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh, | |
911 | .maxlen = sizeof(int), | |
912 | .mode = 0644, | |
913 | .proc_handler = proc_dointvec_minmax, | |
bf4e0a3d NA |
914 | .extra1 = &zero, |
915 | .extra2 = &one, | |
916 | }, | |
917 | { | |
918 | .procname = "fib_multipath_hash_policy", | |
919 | .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, | |
920 | .maxlen = sizeof(int), | |
921 | .mode = 0644, | |
3ae6ec08 | 922 | .proc_handler = proc_fib_multipath_hash_policy, |
a6db4494 DA |
923 | .extra1 = &zero, |
924 | .extra2 = &one, | |
925 | }, | |
926 | #endif | |
4548b683 KJ |
927 | { |
928 | .procname = "ip_unprivileged_port_start", | |
929 | .maxlen = sizeof(int), | |
930 | .data = &init_net.ipv4.sysctl_ip_prot_sock, | |
931 | .mode = 0644, | |
932 | .proc_handler = ipv4_privileged_ports, | |
933 | }, | |
63a6fff3 RS |
934 | #ifdef CONFIG_NET_L3_MASTER_DEV |
935 | { | |
936 | .procname = "udp_l3mdev_accept", | |
937 | .data = &init_net.ipv4.sysctl_udp_l3mdev_accept, | |
938 | .maxlen = sizeof(int), | |
939 | .mode = 0644, | |
940 | .proc_handler = proc_dointvec_minmax, | |
941 | .extra1 = &zero, | |
942 | .extra2 = &one, | |
943 | }, | |
944 | #endif | |
f9301034 ED |
945 | { |
946 | .procname = "tcp_sack", | |
947 | .data = &init_net.ipv4.sysctl_tcp_sack, | |
948 | .maxlen = sizeof(int), | |
949 | .mode = 0644, | |
950 | .proc_handler = proc_dointvec | |
951 | }, | |
9bb37ef0 ED |
952 | { |
953 | .procname = "tcp_window_scaling", | |
954 | .data = &init_net.ipv4.sysctl_tcp_window_scaling, | |
955 | .maxlen = sizeof(int), | |
956 | .mode = 0644, | |
957 | .proc_handler = proc_dointvec | |
958 | }, | |
5d2ed052 ED |
959 | { |
960 | .procname = "tcp_timestamps", | |
961 | .data = &init_net.ipv4.sysctl_tcp_timestamps, | |
962 | .maxlen = sizeof(int), | |
963 | .mode = 0644, | |
964 | .proc_handler = proc_dointvec | |
965 | }, | |
2ae21cf5 ED |
966 | { |
967 | .procname = "tcp_early_retrans", | |
968 | .data = &init_net.ipv4.sysctl_tcp_early_retrans, | |
969 | .maxlen = sizeof(int), | |
970 | .mode = 0644, | |
971 | .proc_handler = proc_dointvec_minmax, | |
972 | .extra1 = &zero, | |
973 | .extra2 = &four, | |
974 | }, | |
e20223f1 ED |
975 | { |
976 | .procname = "tcp_recovery", | |
977 | .data = &init_net.ipv4.sysctl_tcp_recovery, | |
978 | .maxlen = sizeof(int), | |
979 | .mode = 0644, | |
980 | .proc_handler = proc_dointvec, | |
981 | }, | |
2c04ac8a ED |
982 | { |
983 | .procname = "tcp_thin_linear_timeouts", | |
984 | .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts, | |
985 | .maxlen = sizeof(int), | |
986 | .mode = 0644, | |
987 | .proc_handler = proc_dointvec | |
988 | }, | |
b510f0d2 ED |
989 | { |
990 | .procname = "tcp_slow_start_after_idle", | |
991 | .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle, | |
992 | .maxlen = sizeof(int), | |
993 | .mode = 0644, | |
994 | .proc_handler = proc_dointvec | |
995 | }, | |
e0a1e5b5 ED |
996 | { |
997 | .procname = "tcp_retrans_collapse", | |
998 | .data = &init_net.ipv4.sysctl_tcp_retrans_collapse, | |
999 | .maxlen = sizeof(int), | |
1000 | .mode = 0644, | |
1001 | .proc_handler = proc_dointvec | |
1002 | }, | |
3f4c7c6f ED |
1003 | { |
1004 | .procname = "tcp_stdurg", | |
1005 | .data = &init_net.ipv4.sysctl_tcp_stdurg, | |
1006 | .maxlen = sizeof(int), | |
1007 | .mode = 0644, | |
1008 | .proc_handler = proc_dointvec | |
1009 | }, | |
625357aa ED |
1010 | { |
1011 | .procname = "tcp_rfc1337", | |
1012 | .data = &init_net.ipv4.sysctl_tcp_rfc1337, | |
1013 | .maxlen = sizeof(int), | |
1014 | .mode = 0644, | |
1015 | .proc_handler = proc_dointvec | |
1016 | }, | |
65c9410c ED |
1017 | { |
1018 | .procname = "tcp_abort_on_overflow", | |
1019 | .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow, | |
1020 | .maxlen = sizeof(int), | |
1021 | .mode = 0644, | |
1022 | .proc_handler = proc_dointvec | |
1023 | }, | |
0bc65a28 ED |
1024 | { |
1025 | .procname = "tcp_fack", | |
1026 | .data = &init_net.ipv4.sysctl_tcp_fack, | |
1027 | .maxlen = sizeof(int), | |
1028 | .mode = 0644, | |
1029 | .proc_handler = proc_dointvec | |
1030 | }, | |
c6e21803 ED |
1031 | { |
1032 | .procname = "tcp_max_reordering", | |
1033 | .data = &init_net.ipv4.sysctl_tcp_max_reordering, | |
1034 | .maxlen = sizeof(int), | |
1035 | .mode = 0644, | |
1036 | .proc_handler = proc_dointvec | |
1037 | }, | |
6496f6bd ED |
1038 | { |
1039 | .procname = "tcp_dsack", | |
1040 | .data = &init_net.ipv4.sysctl_tcp_dsack, | |
1041 | .maxlen = sizeof(int), | |
1042 | .mode = 0644, | |
1043 | .proc_handler = proc_dointvec | |
1044 | }, | |
0c12654a ED |
1045 | { |
1046 | .procname = "tcp_app_win", | |
1047 | .data = &init_net.ipv4.sysctl_tcp_app_win, | |
1048 | .maxlen = sizeof(int), | |
1049 | .mode = 0644, | |
1050 | .proc_handler = proc_dointvec | |
1051 | }, | |
94f0893e ED |
1052 | { |
1053 | .procname = "tcp_adv_win_scale", | |
1054 | .data = &init_net.ipv4.sysctl_tcp_adv_win_scale, | |
1055 | .maxlen = sizeof(int), | |
1056 | .mode = 0644, | |
1057 | .proc_handler = proc_dointvec_minmax, | |
1058 | .extra1 = &tcp_adv_win_scale_min, | |
1059 | .extra2 = &tcp_adv_win_scale_max, | |
1060 | }, | |
af9b69a7 ED |
1061 | { |
1062 | .procname = "tcp_frto", | |
1063 | .data = &init_net.ipv4.sysctl_tcp_frto, | |
1064 | .maxlen = sizeof(int), | |
1065 | .mode = 0644, | |
1066 | .proc_handler = proc_dointvec | |
1067 | }, | |
ec36e416 ED |
1068 | { |
1069 | .procname = "tcp_no_metrics_save", | |
1070 | .data = &init_net.ipv4.sysctl_tcp_nometrics_save, | |
1071 | .maxlen = sizeof(int), | |
1072 | .mode = 0644, | |
1073 | .proc_handler = proc_dointvec, | |
1074 | }, | |
4540c0cf ED |
1075 | { |
1076 | .procname = "tcp_moderate_rcvbuf", | |
1077 | .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf, | |
1078 | .maxlen = sizeof(int), | |
1079 | .mode = 0644, | |
1080 | .proc_handler = proc_dointvec, | |
1081 | }, | |
d06a9904 ED |
1082 | { |
1083 | .procname = "tcp_tso_win_divisor", | |
1084 | .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor, | |
1085 | .maxlen = sizeof(int), | |
1086 | .mode = 0644, | |
1087 | .proc_handler = proc_dointvec, | |
1088 | }, | |
ceef9ab6 ED |
1089 | { |
1090 | .procname = "tcp_workaround_signed_windows", | |
1091 | .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows, | |
1092 | .maxlen = sizeof(int), | |
1093 | .mode = 0644, | |
1094 | .proc_handler = proc_dointvec | |
1095 | }, | |
9184d8bb ED |
1096 | { |
1097 | .procname = "tcp_limit_output_bytes", | |
1098 | .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes, | |
1099 | .maxlen = sizeof(int), | |
1100 | .mode = 0644, | |
1101 | .proc_handler = proc_dointvec | |
1102 | }, | |
b530b681 ED |
1103 | { |
1104 | .procname = "tcp_challenge_ack_limit", | |
1105 | .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit, | |
1106 | .maxlen = sizeof(int), | |
1107 | .mode = 0644, | |
1108 | .proc_handler = proc_dointvec | |
1109 | }, | |
26e9596e ED |
1110 | { |
1111 | .procname = "tcp_min_tso_segs", | |
1112 | .data = &init_net.ipv4.sysctl_tcp_min_tso_segs, | |
1113 | .maxlen = sizeof(int), | |
1114 | .mode = 0644, | |
1115 | .proc_handler = proc_dointvec_minmax, | |
1116 | .extra1 = &one, | |
1117 | .extra2 = &gso_max_segs, | |
1118 | }, | |
bd239704 ED |
1119 | { |
1120 | .procname = "tcp_min_rtt_wlen", | |
1121 | .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen, | |
1122 | .maxlen = sizeof(int), | |
1123 | .mode = 0644, | |
1124 | .proc_handler = proc_dointvec | |
1125 | }, | |
790f00e1 ED |
1126 | { |
1127 | .procname = "tcp_autocorking", | |
1128 | .data = &init_net.ipv4.sysctl_tcp_autocorking, | |
1129 | .maxlen = sizeof(int), | |
1130 | .mode = 0644, | |
1131 | .proc_handler = proc_dointvec_minmax, | |
1132 | .extra1 = &zero, | |
1133 | .extra2 = &one, | |
1134 | }, | |
4170ba6b ED |
1135 | { |
1136 | .procname = "tcp_invalid_ratelimit", | |
1137 | .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit, | |
1138 | .maxlen = sizeof(int), | |
1139 | .mode = 0644, | |
1140 | .proc_handler = proc_dointvec_ms_jiffies, | |
1141 | }, | |
23a7102a ED |
1142 | { |
1143 | .procname = "tcp_pacing_ss_ratio", | |
1144 | .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio, | |
1145 | .maxlen = sizeof(int), | |
1146 | .mode = 0644, | |
1147 | .proc_handler = proc_dointvec_minmax, | |
1148 | .extra1 = &zero, | |
1149 | .extra2 = &thousand, | |
1150 | }, | |
c26e91f8 ED |
1151 | { |
1152 | .procname = "tcp_pacing_ca_ratio", | |
1153 | .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio, | |
1154 | .maxlen = sizeof(int), | |
1155 | .mode = 0644, | |
1156 | .proc_handler = proc_dointvec_minmax, | |
1157 | .extra1 = &zero, | |
1158 | .extra2 = &thousand, | |
1159 | }, | |
356d1833 ED |
1160 | { |
1161 | .procname = "tcp_wmem", | |
1162 | .data = &init_net.ipv4.sysctl_tcp_wmem, | |
1163 | .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem), | |
1164 | .mode = 0644, | |
1165 | .proc_handler = proc_dointvec_minmax, | |
1166 | .extra1 = &one, | |
1167 | }, | |
1168 | { | |
1169 | .procname = "tcp_rmem", | |
1170 | .data = &init_net.ipv4.sysctl_tcp_rmem, | |
1171 | .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem), | |
1172 | .mode = 0644, | |
1173 | .proc_handler = proc_dointvec_minmax, | |
1174 | .extra1 = &one, | |
1175 | }, | |
6d82aa24 ED |
1176 | { |
1177 | .procname = "tcp_comp_sack_delay_ns", | |
1178 | .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns, | |
1179 | .maxlen = sizeof(unsigned long), | |
1180 | .mode = 0644, | |
1181 | .proc_handler = proc_doulongvec_minmax, | |
1182 | }, | |
9c21d2fc ED |
1183 | { |
1184 | .procname = "tcp_comp_sack_nr", | |
1185 | .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr, | |
1186 | .maxlen = sizeof(int), | |
1187 | .mode = 0644, | |
1188 | .proc_handler = proc_dointvec_minmax, | |
1189 | .extra1 = &zero, | |
1190 | .extra2 = &comp_sack_nr_max, | |
1191 | }, | |
1e802951 TZ |
1192 | { |
1193 | .procname = "udp_rmem_min", | |
1194 | .data = &init_net.ipv4.sysctl_udp_rmem_min, | |
1195 | .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min), | |
1196 | .mode = 0644, | |
1197 | .proc_handler = proc_dointvec_minmax, | |
1198 | .extra1 = &one | |
1199 | }, | |
1200 | { | |
1201 | .procname = "udp_wmem_min", | |
1202 | .data = &init_net.ipv4.sysctl_udp_wmem_min, | |
1203 | .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min), | |
1204 | .mode = 0644, | |
1205 | .proc_handler = proc_dointvec_minmax, | |
1206 | .extra1 = &one | |
1207 | }, | |
68528f09 PE |
1208 | { } |
1209 | }; | |
1210 | ||
1577519d PE |
1211 | static __net_init int ipv4_sysctl_init_net(struct net *net) |
1212 | { | |
68528f09 PE |
1213 | struct ctl_table *table; |
1214 | ||
1215 | table = ipv4_net_table; | |
09ad9bc7 | 1216 | if (!net_eq(net, &init_net)) { |
0a6fa23d EB |
1217 | int i; |
1218 | ||
68528f09 | 1219 | table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); |
51456b29 | 1220 | if (!table) |
68528f09 PE |
1221 | goto err_alloc; |
1222 | ||
0a6fa23d EB |
1223 | /* Update the variables to point into the current struct net */ |
1224 | for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) | |
1225 | table[i].data += (void *)net - (void *)&init_net; | |
68528f09 PE |
1226 | } |
1227 | ||
ec8f23ce | 1228 | net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); |
51456b29 | 1229 | if (!net->ipv4.ipv4_hdr) |
68528f09 PE |
1230 | goto err_reg; |
1231 | ||
122ff243 WC |
1232 | net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL); |
1233 | if (!net->ipv4.sysctl_local_reserved_ports) | |
1234 | goto err_ports; | |
1235 | ||
1577519d | 1236 | return 0; |
68528f09 | 1237 | |
122ff243 WC |
1238 | err_ports: |
1239 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); | |
68528f09 | 1240 | err_reg: |
09ad9bc7 | 1241 | if (!net_eq(net, &init_net)) |
68528f09 PE |
1242 | kfree(table); |
1243 | err_alloc: | |
1244 | return -ENOMEM; | |
1577519d PE |
1245 | } |
1246 | ||
1247 | static __net_exit void ipv4_sysctl_exit_net(struct net *net) | |
1248 | { | |
68528f09 PE |
1249 | struct ctl_table *table; |
1250 | ||
122ff243 | 1251 | kfree(net->ipv4.sysctl_local_reserved_ports); |
68528f09 PE |
1252 | table = net->ipv4.ipv4_hdr->ctl_table_arg; |
1253 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); | |
1254 | kfree(table); | |
1577519d PE |
1255 | } |
1256 | ||
1257 | static __net_initdata struct pernet_operations ipv4_sysctl_ops = { | |
1258 | .init = ipv4_sysctl_init_net, | |
1259 | .exit = ipv4_sysctl_exit_net, | |
1260 | }; | |
1261 | ||
3e37c3f9 PE |
1262 | static __init int sysctl_ipv4_init(void) |
1263 | { | |
1264 | struct ctl_table_header *hdr; | |
1265 | ||
ec8f23ce | 1266 | hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table); |
51456b29 | 1267 | if (!hdr) |
1577519d PE |
1268 | return -ENOMEM; |
1269 | ||
1270 | if (register_pernet_subsys(&ipv4_sysctl_ops)) { | |
5dd3df10 | 1271 | unregister_net_sysctl_table(hdr); |
1577519d PE |
1272 | return -ENOMEM; |
1273 | } | |
1274 | ||
1275 | return 0; | |
3e37c3f9 PE |
1276 | } |
1277 | ||
1278 | __initcall(sysctl_ipv4_init); |