Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem. |
| 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 12 | #include <linux/igmp.h> |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 13 | #include <linux/inetdevice.h> |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 14 | #include <linux/seqlock.h> |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 15 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 17 | #include <linux/nsproxy.h> |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 18 | #include <linux/swap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <net/snmp.h> |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 20 | #include <net/icmp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <net/ip.h> |
| 22 | #include <net/route.h> |
| 23 | #include <net/tcp.h> |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 24 | #include <net/udp.h> |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 25 | #include <net/cipso_ipv4.h> |
Pavel Emelyanov | 04128f2 | 2007-10-15 02:33:45 -0700 | [diff] [blame] | 26 | #include <net/inet_frag.h> |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 27 | #include <net/ping.h> |
subashab@codeaurora.org | dddb64b | 2017-03-23 13:34:16 -0600 | [diff] [blame] | 28 | #include <net/protocol.h> |
Ido Schimmel | 3ae6ec0 | 2017-11-02 17:14:05 +0100 | [diff] [blame] | 29 | #include <net/netevent.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Herbert Xu | 89cee8b | 2005-12-13 23:14:27 -0800 | [diff] [blame] | 31 | static int zero; |
bingtian.ly@taobao.com | cdda889 | 2013-01-23 20:35:28 +0000 | [diff] [blame] | 32 | static int one = 1; |
Nandita Dukkipati | 6ba8a3b | 2013-03-11 10:00:43 +0000 | [diff] [blame] | 33 | static int four = 4; |
Eric Dumazet | 43e122b | 2015-08-21 17:38:02 -0700 | [diff] [blame] | 34 | static int thousand = 1000; |
Eric Dumazet | 95bd09e | 2013-08-27 05:46:32 -0700 | [diff] [blame] | 35 | static int gso_max_segs = GSO_MAX_SEGS; |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 36 | static int tcp_retr1_max = 255; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | static int ip_local_port_range_min[] = { 1, 1 }; |
| 38 | static int ip_local_port_range_max[] = { 65535, 65535 }; |
Alexey Dobriyan | 0147fc0 | 2010-11-22 12:54:21 +0000 | [diff] [blame] | 39 | static int tcp_adv_win_scale_min = -31; |
| 40 | static int tcp_adv_win_scale_max = 31; |
Krister Johansen | 4548b68 | 2017-01-20 17:49:11 -0800 | [diff] [blame] | 41 | static int ip_privileged_port_min; |
| 42 | static int ip_privileged_port_max = 65535; |
Eric Dumazet | 249fab7 | 2010-12-13 12:16:14 -0800 | [diff] [blame] | 43 | static int ip_ttl_min = 1; |
| 44 | static int ip_ttl_max = 255; |
Michal Tesar | 651e927 | 2013-07-19 14:09:01 +0200 | [diff] [blame] | 45 | static int tcp_syn_retries_min = 1; |
| 46 | static int tcp_syn_retries_max = MAX_TCP_SYNCNT; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 47 | static int ip_ping_group_range_min[] = { 0, 0 }; |
| 48 | static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Florian Westphal | b6690b1 | 2017-07-30 03:57:20 +0200 | [diff] [blame] | 50 | /* obsolete */ |
| 51 | static int sysctl_tcp_low_latency __read_mostly; |
| 52 | |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 53 | /* Update system visible IP port range */ |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 54 | static void set_local_port_range(struct net *net, int range[2]) |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 55 | { |
Eric Dumazet | ed2dfd9 | 2015-05-27 11:34:37 -0700 | [diff] [blame] | 56 | bool same_parity = !((range[0] ^ range[1]) & 1); |
| 57 | |
WANG Cong | 4ee3bd4 | 2015-11-03 14:32:57 -0800 | [diff] [blame] | 58 | write_seqlock_bh(&net->ipv4.ip_local_ports.lock); |
Eric Dumazet | ed2dfd9 | 2015-05-27 11:34:37 -0700 | [diff] [blame] | 59 | if (same_parity && !net->ipv4.ip_local_ports.warned) { |
| 60 | net->ipv4.ip_local_ports.warned = true; |
| 61 | pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n"); |
| 62 | } |
Cong Wang | c9d8f1a | 2014-05-06 11:02:49 -0700 | [diff] [blame] | 63 | net->ipv4.ip_local_ports.range[0] = range[0]; |
| 64 | net->ipv4.ip_local_ports.range[1] = range[1]; |
WANG Cong | 4ee3bd4 | 2015-11-03 14:32:57 -0800 | [diff] [blame] | 65 | write_sequnlock_bh(&net->ipv4.ip_local_ports.lock); |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /* Validate changes from /proc interface. */ |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 69 | static int ipv4_local_port_range(struct ctl_table *table, int write, |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 70 | void __user *buffer, |
| 71 | size_t *lenp, loff_t *ppos) |
| 72 | { |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 73 | struct net *net = |
Cong Wang | c9d8f1a | 2014-05-06 11:02:49 -0700 | [diff] [blame] | 74 | container_of(table->data, struct net, ipv4.ip_local_ports.range); |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 75 | int ret; |
Eric Dumazet | 3c689b7 | 2008-10-08 14:18:04 -0700 | [diff] [blame] | 76 | int range[2]; |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 77 | struct ctl_table tmp = { |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 78 | .data = &range, |
| 79 | .maxlen = sizeof(range), |
| 80 | .mode = table->mode, |
| 81 | .extra1 = &ip_local_port_range_min, |
| 82 | .extra2 = &ip_local_port_range_max, |
| 83 | }; |
| 84 | |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 85 | inet_get_local_port_range(net, &range[0], &range[1]); |
| 86 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 87 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 88 | |
| 89 | if (write && ret == 0) { |
Krister Johansen | 4548b68 | 2017-01-20 17:49:11 -0800 | [diff] [blame] | 90 | /* Ensure that the upper limit is not smaller than the lower, |
| 91 | * and that the lower does not encroach upon the privileged |
| 92 | * port limit. |
| 93 | */ |
| 94 | if ((range[1] < range[0]) || |
| 95 | (range[0] < net->ipv4.sysctl_ip_prot_sock)) |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 96 | ret = -EINVAL; |
| 97 | else |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 98 | set_local_port_range(net, range); |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | return ret; |
| 102 | } |
| 103 | |
Krister Johansen | 4548b68 | 2017-01-20 17:49:11 -0800 | [diff] [blame] | 104 | /* Validate changes from /proc interface. */ |
| 105 | static int ipv4_privileged_ports(struct ctl_table *table, int write, |
| 106 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 107 | { |
| 108 | struct net *net = container_of(table->data, struct net, |
| 109 | ipv4.sysctl_ip_prot_sock); |
| 110 | int ret; |
| 111 | int pports; |
| 112 | int range[2]; |
| 113 | struct ctl_table tmp = { |
| 114 | .data = &pports, |
| 115 | .maxlen = sizeof(pports), |
| 116 | .mode = table->mode, |
| 117 | .extra1 = &ip_privileged_port_min, |
| 118 | .extra2 = &ip_privileged_port_max, |
| 119 | }; |
| 120 | |
| 121 | pports = net->ipv4.sysctl_ip_prot_sock; |
| 122 | |
| 123 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
| 124 | |
| 125 | if (write && ret == 0) { |
| 126 | inet_get_local_port_range(net, &range[0], &range[1]); |
| 127 | /* Ensure that the local port range doesn't overlap with the |
| 128 | * privileged port range. |
| 129 | */ |
| 130 | if (range[0] < pports) |
| 131 | ret = -EINVAL; |
| 132 | else |
| 133 | net->ipv4.sysctl_ip_prot_sock = pports; |
| 134 | } |
| 135 | |
| 136 | return ret; |
| 137 | } |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 138 | |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 139 | static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high) |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 140 | { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 141 | kgid_t *data = table->data; |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 142 | struct net *net = |
Cong Wang | ba6b918 | 2014-05-06 11:02:50 -0700 | [diff] [blame] | 143 | container_of(table->data, struct net, ipv4.ping_group_range.range); |
Eric Dumazet | 95c9617 | 2012-04-15 05:58:06 +0000 | [diff] [blame] | 144 | unsigned int seq; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 145 | do { |
WANG Cong | 396a30c | 2016-10-20 14:19:46 -0700 | [diff] [blame] | 146 | seq = read_seqbegin(&net->ipv4.ping_group_range.lock); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 147 | |
| 148 | *low = data[0]; |
| 149 | *high = data[1]; |
WANG Cong | 396a30c | 2016-10-20 14:19:46 -0700 | [diff] [blame] | 150 | } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq)); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /* Update system visible IP port range */ |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 154 | static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high) |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 155 | { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 156 | kgid_t *data = table->data; |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 157 | struct net *net = |
Cong Wang | ba6b918 | 2014-05-06 11:02:50 -0700 | [diff] [blame] | 158 | container_of(table->data, struct net, ipv4.ping_group_range.range); |
WANG Cong | 396a30c | 2016-10-20 14:19:46 -0700 | [diff] [blame] | 159 | write_seqlock(&net->ipv4.ping_group_range.lock); |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 160 | data[0] = low; |
| 161 | data[1] = high; |
WANG Cong | 396a30c | 2016-10-20 14:19:46 -0700 | [diff] [blame] | 162 | write_sequnlock(&net->ipv4.ping_group_range.lock); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | /* Validate changes from /proc interface. */ |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 166 | static int ipv4_ping_group_range(struct ctl_table *table, int write, |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 167 | void __user *buffer, |
| 168 | size_t *lenp, loff_t *ppos) |
| 169 | { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 170 | struct user_namespace *user_ns = current_user_ns(); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 171 | int ret; |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 172 | gid_t urange[2]; |
| 173 | kgid_t low, high; |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 174 | struct ctl_table tmp = { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 175 | .data = &urange, |
| 176 | .maxlen = sizeof(urange), |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 177 | .mode = table->mode, |
| 178 | .extra1 = &ip_ping_group_range_min, |
| 179 | .extra2 = &ip_ping_group_range_max, |
| 180 | }; |
| 181 | |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 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); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 185 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
| 186 | |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 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 | (urange[1] < urange[0]) || gid_lt(high, low)) { |
| 192 | low = make_kgid(&init_user_ns, 1); |
| 193 | high = make_kgid(&init_user_ns, 0); |
| 194 | } |
| 195 | set_ping_group_range(table, low, high); |
| 196 | } |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 197 | |
| 198 | return ret; |
| 199 | } |
| 200 | |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 201 | static int proc_tcp_congestion_control(struct ctl_table *ctl, int write, |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 202 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 203 | { |
Stephen Hemminger | 6670e15 | 2017-11-14 08:25:49 -0800 | [diff] [blame] | 204 | struct net *net = container_of(ctl->data, struct net, |
| 205 | ipv4.tcp_congestion_control); |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 206 | char val[TCP_CA_NAME_MAX]; |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 207 | struct ctl_table tbl = { |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 208 | .data = val, |
| 209 | .maxlen = TCP_CA_NAME_MAX, |
| 210 | }; |
| 211 | int ret; |
| 212 | |
Stephen Hemminger | 6670e15 | 2017-11-14 08:25:49 -0800 | [diff] [blame] | 213 | tcp_get_default_congestion_control(net, val); |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 214 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 215 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 216 | if (write && ret == 0) |
Stephen Hemminger | 6670e15 | 2017-11-14 08:25:49 -0800 | [diff] [blame] | 217 | ret = tcp_set_default_congestion_control(net, val); |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 218 | return ret; |
| 219 | } |
| 220 | |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 221 | static int proc_tcp_available_congestion_control(struct ctl_table *ctl, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 222 | int write, |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 223 | void __user *buffer, size_t *lenp, |
| 224 | loff_t *ppos) |
| 225 | { |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 226 | struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, }; |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 227 | int ret; |
| 228 | |
| 229 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); |
| 230 | if (!tbl.data) |
| 231 | return -ENOMEM; |
| 232 | tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 233 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 234 | kfree(tbl.data); |
| 235 | return ret; |
| 236 | } |
| 237 | |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 238 | static int proc_allowed_congestion_control(struct ctl_table *ctl, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 239 | int write, |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 240 | void __user *buffer, size_t *lenp, |
| 241 | loff_t *ppos) |
| 242 | { |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 243 | struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX }; |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 244 | int ret; |
| 245 | |
| 246 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); |
| 247 | if (!tbl.data) |
| 248 | return -ENOMEM; |
| 249 | |
| 250 | tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 251 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 252 | if (write && ret == 0) |
| 253 | ret = tcp_set_allowed_congestion_control(tbl.data); |
| 254 | kfree(tbl.data); |
| 255 | return ret; |
| 256 | } |
| 257 | |
Haishuang Yan | 4371384 | 2017-09-27 11:35:42 +0800 | [diff] [blame] | 258 | static int proc_tcp_fastopen_key(struct ctl_table *table, int write, |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 259 | void __user *buffer, size_t *lenp, |
| 260 | loff_t *ppos) |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 261 | { |
Haishuang Yan | 4371384 | 2017-09-27 11:35:42 +0800 | [diff] [blame] | 262 | struct net *net = container_of(table->data, struct net, |
| 263 | ipv4.sysctl_tcp_fastopen); |
Joe Perches | fe2c633 | 2013-06-11 23:04:25 -0700 | [diff] [blame] | 264 | struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) }; |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 265 | struct tcp_fastopen_context *ctxt; |
| 266 | int ret; |
| 267 | u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */ |
| 268 | |
| 269 | tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL); |
| 270 | if (!tbl.data) |
| 271 | return -ENOMEM; |
| 272 | |
| 273 | rcu_read_lock(); |
Haishuang Yan | 4371384 | 2017-09-27 11:35:42 +0800 | [diff] [blame] | 274 | ctxt = rcu_dereference(net->ipv4.tcp_fastopen_ctx); |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 275 | if (ctxt) |
| 276 | memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH); |
Alan Cox | 0e24c4f | 2012-10-11 06:24:14 +0000 | [diff] [blame] | 277 | else |
| 278 | memset(user_key, 0, sizeof(user_key)); |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 279 | rcu_read_unlock(); |
| 280 | |
| 281 | snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x", |
| 282 | user_key[0], user_key[1], user_key[2], user_key[3]); |
| 283 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
| 284 | |
| 285 | if (write && ret == 0) { |
| 286 | if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1, |
| 287 | user_key + 2, user_key + 3) != 4) { |
| 288 | ret = -EINVAL; |
| 289 | goto bad_key; |
| 290 | } |
Yuchung Cheng | 1fba70e | 2017-10-18 11:22:51 -0700 | [diff] [blame] | 291 | tcp_fastopen_reset_cipher(net, NULL, user_key, |
| 292 | TCP_FASTOPEN_KEY_LENGTH); |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | bad_key: |
| 296 | pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n", |
| 297 | user_key[0], user_key[1], user_key[2], user_key[3], |
| 298 | (char *)tbl.data, ret); |
| 299 | kfree(tbl.data); |
| 300 | return ret; |
| 301 | } |
| 302 | |
subashab@codeaurora.org | dddb64b | 2017-03-23 13:34:16 -0600 | [diff] [blame] | 303 | static void proc_configure_early_demux(int enabled, int protocol) |
| 304 | { |
| 305 | struct net_protocol *ipprot; |
| 306 | #if IS_ENABLED(CONFIG_IPV6) |
| 307 | struct inet6_protocol *ip6prot; |
| 308 | #endif |
| 309 | |
David Ahern | 58c4c6a | 2017-04-22 09:33:16 -0700 | [diff] [blame] | 310 | rcu_read_lock(); |
| 311 | |
subashab@codeaurora.org | dddb64b | 2017-03-23 13:34:16 -0600 | [diff] [blame] | 312 | ipprot = rcu_dereference(inet_protos[protocol]); |
| 313 | if (ipprot) |
| 314 | ipprot->early_demux = enabled ? ipprot->early_demux_handler : |
| 315 | NULL; |
| 316 | |
| 317 | #if IS_ENABLED(CONFIG_IPV6) |
| 318 | ip6prot = rcu_dereference(inet6_protos[protocol]); |
| 319 | if (ip6prot) |
| 320 | ip6prot->early_demux = enabled ? ip6prot->early_demux_handler : |
| 321 | NULL; |
| 322 | #endif |
David Ahern | 58c4c6a | 2017-04-22 09:33:16 -0700 | [diff] [blame] | 323 | rcu_read_unlock(); |
subashab@codeaurora.org | dddb64b | 2017-03-23 13:34:16 -0600 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static int proc_tcp_early_demux(struct ctl_table *table, int write, |
| 327 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 328 | { |
| 329 | int ret = 0; |
| 330 | |
| 331 | ret = proc_dointvec(table, write, buffer, lenp, ppos); |
| 332 | |
| 333 | if (write && !ret) { |
| 334 | int enabled = init_net.ipv4.sysctl_tcp_early_demux; |
| 335 | |
| 336 | proc_configure_early_demux(enabled, IPPROTO_TCP); |
| 337 | } |
| 338 | |
| 339 | return ret; |
| 340 | } |
| 341 | |
| 342 | static int proc_udp_early_demux(struct ctl_table *table, int write, |
| 343 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 344 | { |
| 345 | int ret = 0; |
| 346 | |
| 347 | ret = proc_dointvec(table, write, buffer, lenp, ppos); |
| 348 | |
| 349 | if (write && !ret) { |
| 350 | int enabled = init_net.ipv4.sysctl_udp_early_demux; |
| 351 | |
| 352 | proc_configure_early_demux(enabled, IPPROTO_UDP); |
| 353 | } |
| 354 | |
| 355 | return ret; |
| 356 | } |
| 357 | |
Wei Wang | cf1ef3f | 2017-04-20 14:45:46 -0700 | [diff] [blame] | 358 | static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table, |
| 359 | int write, |
| 360 | void __user *buffer, |
| 361 | size_t *lenp, loff_t *ppos) |
| 362 | { |
Haishuang Yan | 3733be1 | 2017-09-27 11:35:43 +0800 | [diff] [blame] | 363 | struct net *net = container_of(table->data, struct net, |
| 364 | ipv4.sysctl_tcp_fastopen_blackhole_timeout); |
Wei Wang | cf1ef3f | 2017-04-20 14:45:46 -0700 | [diff] [blame] | 365 | int ret; |
| 366 | |
| 367 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
| 368 | if (write && ret == 0) |
Haishuang Yan | 3733be1 | 2017-09-27 11:35:43 +0800 | [diff] [blame] | 369 | atomic_set(&net->ipv4.tfo_active_disable_times, 0); |
Dave Watson | 734942c | 2017-06-14 11:37:14 -0700 | [diff] [blame] | 370 | |
| 371 | return ret; |
| 372 | } |
| 373 | |
| 374 | static int proc_tcp_available_ulp(struct ctl_table *ctl, |
| 375 | int write, |
| 376 | void __user *buffer, size_t *lenp, |
| 377 | loff_t *ppos) |
| 378 | { |
| 379 | struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, }; |
| 380 | int ret; |
| 381 | |
| 382 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); |
| 383 | if (!tbl.data) |
| 384 | return -ENOMEM; |
| 385 | tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX); |
| 386 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
| 387 | kfree(tbl.data); |
| 388 | |
Wei Wang | cf1ef3f | 2017-04-20 14:45:46 -0700 | [diff] [blame] | 389 | return ret; |
| 390 | } |
| 391 | |
Ido Schimmel | 3ae6ec0 | 2017-11-02 17:14:05 +0100 | [diff] [blame] | 392 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
| 393 | static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write, |
| 394 | void __user *buffer, size_t *lenp, |
| 395 | loff_t *ppos) |
| 396 | { |
| 397 | struct net *net = container_of(table->data, struct net, |
| 398 | ipv4.sysctl_fib_multipath_hash_policy); |
| 399 | int ret; |
| 400 | |
| 401 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
| 402 | if (write && ret == 0) |
David Ahern | 3192dac | 2018-03-02 08:32:16 -0800 | [diff] [blame] | 403 | call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net); |
Ido Schimmel | 3ae6ec0 | 2017-11-02 17:14:05 +0100 | [diff] [blame] | 404 | |
| 405 | return ret; |
| 406 | } |
| 407 | #endif |
| 408 | |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 409 | static struct ctl_table ipv4_table[] = { |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 410 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | .procname = "tcp_max_orphans", |
| 412 | .data = &sysctl_tcp_max_orphans, |
| 413 | .maxlen = sizeof(int), |
| 414 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 415 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | }, |
| 417 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | .procname = "inet_peer_threshold", |
| 419 | .data = &inet_peer_threshold, |
| 420 | .maxlen = sizeof(int), |
| 421 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 422 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | }, |
| 424 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | .procname = "inet_peer_minttl", |
| 426 | .data = &inet_peer_minttl, |
| 427 | .maxlen = sizeof(int), |
| 428 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 429 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | }, |
| 431 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | .procname = "inet_peer_maxttl", |
| 433 | .data = &inet_peer_maxttl, |
| 434 | .maxlen = sizeof(int), |
| 435 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 436 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | }, |
| 438 | { |
Eric W. Biederman | a4fe34b | 2013-10-19 16:25:36 -0700 | [diff] [blame] | 439 | .procname = "tcp_mem", |
| 440 | .maxlen = sizeof(sysctl_tcp_mem), |
| 441 | .data = &sysctl_tcp_mem, |
| 442 | .mode = 0644, |
| 443 | .proc_handler = proc_doulongvec_minmax, |
| 444 | }, |
| 445 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | .procname = "tcp_low_latency", |
| 447 | .data = &sysctl_tcp_low_latency, |
| 448 | .maxlen = sizeof(int), |
| 449 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 450 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | }, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 452 | #ifdef CONFIG_NETLABEL |
| 453 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 454 | .procname = "cipso_cache_enable", |
| 455 | .data = &cipso_v4_cache_enabled, |
| 456 | .maxlen = sizeof(int), |
| 457 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 458 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 459 | }, |
| 460 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 461 | .procname = "cipso_cache_bucket_size", |
| 462 | .data = &cipso_v4_cache_bucketsize, |
| 463 | .maxlen = sizeof(int), |
| 464 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 465 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 466 | }, |
| 467 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 468 | .procname = "cipso_rbm_optfmt", |
| 469 | .data = &cipso_v4_rbm_optfmt, |
| 470 | .maxlen = sizeof(int), |
| 471 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 472 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 473 | }, |
| 474 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 475 | .procname = "cipso_rbm_strictvalid", |
| 476 | .data = &cipso_v4_rbm_strictvalid, |
| 477 | .maxlen = sizeof(int), |
| 478 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 479 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 480 | }, |
| 481 | #endif /* CONFIG_NETLABEL */ |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 482 | { |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 483 | .procname = "tcp_available_congestion_control", |
| 484 | .maxlen = TCP_CA_BUF_MAX, |
| 485 | .mode = 0444, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 486 | .proc_handler = proc_tcp_available_congestion_control, |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 487 | }, |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 488 | { |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 489 | .procname = "tcp_allowed_congestion_control", |
| 490 | .maxlen = TCP_CA_BUF_MAX, |
| 491 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 492 | .proc_handler = proc_allowed_congestion_control, |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 493 | }, |
John Heffner | 886236c | 2007-03-25 19:21:45 -0700 | [diff] [blame] | 494 | { |
Dave Watson | 734942c | 2017-06-14 11:37:14 -0700 | [diff] [blame] | 495 | .procname = "tcp_available_ulp", |
| 496 | .maxlen = TCP_ULP_BUF_MAX, |
| 497 | .mode = 0444, |
| 498 | .proc_handler = proc_tcp_available_ulp, |
| 499 | }, |
| 500 | { |
Eric Dumazet | 4cdf507 | 2014-09-19 07:38:40 -0700 | [diff] [blame] | 501 | .procname = "icmp_msgs_per_sec", |
| 502 | .data = &sysctl_icmp_msgs_per_sec, |
| 503 | .maxlen = sizeof(int), |
| 504 | .mode = 0644, |
| 505 | .proc_handler = proc_dointvec_minmax, |
| 506 | .extra1 = &zero, |
| 507 | }, |
| 508 | { |
| 509 | .procname = "icmp_msgs_burst", |
| 510 | .data = &sysctl_icmp_msgs_burst, |
| 511 | .maxlen = sizeof(int), |
| 512 | .mode = 0644, |
| 513 | .proc_handler = proc_dointvec_minmax, |
| 514 | .extra1 = &zero, |
| 515 | }, |
| 516 | { |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 517 | .procname = "udp_mem", |
| 518 | .data = &sysctl_udp_mem, |
| 519 | .maxlen = sizeof(sysctl_udp_mem), |
| 520 | .mode = 0644, |
Eric Dumazet | 8d987e5 | 2010-11-09 23:24:26 +0000 | [diff] [blame] | 521 | .proc_handler = proc_doulongvec_minmax, |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 522 | }, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 523 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | }; |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 525 | |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 526 | static struct ctl_table ipv4_net_table[] = { |
| 527 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 528 | .procname = "icmp_echo_ignore_all", |
| 529 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, |
| 530 | .maxlen = sizeof(int), |
| 531 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 532 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 533 | }, |
| 534 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 535 | .procname = "icmp_echo_ignore_broadcasts", |
| 536 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, |
| 537 | .maxlen = sizeof(int), |
| 538 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 539 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 540 | }, |
| 541 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 542 | .procname = "icmp_ignore_bogus_error_responses", |
| 543 | .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, |
| 544 | .maxlen = sizeof(int), |
| 545 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 546 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 547 | }, |
| 548 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 549 | .procname = "icmp_errors_use_inbound_ifaddr", |
| 550 | .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, |
| 551 | .maxlen = sizeof(int), |
| 552 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 553 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 554 | }, |
| 555 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 556 | .procname = "icmp_ratelimit", |
| 557 | .data = &init_net.ipv4.sysctl_icmp_ratelimit, |
| 558 | .maxlen = sizeof(int), |
| 559 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 560 | .proc_handler = proc_dointvec_ms_jiffies, |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 561 | }, |
| 562 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 563 | .procname = "icmp_ratemask", |
| 564 | .data = &init_net.ipv4.sysctl_icmp_ratemask, |
| 565 | .maxlen = sizeof(int), |
| 566 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 567 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 568 | }, |
Neil Horman | 1080d70 | 2008-10-27 12:28:25 -0700 | [diff] [blame] | 569 | { |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 570 | .procname = "ping_group_range", |
Cong Wang | ba6b918 | 2014-05-06 11:02:50 -0700 | [diff] [blame] | 571 | .data = &init_net.ipv4.ping_group_range.range, |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 572 | .maxlen = sizeof(gid_t)*2, |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 573 | .mode = 0644, |
| 574 | .proc_handler = ipv4_ping_group_range, |
| 575 | }, |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 576 | { |
Hannes Frederic Sowa | 5d134f1 | 2013-01-05 16:10:48 +0000 | [diff] [blame] | 577 | .procname = "tcp_ecn", |
| 578 | .data = &init_net.ipv4.sysctl_tcp_ecn, |
| 579 | .maxlen = sizeof(int), |
| 580 | .mode = 0644, |
| 581 | .proc_handler = proc_dointvec |
| 582 | }, |
| 583 | { |
Daniel Borkmann | 4921355 | 2015-05-19 21:04:22 +0200 | [diff] [blame] | 584 | .procname = "tcp_ecn_fallback", |
| 585 | .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, |
| 586 | .maxlen = sizeof(int), |
| 587 | .mode = 0644, |
| 588 | .proc_handler = proc_dointvec |
| 589 | }, |
| 590 | { |
Nikolay Borisov | 287b7f3 | 2016-02-15 12:11:29 +0200 | [diff] [blame] | 591 | .procname = "ip_dynaddr", |
| 592 | .data = &init_net.ipv4.sysctl_ip_dynaddr, |
| 593 | .maxlen = sizeof(int), |
| 594 | .mode = 0644, |
| 595 | .proc_handler = proc_dointvec |
| 596 | }, |
| 597 | { |
Nikolay Borisov | e21145a | 2016-02-15 12:11:30 +0200 | [diff] [blame] | 598 | .procname = "ip_early_demux", |
| 599 | .data = &init_net.ipv4.sysctl_ip_early_demux, |
| 600 | .maxlen = sizeof(int), |
| 601 | .mode = 0644, |
| 602 | .proc_handler = proc_dointvec |
| 603 | }, |
| 604 | { |
subashab@codeaurora.org | dddb64b | 2017-03-23 13:34:16 -0600 | [diff] [blame] | 605 | .procname = "udp_early_demux", |
| 606 | .data = &init_net.ipv4.sysctl_udp_early_demux, |
| 607 | .maxlen = sizeof(int), |
| 608 | .mode = 0644, |
| 609 | .proc_handler = proc_udp_early_demux |
| 610 | }, |
| 611 | { |
| 612 | .procname = "tcp_early_demux", |
| 613 | .data = &init_net.ipv4.sysctl_tcp_early_demux, |
| 614 | .maxlen = sizeof(int), |
| 615 | .mode = 0644, |
| 616 | .proc_handler = proc_tcp_early_demux |
| 617 | }, |
| 618 | { |
Nikolay Borisov | fa50d97 | 2016-02-15 12:11:27 +0200 | [diff] [blame] | 619 | .procname = "ip_default_ttl", |
| 620 | .data = &init_net.ipv4.sysctl_ip_default_ttl, |
| 621 | .maxlen = sizeof(int), |
| 622 | .mode = 0644, |
| 623 | .proc_handler = proc_dointvec_minmax, |
| 624 | .extra1 = &ip_ttl_min, |
| 625 | .extra2 = &ip_ttl_max, |
| 626 | }, |
| 627 | { |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 628 | .procname = "ip_local_port_range", |
Cong Wang | c9d8f1a | 2014-05-06 11:02:49 -0700 | [diff] [blame] | 629 | .maxlen = sizeof(init_net.ipv4.ip_local_ports.range), |
| 630 | .data = &init_net.ipv4.ip_local_ports.range, |
Eric W. Biederman | 0bbf87d | 2013-09-28 14:10:59 -0700 | [diff] [blame] | 631 | .mode = 0644, |
| 632 | .proc_handler = ipv4_local_port_range, |
| 633 | }, |
Hannes Frederic Sowa | 974eda1 | 2013-12-14 05:13:38 +0100 | [diff] [blame] | 634 | { |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 635 | .procname = "ip_local_reserved_ports", |
| 636 | .data = &init_net.ipv4.sysctl_local_reserved_ports, |
| 637 | .maxlen = 65536, |
| 638 | .mode = 0644, |
| 639 | .proc_handler = proc_do_large_bitmap, |
| 640 | }, |
| 641 | { |
Hannes Frederic Sowa | 974eda1 | 2013-12-14 05:13:38 +0100 | [diff] [blame] | 642 | .procname = "ip_no_pmtu_disc", |
| 643 | .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc, |
| 644 | .maxlen = sizeof(int), |
| 645 | .mode = 0644, |
| 646 | .proc_handler = proc_dointvec |
| 647 | }, |
Hannes Frederic Sowa | f87c10a | 2014-01-09 10:01:15 +0100 | [diff] [blame] | 648 | { |
| 649 | .procname = "ip_forward_use_pmtu", |
| 650 | .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu, |
| 651 | .maxlen = sizeof(int), |
| 652 | .mode = 0644, |
| 653 | .proc_handler = proc_dointvec, |
| 654 | }, |
Lorenzo Colitti | e110861 | 2014-05-13 10:17:33 -0700 | [diff] [blame] | 655 | { |
Vincent Bernat | 49a6015 | 2014-09-05 15:09:03 +0200 | [diff] [blame] | 656 | .procname = "ip_nonlocal_bind", |
| 657 | .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, |
| 658 | .maxlen = sizeof(int), |
| 659 | .mode = 0644, |
| 660 | .proc_handler = proc_dointvec |
| 661 | }, |
| 662 | { |
Lorenzo Colitti | e110861 | 2014-05-13 10:17:33 -0700 | [diff] [blame] | 663 | .procname = "fwmark_reflect", |
| 664 | .data = &init_net.ipv4.sysctl_fwmark_reflect, |
| 665 | .maxlen = sizeof(int), |
| 666 | .mode = 0644, |
| 667 | .proc_handler = proc_dointvec, |
| 668 | }, |
Lorenzo Colitti | 84f39b0 | 2014-05-13 10:17:35 -0700 | [diff] [blame] | 669 | { |
| 670 | .procname = "tcp_fwmark_accept", |
| 671 | .data = &init_net.ipv4.sysctl_tcp_fwmark_accept, |
| 672 | .maxlen = sizeof(int), |
| 673 | .mode = 0644, |
| 674 | .proc_handler = proc_dointvec, |
| 675 | }, |
David Ahern | 6dd9a14 | 2015-12-16 13:20:44 -0800 | [diff] [blame] | 676 | #ifdef CONFIG_NET_L3_MASTER_DEV |
| 677 | { |
| 678 | .procname = "tcp_l3mdev_accept", |
| 679 | .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept, |
| 680 | .maxlen = sizeof(int), |
| 681 | .mode = 0644, |
| 682 | .proc_handler = proc_dointvec_minmax, |
| 683 | .extra1 = &zero, |
| 684 | .extra2 = &one, |
| 685 | }, |
| 686 | #endif |
Fan Du | b0f9ca5 | 2015-02-10 09:53:16 +0800 | [diff] [blame] | 687 | { |
| 688 | .procname = "tcp_mtu_probing", |
| 689 | .data = &init_net.ipv4.sysctl_tcp_mtu_probing, |
| 690 | .maxlen = sizeof(int), |
| 691 | .mode = 0644, |
| 692 | .proc_handler = proc_dointvec, |
| 693 | }, |
| 694 | { |
| 695 | .procname = "tcp_base_mss", |
| 696 | .data = &init_net.ipv4.sysctl_tcp_base_mss, |
| 697 | .maxlen = sizeof(int), |
| 698 | .mode = 0644, |
| 699 | .proc_handler = proc_dointvec, |
| 700 | }, |
Fan Du | 6b58e0a | 2015-03-06 11:18:23 +0800 | [diff] [blame] | 701 | { |
| 702 | .procname = "tcp_probe_threshold", |
| 703 | .data = &init_net.ipv4.sysctl_tcp_probe_threshold, |
| 704 | .maxlen = sizeof(int), |
| 705 | .mode = 0644, |
| 706 | .proc_handler = proc_dointvec, |
| 707 | }, |
Fan Du | 05cbc0d | 2015-03-06 11:18:24 +0800 | [diff] [blame] | 708 | { |
| 709 | .procname = "tcp_probe_interval", |
| 710 | .data = &init_net.ipv4.sysctl_tcp_probe_interval, |
| 711 | .maxlen = sizeof(int), |
| 712 | .mode = 0644, |
| 713 | .proc_handler = proc_dointvec, |
| 714 | }, |
Philip Downey | df2cf4a | 2015-08-27 16:46:26 +0100 | [diff] [blame] | 715 | { |
| 716 | .procname = "igmp_link_local_mcast_reports", |
Nikolay Borisov | 87a8a2a | 2016-02-09 00:13:50 +0200 | [diff] [blame] | 717 | .data = &init_net.ipv4.sysctl_igmp_llm_reports, |
Philip Downey | df2cf4a | 2015-08-27 16:46:26 +0100 | [diff] [blame] | 718 | .maxlen = sizeof(int), |
| 719 | .mode = 0644, |
| 720 | .proc_handler = proc_dointvec |
| 721 | }, |
Nikolay Borisov | 13b287e | 2016-01-07 16:38:43 +0200 | [diff] [blame] | 722 | { |
Nikolay Borisov | 815c527 | 2016-02-08 23:29:21 +0200 | [diff] [blame] | 723 | .procname = "igmp_max_memberships", |
| 724 | .data = &init_net.ipv4.sysctl_igmp_max_memberships, |
| 725 | .maxlen = sizeof(int), |
| 726 | .mode = 0644, |
| 727 | .proc_handler = proc_dointvec |
| 728 | }, |
| 729 | { |
Nikolay Borisov | 166b6b2 | 2016-02-08 23:29:22 +0200 | [diff] [blame] | 730 | .procname = "igmp_max_msf", |
| 731 | .data = &init_net.ipv4.sysctl_igmp_max_msf, |
| 732 | .maxlen = sizeof(int), |
| 733 | .mode = 0644, |
| 734 | .proc_handler = proc_dointvec |
| 735 | }, |
Nikolay Borisov | 165094a | 2016-02-08 23:29:24 +0200 | [diff] [blame] | 736 | #ifdef CONFIG_IP_MULTICAST |
| 737 | { |
| 738 | .procname = "igmp_qrv", |
| 739 | .data = &init_net.ipv4.sysctl_igmp_qrv, |
| 740 | .maxlen = sizeof(int), |
| 741 | .mode = 0644, |
| 742 | .proc_handler = proc_dointvec_minmax, |
| 743 | .extra1 = &one |
| 744 | }, |
| 745 | #endif |
Nikolay Borisov | 166b6b2 | 2016-02-08 23:29:22 +0200 | [diff] [blame] | 746 | { |
Stephen Hemminger | 6670e15 | 2017-11-14 08:25:49 -0800 | [diff] [blame] | 747 | .procname = "tcp_congestion_control", |
| 748 | .data = &init_net.ipv4.tcp_congestion_control, |
| 749 | .mode = 0644, |
| 750 | .maxlen = TCP_CA_NAME_MAX, |
| 751 | .proc_handler = proc_tcp_congestion_control, |
| 752 | }, |
| 753 | { |
Nikolay Borisov | 13b287e | 2016-01-07 16:38:43 +0200 | [diff] [blame] | 754 | .procname = "tcp_keepalive_time", |
| 755 | .data = &init_net.ipv4.sysctl_tcp_keepalive_time, |
| 756 | .maxlen = sizeof(int), |
| 757 | .mode = 0644, |
| 758 | .proc_handler = proc_dointvec_jiffies, |
| 759 | }, |
Nikolay Borisov | 9bd6861 | 2016-01-07 16:38:44 +0200 | [diff] [blame] | 760 | { |
| 761 | .procname = "tcp_keepalive_probes", |
| 762 | .data = &init_net.ipv4.sysctl_tcp_keepalive_probes, |
| 763 | .maxlen = sizeof(int), |
| 764 | .mode = 0644, |
| 765 | .proc_handler = proc_dointvec |
| 766 | }, |
Nikolay Borisov | b840d15 | 2016-01-07 16:38:45 +0200 | [diff] [blame] | 767 | { |
| 768 | .procname = "tcp_keepalive_intvl", |
| 769 | .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl, |
| 770 | .maxlen = sizeof(int), |
| 771 | .mode = 0644, |
| 772 | .proc_handler = proc_dointvec_jiffies, |
| 773 | }, |
Nikolay Borisov | 6fa2516 | 2016-02-03 09:46:49 +0200 | [diff] [blame] | 774 | { |
| 775 | .procname = "tcp_syn_retries", |
| 776 | .data = &init_net.ipv4.sysctl_tcp_syn_retries, |
| 777 | .maxlen = sizeof(int), |
| 778 | .mode = 0644, |
| 779 | .proc_handler = proc_dointvec_minmax, |
| 780 | .extra1 = &tcp_syn_retries_min, |
| 781 | .extra2 = &tcp_syn_retries_max |
| 782 | }, |
Nikolay Borisov | 7c083ec | 2016-02-03 09:46:50 +0200 | [diff] [blame] | 783 | { |
| 784 | .procname = "tcp_synack_retries", |
| 785 | .data = &init_net.ipv4.sysctl_tcp_synack_retries, |
| 786 | .maxlen = sizeof(int), |
| 787 | .mode = 0644, |
| 788 | .proc_handler = proc_dointvec |
| 789 | }, |
Nikolay Borisov | 12ed824 | 2016-02-03 09:46:51 +0200 | [diff] [blame] | 790 | #ifdef CONFIG_SYN_COOKIES |
| 791 | { |
| 792 | .procname = "tcp_syncookies", |
| 793 | .data = &init_net.ipv4.sysctl_tcp_syncookies, |
| 794 | .maxlen = sizeof(int), |
| 795 | .mode = 0644, |
| 796 | .proc_handler = proc_dointvec |
| 797 | }, |
| 798 | #endif |
Nikolay Borisov | 1043e25 | 2016-02-03 09:46:52 +0200 | [diff] [blame] | 799 | { |
| 800 | .procname = "tcp_reordering", |
| 801 | .data = &init_net.ipv4.sysctl_tcp_reordering, |
| 802 | .maxlen = sizeof(int), |
| 803 | .mode = 0644, |
| 804 | .proc_handler = proc_dointvec |
| 805 | }, |
Nikolay Borisov | ae5c3f4 | 2016-02-03 09:46:53 +0200 | [diff] [blame] | 806 | { |
| 807 | .procname = "tcp_retries1", |
| 808 | .data = &init_net.ipv4.sysctl_tcp_retries1, |
| 809 | .maxlen = sizeof(int), |
| 810 | .mode = 0644, |
| 811 | .proc_handler = proc_dointvec_minmax, |
| 812 | .extra2 = &tcp_retr1_max |
| 813 | }, |
Nikolay Borisov | c6214a9 | 2016-02-03 09:46:54 +0200 | [diff] [blame] | 814 | { |
| 815 | .procname = "tcp_retries2", |
| 816 | .data = &init_net.ipv4.sysctl_tcp_retries2, |
| 817 | .maxlen = sizeof(int), |
| 818 | .mode = 0644, |
| 819 | .proc_handler = proc_dointvec |
| 820 | }, |
Nikolay Borisov | c402d9b | 2016-02-03 09:46:55 +0200 | [diff] [blame] | 821 | { |
| 822 | .procname = "tcp_orphan_retries", |
| 823 | .data = &init_net.ipv4.sysctl_tcp_orphan_retries, |
| 824 | .maxlen = sizeof(int), |
| 825 | .mode = 0644, |
| 826 | .proc_handler = proc_dointvec |
| 827 | }, |
Nikolay Borisov | 1e579ca | 2016-02-03 09:46:56 +0200 | [diff] [blame] | 828 | { |
| 829 | .procname = "tcp_fin_timeout", |
| 830 | .data = &init_net.ipv4.sysctl_tcp_fin_timeout, |
| 831 | .maxlen = sizeof(int), |
| 832 | .mode = 0644, |
| 833 | .proc_handler = proc_dointvec_jiffies, |
| 834 | }, |
Nikolay Borisov | 4979f2d | 2016-02-03 09:46:57 +0200 | [diff] [blame] | 835 | { |
| 836 | .procname = "tcp_notsent_lowat", |
| 837 | .data = &init_net.ipv4.sysctl_tcp_notsent_lowat, |
| 838 | .maxlen = sizeof(unsigned int), |
| 839 | .mode = 0644, |
Pavel Tikhomirov | b007f09 | 2017-01-09 10:45:49 +0300 | [diff] [blame] | 840 | .proc_handler = proc_douintvec, |
Nikolay Borisov | 4979f2d | 2016-02-03 09:46:57 +0200 | [diff] [blame] | 841 | }, |
Haishuang Yan | 56ab6b9 | 2016-12-25 14:33:16 +0800 | [diff] [blame] | 842 | { |
| 843 | .procname = "tcp_tw_reuse", |
| 844 | .data = &init_net.ipv4.sysctl_tcp_tw_reuse, |
| 845 | .maxlen = sizeof(int), |
| 846 | .mode = 0644, |
| 847 | .proc_handler = proc_dointvec |
| 848 | }, |
Haishuang Yan | 1946e67 | 2016-12-28 17:52:32 +0800 | [diff] [blame] | 849 | { |
| 850 | .procname = "tcp_max_tw_buckets", |
| 851 | .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets, |
| 852 | .maxlen = sizeof(int), |
| 853 | .mode = 0644, |
| 854 | .proc_handler = proc_dointvec |
| 855 | }, |
| 856 | { |
Haishuang Yan | fee83d0 | 2016-12-28 17:52:33 +0800 | [diff] [blame] | 857 | .procname = "tcp_max_syn_backlog", |
| 858 | .data = &init_net.ipv4.sysctl_max_syn_backlog, |
| 859 | .maxlen = sizeof(int), |
| 860 | .mode = 0644, |
| 861 | .proc_handler = proc_dointvec |
| 862 | }, |
Haishuang Yan | e1cfcbe | 2017-09-27 11:35:40 +0800 | [diff] [blame] | 863 | { |
| 864 | .procname = "tcp_fastopen", |
| 865 | .data = &init_net.ipv4.sysctl_tcp_fastopen, |
| 866 | .maxlen = sizeof(int), |
| 867 | .mode = 0644, |
| 868 | .proc_handler = proc_dointvec, |
| 869 | }, |
Haishuang Yan | 4371384 | 2017-09-27 11:35:42 +0800 | [diff] [blame] | 870 | { |
| 871 | .procname = "tcp_fastopen_key", |
| 872 | .mode = 0600, |
| 873 | .data = &init_net.ipv4.sysctl_tcp_fastopen, |
| 874 | .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10), |
| 875 | .proc_handler = proc_tcp_fastopen_key, |
| 876 | }, |
Haishuang Yan | 3733be1 | 2017-09-27 11:35:43 +0800 | [diff] [blame] | 877 | { |
| 878 | .procname = "tcp_fastopen_blackhole_timeout_sec", |
| 879 | .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout, |
| 880 | .maxlen = sizeof(int), |
| 881 | .mode = 0644, |
| 882 | .proc_handler = proc_tfo_blackhole_detect_timeout, |
| 883 | .extra1 = &zero, |
| 884 | }, |
David Ahern | a6db449 | 2016-04-07 07:21:00 -0700 | [diff] [blame] | 885 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
| 886 | { |
| 887 | .procname = "fib_multipath_use_neigh", |
| 888 | .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh, |
| 889 | .maxlen = sizeof(int), |
| 890 | .mode = 0644, |
| 891 | .proc_handler = proc_dointvec_minmax, |
| 892 | .extra1 = &zero, |
| 893 | .extra2 = &one, |
| 894 | }, |
Nikolay Aleksandrov | bf4e0a3 | 2017-03-16 15:28:00 +0200 | [diff] [blame] | 895 | { |
| 896 | .procname = "fib_multipath_hash_policy", |
| 897 | .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy, |
| 898 | .maxlen = sizeof(int), |
| 899 | .mode = 0644, |
Ido Schimmel | 3ae6ec0 | 2017-11-02 17:14:05 +0100 | [diff] [blame] | 900 | .proc_handler = proc_fib_multipath_hash_policy, |
Nikolay Aleksandrov | bf4e0a3 | 2017-03-16 15:28:00 +0200 | [diff] [blame] | 901 | .extra1 = &zero, |
| 902 | .extra2 = &one, |
| 903 | }, |
David Ahern | a6db449 | 2016-04-07 07:21:00 -0700 | [diff] [blame] | 904 | #endif |
Krister Johansen | 4548b68 | 2017-01-20 17:49:11 -0800 | [diff] [blame] | 905 | { |
| 906 | .procname = "ip_unprivileged_port_start", |
| 907 | .maxlen = sizeof(int), |
| 908 | .data = &init_net.ipv4.sysctl_ip_prot_sock, |
| 909 | .mode = 0644, |
| 910 | .proc_handler = ipv4_privileged_ports, |
| 911 | }, |
Robert Shearman | 63a6fff | 2017-01-26 18:02:24 +0000 | [diff] [blame] | 912 | #ifdef CONFIG_NET_L3_MASTER_DEV |
| 913 | { |
| 914 | .procname = "udp_l3mdev_accept", |
| 915 | .data = &init_net.ipv4.sysctl_udp_l3mdev_accept, |
| 916 | .maxlen = sizeof(int), |
| 917 | .mode = 0644, |
| 918 | .proc_handler = proc_dointvec_minmax, |
| 919 | .extra1 = &zero, |
| 920 | .extra2 = &one, |
| 921 | }, |
| 922 | #endif |
Eric Dumazet | f930103 | 2017-06-07 10:34:37 -0700 | [diff] [blame] | 923 | { |
| 924 | .procname = "tcp_sack", |
| 925 | .data = &init_net.ipv4.sysctl_tcp_sack, |
| 926 | .maxlen = sizeof(int), |
| 927 | .mode = 0644, |
| 928 | .proc_handler = proc_dointvec |
| 929 | }, |
Eric Dumazet | 9bb37ef | 2017-06-07 10:34:38 -0700 | [diff] [blame] | 930 | { |
| 931 | .procname = "tcp_window_scaling", |
| 932 | .data = &init_net.ipv4.sysctl_tcp_window_scaling, |
| 933 | .maxlen = sizeof(int), |
| 934 | .mode = 0644, |
| 935 | .proc_handler = proc_dointvec |
| 936 | }, |
Eric Dumazet | 5d2ed05 | 2017-06-07 10:34:39 -0700 | [diff] [blame] | 937 | { |
| 938 | .procname = "tcp_timestamps", |
| 939 | .data = &init_net.ipv4.sysctl_tcp_timestamps, |
| 940 | .maxlen = sizeof(int), |
| 941 | .mode = 0644, |
| 942 | .proc_handler = proc_dointvec |
| 943 | }, |
Eric Dumazet | 2ae21cf | 2017-10-26 21:54:56 -0700 | [diff] [blame] | 944 | { |
| 945 | .procname = "tcp_early_retrans", |
| 946 | .data = &init_net.ipv4.sysctl_tcp_early_retrans, |
| 947 | .maxlen = sizeof(int), |
| 948 | .mode = 0644, |
| 949 | .proc_handler = proc_dointvec_minmax, |
| 950 | .extra1 = &zero, |
| 951 | .extra2 = &four, |
| 952 | }, |
Eric Dumazet | e20223f | 2017-10-26 21:54:57 -0700 | [diff] [blame] | 953 | { |
| 954 | .procname = "tcp_recovery", |
| 955 | .data = &init_net.ipv4.sysctl_tcp_recovery, |
| 956 | .maxlen = sizeof(int), |
| 957 | .mode = 0644, |
| 958 | .proc_handler = proc_dointvec, |
| 959 | }, |
Eric Dumazet | 2c04ac8 | 2017-10-26 21:54:58 -0700 | [diff] [blame] | 960 | { |
| 961 | .procname = "tcp_thin_linear_timeouts", |
| 962 | .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts, |
| 963 | .maxlen = sizeof(int), |
| 964 | .mode = 0644, |
| 965 | .proc_handler = proc_dointvec |
| 966 | }, |
Eric Dumazet | b510f0d | 2017-10-26 21:54:59 -0700 | [diff] [blame] | 967 | { |
| 968 | .procname = "tcp_slow_start_after_idle", |
| 969 | .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle, |
| 970 | .maxlen = sizeof(int), |
| 971 | .mode = 0644, |
| 972 | .proc_handler = proc_dointvec |
| 973 | }, |
Eric Dumazet | e0a1e5b | 2017-10-26 21:55:00 -0700 | [diff] [blame] | 974 | { |
| 975 | .procname = "tcp_retrans_collapse", |
| 976 | .data = &init_net.ipv4.sysctl_tcp_retrans_collapse, |
| 977 | .maxlen = sizeof(int), |
| 978 | .mode = 0644, |
| 979 | .proc_handler = proc_dointvec |
| 980 | }, |
Eric Dumazet | 3f4c7c6 | 2017-10-26 21:55:01 -0700 | [diff] [blame] | 981 | { |
| 982 | .procname = "tcp_stdurg", |
| 983 | .data = &init_net.ipv4.sysctl_tcp_stdurg, |
| 984 | .maxlen = sizeof(int), |
| 985 | .mode = 0644, |
| 986 | .proc_handler = proc_dointvec |
| 987 | }, |
Eric Dumazet | 625357a | 2017-10-26 21:55:02 -0700 | [diff] [blame] | 988 | { |
| 989 | .procname = "tcp_rfc1337", |
| 990 | .data = &init_net.ipv4.sysctl_tcp_rfc1337, |
| 991 | .maxlen = sizeof(int), |
| 992 | .mode = 0644, |
| 993 | .proc_handler = proc_dointvec |
| 994 | }, |
Eric Dumazet | 65c9410 | 2017-10-26 21:55:03 -0700 | [diff] [blame] | 995 | { |
| 996 | .procname = "tcp_abort_on_overflow", |
| 997 | .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow, |
| 998 | .maxlen = sizeof(int), |
| 999 | .mode = 0644, |
| 1000 | .proc_handler = proc_dointvec |
| 1001 | }, |
Eric Dumazet | 0bc65a2 | 2017-10-26 21:55:04 -0700 | [diff] [blame] | 1002 | { |
| 1003 | .procname = "tcp_fack", |
| 1004 | .data = &init_net.ipv4.sysctl_tcp_fack, |
| 1005 | .maxlen = sizeof(int), |
| 1006 | .mode = 0644, |
| 1007 | .proc_handler = proc_dointvec |
| 1008 | }, |
Eric Dumazet | c6e2180 | 2017-10-26 21:55:06 -0700 | [diff] [blame] | 1009 | { |
| 1010 | .procname = "tcp_max_reordering", |
| 1011 | .data = &init_net.ipv4.sysctl_tcp_max_reordering, |
| 1012 | .maxlen = sizeof(int), |
| 1013 | .mode = 0644, |
| 1014 | .proc_handler = proc_dointvec |
| 1015 | }, |
Eric Dumazet | 6496f6b | 2017-10-26 21:55:07 -0700 | [diff] [blame] | 1016 | { |
| 1017 | .procname = "tcp_dsack", |
| 1018 | .data = &init_net.ipv4.sysctl_tcp_dsack, |
| 1019 | .maxlen = sizeof(int), |
| 1020 | .mode = 0644, |
| 1021 | .proc_handler = proc_dointvec |
| 1022 | }, |
Eric Dumazet | 0c12654 | 2017-10-26 21:55:08 -0700 | [diff] [blame] | 1023 | { |
| 1024 | .procname = "tcp_app_win", |
| 1025 | .data = &init_net.ipv4.sysctl_tcp_app_win, |
| 1026 | .maxlen = sizeof(int), |
| 1027 | .mode = 0644, |
| 1028 | .proc_handler = proc_dointvec |
| 1029 | }, |
Eric Dumazet | 94f0893 | 2017-10-26 21:55:09 -0700 | [diff] [blame] | 1030 | { |
| 1031 | .procname = "tcp_adv_win_scale", |
| 1032 | .data = &init_net.ipv4.sysctl_tcp_adv_win_scale, |
| 1033 | .maxlen = sizeof(int), |
| 1034 | .mode = 0644, |
| 1035 | .proc_handler = proc_dointvec_minmax, |
| 1036 | .extra1 = &tcp_adv_win_scale_min, |
| 1037 | .extra2 = &tcp_adv_win_scale_max, |
| 1038 | }, |
Eric Dumazet | af9b69a | 2017-10-26 21:55:10 -0700 | [diff] [blame] | 1039 | { |
| 1040 | .procname = "tcp_frto", |
| 1041 | .data = &init_net.ipv4.sysctl_tcp_frto, |
| 1042 | .maxlen = sizeof(int), |
| 1043 | .mode = 0644, |
| 1044 | .proc_handler = proc_dointvec |
| 1045 | }, |
Eric Dumazet | ec36e41 | 2017-10-27 07:47:21 -0700 | [diff] [blame] | 1046 | { |
| 1047 | .procname = "tcp_no_metrics_save", |
| 1048 | .data = &init_net.ipv4.sysctl_tcp_nometrics_save, |
| 1049 | .maxlen = sizeof(int), |
| 1050 | .mode = 0644, |
| 1051 | .proc_handler = proc_dointvec, |
| 1052 | }, |
Eric Dumazet | 4540c0c | 2017-10-27 07:47:22 -0700 | [diff] [blame] | 1053 | { |
| 1054 | .procname = "tcp_moderate_rcvbuf", |
| 1055 | .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf, |
| 1056 | .maxlen = sizeof(int), |
| 1057 | .mode = 0644, |
| 1058 | .proc_handler = proc_dointvec, |
| 1059 | }, |
Eric Dumazet | d06a990 | 2017-10-27 07:47:23 -0700 | [diff] [blame] | 1060 | { |
| 1061 | .procname = "tcp_tso_win_divisor", |
| 1062 | .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor, |
| 1063 | .maxlen = sizeof(int), |
| 1064 | .mode = 0644, |
| 1065 | .proc_handler = proc_dointvec, |
| 1066 | }, |
Eric Dumazet | ceef9ab | 2017-10-27 07:47:24 -0700 | [diff] [blame] | 1067 | { |
| 1068 | .procname = "tcp_workaround_signed_windows", |
| 1069 | .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows, |
| 1070 | .maxlen = sizeof(int), |
| 1071 | .mode = 0644, |
| 1072 | .proc_handler = proc_dointvec |
| 1073 | }, |
Eric Dumazet | 9184d8b | 2017-10-27 07:47:25 -0700 | [diff] [blame] | 1074 | { |
| 1075 | .procname = "tcp_limit_output_bytes", |
| 1076 | .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes, |
| 1077 | .maxlen = sizeof(int), |
| 1078 | .mode = 0644, |
| 1079 | .proc_handler = proc_dointvec |
| 1080 | }, |
Eric Dumazet | b530b68 | 2017-10-27 07:47:26 -0700 | [diff] [blame] | 1081 | { |
| 1082 | .procname = "tcp_challenge_ack_limit", |
| 1083 | .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit, |
| 1084 | .maxlen = sizeof(int), |
| 1085 | .mode = 0644, |
| 1086 | .proc_handler = proc_dointvec |
| 1087 | }, |
Eric Dumazet | 26e9596 | 2017-10-27 07:47:27 -0700 | [diff] [blame] | 1088 | { |
| 1089 | .procname = "tcp_min_tso_segs", |
| 1090 | .data = &init_net.ipv4.sysctl_tcp_min_tso_segs, |
| 1091 | .maxlen = sizeof(int), |
| 1092 | .mode = 0644, |
| 1093 | .proc_handler = proc_dointvec_minmax, |
| 1094 | .extra1 = &one, |
| 1095 | .extra2 = &gso_max_segs, |
| 1096 | }, |
Eric Dumazet | bd23970 | 2017-10-27 07:47:28 -0700 | [diff] [blame] | 1097 | { |
| 1098 | .procname = "tcp_min_rtt_wlen", |
| 1099 | .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen, |
| 1100 | .maxlen = sizeof(int), |
| 1101 | .mode = 0644, |
| 1102 | .proc_handler = proc_dointvec |
| 1103 | }, |
Eric Dumazet | 790f00e | 2017-10-27 07:47:29 -0700 | [diff] [blame] | 1104 | { |
| 1105 | .procname = "tcp_autocorking", |
| 1106 | .data = &init_net.ipv4.sysctl_tcp_autocorking, |
| 1107 | .maxlen = sizeof(int), |
| 1108 | .mode = 0644, |
| 1109 | .proc_handler = proc_dointvec_minmax, |
| 1110 | .extra1 = &zero, |
| 1111 | .extra2 = &one, |
| 1112 | }, |
Eric Dumazet | 4170ba6 | 2017-10-27 07:47:30 -0700 | [diff] [blame] | 1113 | { |
| 1114 | .procname = "tcp_invalid_ratelimit", |
| 1115 | .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit, |
| 1116 | .maxlen = sizeof(int), |
| 1117 | .mode = 0644, |
| 1118 | .proc_handler = proc_dointvec_ms_jiffies, |
| 1119 | }, |
Eric Dumazet | 23a7102a | 2017-10-27 07:47:31 -0700 | [diff] [blame] | 1120 | { |
| 1121 | .procname = "tcp_pacing_ss_ratio", |
| 1122 | .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio, |
| 1123 | .maxlen = sizeof(int), |
| 1124 | .mode = 0644, |
| 1125 | .proc_handler = proc_dointvec_minmax, |
| 1126 | .extra1 = &zero, |
| 1127 | .extra2 = &thousand, |
| 1128 | }, |
Eric Dumazet | c26e91f | 2017-10-27 07:47:32 -0700 | [diff] [blame] | 1129 | { |
| 1130 | .procname = "tcp_pacing_ca_ratio", |
| 1131 | .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio, |
| 1132 | .maxlen = sizeof(int), |
| 1133 | .mode = 0644, |
| 1134 | .proc_handler = proc_dointvec_minmax, |
| 1135 | .extra1 = &zero, |
| 1136 | .extra2 = &thousand, |
| 1137 | }, |
Eric Dumazet | 356d183 | 2017-11-07 00:29:28 -0800 | [diff] [blame] | 1138 | { |
| 1139 | .procname = "tcp_wmem", |
| 1140 | .data = &init_net.ipv4.sysctl_tcp_wmem, |
| 1141 | .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem), |
| 1142 | .mode = 0644, |
| 1143 | .proc_handler = proc_dointvec_minmax, |
| 1144 | .extra1 = &one, |
| 1145 | }, |
| 1146 | { |
| 1147 | .procname = "tcp_rmem", |
| 1148 | .data = &init_net.ipv4.sysctl_tcp_rmem, |
| 1149 | .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem), |
| 1150 | .mode = 0644, |
| 1151 | .proc_handler = proc_dointvec_minmax, |
| 1152 | .extra1 = &one, |
| 1153 | }, |
Tonghao Zhang | 1e80295 | 2018-03-13 21:57:16 -0700 | [diff] [blame] | 1154 | { |
| 1155 | .procname = "udp_rmem_min", |
| 1156 | .data = &init_net.ipv4.sysctl_udp_rmem_min, |
| 1157 | .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min), |
| 1158 | .mode = 0644, |
| 1159 | .proc_handler = proc_dointvec_minmax, |
| 1160 | .extra1 = &one |
| 1161 | }, |
| 1162 | { |
| 1163 | .procname = "udp_wmem_min", |
| 1164 | .data = &init_net.ipv4.sysctl_udp_wmem_min, |
| 1165 | .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min), |
| 1166 | .mode = 0644, |
| 1167 | .proc_handler = proc_dointvec_minmax, |
| 1168 | .extra1 = &one |
| 1169 | }, |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1170 | { } |
| 1171 | }; |
| 1172 | |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1173 | static __net_init int ipv4_sysctl_init_net(struct net *net) |
| 1174 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1175 | struct ctl_table *table; |
| 1176 | |
| 1177 | table = ipv4_net_table; |
Octavian Purdila | 09ad9bc | 2009-11-25 15:14:13 -0800 | [diff] [blame] | 1178 | if (!net_eq(net, &init_net)) { |
Eric W. Biederman | 0a6fa23 | 2013-10-19 16:27:03 -0700 | [diff] [blame] | 1179 | int i; |
| 1180 | |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1181 | table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); |
Ian Morris | 51456b2 | 2015-04-03 09:17:26 +0100 | [diff] [blame] | 1182 | if (!table) |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1183 | goto err_alloc; |
| 1184 | |
Eric W. Biederman | 0a6fa23 | 2013-10-19 16:27:03 -0700 | [diff] [blame] | 1185 | /* Update the variables to point into the current struct net */ |
| 1186 | for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) |
| 1187 | table[i].data += (void *)net - (void *)&init_net; |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1188 | } |
| 1189 | |
Eric W. Biederman | ec8f23c | 2012-04-19 13:44:49 +0000 | [diff] [blame] | 1190 | net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); |
Ian Morris | 51456b2 | 2015-04-03 09:17:26 +0100 | [diff] [blame] | 1191 | if (!net->ipv4.ipv4_hdr) |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1192 | goto err_reg; |
| 1193 | |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 1194 | net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL); |
| 1195 | if (!net->ipv4.sysctl_local_reserved_ports) |
| 1196 | goto err_ports; |
| 1197 | |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1198 | return 0; |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1199 | |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 1200 | err_ports: |
| 1201 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1202 | err_reg: |
Octavian Purdila | 09ad9bc | 2009-11-25 15:14:13 -0800 | [diff] [blame] | 1203 | if (!net_eq(net, &init_net)) |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1204 | kfree(table); |
| 1205 | err_alloc: |
| 1206 | return -ENOMEM; |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | static __net_exit void ipv4_sysctl_exit_net(struct net *net) |
| 1210 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1211 | struct ctl_table *table; |
| 1212 | |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 1213 | kfree(net->ipv4.sysctl_local_reserved_ports); |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 1214 | table = net->ipv4.ipv4_hdr->ctl_table_arg; |
| 1215 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); |
| 1216 | kfree(table); |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1217 | } |
| 1218 | |
| 1219 | static __net_initdata struct pernet_operations ipv4_sysctl_ops = { |
| 1220 | .init = ipv4_sysctl_init_net, |
| 1221 | .exit = ipv4_sysctl_exit_net, |
Kirill Tkhai | 22769a2 | 2018-02-13 12:30:18 +0300 | [diff] [blame] | 1222 | .async = true, |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1223 | }; |
| 1224 | |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 1225 | static __init int sysctl_ipv4_init(void) |
| 1226 | { |
| 1227 | struct ctl_table_header *hdr; |
| 1228 | |
Eric W. Biederman | ec8f23c | 2012-04-19 13:44:49 +0000 | [diff] [blame] | 1229 | hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table); |
Ian Morris | 51456b2 | 2015-04-03 09:17:26 +0100 | [diff] [blame] | 1230 | if (!hdr) |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1231 | return -ENOMEM; |
| 1232 | |
| 1233 | if (register_pernet_subsys(&ipv4_sysctl_ops)) { |
Eric W. Biederman | 5dd3df1 | 2012-04-19 13:24:33 +0000 | [diff] [blame] | 1234 | unregister_net_sysctl_table(hdr); |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 1235 | return -ENOMEM; |
| 1236 | } |
| 1237 | |
| 1238 | return 0; |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | __initcall(sysctl_ipv4_init); |