blob: c83a5d05aeaaf0896846f853c1c6d97b74981726 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// SPDX-License-Identifier: GPL-2.0
2/*
3 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
4 *
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>
12#include <linux/igmp.h>
13#include <linux/inetdevice.h>
14#include <linux/seqlock.h>
15#include <linux/init.h>
16#include <linux/slab.h>
17#include <linux/nsproxy.h>
18#include <linux/swap.h>
19#include <net/snmp.h>
20#include <net/icmp.h>
21#include <net/ip.h>
22#include <net/route.h>
23#include <net/tcp.h>
24#include <net/udp.h>
25#include <net/cipso_ipv4.h>
26#include <net/inet_frag.h>
27#include <net/ping.h>
28#include <net/protocol.h>
29#include <net/netevent.h>
30
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031static int two = 2;
32static int four = 4;
33static int thousand = 1000;
34static int gso_max_segs = GSO_MAX_SEGS;
35static int tcp_retr1_max = 255;
36static int ip_local_port_range_min[] = { 1, 1 };
37static int ip_local_port_range_max[] = { 65535, 65535 };
38static int tcp_adv_win_scale_min = -31;
39static int tcp_adv_win_scale_max = 31;
David Brazdil0f672f62019-12-10 10:32:29 +000040static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
41static int tcp_min_snd_mss_max = 65535;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000042static int ip_privileged_port_min;
43static int ip_privileged_port_max = 65535;
44static int ip_ttl_min = 1;
45static int ip_ttl_max = 255;
46static int tcp_syn_retries_min = 1;
47static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
48static int ip_ping_group_range_min[] = { 0, 0 };
49static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
50static int comp_sack_nr_max = 255;
51static u32 u32_max_div_HZ = UINT_MAX / HZ;
David Brazdil0f672f62019-12-10 10:32:29 +000052static int one_day_secs = 24 * 3600;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000053
54/* obsolete */
55static int sysctl_tcp_low_latency __read_mostly;
56
57/* Update system visible IP port range */
58static void set_local_port_range(struct net *net, int range[2])
59{
60 bool same_parity = !((range[0] ^ range[1]) & 1);
61
62 write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
63 if (same_parity && !net->ipv4.ip_local_ports.warned) {
64 net->ipv4.ip_local_ports.warned = true;
65 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
66 }
67 net->ipv4.ip_local_ports.range[0] = range[0];
68 net->ipv4.ip_local_ports.range[1] = range[1];
69 write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
70}
71
72/* Validate changes from /proc interface. */
73static int ipv4_local_port_range(struct ctl_table *table, int write,
74 void __user *buffer,
75 size_t *lenp, loff_t *ppos)
76{
77 struct net *net =
78 container_of(table->data, struct net, ipv4.ip_local_ports.range);
79 int ret;
80 int range[2];
81 struct ctl_table tmp = {
82 .data = &range,
83 .maxlen = sizeof(range),
84 .mode = table->mode,
85 .extra1 = &ip_local_port_range_min,
86 .extra2 = &ip_local_port_range_max,
87 };
88
89 inet_get_local_port_range(net, &range[0], &range[1]);
90
91 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
92
93 if (write && ret == 0) {
94 /* Ensure that the upper limit is not smaller than the lower,
95 * and that the lower does not encroach upon the privileged
96 * port limit.
97 */
98 if ((range[1] < range[0]) ||
99 (range[0] < net->ipv4.sysctl_ip_prot_sock))
100 ret = -EINVAL;
101 else
102 set_local_port_range(net, range);
103 }
104
105 return ret;
106}
107
108/* Validate changes from /proc interface. */
109static int ipv4_privileged_ports(struct ctl_table *table, int write,
110 void __user *buffer, size_t *lenp, loff_t *ppos)
111{
112 struct net *net = container_of(table->data, struct net,
113 ipv4.sysctl_ip_prot_sock);
114 int ret;
115 int pports;
116 int range[2];
117 struct ctl_table tmp = {
118 .data = &pports,
119 .maxlen = sizeof(pports),
120 .mode = table->mode,
121 .extra1 = &ip_privileged_port_min,
122 .extra2 = &ip_privileged_port_max,
123 };
124
125 pports = net->ipv4.sysctl_ip_prot_sock;
126
127 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
128
129 if (write && ret == 0) {
130 inet_get_local_port_range(net, &range[0], &range[1]);
131 /* Ensure that the local port range doesn't overlap with the
132 * privileged port range.
133 */
134 if (range[0] < pports)
135 ret = -EINVAL;
136 else
137 net->ipv4.sysctl_ip_prot_sock = pports;
138 }
139
140 return ret;
141}
142
143static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
144{
145 kgid_t *data = table->data;
146 struct net *net =
147 container_of(table->data, struct net, ipv4.ping_group_range.range);
148 unsigned int seq;
149 do {
150 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
151
152 *low = data[0];
153 *high = data[1];
154 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
155}
156
157/* Update system visible IP port range */
158static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
159{
160 kgid_t *data = table->data;
161 struct net *net =
162 container_of(table->data, struct net, ipv4.ping_group_range.range);
163 write_seqlock(&net->ipv4.ping_group_range.lock);
164 data[0] = low;
165 data[1] = high;
166 write_sequnlock(&net->ipv4.ping_group_range.lock);
167}
168
169/* Validate changes from /proc interface. */
170static int ipv4_ping_group_range(struct ctl_table *table, int write,
171 void __user *buffer,
172 size_t *lenp, loff_t *ppos)
173{
174 struct user_namespace *user_ns = current_user_ns();
175 int ret;
176 gid_t urange[2];
177 kgid_t low, high;
178 struct ctl_table tmp = {
179 .data = &urange,
180 .maxlen = sizeof(urange),
181 .mode = table->mode,
182 .extra1 = &ip_ping_group_range_min,
183 .extra2 = &ip_ping_group_range_max,
184 };
185
186 inet_get_ping_group_range_table(table, &low, &high);
187 urange[0] = from_kgid_munged(user_ns, low);
188 urange[1] = from_kgid_munged(user_ns, high);
189 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
190
191 if (write && ret == 0) {
192 low = make_kgid(user_ns, urange[0]);
193 high = make_kgid(user_ns, urange[1]);
194 if (!gid_valid(low) || !gid_valid(high))
195 return -EINVAL;
196 if (urange[1] < urange[0] || gid_lt(high, low)) {
197 low = make_kgid(&init_user_ns, 1);
198 high = make_kgid(&init_user_ns, 0);
199 }
200 set_ping_group_range(table, low, high);
201 }
202
203 return ret;
204}
205
206static int ipv4_fwd_update_priority(struct ctl_table *table, int write,
207 void __user *buffer,
208 size_t *lenp, loff_t *ppos)
209{
210 struct net *net;
211 int ret;
212
213 net = container_of(table->data, struct net,
214 ipv4.sysctl_ip_fwd_update_priority);
215 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
216 if (write && ret == 0)
217 call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
218 net);
219
220 return ret;
221}
222
223static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
224 void __user *buffer, size_t *lenp, loff_t *ppos)
225{
226 struct net *net = container_of(ctl->data, struct net,
227 ipv4.tcp_congestion_control);
228 char val[TCP_CA_NAME_MAX];
229 struct ctl_table tbl = {
230 .data = val,
231 .maxlen = TCP_CA_NAME_MAX,
232 };
233 int ret;
234
235 tcp_get_default_congestion_control(net, val);
236
237 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
238 if (write && ret == 0)
239 ret = tcp_set_default_congestion_control(net, val);
240 return ret;
241}
242
243static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
244 int write,
245 void __user *buffer, size_t *lenp,
246 loff_t *ppos)
247{
248 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
249 int ret;
250
251 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
252 if (!tbl.data)
253 return -ENOMEM;
254 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
255 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
256 kfree(tbl.data);
257 return ret;
258}
259
260static int proc_allowed_congestion_control(struct ctl_table *ctl,
261 int write,
262 void __user *buffer, size_t *lenp,
263 loff_t *ppos)
264{
265 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
266 int ret;
267
268 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
269 if (!tbl.data)
270 return -ENOMEM;
271
272 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
273 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
274 if (write && ret == 0)
275 ret = tcp_set_allowed_congestion_control(tbl.data);
276 kfree(tbl.data);
277 return ret;
278}
279
David Brazdil0f672f62019-12-10 10:32:29 +0000280static int sscanf_key(char *buf, __le32 *key)
281{
282 u32 user_key[4];
283 int i, ret = 0;
284
285 if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
286 user_key + 2, user_key + 3) != 4) {
287 ret = -EINVAL;
288 } else {
289 for (i = 0; i < ARRAY_SIZE(user_key); i++)
290 key[i] = cpu_to_le32(user_key[i]);
291 }
292 pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
293 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
294
295 return ret;
296}
297
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000298static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
299 void __user *buffer, size_t *lenp,
300 loff_t *ppos)
301{
302 struct net *net = container_of(table->data, struct net,
303 ipv4.sysctl_tcp_fastopen);
David Brazdil0f672f62019-12-10 10:32:29 +0000304 /* maxlen to print the list of keys in hex (*2), with dashes
305 * separating doublewords and a comma in between keys.
306 */
307 struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
308 2 * TCP_FASTOPEN_KEY_MAX) +
309 (TCP_FASTOPEN_KEY_MAX * 5)) };
Olivier Deprez0e641232021-09-23 10:07:05 +0200310 u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
311 __le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
David Brazdil0f672f62019-12-10 10:32:29 +0000312 char *backup_data;
Olivier Deprez0e641232021-09-23 10:07:05 +0200313 int ret, i = 0, off = 0, n_keys;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000314
315 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
316 if (!tbl.data)
317 return -ENOMEM;
318
Olivier Deprez0e641232021-09-23 10:07:05 +0200319 n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
David Brazdil0f672f62019-12-10 10:32:29 +0000320 if (!n_keys) {
321 memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
322 n_keys = 1;
323 }
324
325 for (i = 0; i < n_keys * 4; i++)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000326 user_key[i] = le32_to_cpu(key[i]);
327
David Brazdil0f672f62019-12-10 10:32:29 +0000328 for (i = 0; i < n_keys; i++) {
329 off += snprintf(tbl.data + off, tbl.maxlen - off,
330 "%08x-%08x-%08x-%08x",
331 user_key[i * 4],
332 user_key[i * 4 + 1],
333 user_key[i * 4 + 2],
334 user_key[i * 4 + 3]);
335 if (i + 1 < n_keys)
336 off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
337 }
338
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000339 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
340
341 if (write && ret == 0) {
David Brazdil0f672f62019-12-10 10:32:29 +0000342 backup_data = strchr(tbl.data, ',');
343 if (backup_data) {
344 *backup_data = '\0';
345 backup_data++;
346 }
347 if (sscanf_key(tbl.data, key)) {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000348 ret = -EINVAL;
349 goto bad_key;
350 }
David Brazdil0f672f62019-12-10 10:32:29 +0000351 if (backup_data) {
352 if (sscanf_key(backup_data, key + 4)) {
353 ret = -EINVAL;
354 goto bad_key;
355 }
356 }
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000357 tcp_fastopen_reset_cipher(net, NULL, key,
David Brazdil0f672f62019-12-10 10:32:29 +0000358 backup_data ? key + 4 : NULL);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000359 }
360
361bad_key:
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000362 kfree(tbl.data);
363 return ret;
364}
365
366static void proc_configure_early_demux(int enabled, int protocol)
367{
368 struct net_protocol *ipprot;
369#if IS_ENABLED(CONFIG_IPV6)
370 struct inet6_protocol *ip6prot;
371#endif
372
373 rcu_read_lock();
374
375 ipprot = rcu_dereference(inet_protos[protocol]);
376 if (ipprot)
377 ipprot->early_demux = enabled ? ipprot->early_demux_handler :
378 NULL;
379
380#if IS_ENABLED(CONFIG_IPV6)
381 ip6prot = rcu_dereference(inet6_protos[protocol]);
382 if (ip6prot)
383 ip6prot->early_demux = enabled ? ip6prot->early_demux_handler :
384 NULL;
385#endif
386 rcu_read_unlock();
387}
388
389static int proc_tcp_early_demux(struct ctl_table *table, int write,
390 void __user *buffer, size_t *lenp, loff_t *ppos)
391{
392 int ret = 0;
393
394 ret = proc_dointvec(table, write, buffer, lenp, ppos);
395
396 if (write && !ret) {
397 int enabled = init_net.ipv4.sysctl_tcp_early_demux;
398
399 proc_configure_early_demux(enabled, IPPROTO_TCP);
400 }
401
402 return ret;
403}
404
405static int proc_udp_early_demux(struct ctl_table *table, int write,
406 void __user *buffer, size_t *lenp, loff_t *ppos)
407{
408 int ret = 0;
409
410 ret = proc_dointvec(table, write, buffer, lenp, ppos);
411
412 if (write && !ret) {
413 int enabled = init_net.ipv4.sysctl_udp_early_demux;
414
415 proc_configure_early_demux(enabled, IPPROTO_UDP);
416 }
417
418 return ret;
419}
420
421static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
422 int write,
423 void __user *buffer,
424 size_t *lenp, loff_t *ppos)
425{
426 struct net *net = container_of(table->data, struct net,
427 ipv4.sysctl_tcp_fastopen_blackhole_timeout);
428 int ret;
429
430 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
431 if (write && ret == 0)
432 atomic_set(&net->ipv4.tfo_active_disable_times, 0);
433
434 return ret;
435}
436
437static int proc_tcp_available_ulp(struct ctl_table *ctl,
438 int write,
439 void __user *buffer, size_t *lenp,
440 loff_t *ppos)
441{
442 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
443 int ret;
444
445 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
446 if (!tbl.data)
447 return -ENOMEM;
448 tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
449 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
450 kfree(tbl.data);
451
452 return ret;
453}
454
455#ifdef CONFIG_IP_ROUTE_MULTIPATH
456static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
457 void __user *buffer, size_t *lenp,
458 loff_t *ppos)
459{
460 struct net *net = container_of(table->data, struct net,
461 ipv4.sysctl_fib_multipath_hash_policy);
462 int ret;
463
464 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
465 if (write && ret == 0)
466 call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
467
468 return ret;
469}
470#endif
471
472static struct ctl_table ipv4_table[] = {
473 {
474 .procname = "tcp_max_orphans",
475 .data = &sysctl_tcp_max_orphans,
476 .maxlen = sizeof(int),
477 .mode = 0644,
478 .proc_handler = proc_dointvec
479 },
480 {
481 .procname = "inet_peer_threshold",
482 .data = &inet_peer_threshold,
483 .maxlen = sizeof(int),
484 .mode = 0644,
485 .proc_handler = proc_dointvec
486 },
487 {
488 .procname = "inet_peer_minttl",
489 .data = &inet_peer_minttl,
490 .maxlen = sizeof(int),
491 .mode = 0644,
492 .proc_handler = proc_dointvec_jiffies,
493 },
494 {
495 .procname = "inet_peer_maxttl",
496 .data = &inet_peer_maxttl,
497 .maxlen = sizeof(int),
498 .mode = 0644,
499 .proc_handler = proc_dointvec_jiffies,
500 },
501 {
502 .procname = "tcp_mem",
503 .maxlen = sizeof(sysctl_tcp_mem),
504 .data = &sysctl_tcp_mem,
505 .mode = 0644,
506 .proc_handler = proc_doulongvec_minmax,
507 },
508 {
509 .procname = "tcp_low_latency",
510 .data = &sysctl_tcp_low_latency,
511 .maxlen = sizeof(int),
512 .mode = 0644,
513 .proc_handler = proc_dointvec
514 },
515#ifdef CONFIG_NETLABEL
516 {
517 .procname = "cipso_cache_enable",
518 .data = &cipso_v4_cache_enabled,
519 .maxlen = sizeof(int),
520 .mode = 0644,
521 .proc_handler = proc_dointvec,
522 },
523 {
524 .procname = "cipso_cache_bucket_size",
525 .data = &cipso_v4_cache_bucketsize,
526 .maxlen = sizeof(int),
527 .mode = 0644,
528 .proc_handler = proc_dointvec,
529 },
530 {
531 .procname = "cipso_rbm_optfmt",
532 .data = &cipso_v4_rbm_optfmt,
533 .maxlen = sizeof(int),
534 .mode = 0644,
535 .proc_handler = proc_dointvec,
536 },
537 {
538 .procname = "cipso_rbm_strictvalid",
539 .data = &cipso_v4_rbm_strictvalid,
540 .maxlen = sizeof(int),
541 .mode = 0644,
542 .proc_handler = proc_dointvec,
543 },
544#endif /* CONFIG_NETLABEL */
545 {
546 .procname = "tcp_available_congestion_control",
547 .maxlen = TCP_CA_BUF_MAX,
548 .mode = 0444,
549 .proc_handler = proc_tcp_available_congestion_control,
550 },
551 {
552 .procname = "tcp_allowed_congestion_control",
553 .maxlen = TCP_CA_BUF_MAX,
554 .mode = 0644,
555 .proc_handler = proc_allowed_congestion_control,
556 },
557 {
558 .procname = "tcp_available_ulp",
559 .maxlen = TCP_ULP_BUF_MAX,
560 .mode = 0444,
561 .proc_handler = proc_tcp_available_ulp,
562 },
563 {
564 .procname = "icmp_msgs_per_sec",
565 .data = &sysctl_icmp_msgs_per_sec,
566 .maxlen = sizeof(int),
567 .mode = 0644,
568 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +0000569 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000570 },
571 {
572 .procname = "icmp_msgs_burst",
573 .data = &sysctl_icmp_msgs_burst,
574 .maxlen = sizeof(int),
575 .mode = 0644,
576 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +0000577 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000578 },
579 {
580 .procname = "udp_mem",
581 .data = &sysctl_udp_mem,
582 .maxlen = sizeof(sysctl_udp_mem),
583 .mode = 0644,
584 .proc_handler = proc_doulongvec_minmax,
585 },
David Brazdil0f672f62019-12-10 10:32:29 +0000586 {
587 .procname = "fib_sync_mem",
588 .data = &sysctl_fib_sync_mem,
589 .maxlen = sizeof(sysctl_fib_sync_mem),
590 .mode = 0644,
591 .proc_handler = proc_douintvec_minmax,
592 .extra1 = &sysctl_fib_sync_mem_min,
593 .extra2 = &sysctl_fib_sync_mem_max,
594 },
595 {
596 .procname = "tcp_rx_skb_cache",
597 .data = &tcp_rx_skb_cache_key.key,
598 .mode = 0644,
599 .proc_handler = proc_do_static_key,
600 },
601 {
602 .procname = "tcp_tx_skb_cache",
603 .data = &tcp_tx_skb_cache_key.key,
604 .mode = 0644,
605 .proc_handler = proc_do_static_key,
606 },
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000607 { }
608};
609
610static struct ctl_table ipv4_net_table[] = {
611 {
612 .procname = "icmp_echo_ignore_all",
613 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 .proc_handler = proc_dointvec
617 },
618 {
619 .procname = "icmp_echo_ignore_broadcasts",
620 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
621 .maxlen = sizeof(int),
622 .mode = 0644,
623 .proc_handler = proc_dointvec
624 },
625 {
626 .procname = "icmp_ignore_bogus_error_responses",
627 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = proc_dointvec
631 },
632 {
633 .procname = "icmp_errors_use_inbound_ifaddr",
634 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
635 .maxlen = sizeof(int),
636 .mode = 0644,
637 .proc_handler = proc_dointvec
638 },
639 {
640 .procname = "icmp_ratelimit",
641 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
642 .maxlen = sizeof(int),
643 .mode = 0644,
644 .proc_handler = proc_dointvec_ms_jiffies,
645 },
646 {
647 .procname = "icmp_ratemask",
648 .data = &init_net.ipv4.sysctl_icmp_ratemask,
649 .maxlen = sizeof(int),
650 .mode = 0644,
651 .proc_handler = proc_dointvec
652 },
653 {
654 .procname = "ping_group_range",
655 .data = &init_net.ipv4.ping_group_range.range,
656 .maxlen = sizeof(gid_t)*2,
657 .mode = 0644,
658 .proc_handler = ipv4_ping_group_range,
659 },
David Brazdil0f672f62019-12-10 10:32:29 +0000660#ifdef CONFIG_NET_L3_MASTER_DEV
661 {
662 .procname = "raw_l3mdev_accept",
663 .data = &init_net.ipv4.sysctl_raw_l3mdev_accept,
664 .maxlen = sizeof(int),
665 .mode = 0644,
666 .proc_handler = proc_dointvec_minmax,
667 .extra1 = SYSCTL_ZERO,
668 .extra2 = SYSCTL_ONE,
669 },
670#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000671 {
672 .procname = "tcp_ecn",
673 .data = &init_net.ipv4.sysctl_tcp_ecn,
674 .maxlen = sizeof(int),
675 .mode = 0644,
676 .proc_handler = proc_dointvec
677 },
678 {
679 .procname = "tcp_ecn_fallback",
680 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
681 .maxlen = sizeof(int),
682 .mode = 0644,
683 .proc_handler = proc_dointvec
684 },
685 {
686 .procname = "ip_dynaddr",
687 .data = &init_net.ipv4.sysctl_ip_dynaddr,
688 .maxlen = sizeof(int),
689 .mode = 0644,
690 .proc_handler = proc_dointvec
691 },
692 {
693 .procname = "ip_early_demux",
694 .data = &init_net.ipv4.sysctl_ip_early_demux,
695 .maxlen = sizeof(int),
696 .mode = 0644,
697 .proc_handler = proc_dointvec
698 },
699 {
700 .procname = "udp_early_demux",
701 .data = &init_net.ipv4.sysctl_udp_early_demux,
702 .maxlen = sizeof(int),
703 .mode = 0644,
704 .proc_handler = proc_udp_early_demux
705 },
706 {
707 .procname = "tcp_early_demux",
708 .data = &init_net.ipv4.sysctl_tcp_early_demux,
709 .maxlen = sizeof(int),
710 .mode = 0644,
711 .proc_handler = proc_tcp_early_demux
712 },
713 {
714 .procname = "ip_default_ttl",
715 .data = &init_net.ipv4.sysctl_ip_default_ttl,
716 .maxlen = sizeof(int),
717 .mode = 0644,
718 .proc_handler = proc_dointvec_minmax,
719 .extra1 = &ip_ttl_min,
720 .extra2 = &ip_ttl_max,
721 },
722 {
723 .procname = "ip_local_port_range",
724 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
725 .data = &init_net.ipv4.ip_local_ports.range,
726 .mode = 0644,
727 .proc_handler = ipv4_local_port_range,
728 },
729 {
730 .procname = "ip_local_reserved_ports",
731 .data = &init_net.ipv4.sysctl_local_reserved_ports,
732 .maxlen = 65536,
733 .mode = 0644,
734 .proc_handler = proc_do_large_bitmap,
735 },
736 {
737 .procname = "ip_no_pmtu_disc",
738 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
739 .maxlen = sizeof(int),
740 .mode = 0644,
741 .proc_handler = proc_dointvec
742 },
743 {
744 .procname = "ip_forward_use_pmtu",
745 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
746 .maxlen = sizeof(int),
747 .mode = 0644,
748 .proc_handler = proc_dointvec,
749 },
750 {
751 .procname = "ip_forward_update_priority",
752 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = ipv4_fwd_update_priority,
David Brazdil0f672f62019-12-10 10:32:29 +0000756 .extra1 = SYSCTL_ZERO,
757 .extra2 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000758 },
759 {
760 .procname = "ip_nonlocal_bind",
761 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
762 .maxlen = sizeof(int),
763 .mode = 0644,
764 .proc_handler = proc_dointvec
765 },
766 {
767 .procname = "fwmark_reflect",
768 .data = &init_net.ipv4.sysctl_fwmark_reflect,
769 .maxlen = sizeof(int),
770 .mode = 0644,
771 .proc_handler = proc_dointvec,
772 },
773 {
774 .procname = "tcp_fwmark_accept",
775 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
776 .maxlen = sizeof(int),
777 .mode = 0644,
778 .proc_handler = proc_dointvec,
779 },
780#ifdef CONFIG_NET_L3_MASTER_DEV
781 {
782 .procname = "tcp_l3mdev_accept",
783 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
784 .maxlen = sizeof(int),
785 .mode = 0644,
786 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +0000787 .extra1 = SYSCTL_ZERO,
788 .extra2 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000789 },
790#endif
791 {
792 .procname = "tcp_mtu_probing",
793 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
794 .maxlen = sizeof(int),
795 .mode = 0644,
796 .proc_handler = proc_dointvec,
797 },
798 {
799 .procname = "tcp_base_mss",
800 .data = &init_net.ipv4.sysctl_tcp_base_mss,
801 .maxlen = sizeof(int),
802 .mode = 0644,
803 .proc_handler = proc_dointvec,
804 },
805 {
David Brazdil0f672f62019-12-10 10:32:29 +0000806 .procname = "tcp_min_snd_mss",
807 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
808 .maxlen = sizeof(int),
809 .mode = 0644,
810 .proc_handler = proc_dointvec_minmax,
811 .extra1 = &tcp_min_snd_mss_min,
812 .extra2 = &tcp_min_snd_mss_max,
813 },
814 {
815 .procname = "tcp_mtu_probe_floor",
816 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
817 .maxlen = sizeof(int),
818 .mode = 0644,
819 .proc_handler = proc_dointvec_minmax,
820 .extra1 = &tcp_min_snd_mss_min,
821 .extra2 = &tcp_min_snd_mss_max,
822 },
823 {
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000824 .procname = "tcp_probe_threshold",
825 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
826 .maxlen = sizeof(int),
827 .mode = 0644,
828 .proc_handler = proc_dointvec,
829 },
830 {
831 .procname = "tcp_probe_interval",
832 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
833 .maxlen = sizeof(u32),
834 .mode = 0644,
835 .proc_handler = proc_douintvec_minmax,
836 .extra2 = &u32_max_div_HZ,
837 },
838 {
839 .procname = "igmp_link_local_mcast_reports",
840 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
841 .maxlen = sizeof(int),
842 .mode = 0644,
843 .proc_handler = proc_dointvec
844 },
845 {
846 .procname = "igmp_max_memberships",
847 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
848 .maxlen = sizeof(int),
849 .mode = 0644,
850 .proc_handler = proc_dointvec
851 },
852 {
853 .procname = "igmp_max_msf",
854 .data = &init_net.ipv4.sysctl_igmp_max_msf,
855 .maxlen = sizeof(int),
856 .mode = 0644,
857 .proc_handler = proc_dointvec
858 },
859#ifdef CONFIG_IP_MULTICAST
860 {
861 .procname = "igmp_qrv",
862 .data = &init_net.ipv4.sysctl_igmp_qrv,
863 .maxlen = sizeof(int),
864 .mode = 0644,
865 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +0000866 .extra1 = SYSCTL_ONE
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000867 },
868#endif
869 {
870 .procname = "tcp_congestion_control",
871 .data = &init_net.ipv4.tcp_congestion_control,
872 .mode = 0644,
873 .maxlen = TCP_CA_NAME_MAX,
874 .proc_handler = proc_tcp_congestion_control,
875 },
876 {
877 .procname = "tcp_keepalive_time",
878 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
879 .maxlen = sizeof(int),
880 .mode = 0644,
881 .proc_handler = proc_dointvec_jiffies,
882 },
883 {
884 .procname = "tcp_keepalive_probes",
885 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
886 .maxlen = sizeof(int),
887 .mode = 0644,
888 .proc_handler = proc_dointvec
889 },
890 {
891 .procname = "tcp_keepalive_intvl",
892 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
893 .maxlen = sizeof(int),
894 .mode = 0644,
895 .proc_handler = proc_dointvec_jiffies,
896 },
897 {
898 .procname = "tcp_syn_retries",
899 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
900 .maxlen = sizeof(int),
901 .mode = 0644,
902 .proc_handler = proc_dointvec_minmax,
903 .extra1 = &tcp_syn_retries_min,
904 .extra2 = &tcp_syn_retries_max
905 },
906 {
907 .procname = "tcp_synack_retries",
908 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
909 .maxlen = sizeof(int),
910 .mode = 0644,
911 .proc_handler = proc_dointvec
912 },
913#ifdef CONFIG_SYN_COOKIES
914 {
915 .procname = "tcp_syncookies",
916 .data = &init_net.ipv4.sysctl_tcp_syncookies,
917 .maxlen = sizeof(int),
918 .mode = 0644,
919 .proc_handler = proc_dointvec
920 },
921#endif
922 {
923 .procname = "tcp_reordering",
924 .data = &init_net.ipv4.sysctl_tcp_reordering,
925 .maxlen = sizeof(int),
926 .mode = 0644,
927 .proc_handler = proc_dointvec
928 },
929 {
930 .procname = "tcp_retries1",
931 .data = &init_net.ipv4.sysctl_tcp_retries1,
932 .maxlen = sizeof(int),
933 .mode = 0644,
934 .proc_handler = proc_dointvec_minmax,
935 .extra2 = &tcp_retr1_max
936 },
937 {
938 .procname = "tcp_retries2",
939 .data = &init_net.ipv4.sysctl_tcp_retries2,
940 .maxlen = sizeof(int),
941 .mode = 0644,
942 .proc_handler = proc_dointvec
943 },
944 {
945 .procname = "tcp_orphan_retries",
946 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
947 .maxlen = sizeof(int),
948 .mode = 0644,
949 .proc_handler = proc_dointvec
950 },
951 {
952 .procname = "tcp_fin_timeout",
953 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
954 .maxlen = sizeof(int),
955 .mode = 0644,
956 .proc_handler = proc_dointvec_jiffies,
957 },
958 {
959 .procname = "tcp_notsent_lowat",
960 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
961 .maxlen = sizeof(unsigned int),
962 .mode = 0644,
963 .proc_handler = proc_douintvec,
964 },
965 {
966 .procname = "tcp_tw_reuse",
967 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
968 .maxlen = sizeof(int),
969 .mode = 0644,
970 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +0000971 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000972 .extra2 = &two,
973 },
974 {
975 .procname = "tcp_max_tw_buckets",
976 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
977 .maxlen = sizeof(int),
978 .mode = 0644,
979 .proc_handler = proc_dointvec
980 },
981 {
982 .procname = "tcp_max_syn_backlog",
983 .data = &init_net.ipv4.sysctl_max_syn_backlog,
984 .maxlen = sizeof(int),
985 .mode = 0644,
986 .proc_handler = proc_dointvec
987 },
988 {
989 .procname = "tcp_fastopen",
990 .data = &init_net.ipv4.sysctl_tcp_fastopen,
991 .maxlen = sizeof(int),
992 .mode = 0644,
993 .proc_handler = proc_dointvec,
994 },
995 {
996 .procname = "tcp_fastopen_key",
997 .mode = 0600,
998 .data = &init_net.ipv4.sysctl_tcp_fastopen,
David Brazdil0f672f62019-12-10 10:32:29 +0000999 /* maxlen to print the list of keys in hex (*2), with dashes
1000 * separating doublewords and a comma in between keys.
1001 */
1002 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
1003 2 * TCP_FASTOPEN_KEY_MAX) +
1004 (TCP_FASTOPEN_KEY_MAX * 5)),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001005 .proc_handler = proc_tcp_fastopen_key,
1006 },
1007 {
1008 .procname = "tcp_fastopen_blackhole_timeout_sec",
1009 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1010 .maxlen = sizeof(int),
1011 .mode = 0644,
1012 .proc_handler = proc_tfo_blackhole_detect_timeout,
David Brazdil0f672f62019-12-10 10:32:29 +00001013 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001014 },
1015#ifdef CONFIG_IP_ROUTE_MULTIPATH
1016 {
1017 .procname = "fib_multipath_use_neigh",
1018 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1019 .maxlen = sizeof(int),
1020 .mode = 0644,
1021 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001022 .extra1 = SYSCTL_ZERO,
1023 .extra2 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001024 },
1025 {
1026 .procname = "fib_multipath_hash_policy",
1027 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1028 .maxlen = sizeof(int),
1029 .mode = 0644,
1030 .proc_handler = proc_fib_multipath_hash_policy,
David Brazdil0f672f62019-12-10 10:32:29 +00001031 .extra1 = SYSCTL_ZERO,
1032 .extra2 = &two,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001033 },
1034#endif
1035 {
1036 .procname = "ip_unprivileged_port_start",
1037 .maxlen = sizeof(int),
1038 .data = &init_net.ipv4.sysctl_ip_prot_sock,
1039 .mode = 0644,
1040 .proc_handler = ipv4_privileged_ports,
1041 },
1042#ifdef CONFIG_NET_L3_MASTER_DEV
1043 {
1044 .procname = "udp_l3mdev_accept",
1045 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
1046 .maxlen = sizeof(int),
1047 .mode = 0644,
1048 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001049 .extra1 = SYSCTL_ZERO,
1050 .extra2 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001051 },
1052#endif
1053 {
1054 .procname = "tcp_sack",
1055 .data = &init_net.ipv4.sysctl_tcp_sack,
1056 .maxlen = sizeof(int),
1057 .mode = 0644,
1058 .proc_handler = proc_dointvec
1059 },
1060 {
1061 .procname = "tcp_window_scaling",
1062 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
1063 .maxlen = sizeof(int),
1064 .mode = 0644,
1065 .proc_handler = proc_dointvec
1066 },
1067 {
1068 .procname = "tcp_timestamps",
1069 .data = &init_net.ipv4.sysctl_tcp_timestamps,
1070 .maxlen = sizeof(int),
1071 .mode = 0644,
1072 .proc_handler = proc_dointvec
1073 },
1074 {
1075 .procname = "tcp_early_retrans",
1076 .data = &init_net.ipv4.sysctl_tcp_early_retrans,
1077 .maxlen = sizeof(int),
1078 .mode = 0644,
1079 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001080 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001081 .extra2 = &four,
1082 },
1083 {
1084 .procname = "tcp_recovery",
1085 .data = &init_net.ipv4.sysctl_tcp_recovery,
1086 .maxlen = sizeof(int),
1087 .mode = 0644,
1088 .proc_handler = proc_dointvec,
1089 },
1090 {
1091 .procname = "tcp_thin_linear_timeouts",
1092 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1093 .maxlen = sizeof(int),
1094 .mode = 0644,
1095 .proc_handler = proc_dointvec
1096 },
1097 {
1098 .procname = "tcp_slow_start_after_idle",
1099 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1100 .maxlen = sizeof(int),
1101 .mode = 0644,
1102 .proc_handler = proc_dointvec
1103 },
1104 {
1105 .procname = "tcp_retrans_collapse",
1106 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
1107 .maxlen = sizeof(int),
1108 .mode = 0644,
1109 .proc_handler = proc_dointvec
1110 },
1111 {
1112 .procname = "tcp_stdurg",
1113 .data = &init_net.ipv4.sysctl_tcp_stdurg,
1114 .maxlen = sizeof(int),
1115 .mode = 0644,
1116 .proc_handler = proc_dointvec
1117 },
1118 {
1119 .procname = "tcp_rfc1337",
1120 .data = &init_net.ipv4.sysctl_tcp_rfc1337,
1121 .maxlen = sizeof(int),
1122 .mode = 0644,
1123 .proc_handler = proc_dointvec
1124 },
1125 {
1126 .procname = "tcp_abort_on_overflow",
1127 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1128 .maxlen = sizeof(int),
1129 .mode = 0644,
1130 .proc_handler = proc_dointvec
1131 },
1132 {
1133 .procname = "tcp_fack",
1134 .data = &init_net.ipv4.sysctl_tcp_fack,
1135 .maxlen = sizeof(int),
1136 .mode = 0644,
1137 .proc_handler = proc_dointvec
1138 },
1139 {
1140 .procname = "tcp_max_reordering",
1141 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
1142 .maxlen = sizeof(int),
1143 .mode = 0644,
1144 .proc_handler = proc_dointvec
1145 },
1146 {
1147 .procname = "tcp_dsack",
1148 .data = &init_net.ipv4.sysctl_tcp_dsack,
1149 .maxlen = sizeof(int),
1150 .mode = 0644,
1151 .proc_handler = proc_dointvec
1152 },
1153 {
1154 .procname = "tcp_app_win",
1155 .data = &init_net.ipv4.sysctl_tcp_app_win,
1156 .maxlen = sizeof(int),
1157 .mode = 0644,
1158 .proc_handler = proc_dointvec
1159 },
1160 {
1161 .procname = "tcp_adv_win_scale",
1162 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
1163 .maxlen = sizeof(int),
1164 .mode = 0644,
1165 .proc_handler = proc_dointvec_minmax,
1166 .extra1 = &tcp_adv_win_scale_min,
1167 .extra2 = &tcp_adv_win_scale_max,
1168 },
1169 {
1170 .procname = "tcp_frto",
1171 .data = &init_net.ipv4.sysctl_tcp_frto,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
1174 .proc_handler = proc_dointvec
1175 },
1176 {
1177 .procname = "tcp_no_metrics_save",
1178 .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
1179 .maxlen = sizeof(int),
1180 .mode = 0644,
1181 .proc_handler = proc_dointvec,
1182 },
1183 {
1184 .procname = "tcp_moderate_rcvbuf",
1185 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1186 .maxlen = sizeof(int),
1187 .mode = 0644,
1188 .proc_handler = proc_dointvec,
1189 },
1190 {
1191 .procname = "tcp_tso_win_divisor",
1192 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1193 .maxlen = sizeof(int),
1194 .mode = 0644,
1195 .proc_handler = proc_dointvec,
1196 },
1197 {
1198 .procname = "tcp_workaround_signed_windows",
1199 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1200 .maxlen = sizeof(int),
1201 .mode = 0644,
1202 .proc_handler = proc_dointvec
1203 },
1204 {
1205 .procname = "tcp_limit_output_bytes",
1206 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1207 .maxlen = sizeof(int),
1208 .mode = 0644,
1209 .proc_handler = proc_dointvec
1210 },
1211 {
1212 .procname = "tcp_challenge_ack_limit",
1213 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1214 .maxlen = sizeof(int),
1215 .mode = 0644,
1216 .proc_handler = proc_dointvec
1217 },
1218 {
1219 .procname = "tcp_min_tso_segs",
1220 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
1221 .maxlen = sizeof(int),
1222 .mode = 0644,
1223 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001224 .extra1 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001225 .extra2 = &gso_max_segs,
1226 },
1227 {
1228 .procname = "tcp_min_rtt_wlen",
1229 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1230 .maxlen = sizeof(int),
1231 .mode = 0644,
David Brazdil0f672f62019-12-10 10:32:29 +00001232 .proc_handler = proc_dointvec_minmax,
1233 .extra1 = SYSCTL_ZERO,
1234 .extra2 = &one_day_secs
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001235 },
1236 {
1237 .procname = "tcp_autocorking",
1238 .data = &init_net.ipv4.sysctl_tcp_autocorking,
1239 .maxlen = sizeof(int),
1240 .mode = 0644,
1241 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001242 .extra1 = SYSCTL_ZERO,
1243 .extra2 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001244 },
1245 {
1246 .procname = "tcp_invalid_ratelimit",
1247 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1248 .maxlen = sizeof(int),
1249 .mode = 0644,
1250 .proc_handler = proc_dointvec_ms_jiffies,
1251 },
1252 {
1253 .procname = "tcp_pacing_ss_ratio",
1254 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1255 .maxlen = sizeof(int),
1256 .mode = 0644,
1257 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001258 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001259 .extra2 = &thousand,
1260 },
1261 {
1262 .procname = "tcp_pacing_ca_ratio",
1263 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1264 .maxlen = sizeof(int),
1265 .mode = 0644,
1266 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001267 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001268 .extra2 = &thousand,
1269 },
1270 {
1271 .procname = "tcp_wmem",
1272 .data = &init_net.ipv4.sysctl_tcp_wmem,
1273 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem),
1274 .mode = 0644,
1275 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001276 .extra1 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001277 },
1278 {
1279 .procname = "tcp_rmem",
1280 .data = &init_net.ipv4.sysctl_tcp_rmem,
1281 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem),
1282 .mode = 0644,
1283 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001284 .extra1 = SYSCTL_ONE,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001285 },
1286 {
1287 .procname = "tcp_comp_sack_delay_ns",
1288 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1289 .maxlen = sizeof(unsigned long),
1290 .mode = 0644,
1291 .proc_handler = proc_doulongvec_minmax,
1292 },
1293 {
1294 .procname = "tcp_comp_sack_nr",
1295 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1296 .maxlen = sizeof(int),
1297 .mode = 0644,
1298 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001299 .extra1 = SYSCTL_ZERO,
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001300 .extra2 = &comp_sack_nr_max,
1301 },
1302 {
1303 .procname = "udp_rmem_min",
1304 .data = &init_net.ipv4.sysctl_udp_rmem_min,
1305 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1306 .mode = 0644,
1307 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001308 .extra1 = SYSCTL_ONE
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001309 },
1310 {
1311 .procname = "udp_wmem_min",
1312 .data = &init_net.ipv4.sysctl_udp_wmem_min,
1313 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1314 .mode = 0644,
1315 .proc_handler = proc_dointvec_minmax,
David Brazdil0f672f62019-12-10 10:32:29 +00001316 .extra1 = SYSCTL_ONE
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001317 },
1318 { }
1319};
1320
1321static __net_init int ipv4_sysctl_init_net(struct net *net)
1322{
1323 struct ctl_table *table;
1324
1325 table = ipv4_net_table;
1326 if (!net_eq(net, &init_net)) {
1327 int i;
1328
1329 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1330 if (!table)
1331 goto err_alloc;
1332
1333 /* Update the variables to point into the current struct net */
1334 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1335 table[i].data += (void *)net - (void *)&init_net;
1336 }
1337
1338 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
1339 if (!net->ipv4.ipv4_hdr)
1340 goto err_reg;
1341
1342 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1343 if (!net->ipv4.sysctl_local_reserved_ports)
1344 goto err_ports;
1345
1346 return 0;
1347
1348err_ports:
1349 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1350err_reg:
1351 if (!net_eq(net, &init_net))
1352 kfree(table);
1353err_alloc:
1354 return -ENOMEM;
1355}
1356
1357static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1358{
1359 struct ctl_table *table;
1360
1361 kfree(net->ipv4.sysctl_local_reserved_ports);
1362 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1363 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1364 kfree(table);
1365}
1366
1367static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1368 .init = ipv4_sysctl_init_net,
1369 .exit = ipv4_sysctl_exit_net,
1370};
1371
1372static __init int sysctl_ipv4_init(void)
1373{
1374 struct ctl_table_header *hdr;
1375
1376 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1377 if (!hdr)
1378 return -ENOMEM;
1379
1380 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1381 unregister_net_sysctl_table(hdr);
1382 return -ENOMEM;
1383 }
1384
1385 return 0;
1386}
1387
1388__initcall(sysctl_ipv4_init);