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 = 2; 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 */ 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. */ 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. */ 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 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 */ 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. */ 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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, new); 490 } 491 492 static int proc_fib_multipath_hash_seed(const struct ctl_table *table, int write, 493 void *buffer, size_t *lenp, 494 loff_t *ppos) 495 { 496 struct sysctl_fib_multipath_hash_seed *mphs; 497 struct net *net = table->data; 498 struct ctl_table tmp; 499 u32 user_seed; 500 int ret; 501 502 mphs = &net->ipv4.sysctl_fib_multipath_hash_seed; 503 user_seed = mphs->user_seed; 504 505 tmp = *table; 506 tmp.data = &user_seed; 507 508 ret = proc_douintvec_minmax(&tmp, write, buffer, lenp, ppos); 509 510 if (write && ret == 0) { 511 proc_fib_multipath_hash_set_seed(net, user_seed); 512 call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net); 513 } 514 515 return ret; 516 } 517 #else 518 519 static void proc_fib_multipath_hash_init_rand_seed(void) 520 { 521 } 522 523 static void proc_fib_multipath_hash_set_seed(struct net *net, u32 user_seed) 524 { 525 } 526 527 #endif 528 529 static struct ctl_table ipv4_table[] = { 530 { 531 .procname = "tcp_max_orphans", 532 .data = &sysctl_tcp_max_orphans, 533 .maxlen = sizeof(int), 534 .mode = 0644, 535 .proc_handler = proc_dointvec 536 }, 537 { 538 .procname = "inet_peer_threshold", 539 .data = &inet_peer_threshold, 540 .maxlen = sizeof(int), 541 .mode = 0644, 542 .proc_handler = proc_dointvec 543 }, 544 { 545 .procname = "inet_peer_minttl", 546 .data = &inet_peer_minttl, 547 .maxlen = sizeof(int), 548 .mode = 0644, 549 .proc_handler = proc_dointvec_jiffies, 550 }, 551 { 552 .procname = "inet_peer_maxttl", 553 .data = &inet_peer_maxttl, 554 .maxlen = sizeof(int), 555 .mode = 0644, 556 .proc_handler = proc_dointvec_jiffies, 557 }, 558 { 559 .procname = "tcp_mem", 560 .maxlen = sizeof(sysctl_tcp_mem), 561 .data = &sysctl_tcp_mem, 562 .mode = 0644, 563 .proc_handler = proc_doulongvec_minmax, 564 }, 565 { 566 .procname = "tcp_low_latency", 567 .data = &sysctl_tcp_low_latency, 568 .maxlen = sizeof(int), 569 .mode = 0644, 570 .proc_handler = proc_dointvec 571 }, 572 #ifdef CONFIG_NETLABEL 573 { 574 .procname = "cipso_cache_enable", 575 .data = &cipso_v4_cache_enabled, 576 .maxlen = sizeof(int), 577 .mode = 0644, 578 .proc_handler = proc_dointvec, 579 }, 580 { 581 .procname = "cipso_cache_bucket_size", 582 .data = &cipso_v4_cache_bucketsize, 583 .maxlen = sizeof(int), 584 .mode = 0644, 585 .proc_handler = proc_dointvec, 586 }, 587 { 588 .procname = "cipso_rbm_optfmt", 589 .data = &cipso_v4_rbm_optfmt, 590 .maxlen = sizeof(int), 591 .mode = 0644, 592 .proc_handler = proc_dointvec, 593 }, 594 { 595 .procname = "cipso_rbm_strictvalid", 596 .data = &cipso_v4_rbm_strictvalid, 597 .maxlen = sizeof(int), 598 .mode = 0644, 599 .proc_handler = proc_dointvec, 600 }, 601 #endif /* CONFIG_NETLABEL */ 602 { 603 .procname = "tcp_available_ulp", 604 .maxlen = TCP_ULP_BUF_MAX, 605 .mode = 0444, 606 .proc_handler = proc_tcp_available_ulp, 607 }, 608 { 609 .procname = "udp_mem", 610 .data = &sysctl_udp_mem, 611 .maxlen = sizeof(sysctl_udp_mem), 612 .mode = 0644, 613 .proc_handler = proc_doulongvec_minmax, 614 }, 615 { 616 .procname = "fib_sync_mem", 617 .data = &sysctl_fib_sync_mem, 618 .maxlen = sizeof(sysctl_fib_sync_mem), 619 .mode = 0644, 620 .proc_handler = proc_douintvec_minmax, 621 .extra1 = &sysctl_fib_sync_mem_min, 622 .extra2 = &sysctl_fib_sync_mem_max, 623 }, 624 }; 625 626 static struct ctl_table ipv4_net_table[] = { 627 { 628 .procname = "tcp_max_tw_buckets", 629 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets, 630 .maxlen = sizeof(int), 631 .mode = 0644, 632 .proc_handler = proc_dointvec 633 }, 634 { 635 .procname = "icmp_echo_ignore_all", 636 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, 637 .maxlen = sizeof(u8), 638 .mode = 0644, 639 .proc_handler = proc_dou8vec_minmax, 640 .extra1 = SYSCTL_ZERO, 641 .extra2 = SYSCTL_ONE 642 }, 643 { 644 .procname = "icmp_echo_enable_probe", 645 .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe, 646 .maxlen = sizeof(u8), 647 .mode = 0644, 648 .proc_handler = proc_dou8vec_minmax, 649 .extra1 = SYSCTL_ZERO, 650 .extra2 = SYSCTL_ONE 651 }, 652 { 653 .procname = "icmp_echo_ignore_broadcasts", 654 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, 655 .maxlen = sizeof(u8), 656 .mode = 0644, 657 .proc_handler = proc_dou8vec_minmax, 658 .extra1 = SYSCTL_ZERO, 659 .extra2 = SYSCTL_ONE 660 }, 661 { 662 .procname = "icmp_ignore_bogus_error_responses", 663 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, 664 .maxlen = sizeof(u8), 665 .mode = 0644, 666 .proc_handler = proc_dou8vec_minmax, 667 .extra1 = SYSCTL_ZERO, 668 .extra2 = SYSCTL_ONE 669 }, 670 { 671 .procname = "icmp_errors_use_inbound_ifaddr", 672 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, 673 .maxlen = sizeof(u8), 674 .mode = 0644, 675 .proc_handler = proc_dou8vec_minmax, 676 .extra1 = SYSCTL_ZERO, 677 .extra2 = SYSCTL_ONE 678 }, 679 { 680 .procname = "icmp_errors_extension_mask", 681 .data = &init_net.ipv4.sysctl_icmp_errors_extension_mask, 682 .maxlen = sizeof(u8), 683 .mode = 0644, 684 .proc_handler = proc_dou8vec_minmax, 685 .extra1 = SYSCTL_ZERO, 686 .extra2 = &icmp_errors_extension_mask_all, 687 }, 688 { 689 .procname = "icmp_ratelimit", 690 .data = &init_net.ipv4.sysctl_icmp_ratelimit, 691 .maxlen = sizeof(int), 692 .mode = 0644, 693 .proc_handler = proc_dointvec_ms_jiffies, 694 }, 695 { 696 .procname = "icmp_ratemask", 697 .data = &init_net.ipv4.sysctl_icmp_ratemask, 698 .maxlen = sizeof(int), 699 .mode = 0644, 700 .proc_handler = proc_dointvec 701 }, 702 { 703 .procname = "icmp_msgs_per_sec", 704 .data = &init_net.ipv4.sysctl_icmp_msgs_per_sec, 705 .maxlen = sizeof(int), 706 .mode = 0644, 707 .proc_handler = proc_dointvec_minmax, 708 .extra1 = SYSCTL_ZERO, 709 }, 710 { 711 .procname = "icmp_msgs_burst", 712 .data = &init_net.ipv4.sysctl_icmp_msgs_burst, 713 .maxlen = sizeof(int), 714 .mode = 0644, 715 .proc_handler = proc_dointvec_minmax, 716 .extra1 = SYSCTL_ZERO, 717 }, 718 { 719 .procname = "ping_group_range", 720 .data = &init_net.ipv4.ping_group_range.range, 721 .maxlen = sizeof(gid_t)*2, 722 .mode = 0644, 723 .proc_handler = ipv4_ping_group_range, 724 }, 725 #ifdef CONFIG_NET_L3_MASTER_DEV 726 { 727 .procname = "raw_l3mdev_accept", 728 .data = &init_net.ipv4.sysctl_raw_l3mdev_accept, 729 .maxlen = sizeof(u8), 730 .mode = 0644, 731 .proc_handler = proc_dou8vec_minmax, 732 .extra1 = SYSCTL_ZERO, 733 .extra2 = SYSCTL_ONE, 734 }, 735 #endif 736 { 737 .procname = "tcp_ecn", 738 .data = &init_net.ipv4.sysctl_tcp_ecn, 739 .maxlen = sizeof(u8), 740 .mode = 0644, 741 .proc_handler = proc_dou8vec_minmax, 742 .extra1 = SYSCTL_ZERO, 743 .extra2 = &tcp_ecn_mode_max, 744 }, 745 { 746 .procname = "tcp_ecn_option", 747 .data = &init_net.ipv4.sysctl_tcp_ecn_option, 748 .maxlen = sizeof(u8), 749 .mode = 0644, 750 .proc_handler = proc_dou8vec_minmax, 751 .extra1 = SYSCTL_ZERO, 752 .extra2 = SYSCTL_TWO, 753 }, 754 { 755 .procname = "tcp_ecn_option_beacon", 756 .data = &init_net.ipv4.sysctl_tcp_ecn_option_beacon, 757 .maxlen = sizeof(u8), 758 .mode = 0644, 759 .proc_handler = proc_dou8vec_minmax, 760 .extra1 = SYSCTL_ZERO, 761 .extra2 = SYSCTL_THREE, 762 }, 763 { 764 .procname = "tcp_ecn_fallback", 765 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, 766 .maxlen = sizeof(u8), 767 .mode = 0644, 768 .proc_handler = proc_dou8vec_minmax, 769 .extra1 = SYSCTL_ZERO, 770 .extra2 = SYSCTL_ONE, 771 }, 772 { 773 .procname = "ip_dynaddr", 774 .data = &init_net.ipv4.sysctl_ip_dynaddr, 775 .maxlen = sizeof(u8), 776 .mode = 0644, 777 .proc_handler = proc_dou8vec_minmax, 778 }, 779 { 780 .procname = "ip_early_demux", 781 .data = &init_net.ipv4.sysctl_ip_early_demux, 782 .maxlen = sizeof(u8), 783 .mode = 0644, 784 .proc_handler = proc_dou8vec_minmax, 785 }, 786 { 787 .procname = "udp_early_demux", 788 .data = &init_net.ipv4.sysctl_udp_early_demux, 789 .maxlen = sizeof(u8), 790 .mode = 0644, 791 .proc_handler = proc_dou8vec_minmax, 792 }, 793 { 794 .procname = "tcp_early_demux", 795 .data = &init_net.ipv4.sysctl_tcp_early_demux, 796 .maxlen = sizeof(u8), 797 .mode = 0644, 798 .proc_handler = proc_dou8vec_minmax, 799 }, 800 { 801 .procname = "nexthop_compat_mode", 802 .data = &init_net.ipv4.sysctl_nexthop_compat_mode, 803 .maxlen = sizeof(u8), 804 .mode = 0644, 805 .proc_handler = proc_dou8vec_minmax, 806 .extra1 = SYSCTL_ZERO, 807 .extra2 = SYSCTL_ONE, 808 }, 809 { 810 .procname = "ip_default_ttl", 811 .data = &init_net.ipv4.sysctl_ip_default_ttl, 812 .maxlen = sizeof(u8), 813 .mode = 0644, 814 .proc_handler = proc_dou8vec_minmax, 815 .extra1 = &ip_ttl_min, 816 .extra2 = &ip_ttl_max, 817 }, 818 { 819 .procname = "ip_local_port_range", 820 .maxlen = 0, 821 .data = &init_net, 822 .mode = 0644, 823 .proc_handler = ipv4_local_port_range, 824 }, 825 { 826 .procname = "ip_local_reserved_ports", 827 .data = &init_net.ipv4.sysctl_local_reserved_ports, 828 .maxlen = 65536, 829 .mode = 0644, 830 .proc_handler = proc_do_large_bitmap, 831 }, 832 { 833 .procname = "ip_no_pmtu_disc", 834 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc, 835 .maxlen = sizeof(u8), 836 .mode = 0644, 837 .proc_handler = proc_dou8vec_minmax, 838 }, 839 { 840 .procname = "ip_forward_use_pmtu", 841 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu, 842 .maxlen = sizeof(u8), 843 .mode = 0644, 844 .proc_handler = proc_dou8vec_minmax, 845 }, 846 { 847 .procname = "ip_forward_update_priority", 848 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority, 849 .maxlen = sizeof(u8), 850 .mode = 0644, 851 .proc_handler = ipv4_fwd_update_priority, 852 .extra1 = SYSCTL_ZERO, 853 .extra2 = SYSCTL_ONE, 854 }, 855 { 856 .procname = "ip_nonlocal_bind", 857 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, 858 .maxlen = sizeof(u8), 859 .mode = 0644, 860 .proc_handler = proc_dou8vec_minmax, 861 }, 862 { 863 .procname = "ip_autobind_reuse", 864 .data = &init_net.ipv4.sysctl_ip_autobind_reuse, 865 .maxlen = sizeof(u8), 866 .mode = 0644, 867 .proc_handler = proc_dou8vec_minmax, 868 .extra1 = SYSCTL_ZERO, 869 .extra2 = SYSCTL_ONE, 870 }, 871 { 872 .procname = "fwmark_reflect", 873 .data = &init_net.ipv4.sysctl_fwmark_reflect, 874 .maxlen = sizeof(u8), 875 .mode = 0644, 876 .proc_handler = proc_dou8vec_minmax, 877 }, 878 { 879 .procname = "tcp_fwmark_accept", 880 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept, 881 .maxlen = sizeof(u8), 882 .mode = 0644, 883 .proc_handler = proc_dou8vec_minmax, 884 }, 885 #ifdef CONFIG_NET_L3_MASTER_DEV 886 { 887 .procname = "tcp_l3mdev_accept", 888 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept, 889 .maxlen = sizeof(u8), 890 .mode = 0644, 891 .proc_handler = proc_dou8vec_minmax, 892 .extra1 = SYSCTL_ZERO, 893 .extra2 = SYSCTL_ONE, 894 }, 895 #endif 896 { 897 .procname = "tcp_mtu_probing", 898 .data = &init_net.ipv4.sysctl_tcp_mtu_probing, 899 .maxlen = sizeof(u8), 900 .mode = 0644, 901 .proc_handler = proc_dou8vec_minmax, 902 }, 903 { 904 .procname = "tcp_base_mss", 905 .data = &init_net.ipv4.sysctl_tcp_base_mss, 906 .maxlen = sizeof(int), 907 .mode = 0644, 908 .proc_handler = proc_dointvec, 909 }, 910 { 911 .procname = "tcp_min_snd_mss", 912 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss, 913 .maxlen = sizeof(int), 914 .mode = 0644, 915 .proc_handler = proc_dointvec_minmax, 916 .extra1 = &tcp_min_snd_mss_min, 917 .extra2 = &tcp_min_snd_mss_max, 918 }, 919 { 920 .procname = "tcp_mtu_probe_floor", 921 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor, 922 .maxlen = sizeof(int), 923 .mode = 0644, 924 .proc_handler = proc_dointvec_minmax, 925 .extra1 = &tcp_min_snd_mss_min, 926 .extra2 = &tcp_min_snd_mss_max, 927 }, 928 { 929 .procname = "tcp_probe_threshold", 930 .data = &init_net.ipv4.sysctl_tcp_probe_threshold, 931 .maxlen = sizeof(int), 932 .mode = 0644, 933 .proc_handler = proc_dointvec, 934 }, 935 { 936 .procname = "tcp_probe_interval", 937 .data = &init_net.ipv4.sysctl_tcp_probe_interval, 938 .maxlen = sizeof(u32), 939 .mode = 0644, 940 .proc_handler = proc_douintvec_minmax, 941 .extra2 = &u32_max_div_HZ, 942 }, 943 { 944 .procname = "igmp_link_local_mcast_reports", 945 .data = &init_net.ipv4.sysctl_igmp_llm_reports, 946 .maxlen = sizeof(u8), 947 .mode = 0644, 948 .proc_handler = proc_dou8vec_minmax, 949 }, 950 { 951 .procname = "igmp_max_memberships", 952 .data = &init_net.ipv4.sysctl_igmp_max_memberships, 953 .maxlen = sizeof(int), 954 .mode = 0644, 955 .proc_handler = proc_dointvec 956 }, 957 { 958 .procname = "igmp_max_msf", 959 .data = &init_net.ipv4.sysctl_igmp_max_msf, 960 .maxlen = sizeof(int), 961 .mode = 0644, 962 .proc_handler = proc_dointvec 963 }, 964 #ifdef CONFIG_IP_MULTICAST 965 { 966 .procname = "igmp_qrv", 967 .data = &init_net.ipv4.sysctl_igmp_qrv, 968 .maxlen = sizeof(int), 969 .mode = 0644, 970 .proc_handler = proc_dointvec_minmax, 971 .extra1 = SYSCTL_ONE 972 }, 973 #endif 974 { 975 .procname = "tcp_congestion_control", 976 .data = &init_net.ipv4.tcp_congestion_control, 977 .mode = 0644, 978 .maxlen = TCP_CA_NAME_MAX, 979 .proc_handler = proc_tcp_congestion_control, 980 }, 981 { 982 .procname = "tcp_available_congestion_control", 983 .maxlen = TCP_CA_BUF_MAX, 984 .mode = 0444, 985 .proc_handler = proc_tcp_available_congestion_control, 986 }, 987 { 988 .procname = "tcp_allowed_congestion_control", 989 .maxlen = TCP_CA_BUF_MAX, 990 .mode = 0644, 991 .proc_handler = proc_allowed_congestion_control, 992 }, 993 { 994 .procname = "tcp_keepalive_time", 995 .data = &init_net.ipv4.sysctl_tcp_keepalive_time, 996 .maxlen = sizeof(int), 997 .mode = 0644, 998 .proc_handler = proc_dointvec_jiffies, 999 }, 1000 { 1001 .procname = "tcp_keepalive_probes", 1002 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes, 1003 .maxlen = sizeof(u8), 1004 .mode = 0644, 1005 .proc_handler = proc_dou8vec_minmax, 1006 }, 1007 { 1008 .procname = "tcp_keepalive_intvl", 1009 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl, 1010 .maxlen = sizeof(int), 1011 .mode = 0644, 1012 .proc_handler = proc_dointvec_jiffies, 1013 }, 1014 { 1015 .procname = "tcp_syn_retries", 1016 .data = &init_net.ipv4.sysctl_tcp_syn_retries, 1017 .maxlen = sizeof(u8), 1018 .mode = 0644, 1019 .proc_handler = proc_dou8vec_minmax, 1020 .extra1 = &tcp_syn_retries_min, 1021 .extra2 = &tcp_syn_retries_max 1022 }, 1023 { 1024 .procname = "tcp_synack_retries", 1025 .data = &init_net.ipv4.sysctl_tcp_synack_retries, 1026 .maxlen = sizeof(u8), 1027 .mode = 0644, 1028 .proc_handler = proc_dou8vec_minmax, 1029 }, 1030 #ifdef CONFIG_SYN_COOKIES 1031 { 1032 .procname = "tcp_syncookies", 1033 .data = &init_net.ipv4.sysctl_tcp_syncookies, 1034 .maxlen = sizeof(u8), 1035 .mode = 0644, 1036 .proc_handler = proc_dou8vec_minmax, 1037 }, 1038 #endif 1039 { 1040 .procname = "tcp_migrate_req", 1041 .data = &init_net.ipv4.sysctl_tcp_migrate_req, 1042 .maxlen = sizeof(u8), 1043 .mode = 0644, 1044 .proc_handler = proc_dou8vec_minmax, 1045 .extra1 = SYSCTL_ZERO, 1046 .extra2 = SYSCTL_ONE 1047 }, 1048 { 1049 .procname = "tcp_reordering", 1050 .data = &init_net.ipv4.sysctl_tcp_reordering, 1051 .maxlen = sizeof(int), 1052 .mode = 0644, 1053 .proc_handler = proc_dointvec 1054 }, 1055 { 1056 .procname = "tcp_retries1", 1057 .data = &init_net.ipv4.sysctl_tcp_retries1, 1058 .maxlen = sizeof(u8), 1059 .mode = 0644, 1060 .proc_handler = proc_dou8vec_minmax, 1061 .extra2 = &tcp_retr1_max 1062 }, 1063 { 1064 .procname = "tcp_retries2", 1065 .data = &init_net.ipv4.sysctl_tcp_retries2, 1066 .maxlen = sizeof(u8), 1067 .mode = 0644, 1068 .proc_handler = proc_dou8vec_minmax, 1069 }, 1070 { 1071 .procname = "tcp_orphan_retries", 1072 .data = &init_net.ipv4.sysctl_tcp_orphan_retries, 1073 .maxlen = sizeof(u8), 1074 .mode = 0644, 1075 .proc_handler = proc_dou8vec_minmax, 1076 }, 1077 { 1078 .procname = "tcp_fin_timeout", 1079 .data = &init_net.ipv4.sysctl_tcp_fin_timeout, 1080 .maxlen = sizeof(int), 1081 .mode = 0644, 1082 .proc_handler = proc_dointvec_jiffies, 1083 }, 1084 { 1085 .procname = "tcp_notsent_lowat", 1086 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, 1087 .maxlen = sizeof(unsigned int), 1088 .mode = 0644, 1089 .proc_handler = proc_douintvec, 1090 }, 1091 { 1092 .procname = "tcp_tw_reuse", 1093 .data = &init_net.ipv4.sysctl_tcp_tw_reuse, 1094 .maxlen = sizeof(u8), 1095 .mode = 0644, 1096 .proc_handler = proc_dou8vec_minmax, 1097 .extra1 = SYSCTL_ZERO, 1098 .extra2 = SYSCTL_TWO, 1099 }, 1100 { 1101 .procname = "tcp_tw_reuse_delay", 1102 .data = &init_net.ipv4.sysctl_tcp_tw_reuse_delay, 1103 .maxlen = sizeof(unsigned int), 1104 .mode = 0644, 1105 .proc_handler = proc_douintvec_minmax, 1106 .extra1 = SYSCTL_ONE, 1107 .extra2 = &tcp_tw_reuse_delay_max, 1108 }, 1109 { 1110 .procname = "tcp_max_syn_backlog", 1111 .data = &init_net.ipv4.sysctl_max_syn_backlog, 1112 .maxlen = sizeof(int), 1113 .mode = 0644, 1114 .proc_handler = proc_dointvec 1115 }, 1116 { 1117 .procname = "tcp_fastopen", 1118 .data = &init_net.ipv4.sysctl_tcp_fastopen, 1119 .maxlen = sizeof(int), 1120 .mode = 0644, 1121 .proc_handler = proc_dointvec, 1122 }, 1123 { 1124 .procname = "tcp_fastopen_key", 1125 .mode = 0600, 1126 .data = &init_net.ipv4.sysctl_tcp_fastopen, 1127 /* maxlen to print the list of keys in hex (*2), with dashes 1128 * separating doublewords and a comma in between keys. 1129 */ 1130 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 1131 2 * TCP_FASTOPEN_KEY_MAX) + 1132 (TCP_FASTOPEN_KEY_MAX * 5)), 1133 .proc_handler = proc_tcp_fastopen_key, 1134 }, 1135 { 1136 .procname = "tcp_fastopen_blackhole_timeout_sec", 1137 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout, 1138 .maxlen = sizeof(int), 1139 .mode = 0644, 1140 .proc_handler = proc_tfo_blackhole_detect_timeout, 1141 .extra1 = SYSCTL_ZERO, 1142 }, 1143 #ifdef CONFIG_IP_ROUTE_MULTIPATH 1144 { 1145 .procname = "fib_multipath_use_neigh", 1146 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh, 1147 .maxlen = sizeof(u8), 1148 .mode = 0644, 1149 .proc_handler = proc_dou8vec_minmax, 1150 .extra1 = SYSCTL_ZERO, 1151 .extra2 = SYSCTL_ONE, 1152 }, 1153 { 1154 .procname = "fib_multipath_hash_policy", 1155 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, 1156 .maxlen = sizeof(u8), 1157 .mode = 0644, 1158 .proc_handler = proc_fib_multipath_hash_policy, 1159 .extra1 = SYSCTL_ZERO, 1160 .extra2 = SYSCTL_THREE, 1161 }, 1162 { 1163 .procname = "fib_multipath_hash_fields", 1164 .data = &init_net.ipv4.sysctl_fib_multipath_hash_fields, 1165 .maxlen = sizeof(u32), 1166 .mode = 0644, 1167 .proc_handler = proc_fib_multipath_hash_fields, 1168 .extra1 = SYSCTL_ONE, 1169 .extra2 = &fib_multipath_hash_fields_all_mask, 1170 }, 1171 { 1172 .procname = "fib_multipath_hash_seed", 1173 .data = &init_net, 1174 .maxlen = sizeof(u32), 1175 .mode = 0644, 1176 .proc_handler = proc_fib_multipath_hash_seed, 1177 }, 1178 #endif 1179 { 1180 .procname = "ip_unprivileged_port_start", 1181 .maxlen = sizeof(int), 1182 .data = &init_net.ipv4.sysctl_ip_prot_sock, 1183 .mode = 0644, 1184 .proc_handler = ipv4_privileged_ports, 1185 }, 1186 #ifdef CONFIG_NET_L3_MASTER_DEV 1187 { 1188 .procname = "udp_l3mdev_accept", 1189 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept, 1190 .maxlen = sizeof(u8), 1191 .mode = 0644, 1192 .proc_handler = proc_dou8vec_minmax, 1193 .extra1 = SYSCTL_ZERO, 1194 .extra2 = SYSCTL_ONE, 1195 }, 1196 #endif 1197 { 1198 .procname = "tcp_sack", 1199 .data = &init_net.ipv4.sysctl_tcp_sack, 1200 .maxlen = sizeof(u8), 1201 .mode = 0644, 1202 .proc_handler = proc_dou8vec_minmax, 1203 }, 1204 { 1205 .procname = "tcp_window_scaling", 1206 .data = &init_net.ipv4.sysctl_tcp_window_scaling, 1207 .maxlen = sizeof(u8), 1208 .mode = 0644, 1209 .proc_handler = proc_dou8vec_minmax, 1210 }, 1211 { 1212 .procname = "tcp_timestamps", 1213 .data = &init_net.ipv4.sysctl_tcp_timestamps, 1214 .maxlen = sizeof(u8), 1215 .mode = 0644, 1216 .proc_handler = proc_dou8vec_minmax, 1217 }, 1218 { 1219 .procname = "tcp_early_retrans", 1220 .data = &init_net.ipv4.sysctl_tcp_early_retrans, 1221 .maxlen = sizeof(u8), 1222 .mode = 0644, 1223 .proc_handler = proc_dou8vec_minmax, 1224 .extra1 = SYSCTL_ZERO, 1225 .extra2 = SYSCTL_FOUR, 1226 }, 1227 { 1228 .procname = "tcp_recovery", 1229 .data = &init_net.ipv4.sysctl_tcp_recovery, 1230 .maxlen = sizeof(u8), 1231 .mode = 0644, 1232 .proc_handler = proc_dou8vec_minmax, 1233 }, 1234 { 1235 .procname = "tcp_thin_linear_timeouts", 1236 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts, 1237 .maxlen = sizeof(u8), 1238 .mode = 0644, 1239 .proc_handler = proc_dou8vec_minmax, 1240 }, 1241 { 1242 .procname = "tcp_slow_start_after_idle", 1243 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle, 1244 .maxlen = sizeof(u8), 1245 .mode = 0644, 1246 .proc_handler = proc_dou8vec_minmax, 1247 }, 1248 { 1249 .procname = "tcp_retrans_collapse", 1250 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse, 1251 .maxlen = sizeof(u8), 1252 .mode = 0644, 1253 .proc_handler = proc_dou8vec_minmax, 1254 }, 1255 { 1256 .procname = "tcp_stdurg", 1257 .data = &init_net.ipv4.sysctl_tcp_stdurg, 1258 .maxlen = sizeof(u8), 1259 .mode = 0644, 1260 .proc_handler = proc_dou8vec_minmax, 1261 }, 1262 { 1263 .procname = "tcp_rfc1337", 1264 .data = &init_net.ipv4.sysctl_tcp_rfc1337, 1265 .maxlen = sizeof(u8), 1266 .mode = 0644, 1267 .proc_handler = proc_dou8vec_minmax, 1268 }, 1269 { 1270 .procname = "tcp_abort_on_overflow", 1271 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow, 1272 .maxlen = sizeof(u8), 1273 .mode = 0644, 1274 .proc_handler = proc_dou8vec_minmax, 1275 }, 1276 { 1277 .procname = "tcp_fack", 1278 .data = &init_net.ipv4.sysctl_tcp_fack, 1279 .maxlen = sizeof(u8), 1280 .mode = 0644, 1281 .proc_handler = proc_dou8vec_minmax, 1282 }, 1283 { 1284 .procname = "tcp_max_reordering", 1285 .data = &init_net.ipv4.sysctl_tcp_max_reordering, 1286 .maxlen = sizeof(int), 1287 .mode = 0644, 1288 .proc_handler = proc_dointvec 1289 }, 1290 { 1291 .procname = "tcp_dsack", 1292 .data = &init_net.ipv4.sysctl_tcp_dsack, 1293 .maxlen = sizeof(u8), 1294 .mode = 0644, 1295 .proc_handler = proc_dou8vec_minmax, 1296 }, 1297 { 1298 .procname = "tcp_app_win", 1299 .data = &init_net.ipv4.sysctl_tcp_app_win, 1300 .maxlen = sizeof(u8), 1301 .mode = 0644, 1302 .proc_handler = proc_dou8vec_minmax, 1303 .extra1 = SYSCTL_ZERO, 1304 .extra2 = &tcp_app_win_max, 1305 }, 1306 { 1307 .procname = "tcp_adv_win_scale", 1308 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale, 1309 .maxlen = sizeof(int), 1310 .mode = 0644, 1311 .proc_handler = proc_dointvec_minmax, 1312 .extra1 = &tcp_adv_win_scale_min, 1313 .extra2 = &tcp_adv_win_scale_max, 1314 }, 1315 { 1316 .procname = "tcp_frto", 1317 .data = &init_net.ipv4.sysctl_tcp_frto, 1318 .maxlen = sizeof(u8), 1319 .mode = 0644, 1320 .proc_handler = proc_dou8vec_minmax, 1321 }, 1322 { 1323 .procname = "tcp_no_metrics_save", 1324 .data = &init_net.ipv4.sysctl_tcp_nometrics_save, 1325 .maxlen = sizeof(u8), 1326 .mode = 0644, 1327 .proc_handler = proc_dou8vec_minmax, 1328 }, 1329 { 1330 .procname = "tcp_no_ssthresh_metrics_save", 1331 .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save, 1332 .maxlen = sizeof(u8), 1333 .mode = 0644, 1334 .proc_handler = proc_dou8vec_minmax, 1335 .extra1 = SYSCTL_ZERO, 1336 .extra2 = SYSCTL_ONE, 1337 }, 1338 { 1339 .procname = "tcp_moderate_rcvbuf", 1340 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf, 1341 .maxlen = sizeof(u8), 1342 .mode = 0644, 1343 .proc_handler = proc_dou8vec_minmax, 1344 }, 1345 { 1346 .procname = "tcp_rcvbuf_low_rtt", 1347 .data = &init_net.ipv4.sysctl_tcp_rcvbuf_low_rtt, 1348 .maxlen = sizeof(int), 1349 .mode = 0644, 1350 .proc_handler = proc_dointvec_minmax, 1351 .extra1 = SYSCTL_ZERO, 1352 .extra2 = SYSCTL_INT_MAX, 1353 }, 1354 { 1355 .procname = "tcp_tso_win_divisor", 1356 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor, 1357 .maxlen = sizeof(u8), 1358 .mode = 0644, 1359 .proc_handler = proc_dou8vec_minmax, 1360 }, 1361 { 1362 .procname = "tcp_workaround_signed_windows", 1363 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows, 1364 .maxlen = sizeof(u8), 1365 .mode = 0644, 1366 .proc_handler = proc_dou8vec_minmax, 1367 }, 1368 { 1369 .procname = "tcp_limit_output_bytes", 1370 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes, 1371 .maxlen = sizeof(int), 1372 .mode = 0644, 1373 .proc_handler = proc_dointvec 1374 }, 1375 { 1376 .procname = "tcp_challenge_ack_limit", 1377 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit, 1378 .maxlen = sizeof(int), 1379 .mode = 0644, 1380 .proc_handler = proc_dointvec 1381 }, 1382 { 1383 .procname = "tcp_min_tso_segs", 1384 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs, 1385 .maxlen = sizeof(u8), 1386 .mode = 0644, 1387 .proc_handler = proc_dou8vec_minmax, 1388 .extra1 = SYSCTL_ONE, 1389 }, 1390 { 1391 .procname = "tcp_tso_rtt_log", 1392 .data = &init_net.ipv4.sysctl_tcp_tso_rtt_log, 1393 .maxlen = sizeof(u8), 1394 .mode = 0644, 1395 .proc_handler = proc_dou8vec_minmax, 1396 }, 1397 { 1398 .procname = "tcp_min_rtt_wlen", 1399 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen, 1400 .maxlen = sizeof(int), 1401 .mode = 0644, 1402 .proc_handler = proc_dointvec_minmax, 1403 .extra1 = SYSCTL_ZERO, 1404 .extra2 = &one_day_secs 1405 }, 1406 { 1407 .procname = "tcp_autocorking", 1408 .data = &init_net.ipv4.sysctl_tcp_autocorking, 1409 .maxlen = sizeof(u8), 1410 .mode = 0644, 1411 .proc_handler = proc_dou8vec_minmax, 1412 .extra1 = SYSCTL_ZERO, 1413 .extra2 = SYSCTL_ONE, 1414 }, 1415 { 1416 .procname = "tcp_invalid_ratelimit", 1417 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit, 1418 .maxlen = sizeof(int), 1419 .mode = 0644, 1420 .proc_handler = proc_dointvec_ms_jiffies, 1421 }, 1422 { 1423 .procname = "tcp_pacing_ss_ratio", 1424 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio, 1425 .maxlen = sizeof(int), 1426 .mode = 0644, 1427 .proc_handler = proc_dointvec_minmax, 1428 .extra1 = SYSCTL_ZERO, 1429 .extra2 = SYSCTL_ONE_THOUSAND, 1430 }, 1431 { 1432 .procname = "tcp_pacing_ca_ratio", 1433 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio, 1434 .maxlen = sizeof(int), 1435 .mode = 0644, 1436 .proc_handler = proc_dointvec_minmax, 1437 .extra1 = SYSCTL_ZERO, 1438 .extra2 = SYSCTL_ONE_THOUSAND, 1439 }, 1440 { 1441 .procname = "tcp_wmem", 1442 .data = &init_net.ipv4.sysctl_tcp_wmem, 1443 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem), 1444 .mode = 0644, 1445 .proc_handler = proc_dointvec_minmax, 1446 .extra1 = SYSCTL_ONE, 1447 }, 1448 { 1449 .procname = "tcp_rmem", 1450 .data = &init_net.ipv4.sysctl_tcp_rmem, 1451 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem), 1452 .mode = 0644, 1453 .proc_handler = proc_dointvec_minmax, 1454 .extra1 = SYSCTL_ONE, 1455 }, 1456 { 1457 .procname = "tcp_comp_sack_delay_ns", 1458 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns, 1459 .maxlen = sizeof(unsigned long), 1460 .mode = 0644, 1461 .proc_handler = proc_doulongvec_minmax, 1462 }, 1463 { 1464 .procname = "tcp_comp_sack_rtt_percent", 1465 .data = &init_net.ipv4.sysctl_tcp_comp_sack_rtt_percent, 1466 .maxlen = sizeof(int), 1467 .mode = 0644, 1468 .proc_handler = proc_dointvec_minmax, 1469 .extra1 = SYSCTL_ONE, 1470 .extra2 = SYSCTL_ONE_THOUSAND, 1471 }, 1472 { 1473 .procname = "tcp_comp_sack_slack_ns", 1474 .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns, 1475 .maxlen = sizeof(unsigned long), 1476 .mode = 0644, 1477 .proc_handler = proc_doulongvec_minmax, 1478 }, 1479 { 1480 .procname = "tcp_comp_sack_nr", 1481 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr, 1482 .maxlen = sizeof(u8), 1483 .mode = 0644, 1484 .proc_handler = proc_dou8vec_minmax, 1485 .extra1 = SYSCTL_ZERO, 1486 }, 1487 { 1488 .procname = "tcp_backlog_ack_defer", 1489 .data = &init_net.ipv4.sysctl_tcp_backlog_ack_defer, 1490 .maxlen = sizeof(u8), 1491 .mode = 0644, 1492 .proc_handler = proc_dou8vec_minmax, 1493 .extra1 = SYSCTL_ZERO, 1494 .extra2 = SYSCTL_ONE, 1495 }, 1496 { 1497 .procname = "tcp_reflect_tos", 1498 .data = &init_net.ipv4.sysctl_tcp_reflect_tos, 1499 .maxlen = sizeof(u8), 1500 .mode = 0644, 1501 .proc_handler = proc_dou8vec_minmax, 1502 .extra1 = SYSCTL_ZERO, 1503 .extra2 = SYSCTL_ONE, 1504 }, 1505 { 1506 .procname = "tcp_ehash_entries", 1507 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries, 1508 .mode = 0444, 1509 .proc_handler = proc_tcp_ehash_entries, 1510 }, 1511 { 1512 .procname = "tcp_child_ehash_entries", 1513 .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries, 1514 .maxlen = sizeof(unsigned int), 1515 .mode = 0644, 1516 .proc_handler = proc_douintvec_minmax, 1517 .extra1 = SYSCTL_ZERO, 1518 .extra2 = &tcp_child_ehash_entries_max, 1519 }, 1520 { 1521 .procname = "udp_hash_entries", 1522 .data = &init_net.ipv4.sysctl_udp_child_hash_entries, 1523 .mode = 0444, 1524 .proc_handler = proc_udp_hash_entries, 1525 }, 1526 { 1527 .procname = "udp_child_hash_entries", 1528 .data = &init_net.ipv4.sysctl_udp_child_hash_entries, 1529 .maxlen = sizeof(unsigned int), 1530 .mode = 0644, 1531 .proc_handler = proc_douintvec_minmax, 1532 .extra1 = SYSCTL_ZERO, 1533 .extra2 = &udp_child_hash_entries_max, 1534 }, 1535 { 1536 .procname = "udp_rmem_min", 1537 .data = &init_net.ipv4.sysctl_udp_rmem_min, 1538 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min), 1539 .mode = 0644, 1540 .proc_handler = proc_dointvec_minmax, 1541 .extra1 = SYSCTL_ONE 1542 }, 1543 { 1544 .procname = "udp_wmem_min", 1545 .data = &init_net.ipv4.sysctl_udp_wmem_min, 1546 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min), 1547 .mode = 0644, 1548 .proc_handler = proc_dointvec_minmax, 1549 .extra1 = SYSCTL_ONE 1550 }, 1551 { 1552 .procname = "fib_notify_on_flag_change", 1553 .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change, 1554 .maxlen = sizeof(u8), 1555 .mode = 0644, 1556 .proc_handler = proc_dou8vec_minmax, 1557 .extra1 = SYSCTL_ZERO, 1558 .extra2 = SYSCTL_TWO, 1559 }, 1560 { 1561 .procname = "tcp_plb_enabled", 1562 .data = &init_net.ipv4.sysctl_tcp_plb_enabled, 1563 .maxlen = sizeof(u8), 1564 .mode = 0644, 1565 .proc_handler = proc_dou8vec_minmax, 1566 .extra1 = SYSCTL_ZERO, 1567 .extra2 = SYSCTL_ONE, 1568 }, 1569 { 1570 .procname = "tcp_plb_idle_rehash_rounds", 1571 .data = &init_net.ipv4.sysctl_tcp_plb_idle_rehash_rounds, 1572 .maxlen = sizeof(u8), 1573 .mode = 0644, 1574 .proc_handler = proc_dou8vec_minmax, 1575 .extra2 = &tcp_plb_max_rounds, 1576 }, 1577 { 1578 .procname = "tcp_plb_rehash_rounds", 1579 .data = &init_net.ipv4.sysctl_tcp_plb_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_suspend_rto_sec", 1587 .data = &init_net.ipv4.sysctl_tcp_plb_suspend_rto_sec, 1588 .maxlen = sizeof(u8), 1589 .mode = 0644, 1590 .proc_handler = proc_dou8vec_minmax, 1591 }, 1592 { 1593 .procname = "tcp_plb_cong_thresh", 1594 .data = &init_net.ipv4.sysctl_tcp_plb_cong_thresh, 1595 .maxlen = sizeof(int), 1596 .mode = 0644, 1597 .proc_handler = proc_dointvec_minmax, 1598 .extra1 = SYSCTL_ZERO, 1599 .extra2 = &tcp_plb_max_cong_thresh, 1600 }, 1601 { 1602 .procname = "tcp_syn_linear_timeouts", 1603 .data = &init_net.ipv4.sysctl_tcp_syn_linear_timeouts, 1604 .maxlen = sizeof(u8), 1605 .mode = 0644, 1606 .proc_handler = proc_dou8vec_minmax, 1607 .extra1 = SYSCTL_ZERO, 1608 .extra2 = &tcp_syn_linear_timeouts_max, 1609 }, 1610 { 1611 .procname = "tcp_shrink_window", 1612 .data = &init_net.ipv4.sysctl_tcp_shrink_window, 1613 .maxlen = sizeof(u8), 1614 .mode = 0644, 1615 .proc_handler = proc_dou8vec_minmax, 1616 .extra1 = SYSCTL_ZERO, 1617 .extra2 = SYSCTL_ONE, 1618 }, 1619 { 1620 .procname = "tcp_pingpong_thresh", 1621 .data = &init_net.ipv4.sysctl_tcp_pingpong_thresh, 1622 .maxlen = sizeof(u8), 1623 .mode = 0644, 1624 .proc_handler = proc_dou8vec_minmax, 1625 .extra1 = SYSCTL_ONE, 1626 }, 1627 { 1628 .procname = "tcp_rto_min_us", 1629 .data = &init_net.ipv4.sysctl_tcp_rto_min_us, 1630 .maxlen = sizeof(int), 1631 .mode = 0644, 1632 .proc_handler = proc_dointvec_minmax, 1633 .extra1 = SYSCTL_ONE, 1634 }, 1635 { 1636 .procname = "tcp_rto_max_ms", 1637 .data = &init_net.ipv4.sysctl_tcp_rto_max_ms, 1638 .maxlen = sizeof(int), 1639 .mode = 0644, 1640 .proc_handler = proc_dointvec_minmax, 1641 .extra1 = SYSCTL_ONE_THOUSAND, 1642 .extra2 = &tcp_rto_max_max, 1643 }, 1644 }; 1645 1646 static __net_init int ipv4_sysctl_init_net(struct net *net) 1647 { 1648 size_t table_size = ARRAY_SIZE(ipv4_net_table); 1649 struct ctl_table *table; 1650 1651 table = ipv4_net_table; 1652 if (!net_eq(net, &init_net)) { 1653 int i; 1654 1655 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); 1656 if (!table) 1657 goto err_alloc; 1658 1659 for (i = 0; i < table_size; i++) { 1660 if (table[i].data) { 1661 /* Update the variables to point into 1662 * the current struct net 1663 */ 1664 table[i].data += (void *)net - (void *)&init_net; 1665 } else { 1666 /* Entries without data pointer are global; 1667 * Make them read-only in non-init_net ns 1668 */ 1669 table[i].mode &= ~0222; 1670 } 1671 } 1672 } 1673 1674 net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table, 1675 table_size); 1676 if (!net->ipv4.ipv4_hdr) 1677 goto err_reg; 1678 1679 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL); 1680 if (!net->ipv4.sysctl_local_reserved_ports) 1681 goto err_ports; 1682 1683 proc_fib_multipath_hash_set_seed(net, 0); 1684 1685 return 0; 1686 1687 err_ports: 1688 unregister_net_sysctl_table(net->ipv4.ipv4_hdr); 1689 err_reg: 1690 if (!net_eq(net, &init_net)) 1691 kfree(table); 1692 err_alloc: 1693 return -ENOMEM; 1694 } 1695 1696 static __net_exit void ipv4_sysctl_exit_net(struct net *net) 1697 { 1698 const struct ctl_table *table; 1699 1700 kfree(net->ipv4.sysctl_local_reserved_ports); 1701 table = net->ipv4.ipv4_hdr->ctl_table_arg; 1702 unregister_net_sysctl_table(net->ipv4.ipv4_hdr); 1703 kfree(table); 1704 } 1705 1706 static __net_initdata struct pernet_operations ipv4_sysctl_ops = { 1707 .init = ipv4_sysctl_init_net, 1708 .exit = ipv4_sysctl_exit_net, 1709 }; 1710 1711 static __init int sysctl_ipv4_init(void) 1712 { 1713 struct ctl_table_header *hdr; 1714 1715 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table); 1716 if (!hdr) 1717 return -ENOMEM; 1718 1719 proc_fib_multipath_hash_init_rand_seed(); 1720 1721 if (register_pernet_subsys(&ipv4_sysctl_ops)) { 1722 unregister_net_sysctl_table(hdr); 1723 return -ENOMEM; 1724 } 1725 1726 return 0; 1727 } 1728 1729 __initcall(sysctl_ipv4_init); 1730