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_port_step_width",
828 .maxlen = sizeof(u32),
829 .data = &init_net.ipv4.sysctl_ip_local_port_step_width,
830 .mode = 0644,
831 .proc_handler = proc_douintvec,
832 },
833 {
834 .procname = "ip_local_reserved_ports",
835 .data = &init_net.ipv4.sysctl_local_reserved_ports,
836 .maxlen = 65536,
837 .mode = 0644,
838 .proc_handler = proc_do_large_bitmap,
839 },
840 {
841 .procname = "ip_no_pmtu_disc",
842 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
843 .maxlen = sizeof(u8),
844 .mode = 0644,
845 .proc_handler = proc_dou8vec_minmax,
846 },
847 {
848 .procname = "ip_forward_use_pmtu",
849 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
850 .maxlen = sizeof(u8),
851 .mode = 0644,
852 .proc_handler = proc_dou8vec_minmax,
853 },
854 {
855 .procname = "ip_forward_update_priority",
856 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
857 .maxlen = sizeof(u8),
858 .mode = 0644,
859 .proc_handler = ipv4_fwd_update_priority,
860 .extra1 = SYSCTL_ZERO,
861 .extra2 = SYSCTL_ONE,
862 },
863 {
864 .procname = "ip_nonlocal_bind",
865 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
866 .maxlen = sizeof(u8),
867 .mode = 0644,
868 .proc_handler = proc_dou8vec_minmax,
869 },
870 {
871 .procname = "ip_autobind_reuse",
872 .data = &init_net.ipv4.sysctl_ip_autobind_reuse,
873 .maxlen = sizeof(u8),
874 .mode = 0644,
875 .proc_handler = proc_dou8vec_minmax,
876 .extra1 = SYSCTL_ZERO,
877 .extra2 = SYSCTL_ONE,
878 },
879 {
880 .procname = "fwmark_reflect",
881 .data = &init_net.ipv4.sysctl_fwmark_reflect,
882 .maxlen = sizeof(u8),
883 .mode = 0644,
884 .proc_handler = proc_dou8vec_minmax,
885 },
886 {
887 .procname = "tcp_fwmark_accept",
888 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
889 .maxlen = sizeof(u8),
890 .mode = 0644,
891 .proc_handler = proc_dou8vec_minmax,
892 },
893 #ifdef CONFIG_NET_L3_MASTER_DEV
894 {
895 .procname = "tcp_l3mdev_accept",
896 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
897 .maxlen = sizeof(u8),
898 .mode = 0644,
899 .proc_handler = proc_dou8vec_minmax,
900 .extra1 = SYSCTL_ZERO,
901 .extra2 = SYSCTL_ONE,
902 },
903 #endif
904 {
905 .procname = "tcp_mtu_probing",
906 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
907 .maxlen = sizeof(u8),
908 .mode = 0644,
909 .proc_handler = proc_dou8vec_minmax,
910 },
911 {
912 .procname = "tcp_base_mss",
913 .data = &init_net.ipv4.sysctl_tcp_base_mss,
914 .maxlen = sizeof(int),
915 .mode = 0644,
916 .proc_handler = proc_dointvec,
917 },
918 {
919 .procname = "tcp_min_snd_mss",
920 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = proc_dointvec_minmax,
924 .extra1 = &tcp_min_snd_mss_min,
925 .extra2 = &tcp_min_snd_mss_max,
926 },
927 {
928 .procname = "tcp_mtu_probe_floor",
929 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
930 .maxlen = sizeof(int),
931 .mode = 0644,
932 .proc_handler = proc_dointvec_minmax,
933 .extra1 = &tcp_min_snd_mss_min,
934 .extra2 = &tcp_min_snd_mss_max,
935 },
936 {
937 .procname = "tcp_probe_threshold",
938 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
939 .maxlen = sizeof(int),
940 .mode = 0644,
941 .proc_handler = proc_dointvec,
942 },
943 {
944 .procname = "tcp_probe_interval",
945 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
946 .maxlen = sizeof(u32),
947 .mode = 0644,
948 .proc_handler = proc_douintvec_minmax,
949 .extra2 = &u32_max_div_HZ,
950 },
951 {
952 .procname = "igmp_link_local_mcast_reports",
953 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
954 .maxlen = sizeof(u8),
955 .mode = 0644,
956 .proc_handler = proc_dou8vec_minmax,
957 },
958 {
959 .procname = "igmp_max_memberships",
960 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
961 .maxlen = sizeof(int),
962 .mode = 0644,
963 .proc_handler = proc_dointvec
964 },
965 {
966 .procname = "igmp_max_msf",
967 .data = &init_net.ipv4.sysctl_igmp_max_msf,
968 .maxlen = sizeof(int),
969 .mode = 0644,
970 .proc_handler = proc_dointvec
971 },
972 #ifdef CONFIG_IP_MULTICAST
973 {
974 .procname = "igmp_qrv",
975 .data = &init_net.ipv4.sysctl_igmp_qrv,
976 .maxlen = sizeof(int),
977 .mode = 0644,
978 .proc_handler = proc_dointvec_minmax,
979 .extra1 = SYSCTL_ONE
980 },
981 #endif
982 {
983 .procname = "tcp_congestion_control",
984 .data = &init_net.ipv4.tcp_congestion_control,
985 .mode = 0644,
986 .maxlen = TCP_CA_NAME_MAX,
987 .proc_handler = proc_tcp_congestion_control,
988 },
989 {
990 .procname = "tcp_available_congestion_control",
991 .maxlen = TCP_CA_BUF_MAX,
992 .mode = 0444,
993 .proc_handler = proc_tcp_available_congestion_control,
994 },
995 {
996 .procname = "tcp_allowed_congestion_control",
997 .maxlen = TCP_CA_BUF_MAX,
998 .mode = 0644,
999 .proc_handler = proc_allowed_congestion_control,
1000 },
1001 {
1002 .procname = "tcp_keepalive_time",
1003 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
1004 .maxlen = sizeof(int),
1005 .mode = 0644,
1006 .proc_handler = proc_dointvec_jiffies,
1007 },
1008 {
1009 .procname = "tcp_keepalive_probes",
1010 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
1011 .maxlen = sizeof(u8),
1012 .mode = 0644,
1013 .proc_handler = proc_dou8vec_minmax,
1014 },
1015 {
1016 .procname = "tcp_keepalive_intvl",
1017 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
1018 .maxlen = sizeof(int),
1019 .mode = 0644,
1020 .proc_handler = proc_dointvec_jiffies,
1021 },
1022 {
1023 .procname = "tcp_syn_retries",
1024 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
1025 .maxlen = sizeof(u8),
1026 .mode = 0644,
1027 .proc_handler = proc_dou8vec_minmax,
1028 .extra1 = &tcp_syn_retries_min,
1029 .extra2 = &tcp_syn_retries_max
1030 },
1031 {
1032 .procname = "tcp_synack_retries",
1033 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
1034 .maxlen = sizeof(u8),
1035 .mode = 0644,
1036 .proc_handler = proc_dou8vec_minmax,
1037 },
1038 #ifdef CONFIG_SYN_COOKIES
1039 {
1040 .procname = "tcp_syncookies",
1041 .data = &init_net.ipv4.sysctl_tcp_syncookies,
1042 .maxlen = sizeof(u8),
1043 .mode = 0644,
1044 .proc_handler = proc_dou8vec_minmax,
1045 },
1046 #endif
1047 {
1048 .procname = "tcp_migrate_req",
1049 .data = &init_net.ipv4.sysctl_tcp_migrate_req,
1050 .maxlen = sizeof(u8),
1051 .mode = 0644,
1052 .proc_handler = proc_dou8vec_minmax,
1053 .extra1 = SYSCTL_ZERO,
1054 .extra2 = SYSCTL_ONE
1055 },
1056 {
1057 .procname = "tcp_reordering",
1058 .data = &init_net.ipv4.sysctl_tcp_reordering,
1059 .maxlen = sizeof(int),
1060 .mode = 0644,
1061 .proc_handler = proc_dointvec
1062 },
1063 {
1064 .procname = "tcp_retries1",
1065 .data = &init_net.ipv4.sysctl_tcp_retries1,
1066 .maxlen = sizeof(u8),
1067 .mode = 0644,
1068 .proc_handler = proc_dou8vec_minmax,
1069 .extra2 = &tcp_retr1_max
1070 },
1071 {
1072 .procname = "tcp_retries2",
1073 .data = &init_net.ipv4.sysctl_tcp_retries2,
1074 .maxlen = sizeof(u8),
1075 .mode = 0644,
1076 .proc_handler = proc_dou8vec_minmax,
1077 },
1078 {
1079 .procname = "tcp_orphan_retries",
1080 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
1081 .maxlen = sizeof(u8),
1082 .mode = 0644,
1083 .proc_handler = proc_dou8vec_minmax,
1084 },
1085 {
1086 .procname = "tcp_fin_timeout",
1087 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
1088 .maxlen = sizeof(int),
1089 .mode = 0644,
1090 .proc_handler = proc_dointvec_jiffies,
1091 },
1092 {
1093 .procname = "tcp_notsent_lowat",
1094 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
1095 .maxlen = sizeof(unsigned int),
1096 .mode = 0644,
1097 .proc_handler = proc_douintvec,
1098 },
1099 {
1100 .procname = "tcp_tw_reuse",
1101 .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
1102 .maxlen = sizeof(u8),
1103 .mode = 0644,
1104 .proc_handler = proc_dou8vec_minmax,
1105 .extra1 = SYSCTL_ZERO,
1106 .extra2 = SYSCTL_TWO,
1107 },
1108 {
1109 .procname = "tcp_tw_reuse_delay",
1110 .data = &init_net.ipv4.sysctl_tcp_tw_reuse_delay,
1111 .maxlen = sizeof(unsigned int),
1112 .mode = 0644,
1113 .proc_handler = proc_douintvec_minmax,
1114 .extra1 = SYSCTL_ONE,
1115 .extra2 = &tcp_tw_reuse_delay_max,
1116 },
1117 {
1118 .procname = "tcp_max_syn_backlog",
1119 .data = &init_net.ipv4.sysctl_max_syn_backlog,
1120 .maxlen = sizeof(int),
1121 .mode = 0644,
1122 .proc_handler = proc_dointvec
1123 },
1124 {
1125 .procname = "tcp_fastopen",
1126 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1127 .maxlen = sizeof(int),
1128 .mode = 0644,
1129 .proc_handler = proc_dointvec,
1130 },
1131 {
1132 .procname = "tcp_fastopen_key",
1133 .mode = 0600,
1134 .data = &init_net.ipv4.sysctl_tcp_fastopen,
1135 /* maxlen to print the list of keys in hex (*2), with dashes
1136 * separating doublewords and a comma in between keys.
1137 */
1138 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
1139 2 * TCP_FASTOPEN_KEY_MAX) +
1140 (TCP_FASTOPEN_KEY_MAX * 5)),
1141 .proc_handler = proc_tcp_fastopen_key,
1142 },
1143 {
1144 .procname = "tcp_fastopen_blackhole_timeout_sec",
1145 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
1146 .maxlen = sizeof(int),
1147 .mode = 0644,
1148 .proc_handler = proc_tfo_blackhole_detect_timeout,
1149 .extra1 = SYSCTL_ZERO,
1150 },
1151 #ifdef CONFIG_IP_ROUTE_MULTIPATH
1152 {
1153 .procname = "fib_multipath_use_neigh",
1154 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
1155 .maxlen = sizeof(u8),
1156 .mode = 0644,
1157 .proc_handler = proc_dou8vec_minmax,
1158 .extra1 = SYSCTL_ZERO,
1159 .extra2 = SYSCTL_ONE,
1160 },
1161 {
1162 .procname = "fib_multipath_hash_policy",
1163 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
1164 .maxlen = sizeof(u8),
1165 .mode = 0644,
1166 .proc_handler = proc_fib_multipath_hash_policy,
1167 .extra1 = SYSCTL_ZERO,
1168 .extra2 = SYSCTL_THREE,
1169 },
1170 {
1171 .procname = "fib_multipath_hash_fields",
1172 .data = &init_net.ipv4.sysctl_fib_multipath_hash_fields,
1173 .maxlen = sizeof(u32),
1174 .mode = 0644,
1175 .proc_handler = proc_fib_multipath_hash_fields,
1176 .extra1 = SYSCTL_ONE,
1177 .extra2 = &fib_multipath_hash_fields_all_mask,
1178 },
1179 {
1180 .procname = "fib_multipath_hash_seed",
1181 .data = &init_net,
1182 .maxlen = sizeof(u32),
1183 .mode = 0644,
1184 .proc_handler = proc_fib_multipath_hash_seed,
1185 },
1186 #endif
1187 {
1188 .procname = "ip_unprivileged_port_start",
1189 .maxlen = sizeof(int),
1190 .data = &init_net.ipv4.sysctl_ip_prot_sock,
1191 .mode = 0644,
1192 .proc_handler = ipv4_privileged_ports,
1193 },
1194 #ifdef CONFIG_NET_L3_MASTER_DEV
1195 {
1196 .procname = "udp_l3mdev_accept",
1197 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
1198 .maxlen = sizeof(u8),
1199 .mode = 0644,
1200 .proc_handler = proc_dou8vec_minmax,
1201 .extra1 = SYSCTL_ZERO,
1202 .extra2 = SYSCTL_ONE,
1203 },
1204 #endif
1205 {
1206 .procname = "tcp_sack",
1207 .data = &init_net.ipv4.sysctl_tcp_sack,
1208 .maxlen = sizeof(u8),
1209 .mode = 0644,
1210 .proc_handler = proc_dou8vec_minmax,
1211 },
1212 {
1213 .procname = "tcp_window_scaling",
1214 .data = &init_net.ipv4.sysctl_tcp_window_scaling,
1215 .maxlen = sizeof(u8),
1216 .mode = 0644,
1217 .proc_handler = proc_dou8vec_minmax,
1218 },
1219 {
1220 .procname = "tcp_timestamps",
1221 .data = &init_net.ipv4.sysctl_tcp_timestamps,
1222 .maxlen = sizeof(u8),
1223 .mode = 0644,
1224 .proc_handler = proc_dou8vec_minmax,
1225 },
1226 {
1227 .procname = "tcp_early_retrans",
1228 .data = &init_net.ipv4.sysctl_tcp_early_retrans,
1229 .maxlen = sizeof(u8),
1230 .mode = 0644,
1231 .proc_handler = proc_dou8vec_minmax,
1232 .extra1 = SYSCTL_ZERO,
1233 .extra2 = SYSCTL_FOUR,
1234 },
1235 {
1236 .procname = "tcp_recovery",
1237 .data = &init_net.ipv4.sysctl_tcp_recovery,
1238 .maxlen = sizeof(u8),
1239 .mode = 0644,
1240 .proc_handler = proc_dou8vec_minmax,
1241 },
1242 {
1243 .procname = "tcp_thin_linear_timeouts",
1244 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
1245 .maxlen = sizeof(u8),
1246 .mode = 0644,
1247 .proc_handler = proc_dou8vec_minmax,
1248 },
1249 {
1250 .procname = "tcp_slow_start_after_idle",
1251 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
1252 .maxlen = sizeof(u8),
1253 .mode = 0644,
1254 .proc_handler = proc_dou8vec_minmax,
1255 },
1256 {
1257 .procname = "tcp_retrans_collapse",
1258 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
1259 .maxlen = sizeof(u8),
1260 .mode = 0644,
1261 .proc_handler = proc_dou8vec_minmax,
1262 },
1263 {
1264 .procname = "tcp_stdurg",
1265 .data = &init_net.ipv4.sysctl_tcp_stdurg,
1266 .maxlen = sizeof(u8),
1267 .mode = 0644,
1268 .proc_handler = proc_dou8vec_minmax,
1269 },
1270 {
1271 .procname = "tcp_rfc1337",
1272 .data = &init_net.ipv4.sysctl_tcp_rfc1337,
1273 .maxlen = sizeof(u8),
1274 .mode = 0644,
1275 .proc_handler = proc_dou8vec_minmax,
1276 },
1277 {
1278 .procname = "tcp_abort_on_overflow",
1279 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
1280 .maxlen = sizeof(u8),
1281 .mode = 0644,
1282 .proc_handler = proc_dou8vec_minmax,
1283 },
1284 {
1285 .procname = "tcp_fack",
1286 .data = &init_net.ipv4.sysctl_tcp_fack,
1287 .maxlen = sizeof(u8),
1288 .mode = 0644,
1289 .proc_handler = proc_dou8vec_minmax,
1290 },
1291 {
1292 .procname = "tcp_max_reordering",
1293 .data = &init_net.ipv4.sysctl_tcp_max_reordering,
1294 .maxlen = sizeof(int),
1295 .mode = 0644,
1296 .proc_handler = proc_dointvec
1297 },
1298 {
1299 .procname = "tcp_dsack",
1300 .data = &init_net.ipv4.sysctl_tcp_dsack,
1301 .maxlen = sizeof(u8),
1302 .mode = 0644,
1303 .proc_handler = proc_dou8vec_minmax,
1304 },
1305 {
1306 .procname = "tcp_app_win",
1307 .data = &init_net.ipv4.sysctl_tcp_app_win,
1308 .maxlen = sizeof(u8),
1309 .mode = 0644,
1310 .proc_handler = proc_dou8vec_minmax,
1311 .extra1 = SYSCTL_ZERO,
1312 .extra2 = &tcp_app_win_max,
1313 },
1314 {
1315 .procname = "tcp_adv_win_scale",
1316 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
1317 .maxlen = sizeof(int),
1318 .mode = 0644,
1319 .proc_handler = proc_dointvec_minmax,
1320 .extra1 = &tcp_adv_win_scale_min,
1321 .extra2 = &tcp_adv_win_scale_max,
1322 },
1323 {
1324 .procname = "tcp_frto",
1325 .data = &init_net.ipv4.sysctl_tcp_frto,
1326 .maxlen = sizeof(u8),
1327 .mode = 0644,
1328 .proc_handler = proc_dou8vec_minmax,
1329 },
1330 {
1331 .procname = "tcp_no_metrics_save",
1332 .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
1333 .maxlen = sizeof(u8),
1334 .mode = 0644,
1335 .proc_handler = proc_dou8vec_minmax,
1336 },
1337 {
1338 .procname = "tcp_no_ssthresh_metrics_save",
1339 .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
1340 .maxlen = sizeof(u8),
1341 .mode = 0644,
1342 .proc_handler = proc_dou8vec_minmax,
1343 .extra1 = SYSCTL_ZERO,
1344 .extra2 = SYSCTL_ONE,
1345 },
1346 {
1347 .procname = "tcp_moderate_rcvbuf",
1348 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
1349 .maxlen = sizeof(u8),
1350 .mode = 0644,
1351 .proc_handler = proc_dou8vec_minmax,
1352 },
1353 {
1354 .procname = "tcp_rcvbuf_low_rtt",
1355 .data = &init_net.ipv4.sysctl_tcp_rcvbuf_low_rtt,
1356 .maxlen = sizeof(int),
1357 .mode = 0644,
1358 .proc_handler = proc_dointvec_minmax,
1359 .extra1 = SYSCTL_ZERO,
1360 .extra2 = SYSCTL_INT_MAX,
1361 },
1362 {
1363 .procname = "tcp_tso_win_divisor",
1364 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
1365 .maxlen = sizeof(u8),
1366 .mode = 0644,
1367 .proc_handler = proc_dou8vec_minmax,
1368 },
1369 {
1370 .procname = "tcp_workaround_signed_windows",
1371 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
1372 .maxlen = sizeof(u8),
1373 .mode = 0644,
1374 .proc_handler = proc_dou8vec_minmax,
1375 },
1376 {
1377 .procname = "tcp_limit_output_bytes",
1378 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
1379 .maxlen = sizeof(int),
1380 .mode = 0644,
1381 .proc_handler = proc_dointvec
1382 },
1383 {
1384 .procname = "tcp_challenge_ack_limit",
1385 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
1386 .maxlen = sizeof(int),
1387 .mode = 0644,
1388 .proc_handler = proc_dointvec
1389 },
1390 {
1391 .procname = "tcp_min_tso_segs",
1392 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
1393 .maxlen = sizeof(u8),
1394 .mode = 0644,
1395 .proc_handler = proc_dou8vec_minmax,
1396 .extra1 = SYSCTL_ONE,
1397 },
1398 {
1399 .procname = "tcp_tso_rtt_log",
1400 .data = &init_net.ipv4.sysctl_tcp_tso_rtt_log,
1401 .maxlen = sizeof(u8),
1402 .mode = 0644,
1403 .proc_handler = proc_dou8vec_minmax,
1404 },
1405 {
1406 .procname = "tcp_min_rtt_wlen",
1407 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
1408 .maxlen = sizeof(int),
1409 .mode = 0644,
1410 .proc_handler = proc_dointvec_minmax,
1411 .extra1 = SYSCTL_ZERO,
1412 .extra2 = &one_day_secs
1413 },
1414 {
1415 .procname = "tcp_autocorking",
1416 .data = &init_net.ipv4.sysctl_tcp_autocorking,
1417 .maxlen = sizeof(u8),
1418 .mode = 0644,
1419 .proc_handler = proc_dou8vec_minmax,
1420 .extra1 = SYSCTL_ZERO,
1421 .extra2 = SYSCTL_ONE,
1422 },
1423 {
1424 .procname = "tcp_invalid_ratelimit",
1425 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
1426 .maxlen = sizeof(int),
1427 .mode = 0644,
1428 .proc_handler = proc_dointvec_ms_jiffies,
1429 },
1430 {
1431 .procname = "tcp_pacing_ss_ratio",
1432 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
1433 .maxlen = sizeof(int),
1434 .mode = 0644,
1435 .proc_handler = proc_dointvec_minmax,
1436 .extra1 = SYSCTL_ZERO,
1437 .extra2 = SYSCTL_ONE_THOUSAND,
1438 },
1439 {
1440 .procname = "tcp_pacing_ca_ratio",
1441 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
1442 .maxlen = sizeof(int),
1443 .mode = 0644,
1444 .proc_handler = proc_dointvec_minmax,
1445 .extra1 = SYSCTL_ZERO,
1446 .extra2 = SYSCTL_ONE_THOUSAND,
1447 },
1448 {
1449 .procname = "tcp_wmem",
1450 .data = &init_net.ipv4.sysctl_tcp_wmem,
1451 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem),
1452 .mode = 0644,
1453 .proc_handler = proc_dointvec_minmax,
1454 .extra1 = SYSCTL_ONE,
1455 },
1456 {
1457 .procname = "tcp_rmem",
1458 .data = &init_net.ipv4.sysctl_tcp_rmem,
1459 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem),
1460 .mode = 0644,
1461 .proc_handler = proc_dointvec_minmax,
1462 .extra1 = SYSCTL_ONE,
1463 },
1464 {
1465 .procname = "tcp_comp_sack_delay_ns",
1466 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
1467 .maxlen = sizeof(unsigned long),
1468 .mode = 0644,
1469 .proc_handler = proc_doulongvec_minmax,
1470 },
1471 {
1472 .procname = "tcp_comp_sack_rtt_percent",
1473 .data = &init_net.ipv4.sysctl_tcp_comp_sack_rtt_percent,
1474 .maxlen = sizeof(int),
1475 .mode = 0644,
1476 .proc_handler = proc_dointvec_minmax,
1477 .extra1 = SYSCTL_ONE,
1478 .extra2 = SYSCTL_ONE_THOUSAND,
1479 },
1480 {
1481 .procname = "tcp_comp_sack_slack_ns",
1482 .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
1483 .maxlen = sizeof(unsigned long),
1484 .mode = 0644,
1485 .proc_handler = proc_doulongvec_minmax,
1486 },
1487 {
1488 .procname = "tcp_comp_sack_nr",
1489 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr,
1490 .maxlen = sizeof(u8),
1491 .mode = 0644,
1492 .proc_handler = proc_dou8vec_minmax,
1493 .extra1 = SYSCTL_ZERO,
1494 },
1495 {
1496 .procname = "tcp_backlog_ack_defer",
1497 .data = &init_net.ipv4.sysctl_tcp_backlog_ack_defer,
1498 .maxlen = sizeof(u8),
1499 .mode = 0644,
1500 .proc_handler = proc_dou8vec_minmax,
1501 .extra1 = SYSCTL_ZERO,
1502 .extra2 = SYSCTL_ONE,
1503 },
1504 {
1505 .procname = "tcp_reflect_tos",
1506 .data = &init_net.ipv4.sysctl_tcp_reflect_tos,
1507 .maxlen = sizeof(u8),
1508 .mode = 0644,
1509 .proc_handler = proc_dou8vec_minmax,
1510 .extra1 = SYSCTL_ZERO,
1511 .extra2 = SYSCTL_ONE,
1512 },
1513 {
1514 .procname = "tcp_ehash_entries",
1515 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1516 .mode = 0444,
1517 .proc_handler = proc_tcp_ehash_entries,
1518 },
1519 {
1520 .procname = "tcp_child_ehash_entries",
1521 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
1522 .maxlen = sizeof(unsigned int),
1523 .mode = 0644,
1524 .proc_handler = proc_douintvec_minmax,
1525 .extra1 = SYSCTL_ZERO,
1526 .extra2 = &tcp_child_ehash_entries_max,
1527 },
1528 {
1529 .procname = "udp_hash_entries",
1530 .data = &init_net.ipv4.sysctl_udp_child_hash_entries,
1531 .mode = 0444,
1532 .proc_handler = proc_udp_hash_entries,
1533 },
1534 {
1535 .procname = "udp_child_hash_entries",
1536 .data = &init_net.ipv4.sysctl_udp_child_hash_entries,
1537 .maxlen = sizeof(unsigned int),
1538 .mode = 0644,
1539 .proc_handler = proc_douintvec_minmax,
1540 .extra1 = SYSCTL_ZERO,
1541 .extra2 = &udp_child_hash_entries_max,
1542 },
1543 {
1544 .procname = "udp_rmem_min",
1545 .data = &init_net.ipv4.sysctl_udp_rmem_min,
1546 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min),
1547 .mode = 0644,
1548 .proc_handler = proc_dointvec_minmax,
1549 .extra1 = SYSCTL_ONE
1550 },
1551 {
1552 .procname = "udp_wmem_min",
1553 .data = &init_net.ipv4.sysctl_udp_wmem_min,
1554 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min),
1555 .mode = 0644,
1556 .proc_handler = proc_dointvec_minmax,
1557 .extra1 = SYSCTL_ONE
1558 },
1559 {
1560 .procname = "fib_notify_on_flag_change",
1561 .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change,
1562 .maxlen = sizeof(u8),
1563 .mode = 0644,
1564 .proc_handler = proc_dou8vec_minmax,
1565 .extra1 = SYSCTL_ZERO,
1566 .extra2 = SYSCTL_TWO,
1567 },
1568 {
1569 .procname = "tcp_plb_enabled",
1570 .data = &init_net.ipv4.sysctl_tcp_plb_enabled,
1571 .maxlen = sizeof(u8),
1572 .mode = 0644,
1573 .proc_handler = proc_dou8vec_minmax,
1574 .extra1 = SYSCTL_ZERO,
1575 .extra2 = SYSCTL_ONE,
1576 },
1577 {
1578 .procname = "tcp_plb_idle_rehash_rounds",
1579 .data = &init_net.ipv4.sysctl_tcp_plb_idle_rehash_rounds,
1580 .maxlen = sizeof(u8),
1581 .mode = 0644,
1582 .proc_handler = proc_dou8vec_minmax,
1583 .extra2 = &tcp_plb_max_rounds,
1584 },
1585 {
1586 .procname = "tcp_plb_rehash_rounds",
1587 .data = &init_net.ipv4.sysctl_tcp_plb_rehash_rounds,
1588 .maxlen = sizeof(u8),
1589 .mode = 0644,
1590 .proc_handler = proc_dou8vec_minmax,
1591 .extra2 = &tcp_plb_max_rounds,
1592 },
1593 {
1594 .procname = "tcp_plb_suspend_rto_sec",
1595 .data = &init_net.ipv4.sysctl_tcp_plb_suspend_rto_sec,
1596 .maxlen = sizeof(u8),
1597 .mode = 0644,
1598 .proc_handler = proc_dou8vec_minmax,
1599 },
1600 {
1601 .procname = "tcp_plb_cong_thresh",
1602 .data = &init_net.ipv4.sysctl_tcp_plb_cong_thresh,
1603 .maxlen = sizeof(int),
1604 .mode = 0644,
1605 .proc_handler = proc_dointvec_minmax,
1606 .extra1 = SYSCTL_ZERO,
1607 .extra2 = &tcp_plb_max_cong_thresh,
1608 },
1609 {
1610 .procname = "tcp_syn_linear_timeouts",
1611 .data = &init_net.ipv4.sysctl_tcp_syn_linear_timeouts,
1612 .maxlen = sizeof(u8),
1613 .mode = 0644,
1614 .proc_handler = proc_dou8vec_minmax,
1615 .extra1 = SYSCTL_ZERO,
1616 .extra2 = &tcp_syn_linear_timeouts_max,
1617 },
1618 {
1619 .procname = "tcp_shrink_window",
1620 .data = &init_net.ipv4.sysctl_tcp_shrink_window,
1621 .maxlen = sizeof(u8),
1622 .mode = 0644,
1623 .proc_handler = proc_dou8vec_minmax,
1624 .extra1 = SYSCTL_ZERO,
1625 .extra2 = SYSCTL_ONE,
1626 },
1627 {
1628 .procname = "tcp_pingpong_thresh",
1629 .data = &init_net.ipv4.sysctl_tcp_pingpong_thresh,
1630 .maxlen = sizeof(u8),
1631 .mode = 0644,
1632 .proc_handler = proc_dou8vec_minmax,
1633 .extra1 = SYSCTL_ONE,
1634 },
1635 {
1636 .procname = "tcp_rto_min_us",
1637 .data = &init_net.ipv4.sysctl_tcp_rto_min_us,
1638 .maxlen = sizeof(int),
1639 .mode = 0644,
1640 .proc_handler = proc_dointvec_minmax,
1641 .extra1 = SYSCTL_ONE,
1642 },
1643 {
1644 .procname = "tcp_rto_max_ms",
1645 .data = &init_net.ipv4.sysctl_tcp_rto_max_ms,
1646 .maxlen = sizeof(int),
1647 .mode = 0644,
1648 .proc_handler = proc_dointvec_minmax,
1649 .extra1 = SYSCTL_ONE_THOUSAND,
1650 .extra2 = &tcp_rto_max_max,
1651 },
1652 };
1653
ipv4_sysctl_init_net(struct net * net)1654 static __net_init int ipv4_sysctl_init_net(struct net *net)
1655 {
1656 size_t table_size = ARRAY_SIZE(ipv4_net_table);
1657 struct ctl_table *table;
1658
1659 table = ipv4_net_table;
1660 if (!net_eq(net, &init_net)) {
1661 int i;
1662
1663 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
1664 if (!table)
1665 goto err_alloc;
1666
1667 for (i = 0; i < table_size; i++) {
1668 if (table[i].data) {
1669 /* Update the variables to point into
1670 * the current struct net
1671 */
1672 table[i].data += (void *)net - (void *)&init_net;
1673 } else {
1674 /* Entries without data pointer are global;
1675 * Make them read-only in non-init_net ns
1676 */
1677 table[i].mode &= ~0222;
1678 }
1679 }
1680 }
1681
1682 net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table,
1683 table_size);
1684 if (!net->ipv4.ipv4_hdr)
1685 goto err_reg;
1686
1687 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1688 if (!net->ipv4.sysctl_local_reserved_ports)
1689 goto err_ports;
1690
1691 proc_fib_multipath_hash_set_seed(net, 0);
1692
1693 return 0;
1694
1695 err_ports:
1696 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1697 err_reg:
1698 if (!net_eq(net, &init_net))
1699 kfree(table);
1700 err_alloc:
1701 return -ENOMEM;
1702 }
1703
ipv4_sysctl_exit_net(struct net * net)1704 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1705 {
1706 const struct ctl_table *table;
1707
1708 kfree(net->ipv4.sysctl_local_reserved_ports);
1709 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1710 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1711 kfree(table);
1712 }
1713
1714 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1715 .init = ipv4_sysctl_init_net,
1716 .exit = ipv4_sysctl_exit_net,
1717 };
1718
sysctl_ipv4_init(void)1719 static __init int sysctl_ipv4_init(void)
1720 {
1721 struct ctl_table_header *hdr;
1722
1723 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
1724 if (!hdr)
1725 return -ENOMEM;
1726
1727 proc_fib_multipath_hash_init_rand_seed();
1728
1729 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
1730 unregister_net_sysctl_table(hdr);
1731 return -ENOMEM;
1732 }
1733
1734 return 0;
1735 }
1736
1737 __initcall(sysctl_ipv4_init);
1738