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