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