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