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> |
Glauber Costa | 3aaabe2 | 2011-12-11 21:47:06 +0000 | [diff] [blame] | 27 | #include <net/tcp_memcontrol.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Herbert Xu | 89cee8b | 2005-12-13 23:14:27 -0800 | [diff] [blame] | 29 | static int zero; |
bingtian.ly@taobao.com | cdda889 | 2013-01-23 20:35:28 +0000 | [diff] [blame] | 30 | static int one = 1; |
Nandita Dukkipati | 6ba8a3b | 2013-03-11 10:00:43 +0000 | [diff] [blame] | 31 | static int four = 4; |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 32 | static int tcp_retr1_max = 255; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | static int ip_local_port_range_min[] = { 1, 1 }; |
| 34 | static int ip_local_port_range_max[] = { 65535, 65535 }; |
Alexey Dobriyan | 0147fc0 | 2010-11-22 12:54:21 +0000 | [diff] [blame] | 35 | static int tcp_adv_win_scale_min = -31; |
| 36 | static int tcp_adv_win_scale_max = 31; |
Eric Dumazet | 249fab7 | 2010-12-13 12:16:14 -0800 | [diff] [blame] | 37 | static int ip_ttl_min = 1; |
| 38 | static int ip_ttl_max = 255; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 39 | static int ip_ping_group_range_min[] = { 0, 0 }; |
| 40 | 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] | 41 | |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 42 | /* Update system visible IP port range */ |
| 43 | static void set_local_port_range(int range[2]) |
| 44 | { |
Eric Dumazet | 3c689b7 | 2008-10-08 14:18:04 -0700 | [diff] [blame] | 45 | write_seqlock(&sysctl_local_ports.lock); |
| 46 | sysctl_local_ports.range[0] = range[0]; |
| 47 | sysctl_local_ports.range[1] = range[1]; |
| 48 | write_sequnlock(&sysctl_local_ports.lock); |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | /* Validate changes from /proc interface. */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 52 | static int ipv4_local_port_range(ctl_table *table, int write, |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 53 | void __user *buffer, |
| 54 | size_t *lenp, loff_t *ppos) |
| 55 | { |
| 56 | int ret; |
Eric Dumazet | 3c689b7 | 2008-10-08 14:18:04 -0700 | [diff] [blame] | 57 | int range[2]; |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 58 | ctl_table tmp = { |
| 59 | .data = &range, |
| 60 | .maxlen = sizeof(range), |
| 61 | .mode = table->mode, |
| 62 | .extra1 = &ip_local_port_range_min, |
| 63 | .extra2 = &ip_local_port_range_max, |
| 64 | }; |
| 65 | |
Eric Dumazet | 3c689b7 | 2008-10-08 14:18:04 -0700 | [diff] [blame] | 66 | inet_get_local_port_range(range, range + 1); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 67 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 68 | |
| 69 | if (write && ret == 0) { |
Anton Arapov | a25de53 | 2007-10-18 22:00:17 -0700 | [diff] [blame] | 70 | if (range[1] < range[0]) |
Stephen Hemminger | 227b60f | 2007-10-10 17:30:46 -0700 | [diff] [blame] | 71 | ret = -EINVAL; |
| 72 | else |
| 73 | set_local_port_range(range); |
| 74 | } |
| 75 | |
| 76 | return ret; |
| 77 | } |
| 78 | |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 79 | |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 80 | 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] | 81 | { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 82 | kgid_t *data = table->data; |
Eric Dumazet | 95c9617 | 2012-04-15 05:58:06 +0000 | [diff] [blame] | 83 | unsigned int seq; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 84 | do { |
| 85 | seq = read_seqbegin(&sysctl_local_ports.lock); |
| 86 | |
| 87 | *low = data[0]; |
| 88 | *high = data[1]; |
| 89 | } while (read_seqretry(&sysctl_local_ports.lock, seq)); |
| 90 | } |
| 91 | |
| 92 | /* Update system visible IP port range */ |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 93 | 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] | 94 | { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 95 | kgid_t *data = table->data; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 96 | write_seqlock(&sysctl_local_ports.lock); |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 97 | data[0] = low; |
| 98 | data[1] = high; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 99 | write_sequnlock(&sysctl_local_ports.lock); |
| 100 | } |
| 101 | |
| 102 | /* Validate changes from /proc interface. */ |
| 103 | static int ipv4_ping_group_range(ctl_table *table, int write, |
| 104 | void __user *buffer, |
| 105 | size_t *lenp, loff_t *ppos) |
| 106 | { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 107 | struct user_namespace *user_ns = current_user_ns(); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 108 | int ret; |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 109 | gid_t urange[2]; |
| 110 | kgid_t low, high; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 111 | ctl_table tmp = { |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 112 | .data = &urange, |
| 113 | .maxlen = sizeof(urange), |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 114 | .mode = table->mode, |
| 115 | .extra1 = &ip_ping_group_range_min, |
| 116 | .extra2 = &ip_ping_group_range_max, |
| 117 | }; |
| 118 | |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 119 | inet_get_ping_group_range_table(table, &low, &high); |
| 120 | urange[0] = from_kgid_munged(user_ns, low); |
| 121 | urange[1] = from_kgid_munged(user_ns, high); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 122 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
| 123 | |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 124 | if (write && ret == 0) { |
| 125 | low = make_kgid(user_ns, urange[0]); |
| 126 | high = make_kgid(user_ns, urange[1]); |
| 127 | if (!gid_valid(low) || !gid_valid(high) || |
| 128 | (urange[1] < urange[0]) || gid_lt(high, low)) { |
| 129 | low = make_kgid(&init_user_ns, 1); |
| 130 | high = make_kgid(&init_user_ns, 0); |
| 131 | } |
| 132 | set_ping_group_range(table, low, high); |
| 133 | } |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 134 | |
| 135 | return ret; |
| 136 | } |
| 137 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 138 | static int proc_tcp_congestion_control(ctl_table *ctl, int write, |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 139 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 140 | { |
| 141 | char val[TCP_CA_NAME_MAX]; |
| 142 | ctl_table tbl = { |
| 143 | .data = val, |
| 144 | .maxlen = TCP_CA_NAME_MAX, |
| 145 | }; |
| 146 | int ret; |
| 147 | |
| 148 | tcp_get_default_congestion_control(val); |
| 149 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 150 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 151 | if (write && ret == 0) |
| 152 | ret = tcp_set_default_congestion_control(val); |
| 153 | return ret; |
| 154 | } |
| 155 | |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 156 | static int proc_tcp_available_congestion_control(ctl_table *ctl, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 157 | int write, |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 158 | void __user *buffer, size_t *lenp, |
| 159 | loff_t *ppos) |
| 160 | { |
| 161 | ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, }; |
| 162 | int ret; |
| 163 | |
| 164 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); |
| 165 | if (!tbl.data) |
| 166 | return -ENOMEM; |
| 167 | tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 168 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 169 | kfree(tbl.data); |
| 170 | return ret; |
| 171 | } |
| 172 | |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 173 | static int proc_allowed_congestion_control(ctl_table *ctl, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 174 | int write, |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 175 | void __user *buffer, size_t *lenp, |
| 176 | loff_t *ppos) |
| 177 | { |
| 178 | ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX }; |
| 179 | int ret; |
| 180 | |
| 181 | tbl.data = kmalloc(tbl.maxlen, GFP_USER); |
| 182 | if (!tbl.data) |
| 183 | return -ENOMEM; |
| 184 | |
| 185 | tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 186 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 187 | if (write && ret == 0) |
| 188 | ret = tcp_set_allowed_congestion_control(tbl.data); |
| 189 | kfree(tbl.data); |
| 190 | return ret; |
| 191 | } |
| 192 | |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 193 | static int ipv4_tcp_mem(ctl_table *ctl, int write, |
| 194 | void __user *buffer, size_t *lenp, |
| 195 | loff_t *ppos) |
| 196 | { |
| 197 | int ret; |
| 198 | unsigned long vec[3]; |
| 199 | struct net *net = current->nsproxy->net_ns; |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 200 | #ifdef CONFIG_MEMCG_KMEM |
Glauber Costa | 3aaabe2 | 2011-12-11 21:47:06 +0000 | [diff] [blame] | 201 | struct mem_cgroup *memcg; |
| 202 | #endif |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 203 | |
| 204 | ctl_table tmp = { |
| 205 | .data = &vec, |
| 206 | .maxlen = sizeof(vec), |
| 207 | .mode = ctl->mode, |
| 208 | }; |
| 209 | |
| 210 | if (!write) { |
| 211 | ctl->data = &net->ipv4.sysctl_tcp_mem; |
| 212 | return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos); |
| 213 | } |
| 214 | |
| 215 | ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos); |
| 216 | if (ret) |
| 217 | return ret; |
| 218 | |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 219 | #ifdef CONFIG_MEMCG_KMEM |
Glauber Costa | 3aaabe2 | 2011-12-11 21:47:06 +0000 | [diff] [blame] | 220 | rcu_read_lock(); |
| 221 | memcg = mem_cgroup_from_task(current); |
| 222 | |
| 223 | tcp_prot_mem(memcg, vec[0], 0); |
| 224 | tcp_prot_mem(memcg, vec[1], 1); |
| 225 | tcp_prot_mem(memcg, vec[2], 2); |
| 226 | rcu_read_unlock(); |
| 227 | #endif |
| 228 | |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 229 | net->ipv4.sysctl_tcp_mem[0] = vec[0]; |
| 230 | net->ipv4.sysctl_tcp_mem[1] = vec[1]; |
| 231 | net->ipv4.sysctl_tcp_mem[2] = vec[2]; |
| 232 | |
| 233 | return 0; |
| 234 | } |
| 235 | |
stephen hemminger | bb717d7 | 2012-12-28 18:20:24 +0000 | [diff] [blame] | 236 | static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer, |
| 237 | size_t *lenp, loff_t *ppos) |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 238 | { |
| 239 | ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) }; |
| 240 | struct tcp_fastopen_context *ctxt; |
| 241 | int ret; |
| 242 | u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */ |
| 243 | |
| 244 | tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL); |
| 245 | if (!tbl.data) |
| 246 | return -ENOMEM; |
| 247 | |
| 248 | rcu_read_lock(); |
| 249 | ctxt = rcu_dereference(tcp_fastopen_ctx); |
| 250 | if (ctxt) |
| 251 | memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH); |
Alan Cox | 0e24c4f | 2012-10-11 06:24:14 +0000 | [diff] [blame] | 252 | else |
| 253 | memset(user_key, 0, sizeof(user_key)); |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 254 | rcu_read_unlock(); |
| 255 | |
| 256 | snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x", |
| 257 | user_key[0], user_key[1], user_key[2], user_key[3]); |
| 258 | ret = proc_dostring(&tbl, write, buffer, lenp, ppos); |
| 259 | |
| 260 | if (write && ret == 0) { |
| 261 | if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1, |
| 262 | user_key + 2, user_key + 3) != 4) { |
| 263 | ret = -EINVAL; |
| 264 | goto bad_key; |
| 265 | } |
| 266 | tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH); |
| 267 | } |
| 268 | |
| 269 | bad_key: |
| 270 | pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n", |
| 271 | user_key[0], user_key[1], user_key[2], user_key[3], |
| 272 | (char *)tbl.data, ret); |
| 273 | kfree(tbl.data); |
| 274 | return ret; |
| 275 | } |
| 276 | |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 277 | static struct ctl_table ipv4_table[] = { |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 278 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | .procname = "tcp_timestamps", |
| 280 | .data = &sysctl_tcp_timestamps, |
| 281 | .maxlen = sizeof(int), |
| 282 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 283 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | }, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 285 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | .procname = "tcp_window_scaling", |
| 287 | .data = &sysctl_tcp_window_scaling, |
| 288 | .maxlen = sizeof(int), |
| 289 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 290 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | }, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 292 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | .procname = "tcp_sack", |
| 294 | .data = &sysctl_tcp_sack, |
| 295 | .maxlen = sizeof(int), |
| 296 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 297 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | }, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 299 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | .procname = "tcp_retrans_collapse", |
| 301 | .data = &sysctl_tcp_retrans_collapse, |
| 302 | .maxlen = sizeof(int), |
| 303 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 304 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | }, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 306 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | .procname = "ip_default_ttl", |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 308 | .data = &sysctl_ip_default_ttl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | .maxlen = sizeof(int), |
| 310 | .mode = 0644, |
Eric Dumazet | 249fab7 | 2010-12-13 12:16:14 -0800 | [diff] [blame] | 311 | .proc_handler = proc_dointvec_minmax, |
| 312 | .extra1 = &ip_ttl_min, |
| 313 | .extra2 = &ip_ttl_max, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | }, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 315 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | .procname = "ip_no_pmtu_disc", |
| 317 | .data = &ipv4_config.no_pmtu_disc, |
| 318 | .maxlen = sizeof(int), |
| 319 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 320 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | }, |
| 322 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | .procname = "ip_nonlocal_bind", |
| 324 | .data = &sysctl_ip_nonlocal_bind, |
| 325 | .maxlen = sizeof(int), |
| 326 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 327 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | }, |
| 329 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | .procname = "tcp_syn_retries", |
| 331 | .data = &sysctl_tcp_syn_retries, |
| 332 | .maxlen = sizeof(int), |
| 333 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 334 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | }, |
| 336 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | .procname = "tcp_synack_retries", |
| 338 | .data = &sysctl_tcp_synack_retries, |
| 339 | .maxlen = sizeof(int), |
| 340 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 341 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | }, |
| 343 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | .procname = "tcp_max_orphans", |
| 345 | .data = &sysctl_tcp_max_orphans, |
| 346 | .maxlen = sizeof(int), |
| 347 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 348 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | }, |
| 350 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | .procname = "tcp_max_tw_buckets", |
Arnaldo Carvalho de Melo | 295ff7e | 2005-08-09 20:44:40 -0700 | [diff] [blame] | 352 | .data = &tcp_death_row.sysctl_max_tw_buckets, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | .maxlen = sizeof(int), |
| 354 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 355 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | }, |
| 357 | { |
Alexander Duyck | 6648bd7 | 2012-06-21 13:58:31 +0000 | [diff] [blame] | 358 | .procname = "ip_early_demux", |
| 359 | .data = &sysctl_ip_early_demux, |
| 360 | .maxlen = sizeof(int), |
| 361 | .mode = 0644, |
| 362 | .proc_handler = proc_dointvec |
| 363 | }, |
| 364 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | .procname = "ip_dynaddr", |
| 366 | .data = &sysctl_ip_dynaddr, |
| 367 | .maxlen = sizeof(int), |
| 368 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 369 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | }, |
| 371 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | .procname = "tcp_keepalive_time", |
| 373 | .data = &sysctl_tcp_keepalive_time, |
| 374 | .maxlen = sizeof(int), |
| 375 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 376 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | }, |
| 378 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | .procname = "tcp_keepalive_probes", |
| 380 | .data = &sysctl_tcp_keepalive_probes, |
| 381 | .maxlen = sizeof(int), |
| 382 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 383 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | }, |
| 385 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | .procname = "tcp_keepalive_intvl", |
| 387 | .data = &sysctl_tcp_keepalive_intvl, |
| 388 | .maxlen = sizeof(int), |
| 389 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 390 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | }, |
| 392 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | .procname = "tcp_retries1", |
| 394 | .data = &sysctl_tcp_retries1, |
| 395 | .maxlen = sizeof(int), |
| 396 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 397 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | .extra2 = &tcp_retr1_max |
| 399 | }, |
| 400 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | .procname = "tcp_retries2", |
| 402 | .data = &sysctl_tcp_retries2, |
| 403 | .maxlen = sizeof(int), |
| 404 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 405 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | }, |
| 407 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | .procname = "tcp_fin_timeout", |
| 409 | .data = &sysctl_tcp_fin_timeout, |
| 410 | .maxlen = sizeof(int), |
| 411 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 412 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | }, |
| 414 | #ifdef CONFIG_SYN_COOKIES |
| 415 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | .procname = "tcp_syncookies", |
| 417 | .data = &sysctl_tcp_syncookies, |
| 418 | .maxlen = sizeof(int), |
| 419 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 420 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | }, |
| 422 | #endif |
| 423 | { |
Yuchung Cheng | 2100c8d | 2012-07-19 06:43:05 +0000 | [diff] [blame] | 424 | .procname = "tcp_fastopen", |
| 425 | .data = &sysctl_tcp_fastopen, |
| 426 | .maxlen = sizeof(int), |
| 427 | .mode = 0644, |
| 428 | .proc_handler = proc_dointvec, |
| 429 | }, |
| 430 | { |
Jerry Chu | 1046716 | 2012-08-31 12:29:11 +0000 | [diff] [blame] | 431 | .procname = "tcp_fastopen_key", |
| 432 | .mode = 0600, |
| 433 | .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10), |
| 434 | .proc_handler = proc_tcp_fastopen_key, |
| 435 | }, |
| 436 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | .procname = "tcp_tw_recycle", |
Arnaldo Carvalho de Melo | 295ff7e | 2005-08-09 20:44:40 -0700 | [diff] [blame] | 438 | .data = &tcp_death_row.sysctl_tw_recycle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | .maxlen = sizeof(int), |
| 440 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 441 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | }, |
| 443 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | .procname = "tcp_abort_on_overflow", |
| 445 | .data = &sysctl_tcp_abort_on_overflow, |
| 446 | .maxlen = sizeof(int), |
| 447 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 448 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | }, |
| 450 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | .procname = "tcp_stdurg", |
| 452 | .data = &sysctl_tcp_stdurg, |
| 453 | .maxlen = sizeof(int), |
| 454 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 455 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | }, |
| 457 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | .procname = "tcp_rfc1337", |
| 459 | .data = &sysctl_tcp_rfc1337, |
| 460 | .maxlen = sizeof(int), |
| 461 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 462 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | }, |
| 464 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | .procname = "tcp_max_syn_backlog", |
| 466 | .data = &sysctl_max_syn_backlog, |
| 467 | .maxlen = sizeof(int), |
| 468 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 469 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | }, |
| 471 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | .procname = "ip_local_port_range", |
Eric Dumazet | 3c689b7 | 2008-10-08 14:18:04 -0700 | [diff] [blame] | 473 | .data = &sysctl_local_ports.range, |
| 474 | .maxlen = sizeof(sysctl_local_ports.range), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 476 | .proc_handler = ipv4_local_port_range, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | }, |
Amerigo Wang | e3826f1 | 2010-05-05 00:27:06 +0000 | [diff] [blame] | 478 | { |
| 479 | .procname = "ip_local_reserved_ports", |
| 480 | .data = NULL, /* initialized in sysctl_ipv4_init */ |
| 481 | .maxlen = 65536, |
| 482 | .mode = 0644, |
| 483 | .proc_handler = proc_do_large_bitmap, |
| 484 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | .procname = "igmp_max_memberships", |
| 487 | .data = &sysctl_igmp_max_memberships, |
| 488 | .maxlen = sizeof(int), |
| 489 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 490 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | .procname = "igmp_max_msf", |
| 494 | .data = &sysctl_igmp_max_msf, |
| 495 | .maxlen = sizeof(int), |
| 496 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 497 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | }, |
| 499 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | .procname = "inet_peer_threshold", |
| 501 | .data = &inet_peer_threshold, |
| 502 | .maxlen = sizeof(int), |
| 503 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 504 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | }, |
| 506 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | .procname = "inet_peer_minttl", |
| 508 | .data = &inet_peer_minttl, |
| 509 | .maxlen = sizeof(int), |
| 510 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 511 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | }, |
| 513 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | .procname = "inet_peer_maxttl", |
| 515 | .data = &inet_peer_maxttl, |
| 516 | .maxlen = sizeof(int), |
| 517 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 518 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | }, |
| 520 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | .procname = "tcp_orphan_retries", |
| 522 | .data = &sysctl_tcp_orphan_retries, |
| 523 | .maxlen = sizeof(int), |
| 524 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 525 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | }, |
| 527 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | .procname = "tcp_fack", |
| 529 | .data = &sysctl_tcp_fack, |
| 530 | .maxlen = sizeof(int), |
| 531 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 532 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | }, |
| 534 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | .procname = "tcp_reordering", |
| 536 | .data = &sysctl_tcp_reordering, |
| 537 | .maxlen = sizeof(int), |
| 538 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 539 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | }, |
| 541 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | .procname = "tcp_dsack", |
| 543 | .data = &sysctl_tcp_dsack, |
| 544 | .maxlen = sizeof(int), |
| 545 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 546 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | }, |
| 548 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | .procname = "tcp_wmem", |
| 550 | .data = &sysctl_tcp_wmem, |
| 551 | .maxlen = sizeof(sysctl_tcp_wmem), |
| 552 | .mode = 0644, |
bingtian.ly@taobao.com | cdda889 | 2013-01-23 20:35:28 +0000 | [diff] [blame] | 553 | .proc_handler = proc_dointvec_minmax, |
| 554 | .extra1 = &one, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | }, |
| 556 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | .procname = "tcp_rmem", |
| 558 | .data = &sysctl_tcp_rmem, |
| 559 | .maxlen = sizeof(sysctl_tcp_rmem), |
| 560 | .mode = 0644, |
bingtian.ly@taobao.com | cdda889 | 2013-01-23 20:35:28 +0000 | [diff] [blame] | 561 | .proc_handler = proc_dointvec_minmax, |
| 562 | .extra1 = &one, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | }, |
| 564 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | .procname = "tcp_app_win", |
| 566 | .data = &sysctl_tcp_app_win, |
| 567 | .maxlen = sizeof(int), |
| 568 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 569 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | }, |
| 571 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | .procname = "tcp_adv_win_scale", |
| 573 | .data = &sysctl_tcp_adv_win_scale, |
| 574 | .maxlen = sizeof(int), |
| 575 | .mode = 0644, |
Alexey Dobriyan | 0147fc0 | 2010-11-22 12:54:21 +0000 | [diff] [blame] | 576 | .proc_handler = proc_dointvec_minmax, |
| 577 | .extra1 = &tcp_adv_win_scale_min, |
| 578 | .extra2 = &tcp_adv_win_scale_max, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | }, |
| 580 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | .procname = "tcp_tw_reuse", |
| 582 | .data = &sysctl_tcp_tw_reuse, |
| 583 | .maxlen = sizeof(int), |
| 584 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 585 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | }, |
| 587 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | .procname = "tcp_frto", |
| 589 | .data = &sysctl_tcp_frto, |
| 590 | .maxlen = sizeof(int), |
| 591 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 592 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | }, |
| 594 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | .procname = "tcp_low_latency", |
| 596 | .data = &sysctl_tcp_low_latency, |
| 597 | .maxlen = sizeof(int), |
| 598 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 599 | .proc_handler = proc_dointvec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | }, |
| 601 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | .procname = "tcp_no_metrics_save", |
| 603 | .data = &sysctl_tcp_nometrics_save, |
| 604 | .maxlen = sizeof(int), |
| 605 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 606 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | }, |
| 608 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | .procname = "tcp_moderate_rcvbuf", |
| 610 | .data = &sysctl_tcp_moderate_rcvbuf, |
| 611 | .maxlen = sizeof(int), |
| 612 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 613 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | }, |
| 615 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | .procname = "tcp_tso_win_divisor", |
| 617 | .data = &sysctl_tcp_tso_win_divisor, |
| 618 | .maxlen = sizeof(int), |
| 619 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 620 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | }, |
| 622 | { |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 623 | .procname = "tcp_congestion_control", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | .mode = 0644, |
Stephen Hemminger | 317a76f | 2005-06-23 12:19:55 -0700 | [diff] [blame] | 625 | .maxlen = TCP_CA_NAME_MAX, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 626 | .proc_handler = proc_tcp_congestion_control, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | }, |
Stephen Hemminger | 9772efb | 2005-11-10 17:09:53 -0800 | [diff] [blame] | 628 | { |
John Heffner | 5d424d5 | 2006-03-20 17:53:41 -0800 | [diff] [blame] | 629 | .procname = "tcp_mtu_probing", |
| 630 | .data = &sysctl_tcp_mtu_probing, |
| 631 | .maxlen = sizeof(int), |
| 632 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 633 | .proc_handler = proc_dointvec, |
John Heffner | 5d424d5 | 2006-03-20 17:53:41 -0800 | [diff] [blame] | 634 | }, |
| 635 | { |
John Heffner | 5d424d5 | 2006-03-20 17:53:41 -0800 | [diff] [blame] | 636 | .procname = "tcp_base_mss", |
| 637 | .data = &sysctl_tcp_base_mss, |
| 638 | .maxlen = sizeof(int), |
| 639 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 640 | .proc_handler = proc_dointvec, |
John Heffner | 5d424d5 | 2006-03-20 17:53:41 -0800 | [diff] [blame] | 641 | }, |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 642 | { |
Rick Jones | 15d99e0 | 2006-03-20 22:40:29 -0800 | [diff] [blame] | 643 | .procname = "tcp_workaround_signed_windows", |
| 644 | .data = &sysctl_tcp_workaround_signed_windows, |
| 645 | .maxlen = sizeof(int), |
| 646 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 647 | .proc_handler = proc_dointvec |
Rick Jones | 15d99e0 | 2006-03-20 22:40:29 -0800 | [diff] [blame] | 648 | }, |
Eric Dumazet | 46d3cea | 2012-07-11 05:50:31 +0000 | [diff] [blame] | 649 | { |
| 650 | .procname = "tcp_limit_output_bytes", |
| 651 | .data = &sysctl_tcp_limit_output_bytes, |
| 652 | .maxlen = sizeof(int), |
| 653 | .mode = 0644, |
| 654 | .proc_handler = proc_dointvec |
| 655 | }, |
Eric Dumazet | 282f23c | 2012-07-17 10:13:05 +0200 | [diff] [blame] | 656 | { |
| 657 | .procname = "tcp_challenge_ack_limit", |
| 658 | .data = &sysctl_tcp_challenge_ack_limit, |
| 659 | .maxlen = sizeof(int), |
| 660 | .mode = 0644, |
| 661 | .proc_handler = proc_dointvec |
| 662 | }, |
Chris Leech | 9593782 | 2006-05-23 18:02:55 -0700 | [diff] [blame] | 663 | #ifdef CONFIG_NET_DMA |
| 664 | { |
Chris Leech | 9593782 | 2006-05-23 18:02:55 -0700 | [diff] [blame] | 665 | .procname = "tcp_dma_copybreak", |
| 666 | .data = &sysctl_tcp_dma_copybreak, |
| 667 | .maxlen = sizeof(int), |
| 668 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 669 | .proc_handler = proc_dointvec |
Chris Leech | 9593782 | 2006-05-23 18:02:55 -0700 | [diff] [blame] | 670 | }, |
| 671 | #endif |
David S. Miller | 35089bb | 2006-06-13 22:33:04 -0700 | [diff] [blame] | 672 | { |
David S. Miller | 35089bb | 2006-06-13 22:33:04 -0700 | [diff] [blame] | 673 | .procname = "tcp_slow_start_after_idle", |
| 674 | .data = &sysctl_tcp_slow_start_after_idle, |
| 675 | .maxlen = sizeof(int), |
| 676 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 677 | .proc_handler = proc_dointvec |
David S. Miller | 35089bb | 2006-06-13 22:33:04 -0700 | [diff] [blame] | 678 | }, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 679 | #ifdef CONFIG_NETLABEL |
| 680 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 681 | .procname = "cipso_cache_enable", |
| 682 | .data = &cipso_v4_cache_enabled, |
| 683 | .maxlen = sizeof(int), |
| 684 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 685 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 686 | }, |
| 687 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 688 | .procname = "cipso_cache_bucket_size", |
| 689 | .data = &cipso_v4_cache_bucketsize, |
| 690 | .maxlen = sizeof(int), |
| 691 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 692 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 693 | }, |
| 694 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 695 | .procname = "cipso_rbm_optfmt", |
| 696 | .data = &cipso_v4_rbm_optfmt, |
| 697 | .maxlen = sizeof(int), |
| 698 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 699 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 700 | }, |
| 701 | { |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 702 | .procname = "cipso_rbm_strictvalid", |
| 703 | .data = &cipso_v4_rbm_strictvalid, |
| 704 | .maxlen = sizeof(int), |
| 705 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 706 | .proc_handler = proc_dointvec, |
Paul Moore | 446fda4 | 2006-08-03 16:48:06 -0700 | [diff] [blame] | 707 | }, |
| 708 | #endif /* CONFIG_NETLABEL */ |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 709 | { |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 710 | .procname = "tcp_available_congestion_control", |
| 711 | .maxlen = TCP_CA_BUF_MAX, |
| 712 | .mode = 0444, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 713 | .proc_handler = proc_tcp_available_congestion_control, |
Stephen Hemminger | 3ff825b | 2006-11-09 16:32:06 -0800 | [diff] [blame] | 714 | }, |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 715 | { |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 716 | .procname = "tcp_allowed_congestion_control", |
| 717 | .maxlen = TCP_CA_BUF_MAX, |
| 718 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 719 | .proc_handler = proc_allowed_congestion_control, |
Stephen Hemminger | ce7bc3b | 2006-11-09 16:35:15 -0800 | [diff] [blame] | 720 | }, |
John Heffner | 886236c | 2007-03-25 19:21:45 -0700 | [diff] [blame] | 721 | { |
John Heffner | 886236c | 2007-03-25 19:21:45 -0700 | [diff] [blame] | 722 | .procname = "tcp_max_ssthresh", |
| 723 | .data = &sysctl_tcp_max_ssthresh, |
| 724 | .maxlen = sizeof(int), |
| 725 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 726 | .proc_handler = proc_dointvec, |
John Heffner | 886236c | 2007-03-25 19:21:45 -0700 | [diff] [blame] | 727 | }, |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 728 | { |
Andreas Petlund | 36e31b0a | 2010-02-18 02:47:01 +0000 | [diff] [blame] | 729 | .procname = "tcp_thin_linear_timeouts", |
| 730 | .data = &sysctl_tcp_thin_linear_timeouts, |
| 731 | .maxlen = sizeof(int), |
| 732 | .mode = 0644, |
| 733 | .proc_handler = proc_dointvec |
| 734 | }, |
Andreas Petlund | 7e38017 | 2010-02-18 04:48:19 +0000 | [diff] [blame] | 735 | { |
| 736 | .procname = "tcp_thin_dupack", |
| 737 | .data = &sysctl_tcp_thin_dupack, |
| 738 | .maxlen = sizeof(int), |
| 739 | .mode = 0644, |
| 740 | .proc_handler = proc_dointvec |
| 741 | }, |
Andreas Petlund | 36e31b0a | 2010-02-18 02:47:01 +0000 | [diff] [blame] | 742 | { |
Yuchung Cheng | eed530b | 2012-05-02 13:30:03 +0000 | [diff] [blame] | 743 | .procname = "tcp_early_retrans", |
| 744 | .data = &sysctl_tcp_early_retrans, |
| 745 | .maxlen = sizeof(int), |
| 746 | .mode = 0644, |
| 747 | .proc_handler = proc_dointvec_minmax, |
| 748 | .extra1 = &zero, |
Nandita Dukkipati | 6ba8a3b | 2013-03-11 10:00:43 +0000 | [diff] [blame] | 749 | .extra2 = &four, |
Yuchung Cheng | eed530b | 2012-05-02 13:30:03 +0000 | [diff] [blame] | 750 | }, |
| 751 | { |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 752 | .procname = "udp_mem", |
| 753 | .data = &sysctl_udp_mem, |
| 754 | .maxlen = sizeof(sysctl_udp_mem), |
| 755 | .mode = 0644, |
Eric Dumazet | 8d987e5 | 2010-11-09 23:24:26 +0000 | [diff] [blame] | 756 | .proc_handler = proc_doulongvec_minmax, |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 757 | }, |
| 758 | { |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 759 | .procname = "udp_rmem_min", |
| 760 | .data = &sysctl_udp_rmem_min, |
| 761 | .maxlen = sizeof(sysctl_udp_rmem_min), |
| 762 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 763 | .proc_handler = proc_dointvec_minmax, |
bingtian.ly@taobao.com | cdda889 | 2013-01-23 20:35:28 +0000 | [diff] [blame] | 764 | .extra1 = &one |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 765 | }, |
| 766 | { |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 767 | .procname = "udp_wmem_min", |
| 768 | .data = &sysctl_udp_wmem_min, |
| 769 | .maxlen = sizeof(sysctl_udp_wmem_min), |
| 770 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 771 | .proc_handler = proc_dointvec_minmax, |
bingtian.ly@taobao.com | cdda889 | 2013-01-23 20:35:28 +0000 | [diff] [blame] | 772 | .extra1 = &one |
Hideo Aoki | 95766ff | 2007-12-31 00:29:24 -0800 | [diff] [blame] | 773 | }, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 774 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | }; |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 776 | |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 777 | static struct ctl_table ipv4_net_table[] = { |
| 778 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 779 | .procname = "icmp_echo_ignore_all", |
| 780 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, |
| 781 | .maxlen = sizeof(int), |
| 782 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 783 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 784 | }, |
| 785 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 786 | .procname = "icmp_echo_ignore_broadcasts", |
| 787 | .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, |
| 788 | .maxlen = sizeof(int), |
| 789 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 790 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 791 | }, |
| 792 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 793 | .procname = "icmp_ignore_bogus_error_responses", |
| 794 | .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, |
| 795 | .maxlen = sizeof(int), |
| 796 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 797 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 798 | }, |
| 799 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 800 | .procname = "icmp_errors_use_inbound_ifaddr", |
| 801 | .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, |
| 802 | .maxlen = sizeof(int), |
| 803 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 804 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 805 | }, |
| 806 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 807 | .procname = "icmp_ratelimit", |
| 808 | .data = &init_net.ipv4.sysctl_icmp_ratelimit, |
| 809 | .maxlen = sizeof(int), |
| 810 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 811 | .proc_handler = proc_dointvec_ms_jiffies, |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 812 | }, |
| 813 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 814 | .procname = "icmp_ratemask", |
| 815 | .data = &init_net.ipv4.sysctl_icmp_ratemask, |
| 816 | .maxlen = sizeof(int), |
| 817 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 818 | .proc_handler = proc_dointvec |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 819 | }, |
Neil Horman | 1080d70 | 2008-10-27 12:28:25 -0700 | [diff] [blame] | 820 | { |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 821 | .procname = "ping_group_range", |
| 822 | .data = &init_net.ipv4.sysctl_ping_group_range, |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 823 | .maxlen = sizeof(gid_t)*2, |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 824 | .mode = 0644, |
| 825 | .proc_handler = ipv4_ping_group_range, |
| 826 | }, |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 827 | { |
Hannes Frederic Sowa | 5d134f1 | 2013-01-05 16:10:48 +0000 | [diff] [blame] | 828 | .procname = "tcp_ecn", |
| 829 | .data = &init_net.ipv4.sysctl_tcp_ecn, |
| 830 | .maxlen = sizeof(int), |
| 831 | .mode = 0644, |
| 832 | .proc_handler = proc_dointvec |
| 833 | }, |
| 834 | { |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 835 | .procname = "tcp_mem", |
| 836 | .maxlen = sizeof(init_net.ipv4.sysctl_tcp_mem), |
| 837 | .mode = 0644, |
| 838 | .proc_handler = ipv4_tcp_mem, |
| 839 | }, |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 840 | { } |
| 841 | }; |
| 842 | |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 843 | static __net_init int ipv4_sysctl_init_net(struct net *net) |
| 844 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 845 | struct ctl_table *table; |
| 846 | |
| 847 | table = ipv4_net_table; |
Octavian Purdila | 09ad9bc | 2009-11-25 15:14:13 -0800 | [diff] [blame] | 848 | if (!net_eq(net, &init_net)) { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 849 | table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); |
| 850 | if (table == NULL) |
| 851 | goto err_alloc; |
| 852 | |
| 853 | table[0].data = |
| 854 | &net->ipv4.sysctl_icmp_echo_ignore_all; |
| 855 | table[1].data = |
| 856 | &net->ipv4.sysctl_icmp_echo_ignore_broadcasts; |
| 857 | table[2].data = |
| 858 | &net->ipv4.sysctl_icmp_ignore_bogus_error_responses; |
| 859 | table[3].data = |
| 860 | &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr; |
| 861 | table[4].data = |
| 862 | &net->ipv4.sysctl_icmp_ratelimit; |
| 863 | table[5].data = |
| 864 | &net->ipv4.sysctl_icmp_ratemask; |
Neil Horman | 1080d70 | 2008-10-27 12:28:25 -0700 | [diff] [blame] | 865 | table[6].data = |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 866 | &net->ipv4.sysctl_ping_group_range; |
Hannes Frederic Sowa | 5d134f1 | 2013-01-05 16:10:48 +0000 | [diff] [blame] | 867 | table[7].data = |
| 868 | &net->ipv4.sysctl_tcp_ecn; |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 869 | |
Eric W. Biederman | 464dc80 | 2012-11-16 03:02:59 +0000 | [diff] [blame] | 870 | /* Don't export sysctls to unprivileged users */ |
| 871 | if (net->user_ns != &init_user_ns) |
| 872 | table[0].procname = NULL; |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 873 | } |
| 874 | |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 875 | /* |
| 876 | * Sane defaults - nobody may create ping sockets. |
| 877 | * Boot scripts should set this to distro-specific group. |
| 878 | */ |
Eric W. Biederman | 7064d16 | 2012-05-24 10:34:21 -0600 | [diff] [blame] | 879 | net->ipv4.sysctl_ping_group_range[0] = make_kgid(&init_user_ns, 1); |
| 880 | net->ipv4.sysctl_ping_group_range[1] = make_kgid(&init_user_ns, 0); |
Vasiliy Kulikov | c319b4d | 2011-05-13 10:01:00 +0000 | [diff] [blame] | 881 | |
Glauber Costa | 4acb419 | 2012-01-30 01:20:17 +0000 | [diff] [blame] | 882 | tcp_init_mem(net); |
Glauber Costa | 3dc43e3 | 2011-12-11 21:47:05 +0000 | [diff] [blame] | 883 | |
Eric W. Biederman | ec8f23c | 2012-04-19 13:44:49 +0000 | [diff] [blame] | 884 | net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 885 | if (net->ipv4.ipv4_hdr == NULL) |
| 886 | goto err_reg; |
| 887 | |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 888 | return 0; |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 889 | |
| 890 | err_reg: |
Octavian Purdila | 09ad9bc | 2009-11-25 15:14:13 -0800 | [diff] [blame] | 891 | if (!net_eq(net, &init_net)) |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 892 | kfree(table); |
| 893 | err_alloc: |
| 894 | return -ENOMEM; |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | static __net_exit void ipv4_sysctl_exit_net(struct net *net) |
| 898 | { |
Pavel Emelyanov | 68528f0 | 2008-03-26 01:56:24 -0700 | [diff] [blame] | 899 | struct ctl_table *table; |
| 900 | |
| 901 | table = net->ipv4.ipv4_hdr->ctl_table_arg; |
| 902 | unregister_net_sysctl_table(net->ipv4.ipv4_hdr); |
| 903 | kfree(table); |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | static __net_initdata struct pernet_operations ipv4_sysctl_ops = { |
| 907 | .init = ipv4_sysctl_init_net, |
| 908 | .exit = ipv4_sysctl_exit_net, |
| 909 | }; |
| 910 | |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 911 | static __init int sysctl_ipv4_init(void) |
| 912 | { |
| 913 | struct ctl_table_header *hdr; |
Amerigo Wang | e3826f1 | 2010-05-05 00:27:06 +0000 | [diff] [blame] | 914 | struct ctl_table *i; |
| 915 | |
| 916 | for (i = ipv4_table; i->procname; i++) { |
| 917 | if (strcmp(i->procname, "ip_local_reserved_ports") == 0) { |
| 918 | i->data = sysctl_local_reserved_ports; |
| 919 | break; |
| 920 | } |
| 921 | } |
| 922 | if (!i->procname) |
| 923 | return -EINVAL; |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 924 | |
Eric W. Biederman | ec8f23c | 2012-04-19 13:44:49 +0000 | [diff] [blame] | 925 | hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table); |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 926 | if (hdr == NULL) |
| 927 | return -ENOMEM; |
| 928 | |
| 929 | if (register_pernet_subsys(&ipv4_sysctl_ops)) { |
Eric W. Biederman | 5dd3df1 | 2012-04-19 13:24:33 +0000 | [diff] [blame] | 930 | unregister_net_sysctl_table(hdr); |
Pavel Emelyanov | 1577519 | 2008-03-26 01:54:18 -0700 | [diff] [blame] | 931 | return -ENOMEM; |
| 932 | } |
| 933 | |
| 934 | return 0; |
Pavel Emelyanov | 3e37c3f | 2007-12-05 01:41:26 -0800 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | __initcall(sysctl_ipv4_init); |