blob: c3852a7ff3c7630f4114cbc33a51a35fa3645e8c [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 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Stephen Hemminger227b60f2007-10-10 17:30:46 -070045/* Update system visible IP port range */
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070046static void set_local_port_range(struct net *net, int range[2])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070047{
Cong Wangc9d8f1a2014-05-06 11:02:49 -070048 write_seqlock(&net->ipv4.ip_local_ports.lock);
49 net->ipv4.ip_local_ports.range[0] = range[0];
50 net->ipv4.ip_local_ports.range[1] = range[1];
51 write_sequnlock(&net->ipv4.ip_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070052}
53
54/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070055static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070056 void __user *buffer,
57 size_t *lenp, loff_t *ppos)
58{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070059 struct net *net =
Cong Wangc9d8f1a2014-05-06 11:02:49 -070060 container_of(table->data, struct net, ipv4.ip_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070061 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070062 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070063 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070064 .data = &range,
65 .maxlen = sizeof(range),
66 .mode = table->mode,
67 .extra1 = &ip_local_port_range_min,
68 .extra2 = &ip_local_port_range_max,
69 };
70
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070071 inet_get_local_port_range(net, &range[0], &range[1]);
72
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070073 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070074
75 if (write && ret == 0) {
Anton Arapova25de532007-10-18 22:00:17 -070076 if (range[1] < range[0])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070077 ret = -EINVAL;
78 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070079 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070080 }
81
82 return ret;
83}
84
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000085
Eric W. Biederman7064d162012-05-24 10:34:21 -060086static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000087{
Eric W. Biederman7064d162012-05-24 10:34:21 -060088 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070089 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -070090 container_of(table->data, struct net, ipv4.ping_group_range.range);
Eric Dumazet95c96172012-04-15 05:58:06 +000091 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000092 do {
Cong Wangc9d8f1a2014-05-06 11:02:49 -070093 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000094
95 *low = data[0];
96 *high = data[1];
Cong Wangc9d8f1a2014-05-06 11:02:49 -070097 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000098}
99
100/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600101static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000102{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600103 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700104 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700105 container_of(table->data, struct net, ipv4.ping_group_range.range);
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700106 write_seqlock(&net->ipv4.ip_local_ports.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600107 data[0] = low;
108 data[1] = high;
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700109 write_sequnlock(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000110}
111
112/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700113static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000114 void __user *buffer,
115 size_t *lenp, loff_t *ppos)
116{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600117 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000118 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600119 gid_t urange[2];
120 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700121 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600122 .data = &urange,
123 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000124 .mode = table->mode,
125 .extra1 = &ip_ping_group_range_min,
126 .extra2 = &ip_ping_group_range_max,
127 };
128
Eric W. Biederman7064d162012-05-24 10:34:21 -0600129 inet_get_ping_group_range_table(table, &low, &high);
130 urange[0] = from_kgid_munged(user_ns, low);
131 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000132 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
133
Eric W. Biederman7064d162012-05-24 10:34:21 -0600134 if (write && ret == 0) {
135 low = make_kgid(user_ns, urange[0]);
136 high = make_kgid(user_ns, urange[1]);
137 if (!gid_valid(low) || !gid_valid(high) ||
138 (urange[1] < urange[0]) || gid_lt(high, low)) {
139 low = make_kgid(&init_user_ns, 1);
140 high = make_kgid(&init_user_ns, 0);
141 }
142 set_ping_group_range(table, low, high);
143 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000144
145 return ret;
146}
147
Joe Perchesfe2c6332013-06-11 23:04:25 -0700148static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700149 void __user *buffer, size_t *lenp, loff_t *ppos)
150{
151 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700152 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700153 .data = val,
154 .maxlen = TCP_CA_NAME_MAX,
155 };
156 int ret;
157
158 tcp_get_default_congestion_control(val);
159
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700160 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700161 if (write && ret == 0)
162 ret = tcp_set_default_congestion_control(val);
163 return ret;
164}
165
Joe Perchesfe2c6332013-06-11 23:04:25 -0700166static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700167 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800168 void __user *buffer, size_t *lenp,
169 loff_t *ppos)
170{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700171 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800172 int ret;
173
174 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
175 if (!tbl.data)
176 return -ENOMEM;
177 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700178 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800179 kfree(tbl.data);
180 return ret;
181}
182
Joe Perchesfe2c6332013-06-11 23:04:25 -0700183static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800185 void __user *buffer, size_t *lenp,
186 loff_t *ppos)
187{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700188 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800189 int ret;
190
191 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
192 if (!tbl.data)
193 return -ENOMEM;
194
195 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700196 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800197 if (write && ret == 0)
198 ret = tcp_set_allowed_congestion_control(tbl.data);
199 kfree(tbl.data);
200 return ret;
201}
202
Joe Perchesfe2c6332013-06-11 23:04:25 -0700203static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
204 void __user *buffer, size_t *lenp,
205 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000206{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700207 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000208 struct tcp_fastopen_context *ctxt;
209 int ret;
210 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
211
212 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
213 if (!tbl.data)
214 return -ENOMEM;
215
216 rcu_read_lock();
217 ctxt = rcu_dereference(tcp_fastopen_ctx);
218 if (ctxt)
219 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000220 else
221 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000222 rcu_read_unlock();
223
224 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
225 user_key[0], user_key[1], user_key[2], user_key[3]);
226 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
227
228 if (write && ret == 0) {
229 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
230 user_key + 2, user_key + 3) != 4) {
231 ret = -EINVAL;
232 goto bad_key;
233 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200234 /* Generate a dummy secret but don't publish it. This
235 * is needed so we don't regenerate a new key on the
236 * first invocation of tcp_fastopen_cookie_gen
237 */
238 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000239 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
240 }
241
242bad_key:
243 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
244 user_key[0], user_key[1], user_key[2], user_key[3],
245 (char *)tbl.data, ret);
246 kfree(tbl.data);
247 return ret;
248}
249
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800250static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900251 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 .procname = "tcp_timestamps",
253 .data = &sysctl_tcp_timestamps,
254 .maxlen = sizeof(int),
255 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800256 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900258 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 .procname = "tcp_window_scaling",
260 .data = &sysctl_tcp_window_scaling,
261 .maxlen = sizeof(int),
262 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800263 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900265 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 .procname = "tcp_sack",
267 .data = &sysctl_tcp_sack,
268 .maxlen = sizeof(int),
269 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800270 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 .procname = "tcp_retrans_collapse",
274 .data = &sysctl_tcp_retrans_collapse,
275 .maxlen = sizeof(int),
276 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800277 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900279 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 .procname = "ip_default_ttl",
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900281 .data = &sysctl_ip_default_ttl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 .maxlen = sizeof(int),
283 .mode = 0644,
Eric Dumazet249fab72010-12-13 12:16:14 -0800284 .proc_handler = proc_dointvec_minmax,
285 .extra1 = &ip_ttl_min,
286 .extra2 = &ip_ttl_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900288 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 .procname = "tcp_syn_retries",
290 .data = &sysctl_tcp_syn_retries,
291 .maxlen = sizeof(int),
292 .mode = 0644,
Michal Tesar651e9272013-07-19 14:09:01 +0200293 .proc_handler = proc_dointvec_minmax,
294 .extra1 = &tcp_syn_retries_min,
295 .extra2 = &tcp_syn_retries_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 },
297 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 .procname = "tcp_synack_retries",
299 .data = &sysctl_tcp_synack_retries,
300 .maxlen = sizeof(int),
301 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800302 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 },
304 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 .procname = "tcp_max_orphans",
306 .data = &sysctl_tcp_max_orphans,
307 .maxlen = sizeof(int),
308 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800309 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 },
311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 .procname = "tcp_max_tw_buckets",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700313 .data = &tcp_death_row.sysctl_max_tw_buckets,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 .maxlen = sizeof(int),
315 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800316 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 },
318 {
Alexander Duyck6648bd72012-06-21 13:58:31 +0000319 .procname = "ip_early_demux",
320 .data = &sysctl_ip_early_demux,
321 .maxlen = sizeof(int),
322 .mode = 0644,
323 .proc_handler = proc_dointvec
324 },
325 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 .procname = "ip_dynaddr",
327 .data = &sysctl_ip_dynaddr,
328 .maxlen = sizeof(int),
329 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800330 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 },
332 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 .procname = "tcp_keepalive_time",
334 .data = &sysctl_tcp_keepalive_time,
335 .maxlen = sizeof(int),
336 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800337 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 },
339 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 .procname = "tcp_keepalive_probes",
341 .data = &sysctl_tcp_keepalive_probes,
342 .maxlen = sizeof(int),
343 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800344 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 },
346 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 .procname = "tcp_keepalive_intvl",
348 .data = &sysctl_tcp_keepalive_intvl,
349 .maxlen = sizeof(int),
350 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800351 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 },
353 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 .procname = "tcp_retries1",
355 .data = &sysctl_tcp_retries1,
356 .maxlen = sizeof(int),
357 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800358 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 .extra2 = &tcp_retr1_max
360 },
361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 .procname = "tcp_retries2",
363 .data = &sysctl_tcp_retries2,
364 .maxlen = sizeof(int),
365 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800366 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 },
368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 .procname = "tcp_fin_timeout",
370 .data = &sysctl_tcp_fin_timeout,
371 .maxlen = sizeof(int),
372 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800373 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 },
375#ifdef CONFIG_SYN_COOKIES
376 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 .procname = "tcp_syncookies",
378 .data = &sysctl_tcp_syncookies,
379 .maxlen = sizeof(int),
380 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800381 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 },
383#endif
384 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000385 .procname = "tcp_fastopen",
386 .data = &sysctl_tcp_fastopen,
387 .maxlen = sizeof(int),
388 .mode = 0644,
389 .proc_handler = proc_dointvec,
390 },
391 {
Jerry Chu10467162012-08-31 12:29:11 +0000392 .procname = "tcp_fastopen_key",
393 .mode = 0600,
394 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
395 .proc_handler = proc_tcp_fastopen_key,
396 },
397 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 .procname = "tcp_tw_recycle",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700399 .data = &tcp_death_row.sysctl_tw_recycle,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .maxlen = sizeof(int),
401 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800402 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 },
404 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 .procname = "tcp_abort_on_overflow",
406 .data = &sysctl_tcp_abort_on_overflow,
407 .maxlen = sizeof(int),
408 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800409 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 },
411 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 .procname = "tcp_stdurg",
413 .data = &sysctl_tcp_stdurg,
414 .maxlen = sizeof(int),
415 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800416 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 },
418 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 .procname = "tcp_rfc1337",
420 .data = &sysctl_tcp_rfc1337,
421 .maxlen = sizeof(int),
422 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800423 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 },
425 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 .procname = "tcp_max_syn_backlog",
427 .data = &sysctl_max_syn_backlog,
428 .maxlen = sizeof(int),
429 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800430 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 },
432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 .procname = "igmp_max_memberships",
434 .data = &sysctl_igmp_max_memberships,
435 .maxlen = sizeof(int),
436 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800437 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 .procname = "igmp_max_msf",
441 .data = &sysctl_igmp_max_msf,
442 .maxlen = sizeof(int),
443 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800444 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 },
Hannes Frederic Sowaa9fe8e22014-09-02 15:49:26 +0200446#ifdef CONFIG_IP_MULTICAST
447 {
448 .procname = "igmp_qrv",
449 .data = &sysctl_igmp_qrv,
450 .maxlen = sizeof(int),
451 .mode = 0644,
452 .proc_handler = proc_dointvec_minmax,
453 .extra1 = &one
454 },
455#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .procname = "inet_peer_threshold",
458 .data = &inet_peer_threshold,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800461 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 },
463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "inet_peer_minttl",
465 .data = &inet_peer_minttl,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800468 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "inet_peer_maxttl",
472 .data = &inet_peer_maxttl,
473 .maxlen = sizeof(int),
474 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800475 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 .procname = "tcp_orphan_retries",
479 .data = &sysctl_tcp_orphan_retries,
480 .maxlen = sizeof(int),
481 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800482 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 },
484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .procname = "tcp_fack",
486 .data = &sysctl_tcp_fack,
487 .maxlen = sizeof(int),
488 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800489 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 },
491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 .procname = "tcp_reordering",
493 .data = &sysctl_tcp_reordering,
494 .maxlen = sizeof(int),
495 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800496 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 },
498 {
Eric Dumazetdca145f2014-10-27 21:45:24 -0700499 .procname = "tcp_max_reordering",
500 .data = &sysctl_tcp_max_reordering,
501 .maxlen = sizeof(int),
502 .mode = 0644,
503 .proc_handler = proc_dointvec
504 },
505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 .procname = "tcp_dsack",
507 .data = &sysctl_tcp_dsack,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800510 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 },
512 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700513 .procname = "tcp_mem",
514 .maxlen = sizeof(sysctl_tcp_mem),
515 .data = &sysctl_tcp_mem,
516 .mode = 0644,
517 .proc_handler = proc_doulongvec_minmax,
518 },
519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 .procname = "tcp_wmem",
521 .data = &sysctl_tcp_wmem,
522 .maxlen = sizeof(sysctl_tcp_wmem),
523 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000524 .proc_handler = proc_dointvec_minmax,
525 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 },
527 {
Eric Dumazetc9bee3b72013-07-22 20:27:07 -0700528 .procname = "tcp_notsent_lowat",
529 .data = &sysctl_tcp_notsent_lowat,
530 .maxlen = sizeof(sysctl_tcp_notsent_lowat),
531 .mode = 0644,
532 .proc_handler = proc_dointvec,
533 },
534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "tcp_rmem",
536 .data = &sysctl_tcp_rmem,
537 .maxlen = sizeof(sysctl_tcp_rmem),
538 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000539 .proc_handler = proc_dointvec_minmax,
540 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 },
542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .procname = "tcp_app_win",
544 .data = &sysctl_tcp_app_win,
545 .maxlen = sizeof(int),
546 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800547 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 },
549 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 .procname = "tcp_adv_win_scale",
551 .data = &sysctl_tcp_adv_win_scale,
552 .maxlen = sizeof(int),
553 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000554 .proc_handler = proc_dointvec_minmax,
555 .extra1 = &tcp_adv_win_scale_min,
556 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 .procname = "tcp_tw_reuse",
560 .data = &sysctl_tcp_tw_reuse,
561 .maxlen = sizeof(int),
562 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800563 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 },
565 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 .procname = "tcp_frto",
567 .data = &sysctl_tcp_frto,
568 .maxlen = sizeof(int),
569 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800570 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 },
572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 .procname = "tcp_low_latency",
574 .data = &sysctl_tcp_low_latency,
575 .maxlen = sizeof(int),
576 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800577 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 },
579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "tcp_no_metrics_save",
581 .data = &sysctl_tcp_nometrics_save,
582 .maxlen = sizeof(int),
583 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800584 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "tcp_moderate_rcvbuf",
588 .data = &sysctl_tcp_moderate_rcvbuf,
589 .maxlen = sizeof(int),
590 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "tcp_tso_win_divisor",
595 .data = &sysctl_tcp_tso_win_divisor,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800598 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 },
600 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700601 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700603 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800604 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800606 {
Rick Jones15d99e02006-03-20 22:40:29 -0800607 .procname = "tcp_workaround_signed_windows",
608 .data = &sysctl_tcp_workaround_signed_windows,
609 .maxlen = sizeof(int),
610 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800611 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800612 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000613 {
614 .procname = "tcp_limit_output_bytes",
615 .data = &sysctl_tcp_limit_output_bytes,
616 .maxlen = sizeof(int),
617 .mode = 0644,
618 .proc_handler = proc_dointvec
619 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200620 {
621 .procname = "tcp_challenge_ack_limit",
622 .data = &sysctl_tcp_challenge_ack_limit,
623 .maxlen = sizeof(int),
624 .mode = 0644,
625 .proc_handler = proc_dointvec
626 },
David S. Miller35089bb2006-06-13 22:33:04 -0700627 {
David S. Miller35089bb2006-06-13 22:33:04 -0700628 .procname = "tcp_slow_start_after_idle",
629 .data = &sysctl_tcp_slow_start_after_idle,
630 .maxlen = sizeof(int),
631 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800632 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700633 },
Paul Moore446fda42006-08-03 16:48:06 -0700634#ifdef CONFIG_NETLABEL
635 {
Paul Moore446fda42006-08-03 16:48:06 -0700636 .procname = "cipso_cache_enable",
637 .data = &cipso_v4_cache_enabled,
638 .maxlen = sizeof(int),
639 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800640 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700641 },
642 {
Paul Moore446fda42006-08-03 16:48:06 -0700643 .procname = "cipso_cache_bucket_size",
644 .data = &cipso_v4_cache_bucketsize,
645 .maxlen = sizeof(int),
646 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800647 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700648 },
649 {
Paul Moore446fda42006-08-03 16:48:06 -0700650 .procname = "cipso_rbm_optfmt",
651 .data = &cipso_v4_rbm_optfmt,
652 .maxlen = sizeof(int),
653 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800654 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700655 },
656 {
Paul Moore446fda42006-08-03 16:48:06 -0700657 .procname = "cipso_rbm_strictvalid",
658 .data = &cipso_v4_rbm_strictvalid,
659 .maxlen = sizeof(int),
660 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800661 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700662 },
663#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800664 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800665 .procname = "tcp_available_congestion_control",
666 .maxlen = TCP_CA_BUF_MAX,
667 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800668 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800669 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800670 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800671 .procname = "tcp_allowed_congestion_control",
672 .maxlen = TCP_CA_BUF_MAX,
673 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800674 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800675 },
John Heffner886236c2007-03-25 19:21:45 -0700676 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000677 .procname = "tcp_thin_linear_timeouts",
678 .data = &sysctl_tcp_thin_linear_timeouts,
679 .maxlen = sizeof(int),
680 .mode = 0644,
681 .proc_handler = proc_dointvec
682 },
Weilong Chen5797deb2013-12-23 14:37:31 +0800683 {
Andreas Petlund7e380172010-02-18 04:48:19 +0000684 .procname = "tcp_thin_dupack",
685 .data = &sysctl_tcp_thin_dupack,
686 .maxlen = sizeof(int),
687 .mode = 0644,
688 .proc_handler = proc_dointvec
689 },
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000690 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000691 .procname = "tcp_early_retrans",
692 .data = &sysctl_tcp_early_retrans,
693 .maxlen = sizeof(int),
694 .mode = 0644,
695 .proc_handler = proc_dointvec_minmax,
696 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000697 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000698 },
699 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700700 .procname = "tcp_min_tso_segs",
701 .data = &sysctl_tcp_min_tso_segs,
702 .maxlen = sizeof(int),
703 .mode = 0644,
704 .proc_handler = proc_dointvec_minmax,
705 .extra1 = &zero,
706 .extra2 = &gso_max_segs,
707 },
708 {
Eric Dumazetf54b3112013-12-05 22:36:05 -0800709 .procname = "tcp_autocorking",
710 .data = &sysctl_tcp_autocorking,
711 .maxlen = sizeof(int),
712 .mode = 0644,
713 .proc_handler = proc_dointvec_minmax,
714 .extra1 = &zero,
715 .extra2 = &one,
716 },
717 {
Neal Cardwell032ee422015-02-06 16:04:38 -0500718 .procname = "tcp_invalid_ratelimit",
719 .data = &sysctl_tcp_invalid_ratelimit,
720 .maxlen = sizeof(int),
721 .mode = 0644,
722 .proc_handler = proc_dointvec_ms_jiffies,
723 },
724 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700725 .procname = "icmp_msgs_per_sec",
726 .data = &sysctl_icmp_msgs_per_sec,
727 .maxlen = sizeof(int),
728 .mode = 0644,
729 .proc_handler = proc_dointvec_minmax,
730 .extra1 = &zero,
731 },
732 {
733 .procname = "icmp_msgs_burst",
734 .data = &sysctl_icmp_msgs_burst,
735 .maxlen = sizeof(int),
736 .mode = 0644,
737 .proc_handler = proc_dointvec_minmax,
738 .extra1 = &zero,
739 },
740 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800741 .procname = "udp_mem",
742 .data = &sysctl_udp_mem,
743 .maxlen = sizeof(sysctl_udp_mem),
744 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000745 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800746 },
747 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800748 .procname = "udp_rmem_min",
749 .data = &sysctl_udp_rmem_min,
750 .maxlen = sizeof(sysctl_udp_rmem_min),
751 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800752 .proc_handler = proc_dointvec_minmax,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000753 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800754 },
755 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800756 .procname = "udp_wmem_min",
757 .data = &sysctl_udp_wmem_min,
758 .maxlen = sizeof(sysctl_udp_wmem_min),
759 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800760 .proc_handler = proc_dointvec_minmax,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000761 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800762 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800763 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800765
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700766static struct ctl_table ipv4_net_table[] = {
767 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700768 .procname = "icmp_echo_ignore_all",
769 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
770 .maxlen = sizeof(int),
771 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800772 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700773 },
774 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700775 .procname = "icmp_echo_ignore_broadcasts",
776 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
777 .maxlen = sizeof(int),
778 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800779 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700780 },
781 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700782 .procname = "icmp_ignore_bogus_error_responses",
783 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
784 .maxlen = sizeof(int),
785 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800786 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700787 },
788 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700789 .procname = "icmp_errors_use_inbound_ifaddr",
790 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
791 .maxlen = sizeof(int),
792 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800793 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700794 },
795 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700796 .procname = "icmp_ratelimit",
797 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
798 .maxlen = sizeof(int),
799 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800800 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700801 },
802 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700803 .procname = "icmp_ratemask",
804 .data = &init_net.ipv4.sysctl_icmp_ratemask,
805 .maxlen = sizeof(int),
806 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800807 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700808 },
Neil Horman1080d702008-10-27 12:28:25 -0700809 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000810 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700811 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600812 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000813 .mode = 0644,
814 .proc_handler = ipv4_ping_group_range,
815 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000816 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000817 .procname = "tcp_ecn",
818 .data = &init_net.ipv4.sysctl_tcp_ecn,
819 .maxlen = sizeof(int),
820 .mode = 0644,
821 .proc_handler = proc_dointvec
822 },
823 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700824 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700825 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
826 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700827 .mode = 0644,
828 .proc_handler = ipv4_local_port_range,
829 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100830 {
WANG Cong122ff242014-05-12 16:04:53 -0700831 .procname = "ip_local_reserved_ports",
832 .data = &init_net.ipv4.sysctl_local_reserved_ports,
833 .maxlen = 65536,
834 .mode = 0644,
835 .proc_handler = proc_do_large_bitmap,
836 },
837 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100838 .procname = "ip_no_pmtu_disc",
839 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
840 .maxlen = sizeof(int),
841 .mode = 0644,
842 .proc_handler = proc_dointvec
843 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100844 {
845 .procname = "ip_forward_use_pmtu",
846 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
847 .maxlen = sizeof(int),
848 .mode = 0644,
849 .proc_handler = proc_dointvec,
850 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700851 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200852 .procname = "ip_nonlocal_bind",
853 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
854 .maxlen = sizeof(int),
855 .mode = 0644,
856 .proc_handler = proc_dointvec
857 },
858 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700859 .procname = "fwmark_reflect",
860 .data = &init_net.ipv4.sysctl_fwmark_reflect,
861 .maxlen = sizeof(int),
862 .mode = 0644,
863 .proc_handler = proc_dointvec,
864 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700865 {
866 .procname = "tcp_fwmark_accept",
867 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
868 .maxlen = sizeof(int),
869 .mode = 0644,
870 .proc_handler = proc_dointvec,
871 },
Fan Dub0f9ca52015-02-10 09:53:16 +0800872 {
873 .procname = "tcp_mtu_probing",
874 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
875 .maxlen = sizeof(int),
876 .mode = 0644,
877 .proc_handler = proc_dointvec,
878 },
879 {
880 .procname = "tcp_base_mss",
881 .data = &init_net.ipv4.sysctl_tcp_base_mss,
882 .maxlen = sizeof(int),
883 .mode = 0644,
884 .proc_handler = proc_dointvec,
885 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800886 {
887 .procname = "tcp_probe_threshold",
888 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
889 .maxlen = sizeof(int),
890 .mode = 0644,
891 .proc_handler = proc_dointvec,
892 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800893 {
894 .procname = "tcp_probe_interval",
895 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
896 .maxlen = sizeof(int),
897 .mode = 0644,
898 .proc_handler = proc_dointvec,
899 },
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700900 { }
901};
902
Pavel Emelyanov15775192008-03-26 01:54:18 -0700903static __net_init int ipv4_sysctl_init_net(struct net *net)
904{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700905 struct ctl_table *table;
906
907 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800908 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700909 int i;
910
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700911 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +0100912 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700913 goto err_alloc;
914
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700915 /* Update the variables to point into the current struct net */
916 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
917 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700918 }
919
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000920 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +0100921 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700922 goto err_reg;
923
WANG Cong122ff242014-05-12 16:04:53 -0700924 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
925 if (!net->ipv4.sysctl_local_reserved_ports)
926 goto err_ports;
927
Pavel Emelyanov15775192008-03-26 01:54:18 -0700928 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700929
WANG Cong122ff242014-05-12 16:04:53 -0700930err_ports:
931 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700932err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800933 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700934 kfree(table);
935err_alloc:
936 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -0700937}
938
939static __net_exit void ipv4_sysctl_exit_net(struct net *net)
940{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700941 struct ctl_table *table;
942
WANG Cong122ff242014-05-12 16:04:53 -0700943 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700944 table = net->ipv4.ipv4_hdr->ctl_table_arg;
945 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
946 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700947}
948
949static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
950 .init = ipv4_sysctl_init_net,
951 .exit = ipv4_sysctl_exit_net,
952};
953
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800954static __init int sysctl_ipv4_init(void)
955{
956 struct ctl_table_header *hdr;
957
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000958 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +0100959 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -0700960 return -ENOMEM;
961
962 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +0000963 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -0700964 return -ENOMEM;
965 }
966
967 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800968}
969
970__initcall(sysctl_ipv4_init);