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