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/mm.h> 10 #include <linux/module.h> 11 #include <linux/sysctl.h> 12 #include <linux/igmp.h> 13 #include <linux/inetdevice.h> 14 #include <linux/seqlock.h> 15 #include <linux/init.h> 16 #include <linux/slab.h> 17 #include <linux/nsproxy.h> 18 #include <linux/swap.h> 19 #include <net/snmp.h> 20 #include <net/icmp.h> 21 #include <net/ip.h> 22 #include <net/route.h> 23 #include <net/tcp.h> 24 #include <net/udp.h> 25 #include <net/cipso_ipv4.h> 26 #include <net/inet_frag.h> 27 #include <net/ping.h> 28 #include <net/protocol.h> 29 #include <net/netevent.h> 30 31 static int two = 2; 32 static int four = 4; 33 static int thousand = 1000; 34 static int tcp_retr1_max = 255; 35 static int ip_local_port_range_min[] = { 1, 1 }; 36 static int ip_local_port_range_max[] = { 65535, 65535 }; 37 static int tcp_adv_win_scale_min = -31; 38 static int tcp_adv_win_scale_max = 31; 39 static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS; 40 static int tcp_min_snd_mss_max = 65535; 41 static int ip_privileged_port_min; 42 static int ip_privileged_port_max = 65535; 43 static int ip_ttl_min = 1; 44 static int ip_ttl_max = 255; 45 static int tcp_syn_retries_min = 1; 46 static int tcp_syn_retries_max = MAX_TCP_SYNCNT; 47 static int ip_ping_group_range_min[] = { 0, 0 }; 48 static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; 49 static u32 u32_max_div_HZ = UINT_MAX / HZ; 50 static int one_day_secs = 24 * 3600; 51 52 /* obsolete */ 53 static int sysctl_tcp_low_latency __read_mostly; 54 55 /* Update system visible IP port range */ 56 static void set_local_port_range(struct net *net, int range[2]) 57 { 58 bool same_parity = !((range[0] ^ range[1]) & 1); 59 60 write_seqlock_bh(&net->ipv4.ip_local_ports.lock); 61 if (same_parity && !net->ipv4.ip_local_ports.warned) { 62 net->ipv4.ip_local_ports.warned = true; 63 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n"); 64 } 65 net->ipv4.ip_local_ports.range[0] = range[0]; 66 net->ipv4.ip_local_ports.range[1] = range[1]; 67 write_sequnlock_bh(&net->ipv4.ip_local_ports.lock); 68 } 69 70 /* Validate changes from /proc interface. */ 71 static int ipv4_local_port_range(struct ctl_table *table, int write, 72 void *buffer, size_t *lenp, loff_t *ppos) 73 { 74 struct net *net = 75 container_of(table->data, struct net, ipv4.ip_local_ports.range); 76 int ret; 77 int range[2]; 78 struct ctl_table tmp = { 79 .data = &range, 80 .maxlen = sizeof(range), 81 .mode = table->mode, 82 .extra1 = &ip_local_port_range_min, 83 .extra2 = &ip_local_port_range_max, 84 }; 85 86 inet_get_local_port_range(net, &range[0], &range[1]); 87 88 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 89 90 if (write && ret == 0) { 91 /* Ensure that the upper limit is not smaller than the lower, 92 * and that the lower does not encroach upon the privileged 93 * port limit. 94 */ 95 if ((range[1] < range[0]) || 96 (range[0] < net->ipv4.sysctl_ip_prot_sock)) 97 ret = -EINVAL; 98 else 99 set_local_port_range(net, range); 100 } 101 102 return ret; 103 } 104 105 /* Validate changes from /proc interface. */ 106 static int ipv4_privileged_ports(struct ctl_table *table, int write, 107 void *buffer, size_t *lenp, loff_t *ppos) 108 { 109 struct net *net = container_of(table->data, struct net, 110 ipv4.sysctl_ip_prot_sock); 111 int ret; 112 int pports; 113 int range[2]; 114 struct ctl_table tmp = { 115 .data = &pports, 116 .maxlen = sizeof(pports), 117 .mode = table->mode, 118 .extra1 = &ip_privileged_port_min, 119 .extra2 = &ip_privileged_port_max, 120 }; 121 122 pports = net->ipv4.sysctl_ip_prot_sock; 123 124 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 125 126 if (write && ret == 0) { 127 inet_get_local_port_range(net, &range[0], &range[1]); 128 /* Ensure that the local port range doesn't overlap with the 129 * privileged port range. 130 */ 131 if (range[0] < pports) 132 ret = -EINVAL; 133 else 134 net->ipv4.sysctl_ip_prot_sock = pports; 135 } 136 137 return ret; 138 } 139 140 static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high) 141 { 142 kgid_t *data = table->data; 143 struct net *net = 144 container_of(table->data, struct net, ipv4.ping_group_range.range); 145 unsigned int seq; 146 do { 147 seq = read_seqbegin(&net->ipv4.ping_group_range.lock); 148 149 *low = data[0]; 150 *high = data[1]; 151 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq)); 152 } 153 154 /* Update system visible IP port range */ 155 static void set_ping_group_range(struct ctl_table *table, 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(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 gid_t 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_dointvec_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(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(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(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(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(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 void proc_configure_early_demux(int enabled, int protocol) 363 { 364 struct net_protocol *ipprot; 365 #if IS_ENABLED(CONFIG_IPV6) 366 struct inet6_protocol *ip6prot; 367 #endif 368 369 rcu_read_lock(); 370 371 ipprot = rcu_dereference(inet_protos[protocol]); 372 if (ipprot) 373 ipprot->early_demux = enabled ? ipprot->early_demux_handler : 374 NULL; 375 376 #if IS_ENABLED(CONFIG_IPV6) 377 ip6prot = rcu_dereference(inet6_protos[protocol]); 378 if (ip6prot) 379 ip6prot->early_demux = enabled ? ip6prot->early_demux_handler : 380 NULL; 381 #endif 382 rcu_read_unlock(); 383 } 384 385 static int proc_tcp_early_demux(struct ctl_table *table, int write, 386 void *buffer, size_t *lenp, loff_t *ppos) 387 { 388 int ret = 0; 389 390 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos); 391 392 if (write && !ret) { 393 int enabled = init_net.ipv4.sysctl_tcp_early_demux; 394 395 proc_configure_early_demux(enabled, IPPROTO_TCP); 396 } 397 398 return ret; 399 } 400 401 static int proc_udp_early_demux(struct ctl_table *table, int write, 402 void *buffer, size_t *lenp, loff_t *ppos) 403 { 404 int ret = 0; 405 406 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos); 407 408 if (write && !ret) { 409 int enabled = init_net.ipv4.sysctl_udp_early_demux; 410 411 proc_configure_early_demux(enabled, IPPROTO_UDP); 412 } 413 414 return ret; 415 } 416 417 static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table, 418 int write, void *buffer, 419 size_t *lenp, loff_t *ppos) 420 { 421 struct net *net = container_of(table->data, struct net, 422 ipv4.sysctl_tcp_fastopen_blackhole_timeout); 423 int ret; 424 425 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 426 if (write && ret == 0) 427 atomic_set(&net->ipv4.tfo_active_disable_times, 0); 428 429 return ret; 430 } 431 432 static int proc_tcp_available_ulp(struct ctl_table *ctl, 433 int write, void *buffer, size_t *lenp, 434 loff_t *ppos) 435 { 436 struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, }; 437 int ret; 438 439 tbl.data = kmalloc(tbl.maxlen, GFP_USER); 440 if (!tbl.data) 441 return -ENOMEM; 442 tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX); 443 ret = proc_dostring(&tbl, write, buffer, lenp, ppos); 444 kfree(tbl.data); 445 446 return ret; 447 } 448 449 #ifdef CONFIG_IP_ROUTE_MULTIPATH 450 static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write, 451 void *buffer, size_t *lenp, 452 loff_t *ppos) 453 { 454 struct net *net = container_of(table->data, struct net, 455 ipv4.sysctl_fib_multipath_hash_policy); 456 int ret; 457 458 ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos); 459 if (write && ret == 0) 460 call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net); 461 462 return ret; 463 } 464 #endif 465 466 static struct ctl_table ipv4_table[] = { 467 { 468 .procname = "tcp_max_orphans", 469 .data = &sysctl_tcp_max_orphans, 470 .maxlen = sizeof(int), 471 .mode = 0644, 472 .proc_handler = proc_dointvec 473 }, 474 { 475 .procname = "inet_peer_threshold", 476 .data = &inet_peer_threshold, 477 .maxlen = sizeof(int), 478 .mode = 0644, 479 .proc_handler = proc_dointvec 480 }, 481 { 482 .procname = "inet_peer_minttl", 483 .data = &inet_peer_minttl, 484 .maxlen = sizeof(int), 485 .mode = 0644, 486 .proc_handler = proc_dointvec_jiffies, 487 }, 488 { 489 .procname = "inet_peer_maxttl", 490 .data = &inet_peer_maxttl, 491 .maxlen = sizeof(int), 492 .mode = 0644, 493 .proc_handler = proc_dointvec_jiffies, 494 }, 495 { 496 .procname = "tcp_mem", 497 .maxlen = sizeof(sysctl_tcp_mem), 498 .data = &sysctl_tcp_mem, 499 .mode = 0644, 500 .proc_handler = proc_doulongvec_minmax, 501 }, 502 { 503 .procname = "tcp_low_latency", 504 .data = &sysctl_tcp_low_latency, 505 .maxlen = sizeof(int), 506 .mode = 0644, 507 .proc_handler = proc_dointvec 508 }, 509 #ifdef CONFIG_NETLABEL 510 { 511 .procname = "cipso_cache_enable", 512 .data = &cipso_v4_cache_enabled, 513 .maxlen = sizeof(int), 514 .mode = 0644, 515 .proc_handler = proc_dointvec, 516 }, 517 { 518 .procname = "cipso_cache_bucket_size", 519 .data = &cipso_v4_cache_bucketsize, 520 .maxlen = sizeof(int), 521 .mode = 0644, 522 .proc_handler = proc_dointvec, 523 }, 524 { 525 .procname = "cipso_rbm_optfmt", 526 .data = &cipso_v4_rbm_optfmt, 527 .maxlen = sizeof(int), 528 .mode = 0644, 529 .proc_handler = proc_dointvec, 530 }, 531 { 532 .procname = "cipso_rbm_strictvalid", 533 .data = &cipso_v4_rbm_strictvalid, 534 .maxlen = sizeof(int), 535 .mode = 0644, 536 .proc_handler = proc_dointvec, 537 }, 538 #endif /* CONFIG_NETLABEL */ 539 { 540 .procname = "tcp_available_ulp", 541 .maxlen = TCP_ULP_BUF_MAX, 542 .mode = 0444, 543 .proc_handler = proc_tcp_available_ulp, 544 }, 545 { 546 .procname = "icmp_msgs_per_sec", 547 .data = &sysctl_icmp_msgs_per_sec, 548 .maxlen = sizeof(int), 549 .mode = 0644, 550 .proc_handler = proc_dointvec_minmax, 551 .extra1 = SYSCTL_ZERO, 552 }, 553 { 554 .procname = "icmp_msgs_burst", 555 .data = &sysctl_icmp_msgs_burst, 556 .maxlen = sizeof(int), 557 .mode = 0644, 558 .proc_handler = proc_dointvec_minmax, 559 .extra1 = SYSCTL_ZERO, 560 }, 561 { 562 .procname = "udp_mem", 563 .data = &sysctl_udp_mem, 564 .maxlen = sizeof(sysctl_udp_mem), 565 .mode = 0644, 566 .proc_handler = proc_doulongvec_minmax, 567 }, 568 { 569 .procname = "fib_sync_mem", 570 .data = &sysctl_fib_sync_mem, 571 .maxlen = sizeof(sysctl_fib_sync_mem), 572 .mode = 0644, 573 .proc_handler = proc_douintvec_minmax, 574 .extra1 = &sysctl_fib_sync_mem_min, 575 .extra2 = &sysctl_fib_sync_mem_max, 576 }, 577 { 578 .procname = "tcp_rx_skb_cache", 579 .data = &tcp_rx_skb_cache_key.key, 580 .mode = 0644, 581 .proc_handler = proc_do_static_key, 582 }, 583 { 584 .procname = "tcp_tx_skb_cache", 585 .data = &tcp_tx_skb_cache_key.key, 586 .mode = 0644, 587 .proc_handler = proc_do_static_key, 588 }, 589 { } 590 }; 591 592 static struct ctl_table ipv4_net_table[] = { 593 { 594 .procname = "icmp_echo_ignore_all", 595 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, 596 .maxlen = sizeof(u8), 597 .mode = 0644, 598 .proc_handler = proc_dou8vec_minmax, 599 }, 600 { 601 .procname = "icmp_echo_enable_probe", 602 .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe, 603 .maxlen = sizeof(u8), 604 .mode = 0644, 605 .proc_handler = proc_dou8vec_minmax, 606 .extra1 = SYSCTL_ZERO, 607 .extra2 = SYSCTL_ONE 608 }, 609 { 610 .procname = "icmp_echo_ignore_broadcasts", 611 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, 612 .maxlen = sizeof(u8), 613 .mode = 0644, 614 .proc_handler = proc_dou8vec_minmax, 615 }, 616 { 617 .procname = "icmp_ignore_bogus_error_responses", 618 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, 619 .maxlen = sizeof(u8), 620 .mode = 0644, 621 .proc_handler = proc_dou8vec_minmax, 622 }, 623 { 624 .procname = "icmp_errors_use_inbound_ifaddr", 625 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, 626 .maxlen = sizeof(u8), 627 .mode = 0644, 628 .proc_handler = proc_dou8vec_minmax, 629 }, 630 { 631 .procname = "icmp_ratelimit", 632 .data = &init_net.ipv4.sysctl_icmp_ratelimit, 633 .maxlen = sizeof(int), 634 .mode = 0644, 635 .proc_handler = proc_dointvec_ms_jiffies, 636 }, 637 { 638 .procname = "icmp_ratemask", 639 .data = &init_net.ipv4.sysctl_icmp_ratemask, 640 .maxlen = sizeof(int), 641 .mode = 0644, 642 .proc_handler = proc_dointvec 643 }, 644 { 645 .procname = "ping_group_range", 646 .data = &init_net.ipv4.ping_group_range.range, 647 .maxlen = sizeof(gid_t)*2, 648 .mode = 0644, 649 .proc_handler = ipv4_ping_group_range, 650 }, 651 #ifdef CONFIG_NET_L3_MASTER_DEV 652 { 653 .procname = "raw_l3mdev_accept", 654 .data = &init_net.ipv4.sysctl_raw_l3mdev_accept, 655 .maxlen = sizeof(u8), 656 .mode = 0644, 657 .proc_handler = proc_dou8vec_minmax, 658 .extra1 = SYSCTL_ZERO, 659 .extra2 = SYSCTL_ONE, 660 }, 661 #endif 662 { 663 .procname = "tcp_ecn", 664 .data = &init_net.ipv4.sysctl_tcp_ecn, 665 .maxlen = sizeof(u8), 666 .mode = 0644, 667 .proc_handler = proc_dou8vec_minmax, 668 }, 669 { 670 .procname = "tcp_ecn_fallback", 671 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, 672 .maxlen = sizeof(u8), 673 .mode = 0644, 674 .proc_handler = proc_dou8vec_minmax, 675 }, 676 { 677 .procname = "ip_dynaddr", 678 .data = &init_net.ipv4.sysctl_ip_dynaddr, 679 .maxlen = sizeof(u8), 680 .mode = 0644, 681 .proc_handler = proc_dou8vec_minmax, 682 }, 683 { 684 .procname = "ip_early_demux", 685 .data = &init_net.ipv4.sysctl_ip_early_demux, 686 .maxlen = sizeof(u8), 687 .mode = 0644, 688 .proc_handler = proc_dou8vec_minmax, 689 }, 690 { 691 .procname = "udp_early_demux", 692 .data = &init_net.ipv4.sysctl_udp_early_demux, 693 .maxlen = sizeof(u8), 694 .mode = 0644, 695 .proc_handler = proc_udp_early_demux 696 }, 697 { 698 .procname = "tcp_early_demux", 699 .data = &init_net.ipv4.sysctl_tcp_early_demux, 700 .maxlen = sizeof(u8), 701 .mode = 0644, 702 .proc_handler = proc_tcp_early_demux 703 }, 704 { 705 .procname = "nexthop_compat_mode", 706 .data = &init_net.ipv4.sysctl_nexthop_compat_mode, 707 .maxlen = sizeof(u8), 708 .mode = 0644, 709 .proc_handler = proc_dou8vec_minmax, 710 .extra1 = SYSCTL_ZERO, 711 .extra2 = SYSCTL_ONE, 712 }, 713 { 714 .procname = "ip_default_ttl", 715 .data = &init_net.ipv4.sysctl_ip_default_ttl, 716 .maxlen = sizeof(u8), 717 .mode = 0644, 718 .proc_handler = proc_dou8vec_minmax, 719 .extra1 = &ip_ttl_min, 720 .extra2 = &ip_ttl_max, 721 }, 722 { 723 .procname = "ip_local_port_range", 724 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range), 725 .data = &init_net.ipv4.ip_local_ports.range, 726 .mode = 0644, 727 .proc_handler = ipv4_local_port_range, 728 }, 729 { 730 .procname = "ip_local_reserved_ports", 731 .data = &init_net.ipv4.sysctl_local_reserved_ports, 732 .maxlen = 65536, 733 .mode = 0644, 734 .proc_handler = proc_do_large_bitmap, 735 }, 736 { 737 .procname = "ip_no_pmtu_disc", 738 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc, 739 .maxlen = sizeof(u8), 740 .mode = 0644, 741 .proc_handler = proc_dou8vec_minmax, 742 }, 743 { 744 .procname = "ip_forward_use_pmtu", 745 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu, 746 .maxlen = sizeof(u8), 747 .mode = 0644, 748 .proc_handler = proc_dou8vec_minmax, 749 }, 750 { 751 .procname = "ip_forward_update_priority", 752 .data = &init_net.ipv4.sysctl_ip_fwd_update_priority, 753 .maxlen = sizeof(u8), 754 .mode = 0644, 755 .proc_handler = ipv4_fwd_update_priority, 756 .extra1 = SYSCTL_ZERO, 757 .extra2 = SYSCTL_ONE, 758 }, 759 { 760 .procname = "ip_nonlocal_bind", 761 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, 762 .maxlen = sizeof(u8), 763 .mode = 0644, 764 .proc_handler = proc_dou8vec_minmax, 765 }, 766 { 767 .procname = "ip_autobind_reuse", 768 .data = &init_net.ipv4.sysctl_ip_autobind_reuse, 769 .maxlen = sizeof(u8), 770 .mode = 0644, 771 .proc_handler = proc_dou8vec_minmax, 772 .extra1 = SYSCTL_ZERO, 773 .extra2 = SYSCTL_ONE, 774 }, 775 { 776 .procname = "fwmark_reflect", 777 .data = &init_net.ipv4.sysctl_fwmark_reflect, 778 .maxlen = sizeof(u8), 779 .mode = 0644, 780 .proc_handler = proc_dou8vec_minmax, 781 }, 782 { 783 .procname = "tcp_fwmark_accept", 784 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept, 785 .maxlen = sizeof(u8), 786 .mode = 0644, 787 .proc_handler = proc_dou8vec_minmax, 788 }, 789 #ifdef CONFIG_NET_L3_MASTER_DEV 790 { 791 .procname = "tcp_l3mdev_accept", 792 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept, 793 .maxlen = sizeof(u8), 794 .mode = 0644, 795 .proc_handler = proc_dou8vec_minmax, 796 .extra1 = SYSCTL_ZERO, 797 .extra2 = SYSCTL_ONE, 798 }, 799 #endif 800 { 801 .procname = "tcp_mtu_probing", 802 .data = &init_net.ipv4.sysctl_tcp_mtu_probing, 803 .maxlen = sizeof(u8), 804 .mode = 0644, 805 .proc_handler = proc_dou8vec_minmax, 806 }, 807 { 808 .procname = "tcp_base_mss", 809 .data = &init_net.ipv4.sysctl_tcp_base_mss, 810 .maxlen = sizeof(int), 811 .mode = 0644, 812 .proc_handler = proc_dointvec, 813 }, 814 { 815 .procname = "tcp_min_snd_mss", 816 .data = &init_net.ipv4.sysctl_tcp_min_snd_mss, 817 .maxlen = sizeof(int), 818 .mode = 0644, 819 .proc_handler = proc_dointvec_minmax, 820 .extra1 = &tcp_min_snd_mss_min, 821 .extra2 = &tcp_min_snd_mss_max, 822 }, 823 { 824 .procname = "tcp_mtu_probe_floor", 825 .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor, 826 .maxlen = sizeof(int), 827 .mode = 0644, 828 .proc_handler = proc_dointvec_minmax, 829 .extra1 = &tcp_min_snd_mss_min, 830 .extra2 = &tcp_min_snd_mss_max, 831 }, 832 { 833 .procname = "tcp_probe_threshold", 834 .data = &init_net.ipv4.sysctl_tcp_probe_threshold, 835 .maxlen = sizeof(int), 836 .mode = 0644, 837 .proc_handler = proc_dointvec, 838 }, 839 { 840 .procname = "tcp_probe_interval", 841 .data = &init_net.ipv4.sysctl_tcp_probe_interval, 842 .maxlen = sizeof(u32), 843 .mode = 0644, 844 .proc_handler = proc_douintvec_minmax, 845 .extra2 = &u32_max_div_HZ, 846 }, 847 { 848 .procname = "igmp_link_local_mcast_reports", 849 .data = &init_net.ipv4.sysctl_igmp_llm_reports, 850 .maxlen = sizeof(u8), 851 .mode = 0644, 852 .proc_handler = proc_dou8vec_minmax, 853 }, 854 { 855 .procname = "igmp_max_memberships", 856 .data = &init_net.ipv4.sysctl_igmp_max_memberships, 857 .maxlen = sizeof(int), 858 .mode = 0644, 859 .proc_handler = proc_dointvec 860 }, 861 { 862 .procname = "igmp_max_msf", 863 .data = &init_net.ipv4.sysctl_igmp_max_msf, 864 .maxlen = sizeof(int), 865 .mode = 0644, 866 .proc_handler = proc_dointvec 867 }, 868 #ifdef CONFIG_IP_MULTICAST 869 { 870 .procname = "igmp_qrv", 871 .data = &init_net.ipv4.sysctl_igmp_qrv, 872 .maxlen = sizeof(int), 873 .mode = 0644, 874 .proc_handler = proc_dointvec_minmax, 875 .extra1 = SYSCTL_ONE 876 }, 877 #endif 878 { 879 .procname = "tcp_congestion_control", 880 .data = &init_net.ipv4.tcp_congestion_control, 881 .mode = 0644, 882 .maxlen = TCP_CA_NAME_MAX, 883 .proc_handler = proc_tcp_congestion_control, 884 }, 885 { 886 .procname = "tcp_available_congestion_control", 887 .maxlen = TCP_CA_BUF_MAX, 888 .mode = 0444, 889 .proc_handler = proc_tcp_available_congestion_control, 890 }, 891 { 892 .procname = "tcp_allowed_congestion_control", 893 .maxlen = TCP_CA_BUF_MAX, 894 .mode = 0644, 895 .proc_handler = proc_allowed_congestion_control, 896 }, 897 { 898 .procname = "tcp_keepalive_time", 899 .data = &init_net.ipv4.sysctl_tcp_keepalive_time, 900 .maxlen = sizeof(int), 901 .mode = 0644, 902 .proc_handler = proc_dointvec_jiffies, 903 }, 904 { 905 .procname = "tcp_keepalive_probes", 906 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes, 907 .maxlen = sizeof(u8), 908 .mode = 0644, 909 .proc_handler = proc_dou8vec_minmax, 910 }, 911 { 912 .procname = "tcp_keepalive_intvl", 913 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl, 914 .maxlen = sizeof(int), 915 .mode = 0644, 916 .proc_handler = proc_dointvec_jiffies, 917 }, 918 { 919 .procname = "tcp_syn_retries", 920 .data = &init_net.ipv4.sysctl_tcp_syn_retries, 921 .maxlen = sizeof(u8), 922 .mode = 0644, 923 .proc_handler = proc_dou8vec_minmax, 924 .extra1 = &tcp_syn_retries_min, 925 .extra2 = &tcp_syn_retries_max 926 }, 927 { 928 .procname = "tcp_synack_retries", 929 .data = &init_net.ipv4.sysctl_tcp_synack_retries, 930 .maxlen = sizeof(u8), 931 .mode = 0644, 932 .proc_handler = proc_dou8vec_minmax, 933 }, 934 #ifdef CONFIG_SYN_COOKIES 935 { 936 .procname = "tcp_syncookies", 937 .data = &init_net.ipv4.sysctl_tcp_syncookies, 938 .maxlen = sizeof(u8), 939 .mode = 0644, 940 .proc_handler = proc_dou8vec_minmax, 941 }, 942 #endif 943 { 944 .procname = "tcp_reordering", 945 .data = &init_net.ipv4.sysctl_tcp_reordering, 946 .maxlen = sizeof(int), 947 .mode = 0644, 948 .proc_handler = proc_dointvec 949 }, 950 { 951 .procname = "tcp_retries1", 952 .data = &init_net.ipv4.sysctl_tcp_retries1, 953 .maxlen = sizeof(u8), 954 .mode = 0644, 955 .proc_handler = proc_dou8vec_minmax, 956 .extra2 = &tcp_retr1_max 957 }, 958 { 959 .procname = "tcp_retries2", 960 .data = &init_net.ipv4.sysctl_tcp_retries2, 961 .maxlen = sizeof(u8), 962 .mode = 0644, 963 .proc_handler = proc_dou8vec_minmax, 964 }, 965 { 966 .procname = "tcp_orphan_retries", 967 .data = &init_net.ipv4.sysctl_tcp_orphan_retries, 968 .maxlen = sizeof(u8), 969 .mode = 0644, 970 .proc_handler = proc_dou8vec_minmax, 971 }, 972 { 973 .procname = "tcp_fin_timeout", 974 .data = &init_net.ipv4.sysctl_tcp_fin_timeout, 975 .maxlen = sizeof(int), 976 .mode = 0644, 977 .proc_handler = proc_dointvec_jiffies, 978 }, 979 { 980 .procname = "tcp_notsent_lowat", 981 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, 982 .maxlen = sizeof(unsigned int), 983 .mode = 0644, 984 .proc_handler = proc_douintvec, 985 }, 986 { 987 .procname = "tcp_tw_reuse", 988 .data = &init_net.ipv4.sysctl_tcp_tw_reuse, 989 .maxlen = sizeof(u8), 990 .mode = 0644, 991 .proc_handler = proc_dou8vec_minmax, 992 .extra1 = SYSCTL_ZERO, 993 .extra2 = &two, 994 }, 995 { 996 .procname = "tcp_max_tw_buckets", 997 .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets, 998 .maxlen = sizeof(int), 999 .mode = 0644, 1000 .proc_handler = proc_dointvec 1001 }, 1002 { 1003 .procname = "tcp_max_syn_backlog", 1004 .data = &init_net.ipv4.sysctl_max_syn_backlog, 1005 .maxlen = sizeof(int), 1006 .mode = 0644, 1007 .proc_handler = proc_dointvec 1008 }, 1009 { 1010 .procname = "tcp_fastopen", 1011 .data = &init_net.ipv4.sysctl_tcp_fastopen, 1012 .maxlen = sizeof(int), 1013 .mode = 0644, 1014 .proc_handler = proc_dointvec, 1015 }, 1016 { 1017 .procname = "tcp_fastopen_key", 1018 .mode = 0600, 1019 .data = &init_net.ipv4.sysctl_tcp_fastopen, 1020 /* maxlen to print the list of keys in hex (*2), with dashes 1021 * separating doublewords and a comma in between keys. 1022 */ 1023 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 1024 2 * TCP_FASTOPEN_KEY_MAX) + 1025 (TCP_FASTOPEN_KEY_MAX * 5)), 1026 .proc_handler = proc_tcp_fastopen_key, 1027 }, 1028 { 1029 .procname = "tcp_fastopen_blackhole_timeout_sec", 1030 .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout, 1031 .maxlen = sizeof(int), 1032 .mode = 0644, 1033 .proc_handler = proc_tfo_blackhole_detect_timeout, 1034 .extra1 = SYSCTL_ZERO, 1035 }, 1036 #ifdef CONFIG_IP_ROUTE_MULTIPATH 1037 { 1038 .procname = "fib_multipath_use_neigh", 1039 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh, 1040 .maxlen = sizeof(u8), 1041 .mode = 0644, 1042 .proc_handler = proc_dou8vec_minmax, 1043 .extra1 = SYSCTL_ZERO, 1044 .extra2 = SYSCTL_ONE, 1045 }, 1046 { 1047 .procname = "fib_multipath_hash_policy", 1048 .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, 1049 .maxlen = sizeof(u8), 1050 .mode = 0644, 1051 .proc_handler = proc_fib_multipath_hash_policy, 1052 .extra1 = SYSCTL_ZERO, 1053 .extra2 = &two, 1054 }, 1055 #endif 1056 { 1057 .procname = "ip_unprivileged_port_start", 1058 .maxlen = sizeof(int), 1059 .data = &init_net.ipv4.sysctl_ip_prot_sock, 1060 .mode = 0644, 1061 .proc_handler = ipv4_privileged_ports, 1062 }, 1063 #ifdef CONFIG_NET_L3_MASTER_DEV 1064 { 1065 .procname = "udp_l3mdev_accept", 1066 .data = &init_net.ipv4.sysctl_udp_l3mdev_accept, 1067 .maxlen = sizeof(u8), 1068 .mode = 0644, 1069 .proc_handler = proc_dou8vec_minmax, 1070 .extra1 = SYSCTL_ZERO, 1071 .extra2 = SYSCTL_ONE, 1072 }, 1073 #endif 1074 { 1075 .procname = "tcp_sack", 1076 .data = &init_net.ipv4.sysctl_tcp_sack, 1077 .maxlen = sizeof(u8), 1078 .mode = 0644, 1079 .proc_handler = proc_dou8vec_minmax, 1080 }, 1081 { 1082 .procname = "tcp_window_scaling", 1083 .data = &init_net.ipv4.sysctl_tcp_window_scaling, 1084 .maxlen = sizeof(u8), 1085 .mode = 0644, 1086 .proc_handler = proc_dou8vec_minmax, 1087 }, 1088 { 1089 .procname = "tcp_timestamps", 1090 .data = &init_net.ipv4.sysctl_tcp_timestamps, 1091 .maxlen = sizeof(u8), 1092 .mode = 0644, 1093 .proc_handler = proc_dou8vec_minmax, 1094 }, 1095 { 1096 .procname = "tcp_early_retrans", 1097 .data = &init_net.ipv4.sysctl_tcp_early_retrans, 1098 .maxlen = sizeof(u8), 1099 .mode = 0644, 1100 .proc_handler = proc_dou8vec_minmax, 1101 .extra1 = SYSCTL_ZERO, 1102 .extra2 = &four, 1103 }, 1104 { 1105 .procname = "tcp_recovery", 1106 .data = &init_net.ipv4.sysctl_tcp_recovery, 1107 .maxlen = sizeof(u8), 1108 .mode = 0644, 1109 .proc_handler = proc_dou8vec_minmax, 1110 }, 1111 { 1112 .procname = "tcp_thin_linear_timeouts", 1113 .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts, 1114 .maxlen = sizeof(u8), 1115 .mode = 0644, 1116 .proc_handler = proc_dou8vec_minmax, 1117 }, 1118 { 1119 .procname = "tcp_slow_start_after_idle", 1120 .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle, 1121 .maxlen = sizeof(u8), 1122 .mode = 0644, 1123 .proc_handler = proc_dou8vec_minmax, 1124 }, 1125 { 1126 .procname = "tcp_retrans_collapse", 1127 .data = &init_net.ipv4.sysctl_tcp_retrans_collapse, 1128 .maxlen = sizeof(u8), 1129 .mode = 0644, 1130 .proc_handler = proc_dou8vec_minmax, 1131 }, 1132 { 1133 .procname = "tcp_stdurg", 1134 .data = &init_net.ipv4.sysctl_tcp_stdurg, 1135 .maxlen = sizeof(u8), 1136 .mode = 0644, 1137 .proc_handler = proc_dou8vec_minmax, 1138 }, 1139 { 1140 .procname = "tcp_rfc1337", 1141 .data = &init_net.ipv4.sysctl_tcp_rfc1337, 1142 .maxlen = sizeof(u8), 1143 .mode = 0644, 1144 .proc_handler = proc_dou8vec_minmax, 1145 }, 1146 { 1147 .procname = "tcp_abort_on_overflow", 1148 .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow, 1149 .maxlen = sizeof(u8), 1150 .mode = 0644, 1151 .proc_handler = proc_dou8vec_minmax, 1152 }, 1153 { 1154 .procname = "tcp_fack", 1155 .data = &init_net.ipv4.sysctl_tcp_fack, 1156 .maxlen = sizeof(u8), 1157 .mode = 0644, 1158 .proc_handler = proc_dou8vec_minmax, 1159 }, 1160 { 1161 .procname = "tcp_max_reordering", 1162 .data = &init_net.ipv4.sysctl_tcp_max_reordering, 1163 .maxlen = sizeof(int), 1164 .mode = 0644, 1165 .proc_handler = proc_dointvec 1166 }, 1167 { 1168 .procname = "tcp_dsack", 1169 .data = &init_net.ipv4.sysctl_tcp_dsack, 1170 .maxlen = sizeof(u8), 1171 .mode = 0644, 1172 .proc_handler = proc_dou8vec_minmax, 1173 }, 1174 { 1175 .procname = "tcp_app_win", 1176 .data = &init_net.ipv4.sysctl_tcp_app_win, 1177 .maxlen = sizeof(u8), 1178 .mode = 0644, 1179 .proc_handler = proc_dou8vec_minmax, 1180 }, 1181 { 1182 .procname = "tcp_adv_win_scale", 1183 .data = &init_net.ipv4.sysctl_tcp_adv_win_scale, 1184 .maxlen = sizeof(int), 1185 .mode = 0644, 1186 .proc_handler = proc_dointvec_minmax, 1187 .extra1 = &tcp_adv_win_scale_min, 1188 .extra2 = &tcp_adv_win_scale_max, 1189 }, 1190 { 1191 .procname = "tcp_frto", 1192 .data = &init_net.ipv4.sysctl_tcp_frto, 1193 .maxlen = sizeof(u8), 1194 .mode = 0644, 1195 .proc_handler = proc_dou8vec_minmax, 1196 }, 1197 { 1198 .procname = "tcp_no_metrics_save", 1199 .data = &init_net.ipv4.sysctl_tcp_nometrics_save, 1200 .maxlen = sizeof(u8), 1201 .mode = 0644, 1202 .proc_handler = proc_dou8vec_minmax, 1203 }, 1204 { 1205 .procname = "tcp_no_ssthresh_metrics_save", 1206 .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save, 1207 .maxlen = sizeof(u8), 1208 .mode = 0644, 1209 .proc_handler = proc_dou8vec_minmax, 1210 .extra1 = SYSCTL_ZERO, 1211 .extra2 = SYSCTL_ONE, 1212 }, 1213 { 1214 .procname = "tcp_moderate_rcvbuf", 1215 .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf, 1216 .maxlen = sizeof(u8), 1217 .mode = 0644, 1218 .proc_handler = proc_dou8vec_minmax, 1219 }, 1220 { 1221 .procname = "tcp_tso_win_divisor", 1222 .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor, 1223 .maxlen = sizeof(u8), 1224 .mode = 0644, 1225 .proc_handler = proc_dou8vec_minmax, 1226 }, 1227 { 1228 .procname = "tcp_workaround_signed_windows", 1229 .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows, 1230 .maxlen = sizeof(u8), 1231 .mode = 0644, 1232 .proc_handler = proc_dou8vec_minmax, 1233 }, 1234 { 1235 .procname = "tcp_limit_output_bytes", 1236 .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes, 1237 .maxlen = sizeof(int), 1238 .mode = 0644, 1239 .proc_handler = proc_dointvec 1240 }, 1241 { 1242 .procname = "tcp_challenge_ack_limit", 1243 .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit, 1244 .maxlen = sizeof(int), 1245 .mode = 0644, 1246 .proc_handler = proc_dointvec 1247 }, 1248 { 1249 .procname = "tcp_min_tso_segs", 1250 .data = &init_net.ipv4.sysctl_tcp_min_tso_segs, 1251 .maxlen = sizeof(u8), 1252 .mode = 0644, 1253 .proc_handler = proc_dou8vec_minmax, 1254 .extra1 = SYSCTL_ONE, 1255 }, 1256 { 1257 .procname = "tcp_min_rtt_wlen", 1258 .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen, 1259 .maxlen = sizeof(int), 1260 .mode = 0644, 1261 .proc_handler = proc_dointvec_minmax, 1262 .extra1 = SYSCTL_ZERO, 1263 .extra2 = &one_day_secs 1264 }, 1265 { 1266 .procname = "tcp_autocorking", 1267 .data = &init_net.ipv4.sysctl_tcp_autocorking, 1268 .maxlen = sizeof(u8), 1269 .mode = 0644, 1270 .proc_handler = proc_dou8vec_minmax, 1271 .extra1 = SYSCTL_ZERO, 1272 .extra2 = SYSCTL_ONE, 1273 }, 1274 { 1275 .procname = "tcp_invalid_ratelimit", 1276 .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit, 1277 .maxlen = sizeof(int), 1278 .mode = 0644, 1279 .proc_handler = proc_dointvec_ms_jiffies, 1280 }, 1281 { 1282 .procname = "tcp_pacing_ss_ratio", 1283 .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio, 1284 .maxlen = sizeof(int), 1285 .mode = 0644, 1286 .proc_handler = proc_dointvec_minmax, 1287 .extra1 = SYSCTL_ZERO, 1288 .extra2 = &thousand, 1289 }, 1290 { 1291 .procname = "tcp_pacing_ca_ratio", 1292 .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio, 1293 .maxlen = sizeof(int), 1294 .mode = 0644, 1295 .proc_handler = proc_dointvec_minmax, 1296 .extra1 = SYSCTL_ZERO, 1297 .extra2 = &thousand, 1298 }, 1299 { 1300 .procname = "tcp_wmem", 1301 .data = &init_net.ipv4.sysctl_tcp_wmem, 1302 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem), 1303 .mode = 0644, 1304 .proc_handler = proc_dointvec_minmax, 1305 .extra1 = SYSCTL_ONE, 1306 }, 1307 { 1308 .procname = "tcp_rmem", 1309 .data = &init_net.ipv4.sysctl_tcp_rmem, 1310 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem), 1311 .mode = 0644, 1312 .proc_handler = proc_dointvec_minmax, 1313 .extra1 = SYSCTL_ONE, 1314 }, 1315 { 1316 .procname = "tcp_comp_sack_delay_ns", 1317 .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns, 1318 .maxlen = sizeof(unsigned long), 1319 .mode = 0644, 1320 .proc_handler = proc_doulongvec_minmax, 1321 }, 1322 { 1323 .procname = "tcp_comp_sack_slack_ns", 1324 .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns, 1325 .maxlen = sizeof(unsigned long), 1326 .mode = 0644, 1327 .proc_handler = proc_doulongvec_minmax, 1328 }, 1329 { 1330 .procname = "tcp_comp_sack_nr", 1331 .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr, 1332 .maxlen = sizeof(u8), 1333 .mode = 0644, 1334 .proc_handler = proc_dou8vec_minmax, 1335 .extra1 = SYSCTL_ZERO, 1336 }, 1337 { 1338 .procname = "tcp_reflect_tos", 1339 .data = &init_net.ipv4.sysctl_tcp_reflect_tos, 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 = "udp_rmem_min", 1348 .data = &init_net.ipv4.sysctl_udp_rmem_min, 1349 .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min), 1350 .mode = 0644, 1351 .proc_handler = proc_dointvec_minmax, 1352 .extra1 = SYSCTL_ONE 1353 }, 1354 { 1355 .procname = "udp_wmem_min", 1356 .data = &init_net.ipv4.sysctl_udp_wmem_min, 1357 .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min), 1358 .mode = 0644, 1359 .proc_handler = proc_dointvec_minmax, 1360 .extra1 = SYSCTL_ONE 1361 }, 1362 { 1363 .procname = "fib_notify_on_flag_change", 1364 .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change, 1365 .maxlen = sizeof(u8), 1366 .mode = 0644, 1367 .proc_handler = proc_dou8vec_minmax, 1368 .extra1 = SYSCTL_ZERO, 1369 .extra2 = &two, 1370 }, 1371 { } 1372 }; 1373 1374 static __net_init int ipv4_sysctl_init_net(struct net *net) 1375 { 1376 struct ctl_table *table; 1377 1378 table = ipv4_net_table; 1379 if (!net_eq(net, &init_net)) { 1380 int i; 1381 1382 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); 1383 if (!table) 1384 goto err_alloc; 1385 1386 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) { 1387 if (table[i].data) { 1388 /* Update the variables to point into 1389 * the current struct net 1390 */ 1391 table[i].data += (void *)net - (void *)&init_net; 1392 } else { 1393 /* Entries without data pointer are global; 1394 * Make them read-only in non-init_net ns 1395 */ 1396 table[i].mode &= ~0222; 1397 } 1398 } 1399 } 1400 1401 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); 1402 if (!net->ipv4.ipv4_hdr) 1403 goto err_reg; 1404 1405 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL); 1406 if (!net->ipv4.sysctl_local_reserved_ports) 1407 goto err_ports; 1408 1409 return 0; 1410 1411 err_ports: 1412 unregister_net_sysctl_table(net->ipv4.ipv4_hdr); 1413 err_reg: 1414 if (!net_eq(net, &init_net)) 1415 kfree(table); 1416 err_alloc: 1417 return -ENOMEM; 1418 } 1419 1420 static __net_exit void ipv4_sysctl_exit_net(struct net *net) 1421 { 1422 struct ctl_table *table; 1423 1424 kfree(net->ipv4.sysctl_local_reserved_ports); 1425 table = net->ipv4.ipv4_hdr->ctl_table_arg; 1426 unregister_net_sysctl_table(net->ipv4.ipv4_hdr); 1427 kfree(table); 1428 } 1429 1430 static __net_initdata struct pernet_operations ipv4_sysctl_ops = { 1431 .init = ipv4_sysctl_init_net, 1432 .exit = ipv4_sysctl_exit_net, 1433 }; 1434 1435 static __init int sysctl_ipv4_init(void) 1436 { 1437 struct ctl_table_header *hdr; 1438 1439 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table); 1440 if (!hdr) 1441 return -ENOMEM; 1442 1443 if (register_pernet_subsys(&ipv4_sysctl_ops)) { 1444 unregister_net_sysctl_table(hdr); 1445 return -ENOMEM; 1446 } 1447 1448 return 0; 1449 } 1450 1451 __initcall(sysctl_ipv4_init); 1452