1// 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/sysctl.h>
10#include <linux/seqlock.h>
11#include <linux/init.h>
12#include <linux/slab.h>
13#include <net/icmp.h>
14#include <net/ip.h>
15#include <net/ip_fib.h>
16#include <net/tcp.h>
17#include <net/udp.h>
18#include <net/cipso_ipv4.h>
19#include <net/ping.h>
20#include <net/protocol.h>
21#include <net/netevent.h>
22
23static int tcp_retr1_max = 255;
24static int ip_local_port_range_min[] = { 1, 1 };
25static int ip_local_port_range_max[] = { 65535, 65535 };
26static int tcp_adv_win_scale_min = -31;
27static int tcp_adv_win_scale_max = 31;
28static int tcp_app_win_max = 31;
29static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
30static int tcp_min_snd_mss_max = 65535;
31static int tcp_rto_max_max = TCP_RTO_MAX_SEC * MSEC_PER_SEC;
32static int ip_privileged_port_min;
33static int ip_privileged_port_max = 65535;
34static int ip_ttl_min = 1;
35static int ip_ttl_max = 255;
36static int tcp_syn_retries_min = 1;
37static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
38static int tcp_syn_linear_timeouts_max = MAX_TCP_SYNCNT;
39static unsigned long ip_ping_group_range_min[] = { 0, 0 };
40static unsigned long ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
41static u32 u32_max_div_HZ = UINT_MAX / HZ;
42static int one_day_secs = 24 * 3600;
43static u32 fib_multipath_hash_fields_all_mask __maybe_unused =
44 FIB_MULTIPATH_HASH_FIELD_ALL_MASK;
45static unsigned int tcp_child_ehash_entries_max = 16 * 1024 * 1024;
46static unsigned int udp_child_hash_entries_max = UDP_HTABLE_SIZE_MAX;
47static int tcp_plb_max_rounds = 31;
48static int tcp_plb_max_cong_thresh = 256;
49static unsigned int tcp_tw_reuse_delay_max = TCP_PAWS_MSL * MSEC_PER_SEC;
50static int tcp_ecn_mode_max = 2;
51
52/* obsolete */
53static int sysctl_tcp_low_latency __read_mostly;
54
55/* Update system visible IP port range */
56static void set_local_port_range(struct net *net, unsigned int low, unsigned int high)
57{
58 bool same_parity = !((low ^ high) & 1);
59
60 if (same_parity && !net->ipv4.ip_local_ports.warned) {
61 net->ipv4.ip_local_ports.warned = true;
62 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
63 }
64 WRITE_ONCE(net->ipv4.ip_local_ports.range, high << 16 | low);
65}
66
67/* Validate changes from /proc interface. */
68static int ipv4_local_port_range(const struct ctl_table *table, int write,
69 void *buffer, size_t *lenp, loff_t *ppos)
70{
71 struct net *net = table->data;
72 int ret;
73 int range[2];
74 struct ctl_table tmp = {
75 .data = &range,
76 .maxlen = sizeof(range),
77 .mode = table->mode,
78 .extra1 = &ip_local_port_range_min,
79 .extra2 = &ip_local_port_range_max,
80 };
81
82 inet_get_local_port_range(net, low: &range[0], high: &range[1]);
83
84 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
85
86 if (write && ret == 0) {
87 /* Ensure that the upper limit is not smaller than the lower,
88 * and that the lower does not encroach upon the privileged
89 * port limit.
90 */
91 if ((range[1] < range[0]) ||
92 (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock)))
93 ret = -EINVAL;
94 else
95 set_local_port_range(net, low: range[0], high: range[1]);
96 }
97
98 return ret;
99}
100
101/* Validate changes from /proc interface. */
102static int ipv4_privileged_ports(const struct ctl_table *table, int write,
103 void *buffer, size_t *lenp, loff_t *ppos)
104{
105 struct net *net = container_of(table->data, struct net,
106 ipv4.sysctl_ip_prot_sock);
107 int ret;
108 int pports;
109 int range[2];
110 struct ctl_table tmp = {
111 .data = &pports,
112 .maxlen = sizeof(pports),
113 .mode = table->mode,
114 .extra1 = &ip_privileged_port_min,
115 .extra2 = &ip_privileged_port_max,
116 };
117
118 pports = READ_ONCE(net->ipv4.sysctl_ip_prot_sock);
119
120 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
121
122 if (write && ret == 0) {
123 inet_get_local_port_range(net, low: &range[0], high: &range[1]);
124 /* Ensure that the local port range doesn't overlap with the
125 * privileged port range.
126 */
127 if (range[0] < pports)
128 ret = -EINVAL;
129 else
130 WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports);
131 }
132
133 return ret;
134}
135
136static void inet_get_ping_group_range_table(const struct ctl_table *table,
137 kgid_t *low, kgid_t *high)
138{
139 kgid_t *data = table->data;
140 struct net *net =
141 container_of(table->data, struct net, ipv4.ping_group_range.range);
142 unsigned int seq;
143 do {
144 seq = read_seqbegin(sl: &net->ipv4.ping_group_range.lock);
145
146 *low = data[0];
147 *high = data[1];
148 } while (read_seqretry(sl: &net->ipv4.ping_group_range.lock, start: seq));
149}
150
151/* Update system visible IP port range */
152static void set_ping_group_range(const struct ctl_table *table,
153 kgid_t low, kgid_t high)
154{
155 kgid_t *data = table->data;
156 struct net *net =
157 container_of(table->data, struct net, ipv4.ping_group_range.range);
158 write_seqlock(sl: &net->ipv4.ping_group_range.lock);
159 data[0] = low;
160 data[1] = high;
161 write_sequnlock(sl: &net->ipv4.ping_group_range.lock);
162}
163
164/* Validate changes from /proc interface. */
165static int ipv4_ping_group_range(const struct ctl_table *table, int write,
166 void *buffer, size_t *lenp, loff_t *ppos)
167{
168 struct user_namespace *user_ns = current_user_ns();
169 int ret;
170 unsigned long urange[2];
171 kgid_t low, high;
172 struct ctl_table tmp = {
173 .data = &urange,
174 .maxlen = sizeof(urange),
175 .mode = table->mode,
176 .extra1 = &ip_ping_group_range_min,
177 .extra2 = &ip_ping_group_range_max,
178 };
179
180 inet_get_ping_group_range_table(table, low: &low, high: &high);
181 urange[0] = from_kgid_munged(to: user_ns, kgid: low);
182 urange[1] = from_kgid_munged(to: user_ns, kgid: high);
183 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
184
185 if (write && ret == 0) {
186 low = make_kgid(from: user_ns, gid: urange[0]);
187 high = make_kgid(from: user_ns, gid: urange[1]);
188 if (!gid_valid(gid: low) || !gid_valid(gid: high))
189 return -EINVAL;
190 if (urange[1] < urange[0] || gid_lt(left: high, right: low)) {
191 low = make_kgid(from: &init_user_ns, gid: 1);
192 high = make_kgid(from: &init_user_ns, gid: 0);
193 }
194 set_ping_group_range(table, low, high);
195 }
196
197 return ret;
198}
199
200static int ipv4_fwd_update_priority(const struct ctl_table *table, int write,
201 void *buffer, size_t *lenp, loff_t *ppos)
202{
203 struct net *net;
204 int ret;
205
206 net = container_of(table->data, struct net,
207 ipv4.sysctl_ip_fwd_update_priority);
208 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
209 if (write && ret == 0)
210 call_netevent_notifiers(val: NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
211 v: net);
212
213 return ret;
214}
215
216static int proc_tcp_congestion_control(const struct ctl_table *ctl, int write,
217 void *buffer, size_t *lenp, loff_t *ppos)
218{
219 struct net *net = container_of(ctl->data, struct net,
220 ipv4.tcp_congestion_control);
221 char val[TCP_CA_NAME_MAX];
222 struct ctl_table tbl = {
223 .data = val,
224 .maxlen = TCP_CA_NAME_MAX,
225 };
226 int ret;
227
228 tcp_get_default_congestion_control(net, name: val);
229
230 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
231 if (write && ret == 0)
232 ret = tcp_set_default_congestion_control(net, name: val);
233 return ret;
234}
235
236static int proc_tcp_available_congestion_control(const struct ctl_table *ctl,
237 int write, void *buffer,
238 size_t *lenp, loff_t *ppos)
239{
240 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
241 int ret;
242
243 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
244 if (!tbl.data)
245 return -ENOMEM;
246 tcp_get_available_congestion_control(buf: tbl.data, TCP_CA_BUF_MAX);
247 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
248 kfree(objp: tbl.data);
249 return ret;
250}
251
252static int proc_allowed_congestion_control(const struct ctl_table *ctl,
253 int write, void *buffer,
254 size_t *lenp, loff_t *ppos)
255{
256 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
257 int ret;
258
259 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
260 if (!tbl.data)
261 return -ENOMEM;
262
263 tcp_get_allowed_congestion_control(buf: tbl.data, len: tbl.maxlen);
264 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
265 if (write && ret == 0)
266 ret = tcp_set_allowed_congestion_control(allowed: tbl.data);
267 kfree(objp: tbl.data);
268 return ret;
269}
270
271static int sscanf_key(char *buf, __le32 *key)
272{
273 u32 user_key[4];
274 int i, ret = 0;
275
276 if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
277 user_key + 2, user_key + 3) != 4) {
278 ret = -EINVAL;
279 } else {
280 for (i = 0; i < ARRAY_SIZE(user_key); i++)
281 key[i] = cpu_to_le32(user_key[i]);
282 }
283 pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
284 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
285
286 return ret;
287}
288
289static int proc_tcp_fastopen_key(const struct ctl_table *table, int write,
290 void *buffer, size_t *lenp, loff_t *ppos)
291{
292 struct net *net = container_of(table->data, struct net,
293 ipv4.sysctl_tcp_fastopen);
294 /* maxlen to print the list of keys in hex (*2), with dashes
295 * separating doublewords and a comma in between keys.
296 */
297 struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
298 2 * TCP_FASTOPEN_KEY_MAX) +
299 (TCP_FASTOPEN_KEY_MAX * 5)) };
300 u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
301 __le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
302 char *backup_data;
303 int ret, i = 0, off = 0, n_keys;
304
305 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
306 if (!tbl.data)
307 return -ENOMEM;
308
309 n_keys = tcp_fastopen_get_cipher(net, NULL, key: (u64 *)key);
310 if (!n_keys) {
311 memset(s: &key[0], c: 0, TCP_FASTOPEN_KEY_LENGTH);
312 n_keys = 1;
313 }
314
315 for (i = 0; i < n_keys * 4; i++)
316 user_key[i] = le32_to_cpu(key[i]);
317
318 for (i = 0; i < n_keys; i++) {
319 off += snprintf(buf: tbl.data + off, size: tbl.maxlen - off,
320 fmt: "%08x-%08x-%08x-%08x",
321 user_key[i * 4],
322 user_key[i * 4 + 1],
323 user_key[i * 4 + 2],
324 user_key[i * 4 + 3]);
325
326 if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
327 break;
328
329 if (i + 1 < n_keys)
330 off += snprintf(buf: tbl.data + off, size: tbl.maxlen - off, fmt: ",");
331 }
332
333 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
334
335 if (write && ret == 0) {
336 backup_data = strchr(tbl.data, ',');
337 if (backup_data) {
338 *backup_data = '\0';
339 backup_data++;
340 }
341 if (sscanf_key(buf: tbl.data, key)) {
342 ret = -EINVAL;
343 goto bad_key;
344 }
345 if (backup_data) {
346 if (sscanf_key(buf: backup_data, key: key + 4)) {
347 ret = -EINVAL;
348 goto bad_key;
349 }
350 }
351 tcp_fastopen_reset_cipher(net, NULL, primary_key: key,
352 backup_key: backup_data ? key + 4 : NULL);
353 }
354
355bad_key:
356 kfree(objp: tbl.data);
357 return ret;
358}
359
360static int proc_tfo_blackhole_detect_timeout(const struct ctl_table *table,
361 int write, void *buffer,
362 size_t *lenp, loff_t *ppos)
363{
364 struct net *net = container_of(table->data, struct net,
365 ipv4.sysctl_tcp_fastopen_blackhole_timeout);
366 int ret;
367
368 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
369 if (write && ret == 0)
370 atomic_set(v: &net->ipv4.tfo_active_disable_times, i: 0);
371
372 return ret;
373}
374
375static int proc_tcp_available_ulp(const struct ctl_table *ctl,
376 int write, void *buffer, size_t *lenp,
377 loff_t *ppos)
378{
379 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
380 int ret;
381
382 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
383 if (!tbl.data)
384 return -ENOMEM;
385 tcp_get_available_ulp(buf: tbl.data, TCP_ULP_BUF_MAX);
386 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
387 kfree(objp: tbl.data);
388
389 return ret;
390}
391
392static int proc_tcp_ehash_entries(const struct ctl_table *table, int write,
393 void *buffer, size_t *lenp, loff_t *ppos)
394{
395 struct net *net = container_of(table->data, struct net,
396 ipv4.sysctl_tcp_child_ehash_entries);
397 struct inet_hashinfo *hinfo = net->ipv4.tcp_death_row.hashinfo;
398 int tcp_ehash_entries;
399 struct ctl_table tbl;
400
401 tcp_ehash_entries = hinfo->ehash_mask + 1;
402
403 /* A negative number indicates that the child netns
404 * shares the global ehash.
405 */
406 if (!net_eq(net1: net, net2: &init_net) && !hinfo->pernet)
407 tcp_ehash_entries *= -1;
408
409 memset(s: &tbl, c: 0, n: sizeof(tbl));
410 tbl.data = &tcp_ehash_entries;
411 tbl.maxlen = sizeof(int);
412
413 return proc_dointvec(&tbl, write, buffer, lenp, ppos);
414}
415
416static int proc_udp_hash_entries(const struct ctl_table *table, int write,
417 void *buffer, size_t *lenp, loff_t *ppos)
418{
419 struct net *net = container_of(table->data, struct net,
420 ipv4.sysctl_udp_child_hash_entries);
421 int udp_hash_entries;
422 struct ctl_table tbl;
423
424 udp_hash_entries = net->ipv4.udp_table->mask + 1;
425
426 /* A negative number indicates that the child netns
427 * shares the global udp_table.
428 */
429 if (!net_eq(net1: net, net2: &init_net) && net->ipv4.udp_table == &udp_table)
430 udp_hash_entries *= -1;
431
432 memset(s: &tbl, c: 0, n: sizeof(tbl));
433 tbl.data = &udp_hash_entries;
434 tbl.maxlen = sizeof(int);
435
436 return proc_dointvec(&tbl, write, buffer, lenp, ppos);
437}
438
439#ifdef CONFIG_IP_ROUTE_MULTIPATH
440static int proc_fib_multipath_hash_policy(const struct ctl_table *table, int write,
441 void *buffer, size_t *lenp,
442 loff_t *ppos)
443{
444 struct net *net = container_of(table->data, struct net,
445 ipv4.sysctl_fib_multipath_hash_policy);
446 int ret;
447
448 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
449 if (write && ret == 0)
450 call_netevent_notifiers(val: NETEVENT_IPV4_MPATH_HASH_UPDATE, v: net);
451
452 return ret;
453}
454
455static int proc_fib_multipath_hash_fields(const struct ctl_table *table, int write,
456 void *buffer, size_t *lenp,
457 loff_t *ppos)
458{
459 struct net *net;
460 int ret;
461
462 net = container_of(table->data, struct net,
463 ipv4.sysctl_fib_multipath_hash_fields);
464 ret = proc_douintvec_minmax(table, write, buffer, lenp, ppos);
465 if (write && ret == 0)
466 call_netevent_notifiers(val: NETEVENT_IPV4_MPATH_HASH_UPDATE, v: net);
467
468 return ret;
469}
470
471static u32 proc_fib_multipath_hash_rand_seed __ro_after_init;
472
473static void proc_fib_multipath_hash_init_rand_seed(void)
474{
475 get_random_bytes(buf: &proc_fib_multipath_hash_rand_seed,
476 len: sizeof(proc_fib_multipath_hash_rand_seed));
477}
478
479static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed)
480{
481 struct sysctl_fib_multipath_hash_seed new = {
482 .user_seed = user_seed,
483 .mp_seed = (user_seed ? user_seed :
484 proc_fib_multipath_hash_rand_seed),
485 };
486
487 WRITE_ONCE(net->ipv4.sysctl_fib_multipath_hash_seed, new);
488}
489
490static int proc_fib_multipath_hash_seed(const struct ctl_table *table, int write,
491 void *buffer, size_t *lenp,
492 loff_t *ppos)
493{
494 struct sysctl_fib_multipath_hash_seed *mphs;
495 struct net *net = table->data;
496 struct ctl_table tmp;
497 u32 user_seed;
498 int ret;
499
500 mphs = &net->ipv4.sysctl_fib_multipath_hash_seed;
501 user_seed = mphs->user_seed;
502
503 tmp = *table;
504 tmp.data = &user_seed;
505
506 ret = proc_douintvec_minmax(table: &tmp, write, buffer, lenp, ppos);
507
508 if (write && ret == 0) {
509 proc_fib_multipath_hash_set_seed(net, user_seed);
510 call_netevent_notifiers(val: NETEVENT_IPV4_MPATH_HASH_UPDATE, v: net);
511 }
512
513 return ret;
514}
515#else
516
517static void proc_fib_multipath_hash_init_rand_seed(void)
518{
519}
520
521static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed)
522{
523}
524
525#endif
526
527static struct ctl_table ipv4_table[] = {
528 {
529 .procname = "tcp_max_orphans",
530 .data = &sysctl_tcp_max_orphans,
531 .maxlen = sizeof(int),
532 .mode = 0644,
533 .proc_handler = proc_dointvec
534 },
535 {
536 .procname = "inet_peer_threshold",
537 .data = &inet_peer_threshold,
538 .maxlen = sizeof(int),
539 .mode = 0644,
540 .proc_handler = proc_dointvec
541 },
542 {
543 .procname = "inet_peer_minttl",
544 .data = &inet_peer_minttl,
545 .maxlen = sizeof(int),
546 .mode = 0644,
547 .proc_handler = proc_dointvec_jiffies,
548 },
549 {
550 .procname = "inet_peer_maxttl",
551 .data = &inet_peer_maxttl,
552 .maxlen = sizeof(int),
553 .mode = 0644,
554 .proc_handler = proc_dointvec_jiffies,
555 },
556 {
557 .procname = "tcp_mem",
558 .maxlen = sizeof(sysctl_tcp_mem),
559 .data = &sysctl_tcp_mem,
560 .mode = 0644,
561 .proc_handler = proc_doulongvec_minmax,
562 },
563 {
564 .procname = "tcp_low_latency",
565 .data = &sysctl_tcp_low_latency,
566 .maxlen = sizeof(int),
567 .mode = 0644,
568 .proc_handler = proc_dointvec
569 },
570#ifdef CONFIG_NETLABEL
571 {
572 .procname = "cipso_cache_enable",
573 .data = &cipso_v4_cache_enabled,
574 .maxlen = sizeof(int),
575 .mode = 0644,
576 .proc_handler = proc_dointvec,
577 },
578 {
579 .procname = "cipso_cache_bucket_size",
580 .data = &cipso_v4_cache_bucketsize,
581 .maxlen = sizeof(int),
582 .mode = 0644,
583 .proc_handler = proc_dointvec,
584 },
585 {
586 .procname = "cipso_rbm_optfmt",
587 .data = &cipso_v4_rbm_optfmt,
588 .maxlen = sizeof(int),
589 .mode = 0644,
590 .proc_handler = proc_dointvec,
591 },
592 {
593 .procname = "cipso_rbm_strictvalid",
594 .data = &cipso_v4_rbm_strictvalid,
595 .maxlen = sizeof(int),
596 .mode = 0644,
597 .proc_handler = proc_dointvec,
598 },
599#endif /* CONFIG_NETLABEL */
600 {
601 .procname = "tcp_available_ulp",
602 .maxlen = TCP_ULP_BUF_MAX,
603 .mode = 0444,
604 .proc_handler = proc_tcp_available_ulp,
605 },
606 {
607 .procname = "udp_mem",
608 .data = &sysctl_udp_mem,
609 .maxlen = sizeof(sysctl_udp_mem),
610 .mode = 0644,
611 .proc_handler = proc_doulongvec_minmax,
612 },
613 {
614 .procname = "fib_sync_mem",
615 .data = &sysctl_fib_sync_mem,
616 .maxlen = sizeof(sysctl_fib_sync_mem),
617 .mode = 0644,
618 .proc_handler = proc_douintvec_minmax,
619 .extra1 = &sysctl_fib_sync_mem_min,
620 .extra2 = &sysctl_fib_sync_mem_max,
621 },
622};
623
624static struct ctl_table ipv4_net_table[] = {
625 {
626 .procname = "tcp_max_tw_buckets",
627 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = proc_dointvec
631 },
632 {
633 .procname = "icmp_echo_ignore_all",
634 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
635 .maxlen = sizeof(u8),
636 .mode = 0644,
637 .proc_handler = proc_dou8vec_minmax,
638 .extra1 = SYSCTL_ZERO,
639 .extra2 = SYSCTL_ONE
640 },
641 {
642 .procname = "icmp_echo_enable_probe",
643 .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe,
644 .maxlen = sizeof(u8),
645 .mode = 0644,
646 .proc_handler = proc_dou8vec_minmax,
647 .extra1 = SYSCTL_ZERO,
648 .extra2 = SYSCTL_ONE
649 },
650 {
651 .procname = "icmp_echo_ignore_broadcasts",
652 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
653 .maxlen = sizeof(u8),
654 .mode = 0644,
655 .proc_handler = proc_dou8vec_minmax,
656 .extra1 = SYSCTL_ZERO,
657 .extra2 = SYSCTL_ONE
658 },
659 {
660 .procname = "icmp_ignore_bogus_error_responses",
661 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
662 .maxlen = sizeof(u8),
663 .mode = 0644,
664 .proc_handler = proc_dou8vec_minmax,
665 .extra1 = SYSCTL_ZERO,
666 .extra2 = SYSCTL_ONE
667 },
668 {
669 .procname = "icmp_errors_use_inbound_ifaddr",
670 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
671 .maxlen = sizeof(u8),
672 .mode = 0644,
673 .proc_handler = proc_dou8vec_minmax,
674 .extra1 = SYSCTL_ZERO,
675 .extra2 = SYSCTL_ONE
676 },
677 {
678 .procname = "icmp_ratelimit",
679 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
680 .maxlen = sizeof(int),
681 .mode = 0644,
682 .proc_handler = proc_dointvec_ms_jiffies,
683 },
684 {
685 .procname = "icmp_ratemask",
686 .data = &init_net.ipv4.sysctl_icmp_ratemask,
687 .maxlen = sizeof(int),
688 .mode = 0644,
689 .proc_handler = proc_dointvec
690 },
691 {
692 .procname = "icmp_msgs_per_sec",
693 .data = &init_net.ipv4.sysctl_icmp_msgs_per_sec,
694 .maxlen = sizeof(int),
695 .mode = 0644,
696 .proc_handler = proc_dointvec_minmax,
697 .extra1 = SYSCTL_ZERO,
698 },
699 {
700 .procname = "icmp_msgs_burst",
701 .data = &init_net.ipv4.sysctl_icmp_msgs_burst,
702 .maxlen = sizeof(int),
703 .mode = 0644,
704 .proc_handler = proc_dointvec_minmax,
705 .extra1 = SYSCTL_ZERO,
706 },
707 {
708 .procname = "ping_group_range",
709 .data = &init_net.ipv4.ping_group_range.range,
710 .maxlen = sizeof(gid_t)*2,
711 .mode = 0644,
712 .proc_handler = ipv4_ping_group_range,
713 },
714#ifdef CONFIG_NET_L3_MASTER_DEV
715 {
716 .procname = "raw_l3mdev_accept",
717 .data = &init_net.ipv4.sysctl_raw_l3mdev_accept,
718 .maxlen = sizeof(u8),
719 .mode = 0644,
720 .proc_handler = proc_dou8vec_minmax,
721 .extra1 = SYSCTL_ZERO,
722 .extra2 = SYSCTL_ONE,
723 },
724#endif
725 {
726 .procname = "tcp_ecn",
727 .data = &init_net.ipv4.sysctl_tcp_ecn,
728 .maxlen = sizeof(u8),
729 .mode = 0644,
730 .proc_handler = proc_dou8vec_minmax,
731 .extra1 = SYSCTL_ZERO,
732 .extra2 = &tcp_ecn_mode_max,
733 },
734 {
735 .procname = "tcp_ecn_option",
736 .data = &init_net.ipv4.sysctl_tcp_ecn_option,
737 .maxlen = sizeof(u8),
738 .mode = 0644,
739 .proc_handler = proc_dou8vec_minmax,
740 .extra1 = SYSCTL_ZERO,
741 .extra2 = SYSCTL_TWO,
742 },
743 {
744 .procname = "tcp_ecn_option_beacon",
745 .data = &init_net.ipv4.sysctl_tcp_ecn_option_beacon,
746 .maxlen = sizeof(u8),
747 .mode = 0644,
748 .proc_handler = proc_dou8vec_minmax,
749 .extra1 = SYSCTL_ZERO,
750 .extra2 = SYSCTL_THREE,
751 },
752 {
753 .procname = "tcp_ecn_fallback",
754 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
755 .maxlen = sizeof(u8),
756 .mode = 0644,
757 .proc_handler = proc_dou8vec_minmax,
758 .extra1 = SYSCTL_ZERO,
759 .extra2 = SYSCTL_ONE,
760 },
761 {
762 .procname = "ip_dynaddr",
763 .data = &init_net.ipv4.sysctl_ip_dynaddr,
764 .maxlen = sizeof(u8),
765 .mode = 0644,
766 .proc_handler = proc_dou8vec_minmax,
767 },
768 {
769 .procname = "ip_early_demux",
770 .data = &init_net.ipv4.sysctl_ip_early_demux,
771 .maxlen = sizeof(u8),
772 .mode = 0644,
773 .proc_handler = proc_dou8vec_minmax,
774 },
775 {
776 .procname = "udp_early_demux",
777 .data = &init_net.ipv4.sysctl_udp_early_demux,
778 .maxlen = sizeof(u8),
779 .mode = 0644,
780 .proc_handler = proc_dou8vec_minmax,
781 },
782 {
783 .procname = "tcp_early_demux",
784 .data = &init_net.ipv4.sysctl_tcp_early_demux,
785 .maxlen = sizeof(u8),
786 .mode = 0644,
787 .proc_handler = proc_dou8vec_minmax,
788 },
789 {
790 .procname = "nexthop_compat_mode",
791 .data = &init_net.ipv4.sysctl_nexthop_compat_mode,
792 .maxlen = sizeof(u8),
793 .mode = 0644,
794 .proc_handler = proc_dou8vec_minmax,
795 .extra1 = SYSCTL_ZERO,
796 .extra2 = SYSCTL_ONE,
797 },
798 {
799 .procname = "ip_default_ttl",
800 .data = &init_net.ipv4.sysctl_ip_default_ttl,
801 .maxlen = sizeof(u8),
802 .mode = 0644,
803 .proc_handler = proc_dou8vec_minmax,
804 .extra1 = &ip_ttl_min,
805 .extra2 = &ip_ttl_max,
806 },
807 {
808 .procname = "ip_local_port_range",
809 .maxlen = 0,
810 .data = &init_net,
811 .mode = 0644,
812 .proc_handler = ipv4_local_port_range,
813 },
814 {
815 .procname = "ip_local_reserved_ports",
816 .data = &init_net.ipv4.sysctl_local_reserved_ports,
817 .maxlen = 65536,
818 .mode = 0644,
819 .proc_handler = proc_do_large_bitmap,
820 },
821 {
822 .procname = "ip_no_pmtu_disc",
823 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
824 .maxlen = sizeof(u8),
825 .mode = 0644,
826 .proc_handler = proc_dou8vec_minmax,
827 },
828 {
829 .procname = "ip_forward_use_pmtu",
830 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
831 .maxlen = sizeof(u8),
832 .mode = 0644,
833 .proc_handler = proc_dou8vec_minmax,
834 },
835 {
836 .procname = "ip_forward_update_priority",
837 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
838 .maxlen = sizeof(u8),
839 .mode = 0644,
840 .proc_handler = ipv4_fwd_update_priority,
841 .extra1 = SYSCTL_ZERO,
842 .extra2 = SYSCTL_ONE,
843 },
844 {
845 .procname = "ip_nonlocal_bind",
846 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
847 .maxlen = sizeof(u8),
848 .mode = 0644,
849 .proc_handler = proc_dou8vec_minmax,
850 },
851 {
852 .procname = "ip_autobind_reuse",
853 .data = &init_net.ipv4.sysctl_ip_autobind_reuse,
854 .maxlen = sizeof(u8),
855 .mode = 0644,
856 .proc_handler = proc_dou8vec_minmax,
857 .extra1 = SYSCTL_ZERO,
858 .extra2 = SYSCTL_ONE,
859 },
860 {
861 .procname = "fwmark_reflect",
862 .data = &init_net.ipv4.sysctl_fwmark_reflect,
863 .maxlen = sizeof(u8),
864 .mode = 0644,
865 .proc_handler = proc_dou8vec_minmax,
866 },
867 {
868 .procname = "tcp_fwmark_accept",
869 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
870 .maxlen = sizeof(u8),
871 .mode = 0644,
872 .proc_handler = proc_dou8vec_minmax,
873 },
874#ifdef CONFIG_NET_L3_MASTER_DEV
875 {
876 .procname = "tcp_l3mdev_accept",
877 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
878 .maxlen = sizeof(u8),
879 .mode = 0644,
880 .proc_handler = proc_dou8vec_minmax,
881 .extra1 = SYSCTL_ZERO,
882 .extra2 = SYSCTL_ONE,
883 },
884#endif
885 {
886 .procname = "tcp_mtu_probing",
887 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
888 .maxlen = sizeof(u8),
889 .mode = 0644,
890 .proc_handler = proc_dou8vec_minmax,
891 },
892 {
893 .procname = "tcp_base_mss",
894 .data = &init_net.ipv4.sysctl_tcp_base_mss,
895 .maxlen = sizeof(int),
896 .mode = 0644,
897 .proc_handler = proc_dointvec,
898 },
899 {
900 .procname = "tcp_min_snd_mss",
901 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
902 .maxlen = sizeof(int),
903 .mode = 0644,
904 .proc_handler = proc_dointvec_minmax,
905 .extra1 = &tcp_min_snd_mss_min,
906 .extra2 = &tcp_min_snd_mss_max,
907 },
908 {
909 .procname = "tcp_mtu_probe_floor",
910 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
911 .maxlen = sizeof(int),
912 .mode = 0644,
913 .proc_handler = proc_dointvec_minmax,
914 .extra1 = &tcp_min_snd_mss_min,
915 .extra2 = &tcp_min_snd_mss_max,
916 },
917 {
918 .procname = "tcp_probe_threshold",
919 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
920 .maxlen = sizeof(int),
921 .mode = 0644,
922 .proc_handler = proc_dointvec,
923 },
924 {
925 .procname = "tcp_probe_interval",
926 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
927 .maxlen = sizeof(u32),
928 .mode = 0644,
929 .proc_handler = proc_douintvec_minmax,
930 .extra2 = &u32_max_div_HZ,
931 },
932 {
933 .procname = "igmp_link_local_mcast_reports",
934 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
935 .maxlen = sizeof(u8),
936 .mode = 0644,
937 .proc_handler = proc_dou8vec_minmax,
938 },
939 {
940 .procname = "igmp_max_memberships",
941 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
942 .maxlen = sizeof(int),
943 .mode = 0644,
944 .proc_handler = proc_dointvec
945 },
946 {
947 .procname = "igmp_max_msf",
948 .data = &init_net.ipv4.sysctl_igmp_max_msf,
949 .maxlen = sizeof(int),
950 .mode = 0644,
951 .proc_handler = proc_dointvec
952 },
953#ifdef CONFIG_IP_MULTICAST
954 {
955 .procname = "igmp_qrv",
956 .data = &init_net.ipv4.sysctl_igmp_qrv,
957 .maxlen = sizeof(int),
958 .mode = 0644,
959 .proc_handler = proc_dointvec_minmax,
960 .extra1 = SYSCTL_ONE
961 },
962#endif
963 {
964 .procname = "tcp_congestion_control",
965 .data = &init_net.ipv4.tcp_congestion_control,
966 .mode = 0644,
967 .maxlen = TCP_CA_NAME_MAX,
968 .proc_handler = proc_tcp_congestion_control,
969 },
970 {
971 .procname = "tcp_available_congestion_control",
972 .maxlen = TCP_CA_BUF_MAX,
973 .mode = 0444,
974 .proc_handler = proc_tcp_available_congestion_control,
975 },
976 {
977 .procname = "tcp_allowed_congestion_control",
978 .maxlen = TCP_CA_BUF_MAX,
979 .mode = 0644,
980 .proc_handler = proc_allowed_congestion_control,
981 },
982 {
983 .procname = "tcp_keepalive_time",
984 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
985 .maxlen = sizeof(int),
986 .mode = 0644,
987 .proc_handler = proc_dointvec_jiffies,
988 },
989 {
990 .procname = "tcp_keepalive_probes",
991 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
992 .maxlen = sizeof(u8),
993 .mode = 0644,
994 .proc_handler = proc_dou8vec_minmax,
995 },
996 {
997 .procname = "tcp_keepalive_intvl",
998 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
999 .maxlen = sizeof(int),
1000 .mode = 0644,
1001 .proc_handler = proc_dointvec_jiffies,
1002 },
1003 {
1004 .procname = "tcp_syn_retries",
1005 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
1006 .maxlen = sizeof(u8),
1007 .mode = 0644,
1008 .proc_handler = proc_dou8vec_minmax,
1009 .extra1 = &tcp_syn_retries_min,
1010 .extra2 = &tcp_syn_retries_max
1011 },
1012 {
1013 .procname = "tcp_synack_retries",
1014 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
1015 .maxlen = sizeof(u8),
1016 .mode = 0644,
1017 .proc_handler = proc_dou8vec_minmax,
1018 },
1019#ifdef CONFIG_SYN_COOKIES
1020 {
1021 .procname = "tcp_syncookies",
1022 .data = &init_net.ipv4.sysctl_tcp_syncookies,
1023 .maxlen = sizeof(u8),
1024 .mode = 0644,
1025 .proc_handler = proc_dou8vec_minmax,
1026 },
1027#endif
1028 {
1029 .procname = "tcp_migrate_req",
1030 .data = &init_net.ipv4.sysctl_tcp_migrate_req,
1031 .maxlen = sizeof(u8),
1032 .mode = 0644,
1033 .proc_handler = proc_dou8vec_minmax,
1034 .extra1 = SYSCTL_ZERO,
1035 .extra2 = SYSCTL_ONE
1036 },
1037 {
1038 .procname = "tcp_reordering",
1039 .data = &init_net.ipv4.sysctl_tcp_reordering,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
1042 .proc_handler = proc_dointvec
1043 },
1044 {
1045 .procname = "tcp_retries1",
1046 .data = &init_net.ipv4.sysctl_tcp_retries1,
1047 .maxlen = sizeof(u8),
1048 .mode = 0644,
1049 .proc_handler = proc_dou8vec_minmax,
1050 .extra2 = &tcp_retr1_max
1051 },
1052 {
1053 .procname = "tcp_retries2",
1054 .data = &init_net.ipv4.sysctl_tcp_retries2,
1055 .maxlen = sizeof(u8),
1056 .mode = 0644,
1057 .proc_handler = proc_dou8vec_minmax,
1058 },
1059 {
1060 .procname = "tcp_orphan_retries",
1061 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
1062 .maxlen = sizeof(u8),
1063 .mode = 0644,
1064 .proc_handler = proc_dou8vec_minmax,
1065 },
1066 {
1067 .procname = "tcp_fin_timeout",
1068 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
1069 .maxlen = sizeof(int),
1070 .mode = 0644,
1071 .proc_handler = proc_dointvec_jiffies,
1072 },
1073 {
1074 .procname = "tcp_notsent_lowat",
1075 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
1076 .maxlen = sizeof(unsigned int),
1077 .mode = 0644,
1078 .proc_handler = proc_douintvec,
1079 },
1080 {
1081 .procname = "tcp_tw_reuse",
1082 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
1083 .maxlen = sizeof(u8),
1084 .mode = 0644,
1085 .proc_handler = proc_dou8vec_minmax,
1086 .extra1 = SYSCTL_ZERO,
1087 .extra2 = SYSCTL_TWO,
1088 },
1089 {
1090 .procname = "tcp_tw_reuse_delay",
1091 .data = &init_net.ipv4.sysctl_tcp_tw_reuse_delay,
1092 .maxlen = sizeof(unsigned int),
1093 .mode = 0644,
1094 .proc_handler = proc_douintvec_minmax,
1095 .extra1 = SYSCTL_ONE,
1096 .extra2 = &tcp_tw_reuse_delay_max,
1097 },
1098 {
1099 .procname = "tcp_max_syn_backlog",
1100 .data = &init_net.ipv4.sysctl_max_syn_backlog,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
1103 .proc_handler = proc_dointvec
1104 },
1105 {
1106 .procname = "tcp_fastopen",
1107 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1108 .maxlen = sizeof(int),
1109 .mode = 0644,
1110 .proc_handler = proc_dointvec,
1111 },
1112 {
1113 .procname = "tcp_fastopen_key",
1114 .mode = 0600,
1115 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1116 /* maxlen to print the list of keys in hex (*2), with dashes
1117 * separating doublewords and a comma in between keys.
1118 */
1119 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
1120 2 * TCP_FASTOPEN_KEY_MAX) +
1121 (TCP_FASTOPEN_KEY_MAX * 5)),
1122 .proc_handler = proc_tcp_fastopen_key,
1123 },
1124 {
1125 .procname = "tcp_fastopen_blackhole_timeout_sec",
1126 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1127 .maxlen = sizeof(int),
1128 .mode = 0644,
1129 .proc_handler = proc_tfo_blackhole_detect_timeout,
1130 .extra1 = SYSCTL_ZERO,
1131 },
1132#ifdef CONFIG_IP_ROUTE_MULTIPATH
1133 {
1134 .procname = "fib_multipath_use_neigh",
1135 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1136 .maxlen = sizeof(u8),
1137 .mode = 0644,
1138 .proc_handler = proc_dou8vec_minmax,
1139 .extra1 = SYSCTL_ZERO,
1140 .extra2 = SYSCTL_ONE,
1141 },
1142 {
1143 .procname = "fib_multipath_hash_policy",
1144 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1145 .maxlen = sizeof(u8),
1146 .mode = 0644,
1147 .proc_handler = proc_fib_multipath_hash_policy,
1148 .extra1 = SYSCTL_ZERO,
1149 .extra2 = SYSCTL_THREE,
1150 },
1151 {
1152 .procname = "fib_multipath_hash_fields",
1153 .data = &init_net.ipv4.sysctl_fib_multipath_hash_fields,
1154 .maxlen = sizeof(u32),
1155 .mode = 0644,
1156 .proc_handler = proc_fib_multipath_hash_fields,
1157 .extra1 = SYSCTL_ONE,
1158 .extra2 = &fib_multipath_hash_fields_all_mask,
1159 },
1160 {
1161 .procname = "fib_multipath_hash_seed",
1162 .data = &init_net,
1163 .maxlen = sizeof(u32),
1164 .mode = 0644,
1165 .proc_handler = proc_fib_multipath_hash_seed,
1166 },
1167#endif
1168 {
1169 .procname = "ip_unprivileged_port_start",
1170 .maxlen = sizeof(int),
1171 .data = &init_net.ipv4.sysctl_ip_prot_sock,
1172 .mode = 0644,
1173 .proc_handler = ipv4_privileged_ports,
1174 },
1175#ifdef CONFIG_NET_L3_MASTER_DEV
1176 {
1177 .procname = "udp_l3mdev_accept",
1178 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
1179 .maxlen = sizeof(u8),
1180 .mode = 0644,
1181 .proc_handler = proc_dou8vec_minmax,
1182 .extra1 = SYSCTL_ZERO,
1183 .extra2 = SYSCTL_ONE,
1184 },
1185#endif
1186 {
1187 .procname = "tcp_sack",
1188 .data = &init_net.ipv4.sysctl_tcp_sack,
1189 .maxlen = sizeof(u8),
1190 .mode = 0644,
1191 .proc_handler = proc_dou8vec_minmax,
1192 },
1193 {
1194 .procname = "tcp_window_scaling",
1195 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
1196 .maxlen = sizeof(u8),
1197 .mode = 0644,
1198 .proc_handler = proc_dou8vec_minmax,
1199 },
1200 {
1201 .procname = "tcp_timestamps",
1202 .data = &init_net.ipv4.sysctl_tcp_timestamps,
1203 .maxlen = sizeof(u8),
1204 .mode = 0644,
1205 .proc_handler = proc_dou8vec_minmax,
1206 },
1207 {
1208 .procname = "tcp_early_retrans",
1209 .data = &init_net.ipv4.sysctl_tcp_early_retrans,
1210 .maxlen = sizeof(u8),
1211 .mode = 0644,
1212 .proc_handler = proc_dou8vec_minmax,
1213 .extra1 = SYSCTL_ZERO,
1214 .extra2 = SYSCTL_FOUR,
1215 },
1216 {
1217 .procname = "tcp_recovery",
1218 .data = &init_net.ipv4.sysctl_tcp_recovery,
1219 .maxlen = sizeof(u8),
1220 .mode = 0644,
1221 .proc_handler = proc_dou8vec_minmax,
1222 },
1223 {
1224 .procname = "tcp_thin_linear_timeouts",
1225 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1226 .maxlen = sizeof(u8),
1227 .mode = 0644,
1228 .proc_handler = proc_dou8vec_minmax,
1229 },
1230 {
1231 .procname = "tcp_slow_start_after_idle",
1232 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1233 .maxlen = sizeof(u8),
1234 .mode = 0644,
1235 .proc_handler = proc_dou8vec_minmax,
1236 },
1237 {
1238 .procname = "tcp_retrans_collapse",
1239 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
1240 .maxlen = sizeof(u8),
1241 .mode = 0644,
1242 .proc_handler = proc_dou8vec_minmax,
1243 },
1244 {
1245 .procname = "tcp_stdurg",
1246 .data = &init_net.ipv4.sysctl_tcp_stdurg,
1247 .maxlen = sizeof(u8),
1248 .mode = 0644,
1249 .proc_handler = proc_dou8vec_minmax,
1250 },
1251 {
1252 .procname = "tcp_rfc1337",
1253 .data = &init_net.ipv4.sysctl_tcp_rfc1337,
1254 .maxlen = sizeof(u8),
1255 .mode = 0644,
1256 .proc_handler = proc_dou8vec_minmax,
1257 },
1258 {
1259 .procname = "tcp_abort_on_overflow",
1260 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1261 .maxlen = sizeof(u8),
1262 .mode = 0644,
1263 .proc_handler = proc_dou8vec_minmax,
1264 },
1265 {
1266 .procname = "tcp_fack",
1267 .data = &init_net.ipv4.sysctl_tcp_fack,
1268 .maxlen = sizeof(u8),
1269 .mode = 0644,
1270 .proc_handler = proc_dou8vec_minmax,
1271 },
1272 {
1273 .procname = "tcp_max_reordering",
1274 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
1275 .maxlen = sizeof(int),
1276 .mode = 0644,
1277 .proc_handler = proc_dointvec
1278 },
1279 {
1280 .procname = "tcp_dsack",
1281 .data = &init_net.ipv4.sysctl_tcp_dsack,
1282 .maxlen = sizeof(u8),
1283 .mode = 0644,
1284 .proc_handler = proc_dou8vec_minmax,
1285 },
1286 {
1287 .procname = "tcp_app_win",
1288 .data = &init_net.ipv4.sysctl_tcp_app_win,
1289 .maxlen = sizeof(u8),
1290 .mode = 0644,
1291 .proc_handler = proc_dou8vec_minmax,
1292 .extra1 = SYSCTL_ZERO,
1293 .extra2 = &tcp_app_win_max,
1294 },
1295 {
1296 .procname = "tcp_adv_win_scale",
1297 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
1298 .maxlen = sizeof(int),
1299 .mode = 0644,
1300 .proc_handler = proc_dointvec_minmax,
1301 .extra1 = &tcp_adv_win_scale_min,
1302 .extra2 = &tcp_adv_win_scale_max,
1303 },
1304 {
1305 .procname = "tcp_frto",
1306 .data = &init_net.ipv4.sysctl_tcp_frto,
1307 .maxlen = sizeof(u8),
1308 .mode = 0644,
1309 .proc_handler = proc_dou8vec_minmax,
1310 },
1311 {
1312 .procname = "tcp_no_metrics_save",
1313 .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
1314 .maxlen = sizeof(u8),
1315 .mode = 0644,
1316 .proc_handler = proc_dou8vec_minmax,
1317 },
1318 {
1319 .procname = "tcp_no_ssthresh_metrics_save",
1320 .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1321 .maxlen = sizeof(u8),
1322 .mode = 0644,
1323 .proc_handler = proc_dou8vec_minmax,
1324 .extra1 = SYSCTL_ZERO,
1325 .extra2 = SYSCTL_ONE,
1326 },
1327 {
1328 .procname = "tcp_moderate_rcvbuf",
1329 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1330 .maxlen = sizeof(u8),
1331 .mode = 0644,
1332 .proc_handler = proc_dou8vec_minmax,
1333 },
1334 {
1335 .procname = "tcp_tso_win_divisor",
1336 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1337 .maxlen = sizeof(u8),
1338 .mode = 0644,
1339 .proc_handler = proc_dou8vec_minmax,
1340 },
1341 {
1342 .procname = "tcp_workaround_signed_windows",
1343 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1344 .maxlen = sizeof(u8),
1345 .mode = 0644,
1346 .proc_handler = proc_dou8vec_minmax,
1347 },
1348 {
1349 .procname = "tcp_limit_output_bytes",
1350 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1351 .maxlen = sizeof(int),
1352 .mode = 0644,
1353 .proc_handler = proc_dointvec
1354 },
1355 {
1356 .procname = "tcp_challenge_ack_limit",
1357 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1358 .maxlen = sizeof(int),
1359 .mode = 0644,
1360 .proc_handler = proc_dointvec
1361 },
1362 {
1363 .procname = "tcp_min_tso_segs",
1364 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
1365 .maxlen = sizeof(u8),
1366 .mode = 0644,
1367 .proc_handler = proc_dou8vec_minmax,
1368 .extra1 = SYSCTL_ONE,
1369 },
1370 {
1371 .procname = "tcp_tso_rtt_log",
1372 .data = &init_net.ipv4.sysctl_tcp_tso_rtt_log,
1373 .maxlen = sizeof(u8),
1374 .mode = 0644,
1375 .proc_handler = proc_dou8vec_minmax,
1376 },
1377 {
1378 .procname = "tcp_min_rtt_wlen",
1379 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1380 .maxlen = sizeof(int),
1381 .mode = 0644,
1382 .proc_handler = proc_dointvec_minmax,
1383 .extra1 = SYSCTL_ZERO,
1384 .extra2 = &one_day_secs
1385 },
1386 {
1387 .procname = "tcp_autocorking",
1388 .data = &init_net.ipv4.sysctl_tcp_autocorking,
1389 .maxlen = sizeof(u8),
1390 .mode = 0644,
1391 .proc_handler = proc_dou8vec_minmax,
1392 .extra1 = SYSCTL_ZERO,
1393 .extra2 = SYSCTL_ONE,
1394 },
1395 {
1396 .procname = "tcp_invalid_ratelimit",
1397 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1398 .maxlen = sizeof(int),
1399 .mode = 0644,
1400 .proc_handler = proc_dointvec_ms_jiffies,
1401 },
1402 {
1403 .procname = "tcp_pacing_ss_ratio",
1404 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1405 .maxlen = sizeof(int),
1406 .mode = 0644,
1407 .proc_handler = proc_dointvec_minmax,
1408 .extra1 = SYSCTL_ZERO,
1409 .extra2 = SYSCTL_ONE_THOUSAND,
1410 },
1411 {
1412 .procname = "tcp_pacing_ca_ratio",
1413 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1414 .maxlen = sizeof(int),
1415 .mode = 0644,
1416 .proc_handler = proc_dointvec_minmax,
1417 .extra1 = SYSCTL_ZERO,
1418 .extra2 = SYSCTL_ONE_THOUSAND,
1419 },
1420 {
1421 .procname = "tcp_wmem",
1422 .data = &init_net.ipv4.sysctl_tcp_wmem,
1423 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem),
1424 .mode = 0644,
1425 .proc_handler = proc_dointvec_minmax,
1426 .extra1 = SYSCTL_ONE,
1427 },
1428 {
1429 .procname = "tcp_rmem",
1430 .data = &init_net.ipv4.sysctl_tcp_rmem,
1431 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem),
1432 .mode = 0644,
1433 .proc_handler = proc_dointvec_minmax,
1434 .extra1 = SYSCTL_ONE,
1435 },
1436 {
1437 .procname = "tcp_comp_sack_delay_ns",
1438 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1439 .maxlen = sizeof(unsigned long),
1440 .mode = 0644,
1441 .proc_handler = proc_doulongvec_minmax,
1442 },
1443 {
1444 .procname = "tcp_comp_sack_slack_ns",
1445 .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
1446 .maxlen = sizeof(unsigned long),
1447 .mode = 0644,
1448 .proc_handler = proc_doulongvec_minmax,
1449 },
1450 {
1451 .procname = "tcp_comp_sack_nr",
1452 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1453 .maxlen = sizeof(u8),
1454 .mode = 0644,
1455 .proc_handler = proc_dou8vec_minmax,
1456 .extra1 = SYSCTL_ZERO,
1457 },
1458 {
1459 .procname = "tcp_backlog_ack_defer",
1460 .data = &init_net.ipv4.sysctl_tcp_backlog_ack_defer,
1461 .maxlen = sizeof(u8),
1462 .mode = 0644,
1463 .proc_handler = proc_dou8vec_minmax,
1464 .extra1 = SYSCTL_ZERO,
1465 .extra2 = SYSCTL_ONE,
1466 },
1467 {
1468 .procname = "tcp_reflect_tos",
1469 .data = &init_net.ipv4.sysctl_tcp_reflect_tos,
1470 .maxlen = sizeof(u8),
1471 .mode = 0644,
1472 .proc_handler = proc_dou8vec_minmax,
1473 .extra1 = SYSCTL_ZERO,
1474 .extra2 = SYSCTL_ONE,
1475 },
1476 {
1477 .procname = "tcp_ehash_entries",
1478 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1479 .mode = 0444,
1480 .proc_handler = proc_tcp_ehash_entries,
1481 },
1482 {
1483 .procname = "tcp_child_ehash_entries",
1484 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1485 .maxlen = sizeof(unsigned int),
1486 .mode = 0644,
1487 .proc_handler = proc_douintvec_minmax,
1488 .extra1 = SYSCTL_ZERO,
1489 .extra2 = &tcp_child_ehash_entries_max,
1490 },
1491 {
1492 .procname = "udp_hash_entries",
1493 .data = &init_net.ipv4.sysctl_udp_child_hash_entries,
1494 .mode = 0444,
1495 .proc_handler = proc_udp_hash_entries,
1496 },
1497 {
1498 .procname = "udp_child_hash_entries",
1499 .data = &init_net.ipv4.sysctl_udp_child_hash_entries,
1500 .maxlen = sizeof(unsigned int),
1501 .mode = 0644,
1502 .proc_handler = proc_douintvec_minmax,
1503 .extra1 = SYSCTL_ZERO,
1504 .extra2 = &udp_child_hash_entries_max,
1505 },
1506 {
1507 .procname = "udp_rmem_min",
1508 .data = &init_net.ipv4.sysctl_udp_rmem_min,
1509 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1510 .mode = 0644,
1511 .proc_handler = proc_dointvec_minmax,
1512 .extra1 = SYSCTL_ONE
1513 },
1514 {
1515 .procname = "udp_wmem_min",
1516 .data = &init_net.ipv4.sysctl_udp_wmem_min,
1517 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1518 .mode = 0644,
1519 .proc_handler = proc_dointvec_minmax,
1520 .extra1 = SYSCTL_ONE
1521 },
1522 {
1523 .procname = "fib_notify_on_flag_change",
1524 .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change,
1525 .maxlen = sizeof(u8),
1526 .mode = 0644,
1527 .proc_handler = proc_dou8vec_minmax,
1528 .extra1 = SYSCTL_ZERO,
1529 .extra2 = SYSCTL_TWO,
1530 },
1531 {
1532 .procname = "tcp_plb_enabled",
1533 .data = &init_net.ipv4.sysctl_tcp_plb_enabled,
1534 .maxlen = sizeof(u8),
1535 .mode = 0644,
1536 .proc_handler = proc_dou8vec_minmax,
1537 .extra1 = SYSCTL_ZERO,
1538 .extra2 = SYSCTL_ONE,
1539 },
1540 {
1541 .procname = "tcp_plb_idle_rehash_rounds",
1542 .data = &init_net.ipv4.sysctl_tcp_plb_idle_rehash_rounds,
1543 .maxlen = sizeof(u8),
1544 .mode = 0644,
1545 .proc_handler = proc_dou8vec_minmax,
1546 .extra2 = &tcp_plb_max_rounds,
1547 },
1548 {
1549 .procname = "tcp_plb_rehash_rounds",
1550 .data = &init_net.ipv4.sysctl_tcp_plb_rehash_rounds,
1551 .maxlen = sizeof(u8),
1552 .mode = 0644,
1553 .proc_handler = proc_dou8vec_minmax,
1554 .extra2 = &tcp_plb_max_rounds,
1555 },
1556 {
1557 .procname = "tcp_plb_suspend_rto_sec",
1558 .data = &init_net.ipv4.sysctl_tcp_plb_suspend_rto_sec,
1559 .maxlen = sizeof(u8),
1560 .mode = 0644,
1561 .proc_handler = proc_dou8vec_minmax,
1562 },
1563 {
1564 .procname = "tcp_plb_cong_thresh",
1565 .data = &init_net.ipv4.sysctl_tcp_plb_cong_thresh,
1566 .maxlen = sizeof(int),
1567 .mode = 0644,
1568 .proc_handler = proc_dointvec_minmax,
1569 .extra1 = SYSCTL_ZERO,
1570 .extra2 = &tcp_plb_max_cong_thresh,
1571 },
1572 {
1573 .procname = "tcp_syn_linear_timeouts",
1574 .data = &init_net.ipv4.sysctl_tcp_syn_linear_timeouts,
1575 .maxlen = sizeof(u8),
1576 .mode = 0644,
1577 .proc_handler = proc_dou8vec_minmax,
1578 .extra1 = SYSCTL_ZERO,
1579 .extra2 = &tcp_syn_linear_timeouts_max,
1580 },
1581 {
1582 .procname = "tcp_shrink_window",
1583 .data = &init_net.ipv4.sysctl_tcp_shrink_window,
1584 .maxlen = sizeof(u8),
1585 .mode = 0644,
1586 .proc_handler = proc_dou8vec_minmax,
1587 .extra1 = SYSCTL_ZERO,
1588 .extra2 = SYSCTL_ONE,
1589 },
1590 {
1591 .procname = "tcp_pingpong_thresh",
1592 .data = &init_net.ipv4.sysctl_tcp_pingpong_thresh,
1593 .maxlen = sizeof(u8),
1594 .mode = 0644,
1595 .proc_handler = proc_dou8vec_minmax,
1596 .extra1 = SYSCTL_ONE,
1597 },
1598 {
1599 .procname = "tcp_rto_min_us",
1600 .data = &init_net.ipv4.sysctl_tcp_rto_min_us,
1601 .maxlen = sizeof(int),
1602 .mode = 0644,
1603 .proc_handler = proc_dointvec_minmax,
1604 .extra1 = SYSCTL_ONE,
1605 },
1606 {
1607 .procname = "tcp_rto_max_ms",
1608 .data = &init_net.ipv4.sysctl_tcp_rto_max_ms,
1609 .maxlen = sizeof(int),
1610 .mode = 0644,
1611 .proc_handler = proc_dointvec_minmax,
1612 .extra1 = SYSCTL_ONE_THOUSAND,
1613 .extra2 = &tcp_rto_max_max,
1614 },
1615};
1616
1617static __net_init int ipv4_sysctl_init_net(struct net *net)
1618{
1619 size_t table_size = ARRAY_SIZE(ipv4_net_table);
1620 struct ctl_table *table;
1621
1622 table = ipv4_net_table;
1623 if (!net_eq(net1: net, net2: &init_net)) {
1624 int i;
1625
1626 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1627 if (!table)
1628 goto err_alloc;
1629
1630 for (i = 0; i < table_size; i++) {
1631 if (table[i].data) {
1632 /* Update the variables to point into
1633 * the current struct net
1634 */
1635 table[i].data += (void *)net - (void *)&init_net;
1636 } else {
1637 /* Entries without data pointer are global;
1638 * Make them read-only in non-init_net ns
1639 */
1640 table[i].mode &= ~0222;
1641 }
1642 }
1643 }
1644
1645 net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, path: "net/ipv4", table,
1646 table_size);
1647 if (!net->ipv4.ipv4_hdr)
1648 goto err_reg;
1649
1650 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1651 if (!net->ipv4.sysctl_local_reserved_ports)
1652 goto err_ports;
1653
1654 proc_fib_multipath_hash_set_seed(net, user_seed: 0);
1655
1656 return 0;
1657
1658err_ports:
1659 unregister_net_sysctl_table(header: net->ipv4.ipv4_hdr);
1660err_reg:
1661 if (!net_eq(net1: net, net2: &init_net))
1662 kfree(objp: table);
1663err_alloc:
1664 return -ENOMEM;
1665}
1666
1667static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1668{
1669 const struct ctl_table *table;
1670
1671 kfree(objp: net->ipv4.sysctl_local_reserved_ports);
1672 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1673 unregister_net_sysctl_table(header: net->ipv4.ipv4_hdr);
1674 kfree(objp: table);
1675}
1676
1677static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1678 .init = ipv4_sysctl_init_net,
1679 .exit = ipv4_sysctl_exit_net,
1680};
1681
1682static __init int sysctl_ipv4_init(void)
1683{
1684 struct ctl_table_header *hdr;
1685
1686 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1687 if (!hdr)
1688 return -ENOMEM;
1689
1690 proc_fib_multipath_hash_init_rand_seed();
1691
1692 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1693 unregister_net_sysctl_table(header: hdr);
1694 return -ENOMEM;
1695 }
1696
1697 return 0;
1698}
1699
1700__initcall(sysctl_ipv4_init);
1701