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