blob: 433231ccfb17fc6d01179247d1d81226803d18df [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
3 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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 Melo20380732005-08-16 02:18:02 -030011#include <linux/igmp.h>
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020012#include <linux/inetdevice.h>
Stephen Hemminger227b60f2007-10-10 17:30:46 -070013#include <linux/seqlock.h>
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -080014#include <linux/init.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015#include <linux/slab.h>
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000016#include <linux/nsproxy.h>
Glauber Costa3dc43e32011-12-11 21:47:05 +000017#include <linux/swap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <net/snmp.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030019#include <net/icmp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <net/ip.h>
21#include <net/route.h>
22#include <net/tcp.h>
Hideo Aoki95766ff2007-12-31 00:29:24 -080023#include <net/udp.h>
Paul Moore446fda42006-08-03 16:48:06 -070024#include <net/cipso_ipv4.h>
Pavel Emelyanov04128f22007-10-15 02:33:45 -070025#include <net/inet_frag.h>
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000026#include <net/ping.h>
Glauber Costa3aaabe22011-12-11 21:47:06 +000027#include <net/tcp_memcontrol.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Herbert Xu89cee8b2005-12-13 23:14:27 -080029static int zero;
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +000030static int one = 1;
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +000031static int four = 4;
Eric Dumazet95bd09e2013-08-27 05:46:32 -070032static int gso_max_segs = GSO_MAX_SEGS;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090033static int tcp_retr1_max = 255;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034static int ip_local_port_range_min[] = { 1, 1 };
35static int ip_local_port_range_max[] = { 65535, 65535 };
Alexey Dobriyan0147fc02010-11-22 12:54:21 +000036static int tcp_adv_win_scale_min = -31;
37static int tcp_adv_win_scale_max = 31;
Eric Dumazet249fab72010-12-13 12:16:14 -080038static int ip_ttl_min = 1;
39static int ip_ttl_max = 255;
Michal Tesar651e9272013-07-19 14:09:01 +020040static int tcp_syn_retries_min = 1;
41static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000042static int ip_ping_group_range_min[] = { 0, 0 };
43static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
Sorin Dumitru81335342015-05-27 22:16:49 +030044static int min_sndbuf = SOCK_MIN_SNDBUF;
45static int min_rcvbuf = SOCK_MIN_RCVBUF;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Stephen Hemminger227b60f2007-10-10 17:30:46 -070047/* Update system visible IP port range */
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070048static void set_local_port_range(struct net *net, int range[2])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070049{
Eric Dumazeted2dfd92015-05-27 11:34:37 -070050 bool same_parity = !((range[0] ^ range[1]) & 1);
51
Cong Wangc9d8f1a2014-05-06 11:02:49 -070052 write_seqlock(&net->ipv4.ip_local_ports.lock);
Eric Dumazeted2dfd92015-05-27 11:34:37 -070053 if (same_parity && !net->ipv4.ip_local_ports.warned) {
54 net->ipv4.ip_local_ports.warned = true;
55 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
56 }
Cong Wangc9d8f1a2014-05-06 11:02:49 -070057 net->ipv4.ip_local_ports.range[0] = range[0];
58 net->ipv4.ip_local_ports.range[1] = range[1];
59 write_sequnlock(&net->ipv4.ip_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070060}
61
62/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070063static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070064 void __user *buffer,
65 size_t *lenp, loff_t *ppos)
66{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070067 struct net *net =
Cong Wangc9d8f1a2014-05-06 11:02:49 -070068 container_of(table->data, struct net, ipv4.ip_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070069 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070070 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070071 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070072 .data = &range,
73 .maxlen = sizeof(range),
74 .mode = table->mode,
75 .extra1 = &ip_local_port_range_min,
76 .extra2 = &ip_local_port_range_max,
77 };
78
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070079 inet_get_local_port_range(net, &range[0], &range[1]);
80
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070081 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070082
83 if (write && ret == 0) {
Anton Arapova25de532007-10-18 22:00:17 -070084 if (range[1] < range[0])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070085 ret = -EINVAL;
86 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070087 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070088 }
89
90 return ret;
91}
92
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000093
Eric W. Biederman7064d162012-05-24 10:34:21 -060094static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000095{
Eric W. Biederman7064d162012-05-24 10:34:21 -060096 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070097 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -070098 container_of(table->data, struct net, ipv4.ping_group_range.range);
Eric Dumazet95c96172012-04-15 05:58:06 +000099 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000100 do {
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700101 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000102
103 *low = data[0];
104 *high = data[1];
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700105 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000106}
107
108/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600109static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000110{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600111 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700112 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700113 container_of(table->data, struct net, ipv4.ping_group_range.range);
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700114 write_seqlock(&net->ipv4.ip_local_ports.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600115 data[0] = low;
116 data[1] = high;
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700117 write_sequnlock(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000118}
119
120/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700121static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000122 void __user *buffer,
123 size_t *lenp, loff_t *ppos)
124{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600125 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000126 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600127 gid_t urange[2];
128 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700129 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600130 .data = &urange,
131 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000132 .mode = table->mode,
133 .extra1 = &ip_ping_group_range_min,
134 .extra2 = &ip_ping_group_range_max,
135 };
136
Eric W. Biederman7064d162012-05-24 10:34:21 -0600137 inet_get_ping_group_range_table(table, &low, &high);
138 urange[0] = from_kgid_munged(user_ns, low);
139 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000140 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
141
Eric W. Biederman7064d162012-05-24 10:34:21 -0600142 if (write && ret == 0) {
143 low = make_kgid(user_ns, urange[0]);
144 high = make_kgid(user_ns, urange[1]);
145 if (!gid_valid(low) || !gid_valid(high) ||
146 (urange[1] < urange[0]) || gid_lt(high, low)) {
147 low = make_kgid(&init_user_ns, 1);
148 high = make_kgid(&init_user_ns, 0);
149 }
150 set_ping_group_range(table, low, high);
151 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000152
153 return ret;
154}
155
Joe Perchesfe2c6332013-06-11 23:04:25 -0700156static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700157 void __user *buffer, size_t *lenp, loff_t *ppos)
158{
159 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700160 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700161 .data = val,
162 .maxlen = TCP_CA_NAME_MAX,
163 };
164 int ret;
165
166 tcp_get_default_congestion_control(val);
167
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700168 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700169 if (write && ret == 0)
170 ret = tcp_set_default_congestion_control(val);
171 return ret;
172}
173
Joe Perchesfe2c6332013-06-11 23:04:25 -0700174static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700175 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800176 void __user *buffer, size_t *lenp,
177 loff_t *ppos)
178{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700179 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800180 int ret;
181
182 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
183 if (!tbl.data)
184 return -ENOMEM;
185 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700186 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800187 kfree(tbl.data);
188 return ret;
189}
190
Joe Perchesfe2c6332013-06-11 23:04:25 -0700191static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700192 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800193 void __user *buffer, size_t *lenp,
194 loff_t *ppos)
195{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700196 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800197 int ret;
198
199 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
200 if (!tbl.data)
201 return -ENOMEM;
202
203 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700204 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800205 if (write && ret == 0)
206 ret = tcp_set_allowed_congestion_control(tbl.data);
207 kfree(tbl.data);
208 return ret;
209}
210
Joe Perchesfe2c6332013-06-11 23:04:25 -0700211static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
212 void __user *buffer, size_t *lenp,
213 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000214{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700215 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000216 struct tcp_fastopen_context *ctxt;
217 int ret;
218 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
219
220 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
221 if (!tbl.data)
222 return -ENOMEM;
223
224 rcu_read_lock();
225 ctxt = rcu_dereference(tcp_fastopen_ctx);
226 if (ctxt)
227 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000228 else
229 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000230 rcu_read_unlock();
231
232 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
233 user_key[0], user_key[1], user_key[2], user_key[3]);
234 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
235
236 if (write && ret == 0) {
237 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
238 user_key + 2, user_key + 3) != 4) {
239 ret = -EINVAL;
240 goto bad_key;
241 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200242 /* Generate a dummy secret but don't publish it. This
243 * is needed so we don't regenerate a new key on the
244 * first invocation of tcp_fastopen_cookie_gen
245 */
246 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000247 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
248 }
249
250bad_key:
251 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
252 user_key[0], user_key[1], user_key[2], user_key[3],
253 (char *)tbl.data, ret);
254 kfree(tbl.data);
255 return ret;
256}
257
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800258static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 .procname = "tcp_timestamps",
261 .data = &sysctl_tcp_timestamps,
262 .maxlen = sizeof(int),
263 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800264 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900266 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 .procname = "tcp_window_scaling",
268 .data = &sysctl_tcp_window_scaling,
269 .maxlen = sizeof(int),
270 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800271 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900273 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 .procname = "tcp_sack",
275 .data = &sysctl_tcp_sack,
276 .maxlen = sizeof(int),
277 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800278 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900280 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 .procname = "tcp_retrans_collapse",
282 .data = &sysctl_tcp_retrans_collapse,
283 .maxlen = sizeof(int),
284 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800285 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900287 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 .procname = "ip_default_ttl",
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900289 .data = &sysctl_ip_default_ttl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 .maxlen = sizeof(int),
291 .mode = 0644,
Eric Dumazet249fab72010-12-13 12:16:14 -0800292 .proc_handler = proc_dointvec_minmax,
293 .extra1 = &ip_ttl_min,
294 .extra2 = &ip_ttl_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 .procname = "tcp_syn_retries",
298 .data = &sysctl_tcp_syn_retries,
299 .maxlen = sizeof(int),
300 .mode = 0644,
Michal Tesar651e9272013-07-19 14:09:01 +0200301 .proc_handler = proc_dointvec_minmax,
302 .extra1 = &tcp_syn_retries_min,
303 .extra2 = &tcp_syn_retries_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 },
305 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 .procname = "tcp_synack_retries",
307 .data = &sysctl_tcp_synack_retries,
308 .maxlen = sizeof(int),
309 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800310 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 },
312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 .procname = "tcp_max_orphans",
314 .data = &sysctl_tcp_max_orphans,
315 .maxlen = sizeof(int),
316 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800317 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 },
319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 .procname = "tcp_max_tw_buckets",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700321 .data = &tcp_death_row.sysctl_max_tw_buckets,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 .maxlen = sizeof(int),
323 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800324 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 },
326 {
Alexander Duyck6648bd72012-06-21 13:58:31 +0000327 .procname = "ip_early_demux",
328 .data = &sysctl_ip_early_demux,
329 .maxlen = sizeof(int),
330 .mode = 0644,
331 .proc_handler = proc_dointvec
332 },
333 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 .procname = "ip_dynaddr",
335 .data = &sysctl_ip_dynaddr,
336 .maxlen = sizeof(int),
337 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800338 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 },
340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 .procname = "tcp_keepalive_time",
342 .data = &sysctl_tcp_keepalive_time,
343 .maxlen = sizeof(int),
344 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800345 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 },
347 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 .procname = "tcp_keepalive_probes",
349 .data = &sysctl_tcp_keepalive_probes,
350 .maxlen = sizeof(int),
351 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800352 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 },
354 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 .procname = "tcp_keepalive_intvl",
356 .data = &sysctl_tcp_keepalive_intvl,
357 .maxlen = sizeof(int),
358 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800359 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 },
361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 .procname = "tcp_retries1",
363 .data = &sysctl_tcp_retries1,
364 .maxlen = sizeof(int),
365 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800366 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 .extra2 = &tcp_retr1_max
368 },
369 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 .procname = "tcp_retries2",
371 .data = &sysctl_tcp_retries2,
372 .maxlen = sizeof(int),
373 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800374 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 },
376 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 .procname = "tcp_fin_timeout",
378 .data = &sysctl_tcp_fin_timeout,
379 .maxlen = sizeof(int),
380 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800381 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 },
383#ifdef CONFIG_SYN_COOKIES
384 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 .procname = "tcp_syncookies",
386 .data = &sysctl_tcp_syncookies,
387 .maxlen = sizeof(int),
388 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800389 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 },
391#endif
392 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000393 .procname = "tcp_fastopen",
394 .data = &sysctl_tcp_fastopen,
395 .maxlen = sizeof(int),
396 .mode = 0644,
397 .proc_handler = proc_dointvec,
398 },
399 {
Jerry Chu10467162012-08-31 12:29:11 +0000400 .procname = "tcp_fastopen_key",
401 .mode = 0600,
402 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
403 .proc_handler = proc_tcp_fastopen_key,
404 },
405 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 .procname = "tcp_tw_recycle",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700407 .data = &tcp_death_row.sysctl_tw_recycle,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 .maxlen = sizeof(int),
409 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800410 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 },
412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 .procname = "tcp_abort_on_overflow",
414 .data = &sysctl_tcp_abort_on_overflow,
415 .maxlen = sizeof(int),
416 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800417 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 },
419 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 .procname = "tcp_stdurg",
421 .data = &sysctl_tcp_stdurg,
422 .maxlen = sizeof(int),
423 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800424 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 },
426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 .procname = "tcp_rfc1337",
428 .data = &sysctl_tcp_rfc1337,
429 .maxlen = sizeof(int),
430 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800431 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 },
433 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 .procname = "tcp_max_syn_backlog",
435 .data = &sysctl_max_syn_backlog,
436 .maxlen = sizeof(int),
437 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800438 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 },
440 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 .procname = "igmp_max_memberships",
442 .data = &sysctl_igmp_max_memberships,
443 .maxlen = sizeof(int),
444 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800445 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 .procname = "igmp_max_msf",
449 .data = &sysctl_igmp_max_msf,
450 .maxlen = sizeof(int),
451 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800452 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 },
Hannes Frederic Sowaa9fe8e22014-09-02 15:49:26 +0200454#ifdef CONFIG_IP_MULTICAST
455 {
456 .procname = "igmp_qrv",
457 .data = &sysctl_igmp_qrv,
458 .maxlen = sizeof(int),
459 .mode = 0644,
460 .proc_handler = proc_dointvec_minmax,
461 .extra1 = &one
462 },
463#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 .procname = "inet_peer_threshold",
466 .data = &inet_peer_threshold,
467 .maxlen = sizeof(int),
468 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800469 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 },
471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "inet_peer_minttl",
473 .data = &inet_peer_minttl,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800476 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 .procname = "inet_peer_maxttl",
480 .data = &inet_peer_maxttl,
481 .maxlen = sizeof(int),
482 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800483 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 },
485 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 .procname = "tcp_orphan_retries",
487 .data = &sysctl_tcp_orphan_retries,
488 .maxlen = sizeof(int),
489 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800490 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 },
492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 .procname = "tcp_fack",
494 .data = &sysctl_tcp_fack,
495 .maxlen = sizeof(int),
496 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800497 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 },
499 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 .procname = "tcp_reordering",
501 .data = &sysctl_tcp_reordering,
502 .maxlen = sizeof(int),
503 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800504 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 },
506 {
Eric Dumazetdca145f2014-10-27 21:45:24 -0700507 .procname = "tcp_max_reordering",
508 .data = &sysctl_tcp_max_reordering,
509 .maxlen = sizeof(int),
510 .mode = 0644,
511 .proc_handler = proc_dointvec
512 },
513 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 .procname = "tcp_dsack",
515 .data = &sysctl_tcp_dsack,
516 .maxlen = sizeof(int),
517 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800518 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 },
520 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700521 .procname = "tcp_mem",
522 .maxlen = sizeof(sysctl_tcp_mem),
523 .data = &sysctl_tcp_mem,
524 .mode = 0644,
525 .proc_handler = proc_doulongvec_minmax,
526 },
527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "tcp_wmem",
529 .data = &sysctl_tcp_wmem,
530 .maxlen = sizeof(sysctl_tcp_wmem),
531 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000532 .proc_handler = proc_dointvec_minmax,
Sorin Dumitru81335342015-05-27 22:16:49 +0300533 .extra1 = &min_sndbuf,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535 {
Eric Dumazetc9bee3b72013-07-22 20:27:07 -0700536 .procname = "tcp_notsent_lowat",
537 .data = &sysctl_tcp_notsent_lowat,
538 .maxlen = sizeof(sysctl_tcp_notsent_lowat),
539 .mode = 0644,
540 .proc_handler = proc_dointvec,
541 },
542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .procname = "tcp_rmem",
544 .data = &sysctl_tcp_rmem,
545 .maxlen = sizeof(sysctl_tcp_rmem),
546 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000547 .proc_handler = proc_dointvec_minmax,
Sorin Dumitru81335342015-05-27 22:16:49 +0300548 .extra1 = &min_rcvbuf,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 },
550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 .procname = "tcp_app_win",
552 .data = &sysctl_tcp_app_win,
553 .maxlen = sizeof(int),
554 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800555 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 },
557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .procname = "tcp_adv_win_scale",
559 .data = &sysctl_tcp_adv_win_scale,
560 .maxlen = sizeof(int),
561 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000562 .proc_handler = proc_dointvec_minmax,
563 .extra1 = &tcp_adv_win_scale_min,
564 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .procname = "tcp_tw_reuse",
568 .data = &sysctl_tcp_tw_reuse,
569 .maxlen = sizeof(int),
570 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800571 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
573 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .procname = "tcp_frto",
575 .data = &sysctl_tcp_frto,
576 .maxlen = sizeof(int),
577 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800578 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 },
580 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 .procname = "tcp_low_latency",
582 .data = &sysctl_tcp_low_latency,
583 .maxlen = sizeof(int),
584 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800585 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 },
587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 .procname = "tcp_no_metrics_save",
589 .data = &sysctl_tcp_nometrics_save,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800592 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 },
594 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 .procname = "tcp_moderate_rcvbuf",
596 .data = &sysctl_tcp_moderate_rcvbuf,
597 .maxlen = sizeof(int),
598 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800599 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 },
601 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 .procname = "tcp_tso_win_divisor",
603 .data = &sysctl_tcp_tso_win_divisor,
604 .maxlen = sizeof(int),
605 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800606 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 },
608 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700609 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700611 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800612 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800614 {
Rick Jones15d99e02006-03-20 22:40:29 -0800615 .procname = "tcp_workaround_signed_windows",
616 .data = &sysctl_tcp_workaround_signed_windows,
617 .maxlen = sizeof(int),
618 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800619 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800620 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000621 {
622 .procname = "tcp_limit_output_bytes",
623 .data = &sysctl_tcp_limit_output_bytes,
624 .maxlen = sizeof(int),
625 .mode = 0644,
626 .proc_handler = proc_dointvec
627 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200628 {
629 .procname = "tcp_challenge_ack_limit",
630 .data = &sysctl_tcp_challenge_ack_limit,
631 .maxlen = sizeof(int),
632 .mode = 0644,
633 .proc_handler = proc_dointvec
634 },
David S. Miller35089bb2006-06-13 22:33:04 -0700635 {
David S. Miller35089bb2006-06-13 22:33:04 -0700636 .procname = "tcp_slow_start_after_idle",
637 .data = &sysctl_tcp_slow_start_after_idle,
638 .maxlen = sizeof(int),
639 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800640 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700641 },
Paul Moore446fda42006-08-03 16:48:06 -0700642#ifdef CONFIG_NETLABEL
643 {
Paul Moore446fda42006-08-03 16:48:06 -0700644 .procname = "cipso_cache_enable",
645 .data = &cipso_v4_cache_enabled,
646 .maxlen = sizeof(int),
647 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800648 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700649 },
650 {
Paul Moore446fda42006-08-03 16:48:06 -0700651 .procname = "cipso_cache_bucket_size",
652 .data = &cipso_v4_cache_bucketsize,
653 .maxlen = sizeof(int),
654 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800655 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700656 },
657 {
Paul Moore446fda42006-08-03 16:48:06 -0700658 .procname = "cipso_rbm_optfmt",
659 .data = &cipso_v4_rbm_optfmt,
660 .maxlen = sizeof(int),
661 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800662 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700663 },
664 {
Paul Moore446fda42006-08-03 16:48:06 -0700665 .procname = "cipso_rbm_strictvalid",
666 .data = &cipso_v4_rbm_strictvalid,
667 .maxlen = sizeof(int),
668 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800669 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700670 },
671#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800672 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800673 .procname = "tcp_available_congestion_control",
674 .maxlen = TCP_CA_BUF_MAX,
675 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800676 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800677 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800678 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800679 .procname = "tcp_allowed_congestion_control",
680 .maxlen = TCP_CA_BUF_MAX,
681 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800682 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800683 },
John Heffner886236c2007-03-25 19:21:45 -0700684 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000685 .procname = "tcp_thin_linear_timeouts",
686 .data = &sysctl_tcp_thin_linear_timeouts,
687 .maxlen = sizeof(int),
688 .mode = 0644,
689 .proc_handler = proc_dointvec
690 },
Weilong Chen5797deb2013-12-23 14:37:31 +0800691 {
Andreas Petlund7e380172010-02-18 04:48:19 +0000692 .procname = "tcp_thin_dupack",
693 .data = &sysctl_tcp_thin_dupack,
694 .maxlen = sizeof(int),
695 .mode = 0644,
696 .proc_handler = proc_dointvec
697 },
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000698 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000699 .procname = "tcp_early_retrans",
700 .data = &sysctl_tcp_early_retrans,
701 .maxlen = sizeof(int),
702 .mode = 0644,
703 .proc_handler = proc_dointvec_minmax,
704 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000705 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000706 },
707 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700708 .procname = "tcp_min_tso_segs",
709 .data = &sysctl_tcp_min_tso_segs,
710 .maxlen = sizeof(int),
711 .mode = 0644,
712 .proc_handler = proc_dointvec_minmax,
Eric Dumazetd6a4e262015-05-26 08:55:28 -0700713 .extra1 = &one,
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700714 .extra2 = &gso_max_segs,
715 },
716 {
Eric Dumazetf54b3112013-12-05 22:36:05 -0800717 .procname = "tcp_autocorking",
718 .data = &sysctl_tcp_autocorking,
719 .maxlen = sizeof(int),
720 .mode = 0644,
721 .proc_handler = proc_dointvec_minmax,
722 .extra1 = &zero,
723 .extra2 = &one,
724 },
725 {
Neal Cardwell032ee422015-02-06 16:04:38 -0500726 .procname = "tcp_invalid_ratelimit",
727 .data = &sysctl_tcp_invalid_ratelimit,
728 .maxlen = sizeof(int),
729 .mode = 0644,
730 .proc_handler = proc_dointvec_ms_jiffies,
731 },
732 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700733 .procname = "icmp_msgs_per_sec",
734 .data = &sysctl_icmp_msgs_per_sec,
735 .maxlen = sizeof(int),
736 .mode = 0644,
737 .proc_handler = proc_dointvec_minmax,
738 .extra1 = &zero,
739 },
740 {
741 .procname = "icmp_msgs_burst",
742 .data = &sysctl_icmp_msgs_burst,
743 .maxlen = sizeof(int),
744 .mode = 0644,
745 .proc_handler = proc_dointvec_minmax,
746 .extra1 = &zero,
747 },
748 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800749 .procname = "udp_mem",
750 .data = &sysctl_udp_mem,
751 .maxlen = sizeof(sysctl_udp_mem),
752 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000753 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800754 },
755 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800756 .procname = "udp_rmem_min",
757 .data = &sysctl_udp_rmem_min,
758 .maxlen = sizeof(sysctl_udp_rmem_min),
759 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800760 .proc_handler = proc_dointvec_minmax,
Sorin Dumitru81335342015-05-27 22:16:49 +0300761 .extra1 = &min_rcvbuf,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800762 },
763 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800764 .procname = "udp_wmem_min",
765 .data = &sysctl_udp_wmem_min,
766 .maxlen = sizeof(sysctl_udp_wmem_min),
767 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800768 .proc_handler = proc_dointvec_minmax,
Sorin Dumitru81335342015-05-27 22:16:49 +0300769 .extra1 = &min_sndbuf,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800770 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800771 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800773
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700774static struct ctl_table ipv4_net_table[] = {
775 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700776 .procname = "icmp_echo_ignore_all",
777 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
778 .maxlen = sizeof(int),
779 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800780 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700781 },
782 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700783 .procname = "icmp_echo_ignore_broadcasts",
784 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
785 .maxlen = sizeof(int),
786 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800787 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700788 },
789 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700790 .procname = "icmp_ignore_bogus_error_responses",
791 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
792 .maxlen = sizeof(int),
793 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800794 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700795 },
796 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700797 .procname = "icmp_errors_use_inbound_ifaddr",
798 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
799 .maxlen = sizeof(int),
800 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800801 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700802 },
803 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700804 .procname = "icmp_ratelimit",
805 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
806 .maxlen = sizeof(int),
807 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800808 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700809 },
810 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700811 .procname = "icmp_ratemask",
812 .data = &init_net.ipv4.sysctl_icmp_ratemask,
813 .maxlen = sizeof(int),
814 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800815 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700816 },
Neil Horman1080d702008-10-27 12:28:25 -0700817 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000818 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700819 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600820 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000821 .mode = 0644,
822 .proc_handler = ipv4_ping_group_range,
823 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000824 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000825 .procname = "tcp_ecn",
826 .data = &init_net.ipv4.sysctl_tcp_ecn,
827 .maxlen = sizeof(int),
828 .mode = 0644,
829 .proc_handler = proc_dointvec
830 },
831 {
Daniel Borkmann49213552015-05-19 21:04:22 +0200832 .procname = "tcp_ecn_fallback",
833 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
834 .maxlen = sizeof(int),
835 .mode = 0644,
836 .proc_handler = proc_dointvec
837 },
838 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700839 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700840 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
841 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700842 .mode = 0644,
843 .proc_handler = ipv4_local_port_range,
844 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100845 {
WANG Cong122ff242014-05-12 16:04:53 -0700846 .procname = "ip_local_reserved_ports",
847 .data = &init_net.ipv4.sysctl_local_reserved_ports,
848 .maxlen = 65536,
849 .mode = 0644,
850 .proc_handler = proc_do_large_bitmap,
851 },
852 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100853 .procname = "ip_no_pmtu_disc",
854 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
855 .maxlen = sizeof(int),
856 .mode = 0644,
857 .proc_handler = proc_dointvec
858 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100859 {
860 .procname = "ip_forward_use_pmtu",
861 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
862 .maxlen = sizeof(int),
863 .mode = 0644,
864 .proc_handler = proc_dointvec,
865 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700866 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200867 .procname = "ip_nonlocal_bind",
868 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
869 .maxlen = sizeof(int),
870 .mode = 0644,
871 .proc_handler = proc_dointvec
872 },
873 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700874 .procname = "fwmark_reflect",
875 .data = &init_net.ipv4.sysctl_fwmark_reflect,
876 .maxlen = sizeof(int),
877 .mode = 0644,
878 .proc_handler = proc_dointvec,
879 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700880 {
881 .procname = "tcp_fwmark_accept",
882 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
883 .maxlen = sizeof(int),
884 .mode = 0644,
885 .proc_handler = proc_dointvec,
886 },
Fan Dub0f9ca52015-02-10 09:53:16 +0800887 {
888 .procname = "tcp_mtu_probing",
889 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
890 .maxlen = sizeof(int),
891 .mode = 0644,
892 .proc_handler = proc_dointvec,
893 },
894 {
895 .procname = "tcp_base_mss",
896 .data = &init_net.ipv4.sysctl_tcp_base_mss,
897 .maxlen = sizeof(int),
898 .mode = 0644,
899 .proc_handler = proc_dointvec,
900 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800901 {
902 .procname = "tcp_probe_threshold",
903 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
904 .maxlen = sizeof(int),
905 .mode = 0644,
906 .proc_handler = proc_dointvec,
907 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800908 {
909 .procname = "tcp_probe_interval",
910 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
911 .maxlen = sizeof(int),
912 .mode = 0644,
913 .proc_handler = proc_dointvec,
914 },
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700915 { }
916};
917
Pavel Emelyanov15775192008-03-26 01:54:18 -0700918static __net_init int ipv4_sysctl_init_net(struct net *net)
919{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700920 struct ctl_table *table;
921
922 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800923 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700924 int i;
925
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700926 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +0100927 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700928 goto err_alloc;
929
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700930 /* Update the variables to point into the current struct net */
931 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
932 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700933 }
934
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000935 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +0100936 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700937 goto err_reg;
938
WANG Cong122ff242014-05-12 16:04:53 -0700939 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
940 if (!net->ipv4.sysctl_local_reserved_ports)
941 goto err_ports;
942
Pavel Emelyanov15775192008-03-26 01:54:18 -0700943 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700944
WANG Cong122ff242014-05-12 16:04:53 -0700945err_ports:
946 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700947err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800948 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700949 kfree(table);
950err_alloc:
951 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -0700952}
953
954static __net_exit void ipv4_sysctl_exit_net(struct net *net)
955{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700956 struct ctl_table *table;
957
WANG Cong122ff242014-05-12 16:04:53 -0700958 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700959 table = net->ipv4.ipv4_hdr->ctl_table_arg;
960 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
961 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700962}
963
964static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
965 .init = ipv4_sysctl_init_net,
966 .exit = ipv4_sysctl_exit_net,
967};
968
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800969static __init int sysctl_ipv4_init(void)
970{
971 struct ctl_table_header *hdr;
972
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000973 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +0100974 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -0700975 return -ENOMEM;
976
977 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +0000978 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700979 return -ENOMEM;
980 }
981
982 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800983}
984
985__initcall(sysctl_ipv4_init);