blob: a0bd7a55193e351c9ec75a469315c44e76195fd1 [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 Dumazet43e122b2015-08-21 17:38:02 -070032static int thousand = 1000;
Eric Dumazet95bd09e2013-08-27 05:46:32 -070033static int gso_max_segs = GSO_MAX_SEGS;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090034static int tcp_retr1_max = 255;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035static int ip_local_port_range_min[] = { 1, 1 };
36static int ip_local_port_range_max[] = { 65535, 65535 };
Alexey Dobriyan0147fc02010-11-22 12:54:21 +000037static int tcp_adv_win_scale_min = -31;
38static int tcp_adv_win_scale_max = 31;
Eric Dumazet249fab72010-12-13 12:16:14 -080039static int ip_ttl_min = 1;
40static int ip_ttl_max = 255;
Michal Tesar651e9272013-07-19 14:09:01 +020041static int tcp_syn_retries_min = 1;
42static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000043static int ip_ping_group_range_min[] = { 0, 0 };
44static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Stephen Hemminger227b60f2007-10-10 17:30:46 -070046/* Update system visible IP port range */
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070047static void set_local_port_range(struct net *net, int range[2])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070048{
Eric Dumazeted2dfd92015-05-27 11:34:37 -070049 bool same_parity = !((range[0] ^ range[1]) & 1);
50
WANG Cong4ee3bd42015-11-03 14:32:57 -080051 write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
Eric Dumazeted2dfd92015-05-27 11:34:37 -070052 if (same_parity && !net->ipv4.ip_local_ports.warned) {
53 net->ipv4.ip_local_ports.warned = true;
54 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
55 }
Cong Wangc9d8f1a2014-05-06 11:02:49 -070056 net->ipv4.ip_local_ports.range[0] = range[0];
57 net->ipv4.ip_local_ports.range[1] = range[1];
WANG Cong4ee3bd42015-11-03 14:32:57 -080058 write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070059}
60
61/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070062static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070063 void __user *buffer,
64 size_t *lenp, loff_t *ppos)
65{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070066 struct net *net =
Cong Wangc9d8f1a2014-05-06 11:02:49 -070067 container_of(table->data, struct net, ipv4.ip_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070068 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070069 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070070 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070071 .data = &range,
72 .maxlen = sizeof(range),
73 .mode = table->mode,
74 .extra1 = &ip_local_port_range_min,
75 .extra2 = &ip_local_port_range_max,
76 };
77
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070078 inet_get_local_port_range(net, &range[0], &range[1]);
79
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070080 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070081
82 if (write && ret == 0) {
Anton Arapova25de532007-10-18 22:00:17 -070083 if (range[1] < range[0])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070084 ret = -EINVAL;
85 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070086 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070087 }
88
89 return ret;
90}
91
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000092
Eric W. Biederman7064d162012-05-24 10:34:21 -060093static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000094{
Eric W. Biederman7064d162012-05-24 10:34:21 -060095 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070096 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -070097 container_of(table->data, struct net, ipv4.ping_group_range.range);
Eric Dumazet95c96172012-04-15 05:58:06 +000098 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000099 do {
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700100 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000101
102 *low = data[0];
103 *high = data[1];
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700104 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000105}
106
107/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600108static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000109{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600110 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700111 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700112 container_of(table->data, struct net, ipv4.ping_group_range.range);
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700113 write_seqlock(&net->ipv4.ip_local_ports.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600114 data[0] = low;
115 data[1] = high;
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700116 write_sequnlock(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000117}
118
119/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700120static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000121 void __user *buffer,
122 size_t *lenp, loff_t *ppos)
123{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600124 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000125 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600126 gid_t urange[2];
127 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700128 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600129 .data = &urange,
130 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000131 .mode = table->mode,
132 .extra1 = &ip_ping_group_range_min,
133 .extra2 = &ip_ping_group_range_max,
134 };
135
Eric W. Biederman7064d162012-05-24 10:34:21 -0600136 inet_get_ping_group_range_table(table, &low, &high);
137 urange[0] = from_kgid_munged(user_ns, low);
138 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000139 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
140
Eric W. Biederman7064d162012-05-24 10:34:21 -0600141 if (write && ret == 0) {
142 low = make_kgid(user_ns, urange[0]);
143 high = make_kgid(user_ns, urange[1]);
144 if (!gid_valid(low) || !gid_valid(high) ||
145 (urange[1] < urange[0]) || gid_lt(high, low)) {
146 low = make_kgid(&init_user_ns, 1);
147 high = make_kgid(&init_user_ns, 0);
148 }
149 set_ping_group_range(table, low, high);
150 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000151
152 return ret;
153}
154
Joe Perchesfe2c6332013-06-11 23:04:25 -0700155static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700156 void __user *buffer, size_t *lenp, loff_t *ppos)
157{
158 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700159 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700160 .data = val,
161 .maxlen = TCP_CA_NAME_MAX,
162 };
163 int ret;
164
165 tcp_get_default_congestion_control(val);
166
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700167 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700168 if (write && ret == 0)
169 ret = tcp_set_default_congestion_control(val);
170 return ret;
171}
172
Joe Perchesfe2c6332013-06-11 23:04:25 -0700173static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700174 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800175 void __user *buffer, size_t *lenp,
176 loff_t *ppos)
177{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700178 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800179 int ret;
180
181 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
182 if (!tbl.data)
183 return -ENOMEM;
184 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800186 kfree(tbl.data);
187 return ret;
188}
189
Joe Perchesfe2c6332013-06-11 23:04:25 -0700190static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700191 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800192 void __user *buffer, size_t *lenp,
193 loff_t *ppos)
194{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700195 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800196 int ret;
197
198 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
199 if (!tbl.data)
200 return -ENOMEM;
201
202 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700203 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800204 if (write && ret == 0)
205 ret = tcp_set_allowed_congestion_control(tbl.data);
206 kfree(tbl.data);
207 return ret;
208}
209
Joe Perchesfe2c6332013-06-11 23:04:25 -0700210static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
211 void __user *buffer, size_t *lenp,
212 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000213{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700214 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000215 struct tcp_fastopen_context *ctxt;
216 int ret;
217 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
218
219 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
220 if (!tbl.data)
221 return -ENOMEM;
222
223 rcu_read_lock();
224 ctxt = rcu_dereference(tcp_fastopen_ctx);
225 if (ctxt)
226 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000227 else
228 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000229 rcu_read_unlock();
230
231 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
232 user_key[0], user_key[1], user_key[2], user_key[3]);
233 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
234
235 if (write && ret == 0) {
236 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
237 user_key + 2, user_key + 3) != 4) {
238 ret = -EINVAL;
239 goto bad_key;
240 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200241 /* Generate a dummy secret but don't publish it. This
242 * is needed so we don't regenerate a new key on the
243 * first invocation of tcp_fastopen_cookie_gen
244 */
245 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000246 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
247 }
248
249bad_key:
250 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
251 user_key[0], user_key[1], user_key[2], user_key[3],
252 (char *)tbl.data, ret);
253 kfree(tbl.data);
254 return ret;
255}
256
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800257static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900258 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 .procname = "tcp_timestamps",
260 .data = &sysctl_tcp_timestamps,
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_window_scaling",
267 .data = &sysctl_tcp_window_scaling,
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_sack",
274 .data = &sysctl_tcp_sack,
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 = "tcp_retrans_collapse",
281 .data = &sysctl_tcp_retrans_collapse,
282 .maxlen = sizeof(int),
283 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800284 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900286 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 .procname = "ip_default_ttl",
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900288 .data = &sysctl_ip_default_ttl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 .maxlen = sizeof(int),
290 .mode = 0644,
Eric Dumazet249fab72010-12-13 12:16:14 -0800291 .proc_handler = proc_dointvec_minmax,
292 .extra1 = &ip_ttl_min,
293 .extra2 = &ip_ttl_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 .procname = "tcp_syn_retries",
297 .data = &sysctl_tcp_syn_retries,
298 .maxlen = sizeof(int),
299 .mode = 0644,
Michal Tesar651e9272013-07-19 14:09:01 +0200300 .proc_handler = proc_dointvec_minmax,
301 .extra1 = &tcp_syn_retries_min,
302 .extra2 = &tcp_syn_retries_max
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 },
304 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 .procname = "tcp_synack_retries",
306 .data = &sysctl_tcp_synack_retries,
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_orphans",
313 .data = &sysctl_tcp_max_orphans,
314 .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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 .procname = "tcp_max_tw_buckets",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700320 .data = &tcp_death_row.sysctl_max_tw_buckets,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 .maxlen = sizeof(int),
322 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800323 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 },
325 {
Alexander Duyck6648bd72012-06-21 13:58:31 +0000326 .procname = "ip_early_demux",
327 .data = &sysctl_ip_early_demux,
328 .maxlen = sizeof(int),
329 .mode = 0644,
330 .proc_handler = proc_dointvec
331 },
332 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 .procname = "ip_dynaddr",
334 .data = &sysctl_ip_dynaddr,
335 .maxlen = sizeof(int),
336 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800337 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 },
339 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 .procname = "tcp_keepalive_time",
341 .data = &sysctl_tcp_keepalive_time,
342 .maxlen = sizeof(int),
343 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800344 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 },
346 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 .procname = "tcp_keepalive_probes",
348 .data = &sysctl_tcp_keepalive_probes,
349 .maxlen = sizeof(int),
350 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800351 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 },
353 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 .procname = "tcp_keepalive_intvl",
355 .data = &sysctl_tcp_keepalive_intvl,
356 .maxlen = sizeof(int),
357 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800358 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 },
360 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 .procname = "tcp_retries1",
362 .data = &sysctl_tcp_retries1,
363 .maxlen = sizeof(int),
364 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800365 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 .extra2 = &tcp_retr1_max
367 },
368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 .procname = "tcp_retries2",
370 .data = &sysctl_tcp_retries2,
371 .maxlen = sizeof(int),
372 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800373 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 },
375 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 .procname = "tcp_fin_timeout",
377 .data = &sysctl_tcp_fin_timeout,
378 .maxlen = sizeof(int),
379 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800380 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 },
382#ifdef CONFIG_SYN_COOKIES
383 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 .procname = "tcp_syncookies",
385 .data = &sysctl_tcp_syncookies,
386 .maxlen = sizeof(int),
387 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800388 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 },
390#endif
391 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000392 .procname = "tcp_fastopen",
393 .data = &sysctl_tcp_fastopen,
394 .maxlen = sizeof(int),
395 .mode = 0644,
396 .proc_handler = proc_dointvec,
397 },
398 {
Jerry Chu10467162012-08-31 12:29:11 +0000399 .procname = "tcp_fastopen_key",
400 .mode = 0600,
401 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
402 .proc_handler = proc_tcp_fastopen_key,
403 },
404 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 .procname = "tcp_tw_recycle",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700406 .data = &tcp_death_row.sysctl_tw_recycle,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 .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_abort_on_overflow",
413 .data = &sysctl_tcp_abort_on_overflow,
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_stdurg",
420 .data = &sysctl_tcp_stdurg,
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_rfc1337",
427 .data = &sysctl_tcp_rfc1337,
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 = "tcp_max_syn_backlog",
434 .data = &sysctl_max_syn_backlog,
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 },
439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 .procname = "igmp_max_memberships",
441 .data = &sysctl_igmp_max_memberships,
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 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 .procname = "igmp_max_msf",
448 .data = &sysctl_igmp_max_msf,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800451 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 },
Hannes Frederic Sowaa9fe8e22014-09-02 15:49:26 +0200453#ifdef CONFIG_IP_MULTICAST
454 {
455 .procname = "igmp_qrv",
456 .data = &sysctl_igmp_qrv,
457 .maxlen = sizeof(int),
458 .mode = 0644,
459 .proc_handler = proc_dointvec_minmax,
460 .extra1 = &one
461 },
462#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "inet_peer_threshold",
465 .data = &inet_peer_threshold,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800468 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "inet_peer_minttl",
472 .data = &inet_peer_minttl,
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 = "inet_peer_maxttl",
479 .data = &inet_peer_maxttl,
480 .maxlen = sizeof(int),
481 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800482 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 },
484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .procname = "tcp_orphan_retries",
486 .data = &sysctl_tcp_orphan_retries,
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_fack",
493 .data = &sysctl_tcp_fack,
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 {
Yuchung Cheng4f41b1c2015-10-16 21:57:47 -0700499 .procname = "tcp_recovery",
500 .data = &sysctl_tcp_recovery,
501 .maxlen = sizeof(int),
502 .mode = 0644,
503 .proc_handler = proc_dointvec,
504 },
505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 .procname = "tcp_reordering",
507 .data = &sysctl_tcp_reordering,
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 Dumazetdca145f2014-10-27 21:45:24 -0700513 .procname = "tcp_max_reordering",
514 .data = &sysctl_tcp_max_reordering,
515 .maxlen = sizeof(int),
516 .mode = 0644,
517 .proc_handler = proc_dointvec
518 },
519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 .procname = "tcp_dsack",
521 .data = &sysctl_tcp_dsack,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800524 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 },
526 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700527 .procname = "tcp_mem",
528 .maxlen = sizeof(sysctl_tcp_mem),
529 .data = &sysctl_tcp_mem,
530 .mode = 0644,
531 .proc_handler = proc_doulongvec_minmax,
532 },
533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 .procname = "tcp_wmem",
535 .data = &sysctl_tcp_wmem,
536 .maxlen = sizeof(sysctl_tcp_wmem),
537 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000538 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700539 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 },
541 {
Eric Dumazetc9bee3b72013-07-22 20:27:07 -0700542 .procname = "tcp_notsent_lowat",
543 .data = &sysctl_tcp_notsent_lowat,
544 .maxlen = sizeof(sysctl_tcp_notsent_lowat),
545 .mode = 0644,
546 .proc_handler = proc_dointvec,
547 },
548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 .procname = "tcp_rmem",
550 .data = &sysctl_tcp_rmem,
551 .maxlen = sizeof(sysctl_tcp_rmem),
552 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000553 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700554 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 },
556 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 .procname = "tcp_app_win",
558 .data = &sysctl_tcp_app_win,
559 .maxlen = sizeof(int),
560 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800561 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 },
563 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 .procname = "tcp_adv_win_scale",
565 .data = &sysctl_tcp_adv_win_scale,
566 .maxlen = sizeof(int),
567 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000568 .proc_handler = proc_dointvec_minmax,
569 .extra1 = &tcp_adv_win_scale_min,
570 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 },
572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 .procname = "tcp_tw_reuse",
574 .data = &sysctl_tcp_tw_reuse,
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_frto",
581 .data = &sysctl_tcp_frto,
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 {
Yuchung Chengf6722582015-10-16 21:57:42 -0700587 .procname = "tcp_min_rtt_wlen",
588 .data = &sysctl_tcp_min_rtt_wlen,
589 .maxlen = sizeof(int),
590 .mode = 0644,
591 .proc_handler = proc_dointvec
592 },
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "tcp_low_latency",
595 .data = &sysctl_tcp_low_latency,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 .procname = "tcp_no_metrics_save",
602 .data = &sysctl_tcp_nometrics_save,
603 .maxlen = sizeof(int),
604 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800605 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 },
607 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 .procname = "tcp_moderate_rcvbuf",
609 .data = &sysctl_tcp_moderate_rcvbuf,
610 .maxlen = sizeof(int),
611 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800612 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 },
614 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 .procname = "tcp_tso_win_divisor",
616 .data = &sysctl_tcp_tso_win_divisor,
617 .maxlen = sizeof(int),
618 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800619 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
621 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700622 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700624 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800625 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800627 {
Rick Jones15d99e02006-03-20 22:40:29 -0800628 .procname = "tcp_workaround_signed_windows",
629 .data = &sysctl_tcp_workaround_signed_windows,
630 .maxlen = sizeof(int),
631 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800632 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800633 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000634 {
635 .procname = "tcp_limit_output_bytes",
636 .data = &sysctl_tcp_limit_output_bytes,
637 .maxlen = sizeof(int),
638 .mode = 0644,
639 .proc_handler = proc_dointvec
640 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200641 {
642 .procname = "tcp_challenge_ack_limit",
643 .data = &sysctl_tcp_challenge_ack_limit,
644 .maxlen = sizeof(int),
645 .mode = 0644,
646 .proc_handler = proc_dointvec
647 },
David S. Miller35089bb2006-06-13 22:33:04 -0700648 {
David S. Miller35089bb2006-06-13 22:33:04 -0700649 .procname = "tcp_slow_start_after_idle",
650 .data = &sysctl_tcp_slow_start_after_idle,
651 .maxlen = sizeof(int),
652 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800653 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700654 },
Paul Moore446fda42006-08-03 16:48:06 -0700655#ifdef CONFIG_NETLABEL
656 {
Paul Moore446fda42006-08-03 16:48:06 -0700657 .procname = "cipso_cache_enable",
658 .data = &cipso_v4_cache_enabled,
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 {
Paul Moore446fda42006-08-03 16:48:06 -0700664 .procname = "cipso_cache_bucket_size",
665 .data = &cipso_v4_cache_bucketsize,
666 .maxlen = sizeof(int),
667 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800668 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700669 },
670 {
Paul Moore446fda42006-08-03 16:48:06 -0700671 .procname = "cipso_rbm_optfmt",
672 .data = &cipso_v4_rbm_optfmt,
673 .maxlen = sizeof(int),
674 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800675 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700676 },
677 {
Paul Moore446fda42006-08-03 16:48:06 -0700678 .procname = "cipso_rbm_strictvalid",
679 .data = &cipso_v4_rbm_strictvalid,
680 .maxlen = sizeof(int),
681 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800682 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700683 },
684#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800685 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800686 .procname = "tcp_available_congestion_control",
687 .maxlen = TCP_CA_BUF_MAX,
688 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800689 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800690 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800691 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800692 .procname = "tcp_allowed_congestion_control",
693 .maxlen = TCP_CA_BUF_MAX,
694 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800695 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800696 },
John Heffner886236c2007-03-25 19:21:45 -0700697 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000698 .procname = "tcp_thin_linear_timeouts",
699 .data = &sysctl_tcp_thin_linear_timeouts,
700 .maxlen = sizeof(int),
701 .mode = 0644,
702 .proc_handler = proc_dointvec
703 },
Weilong Chen5797deb2013-12-23 14:37:31 +0800704 {
Andreas Petlund7e380172010-02-18 04:48:19 +0000705 .procname = "tcp_thin_dupack",
706 .data = &sysctl_tcp_thin_dupack,
707 .maxlen = sizeof(int),
708 .mode = 0644,
709 .proc_handler = proc_dointvec
710 },
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000711 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000712 .procname = "tcp_early_retrans",
713 .data = &sysctl_tcp_early_retrans,
714 .maxlen = sizeof(int),
715 .mode = 0644,
716 .proc_handler = proc_dointvec_minmax,
717 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000718 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000719 },
720 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700721 .procname = "tcp_min_tso_segs",
722 .data = &sysctl_tcp_min_tso_segs,
723 .maxlen = sizeof(int),
724 .mode = 0644,
725 .proc_handler = proc_dointvec_minmax,
Eric Dumazetd6a4e262015-05-26 08:55:28 -0700726 .extra1 = &one,
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700727 .extra2 = &gso_max_segs,
728 },
729 {
Eric Dumazet43e122b2015-08-21 17:38:02 -0700730 .procname = "tcp_pacing_ss_ratio",
731 .data = &sysctl_tcp_pacing_ss_ratio,
732 .maxlen = sizeof(int),
733 .mode = 0644,
734 .proc_handler = proc_dointvec_minmax,
735 .extra1 = &zero,
736 .extra2 = &thousand,
737 },
738 {
739 .procname = "tcp_pacing_ca_ratio",
740 .data = &sysctl_tcp_pacing_ca_ratio,
741 .maxlen = sizeof(int),
742 .mode = 0644,
743 .proc_handler = proc_dointvec_minmax,
744 .extra1 = &zero,
745 .extra2 = &thousand,
746 },
747 {
Eric Dumazetf54b3112013-12-05 22:36:05 -0800748 .procname = "tcp_autocorking",
749 .data = &sysctl_tcp_autocorking,
750 .maxlen = sizeof(int),
751 .mode = 0644,
752 .proc_handler = proc_dointvec_minmax,
753 .extra1 = &zero,
754 .extra2 = &one,
755 },
756 {
Neal Cardwell032ee422015-02-06 16:04:38 -0500757 .procname = "tcp_invalid_ratelimit",
758 .data = &sysctl_tcp_invalid_ratelimit,
759 .maxlen = sizeof(int),
760 .mode = 0644,
761 .proc_handler = proc_dointvec_ms_jiffies,
762 },
763 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700764 .procname = "icmp_msgs_per_sec",
765 .data = &sysctl_icmp_msgs_per_sec,
766 .maxlen = sizeof(int),
767 .mode = 0644,
768 .proc_handler = proc_dointvec_minmax,
769 .extra1 = &zero,
770 },
771 {
772 .procname = "icmp_msgs_burst",
773 .data = &sysctl_icmp_msgs_burst,
774 .maxlen = sizeof(int),
775 .mode = 0644,
776 .proc_handler = proc_dointvec_minmax,
777 .extra1 = &zero,
778 },
779 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800780 .procname = "udp_mem",
781 .data = &sysctl_udp_mem,
782 .maxlen = sizeof(sysctl_udp_mem),
783 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000784 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800785 },
786 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800787 .procname = "udp_rmem_min",
788 .data = &sysctl_udp_rmem_min,
789 .maxlen = sizeof(sysctl_udp_rmem_min),
790 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800791 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700792 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800793 },
794 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800795 .procname = "udp_wmem_min",
796 .data = &sysctl_udp_wmem_min,
797 .maxlen = sizeof(sysctl_udp_wmem_min),
798 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800799 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700800 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800801 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800802 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800804
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700805static struct ctl_table ipv4_net_table[] = {
806 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700807 .procname = "icmp_echo_ignore_all",
808 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
809 .maxlen = sizeof(int),
810 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800811 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700812 },
813 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700814 .procname = "icmp_echo_ignore_broadcasts",
815 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
816 .maxlen = sizeof(int),
817 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800818 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700819 },
820 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700821 .procname = "icmp_ignore_bogus_error_responses",
822 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
823 .maxlen = sizeof(int),
824 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800825 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700826 },
827 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700828 .procname = "icmp_errors_use_inbound_ifaddr",
829 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
830 .maxlen = sizeof(int),
831 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800832 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700833 },
834 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700835 .procname = "icmp_ratelimit",
836 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
837 .maxlen = sizeof(int),
838 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800839 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700840 },
841 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700842 .procname = "icmp_ratemask",
843 .data = &init_net.ipv4.sysctl_icmp_ratemask,
844 .maxlen = sizeof(int),
845 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800846 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700847 },
Neil Horman1080d702008-10-27 12:28:25 -0700848 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000849 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700850 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600851 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000852 .mode = 0644,
853 .proc_handler = ipv4_ping_group_range,
854 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000855 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000856 .procname = "tcp_ecn",
857 .data = &init_net.ipv4.sysctl_tcp_ecn,
858 .maxlen = sizeof(int),
859 .mode = 0644,
860 .proc_handler = proc_dointvec
861 },
862 {
Daniel Borkmann49213552015-05-19 21:04:22 +0200863 .procname = "tcp_ecn_fallback",
864 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
865 .maxlen = sizeof(int),
866 .mode = 0644,
867 .proc_handler = proc_dointvec
868 },
869 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700870 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700871 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
872 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700873 .mode = 0644,
874 .proc_handler = ipv4_local_port_range,
875 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100876 {
WANG Cong122ff242014-05-12 16:04:53 -0700877 .procname = "ip_local_reserved_ports",
878 .data = &init_net.ipv4.sysctl_local_reserved_ports,
879 .maxlen = 65536,
880 .mode = 0644,
881 .proc_handler = proc_do_large_bitmap,
882 },
883 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100884 .procname = "ip_no_pmtu_disc",
885 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
886 .maxlen = sizeof(int),
887 .mode = 0644,
888 .proc_handler = proc_dointvec
889 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100890 {
891 .procname = "ip_forward_use_pmtu",
892 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
893 .maxlen = sizeof(int),
894 .mode = 0644,
895 .proc_handler = proc_dointvec,
896 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700897 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200898 .procname = "ip_nonlocal_bind",
899 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
900 .maxlen = sizeof(int),
901 .mode = 0644,
902 .proc_handler = proc_dointvec
903 },
904 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700905 .procname = "fwmark_reflect",
906 .data = &init_net.ipv4.sysctl_fwmark_reflect,
907 .maxlen = sizeof(int),
908 .mode = 0644,
909 .proc_handler = proc_dointvec,
910 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700911 {
912 .procname = "tcp_fwmark_accept",
913 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
914 .maxlen = sizeof(int),
915 .mode = 0644,
916 .proc_handler = proc_dointvec,
917 },
Fan Dub0f9ca52015-02-10 09:53:16 +0800918 {
919 .procname = "tcp_mtu_probing",
920 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = proc_dointvec,
924 },
925 {
926 .procname = "tcp_base_mss",
927 .data = &init_net.ipv4.sysctl_tcp_base_mss,
928 .maxlen = sizeof(int),
929 .mode = 0644,
930 .proc_handler = proc_dointvec,
931 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800932 {
933 .procname = "tcp_probe_threshold",
934 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
935 .maxlen = sizeof(int),
936 .mode = 0644,
937 .proc_handler = proc_dointvec,
938 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800939 {
940 .procname = "tcp_probe_interval",
941 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
942 .maxlen = sizeof(int),
943 .mode = 0644,
944 .proc_handler = proc_dointvec,
945 },
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100946 {
947 .procname = "igmp_link_local_mcast_reports",
948 .data = &sysctl_igmp_llm_reports,
949 .maxlen = sizeof(int),
950 .mode = 0644,
951 .proc_handler = proc_dointvec
952 },
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700953 { }
954};
955
Pavel Emelyanov15775192008-03-26 01:54:18 -0700956static __net_init int ipv4_sysctl_init_net(struct net *net)
957{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700958 struct ctl_table *table;
959
960 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800961 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700962 int i;
963
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700964 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +0100965 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700966 goto err_alloc;
967
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700968 /* Update the variables to point into the current struct net */
969 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
970 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700971 }
972
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000973 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +0100974 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700975 goto err_reg;
976
WANG Cong122ff242014-05-12 16:04:53 -0700977 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
978 if (!net->ipv4.sysctl_local_reserved_ports)
979 goto err_ports;
980
Pavel Emelyanov15775192008-03-26 01:54:18 -0700981 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700982
WANG Cong122ff242014-05-12 16:04:53 -0700983err_ports:
984 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700985err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800986 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700987 kfree(table);
988err_alloc:
989 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -0700990}
991
992static __net_exit void ipv4_sysctl_exit_net(struct net *net)
993{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700994 struct ctl_table *table;
995
WANG Cong122ff242014-05-12 16:04:53 -0700996 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700997 table = net->ipv4.ipv4_hdr->ctl_table_arg;
998 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
999 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001000}
1001
1002static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1003 .init = ipv4_sysctl_init_net,
1004 .exit = ipv4_sysctl_exit_net,
1005};
1006
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001007static __init int sysctl_ipv4_init(void)
1008{
1009 struct ctl_table_header *hdr;
1010
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001011 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +01001012 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -07001013 return -ENOMEM;
1014
1015 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +00001016 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001017 return -ENOMEM;
1018 }
1019
1020 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001021}
1022
1023__initcall(sysctl_ipv4_init);