blob: bb0419582b8dfed626f04752307ddaf2671ed01c [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Herbert Xu89cee8b2005-12-13 23:14:27 -080028static int zero;
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +000029static int one = 1;
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +000030static int four = 4;
Eric Dumazet43e122b2015-08-21 17:38:02 -070031static int thousand = 1000;
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{
Eric Dumazeted2dfd92015-05-27 11:34:37 -070048 bool same_parity = !((range[0] ^ range[1]) & 1);
49
WANG Cong4ee3bd42015-11-03 14:32:57 -080050 write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
Eric Dumazeted2dfd92015-05-27 11:34:37 -070051 if (same_parity && !net->ipv4.ip_local_ports.warned) {
52 net->ipv4.ip_local_ports.warned = true;
53 pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
54 }
Cong Wangc9d8f1a2014-05-06 11:02:49 -070055 net->ipv4.ip_local_ports.range[0] = range[0];
56 net->ipv4.ip_local_ports.range[1] = range[1];
WANG Cong4ee3bd42015-11-03 14:32:57 -080057 write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070058}
59
60/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -070061static int ipv4_local_port_range(struct ctl_table *table, int write,
Stephen Hemminger227b60f2007-10-10 17:30:46 -070062 void __user *buffer,
63 size_t *lenp, loff_t *ppos)
64{
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070065 struct net *net =
Cong Wangc9d8f1a2014-05-06 11:02:49 -070066 container_of(table->data, struct net, ipv4.ip_local_ports.range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070067 int ret;
Eric Dumazet3c689b72008-10-08 14:18:04 -070068 int range[2];
Joe Perchesfe2c6332013-06-11 23:04:25 -070069 struct ctl_table tmp = {
Stephen Hemminger227b60f2007-10-10 17:30:46 -070070 .data = &range,
71 .maxlen = sizeof(range),
72 .mode = table->mode,
73 .extra1 = &ip_local_port_range_min,
74 .extra2 = &ip_local_port_range_max,
75 };
76
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070077 inet_get_local_port_range(net, &range[0], &range[1]);
78
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070079 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070080
81 if (write && ret == 0) {
Anton Arapova25de532007-10-18 22:00:17 -070082 if (range[1] < range[0])
Stephen Hemminger227b60f2007-10-10 17:30:46 -070083 ret = -EINVAL;
84 else
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070085 set_local_port_range(net, range);
Stephen Hemminger227b60f2007-10-10 17:30:46 -070086 }
87
88 return ret;
89}
90
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000091
Eric W. Biederman7064d162012-05-24 10:34:21 -060092static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000093{
Eric W. Biederman7064d162012-05-24 10:34:21 -060094 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -070095 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -070096 container_of(table->data, struct net, ipv4.ping_group_range.range);
Eric Dumazet95c96172012-04-15 05:58:06 +000097 unsigned int seq;
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +000098 do {
Cong Wangc9d8f1a2014-05-06 11:02:49 -070099 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000100
101 *low = data[0];
102 *high = data[1];
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700103 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq));
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000104}
105
106/* Update system visible IP port range */
Eric W. Biederman7064d162012-05-24 10:34:21 -0600107static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000108{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600109 kgid_t *data = table->data;
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700110 struct net *net =
Cong Wangba6b9182014-05-06 11:02:50 -0700111 container_of(table->data, struct net, ipv4.ping_group_range.range);
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700112 write_seqlock(&net->ipv4.ip_local_ports.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600113 data[0] = low;
114 data[1] = high;
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700115 write_sequnlock(&net->ipv4.ip_local_ports.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000116}
117
118/* Validate changes from /proc interface. */
Joe Perchesfe2c6332013-06-11 23:04:25 -0700119static int ipv4_ping_group_range(struct ctl_table *table, int write,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000120 void __user *buffer,
121 size_t *lenp, loff_t *ppos)
122{
Eric W. Biederman7064d162012-05-24 10:34:21 -0600123 struct user_namespace *user_ns = current_user_ns();
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000124 int ret;
Eric W. Biederman7064d162012-05-24 10:34:21 -0600125 gid_t urange[2];
126 kgid_t low, high;
Joe Perchesfe2c6332013-06-11 23:04:25 -0700127 struct ctl_table tmp = {
Eric W. Biederman7064d162012-05-24 10:34:21 -0600128 .data = &urange,
129 .maxlen = sizeof(urange),
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000130 .mode = table->mode,
131 .extra1 = &ip_ping_group_range_min,
132 .extra2 = &ip_ping_group_range_max,
133 };
134
Eric W. Biederman7064d162012-05-24 10:34:21 -0600135 inet_get_ping_group_range_table(table, &low, &high);
136 urange[0] = from_kgid_munged(user_ns, low);
137 urange[1] = from_kgid_munged(user_ns, high);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000138 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
139
Eric W. Biederman7064d162012-05-24 10:34:21 -0600140 if (write && ret == 0) {
141 low = make_kgid(user_ns, urange[0]);
142 high = make_kgid(user_ns, urange[1]);
143 if (!gid_valid(low) || !gid_valid(high) ||
144 (urange[1] < urange[0]) || gid_lt(high, low)) {
145 low = make_kgid(&init_user_ns, 1);
146 high = make_kgid(&init_user_ns, 0);
147 }
148 set_ping_group_range(table, low, high);
149 }
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000150
151 return ret;
152}
153
Joe Perchesfe2c6332013-06-11 23:04:25 -0700154static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700155 void __user *buffer, size_t *lenp, loff_t *ppos)
156{
157 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700158 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700159 .data = val,
160 .maxlen = TCP_CA_NAME_MAX,
161 };
162 int ret;
163
164 tcp_get_default_congestion_control(val);
165
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700166 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700167 if (write && ret == 0)
168 ret = tcp_set_default_congestion_control(val);
169 return ret;
170}
171
Joe Perchesfe2c6332013-06-11 23:04:25 -0700172static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700173 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800174 void __user *buffer, size_t *lenp,
175 loff_t *ppos)
176{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700177 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800178 int ret;
179
180 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
181 if (!tbl.data)
182 return -ENOMEM;
183 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800185 kfree(tbl.data);
186 return ret;
187}
188
Joe Perchesfe2c6332013-06-11 23:04:25 -0700189static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700190 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800191 void __user *buffer, size_t *lenp,
192 loff_t *ppos)
193{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700194 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800195 int ret;
196
197 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
198 if (!tbl.data)
199 return -ENOMEM;
200
201 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700202 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800203 if (write && ret == 0)
204 ret = tcp_set_allowed_congestion_control(tbl.data);
205 kfree(tbl.data);
206 return ret;
207}
208
Joe Perchesfe2c6332013-06-11 23:04:25 -0700209static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
210 void __user *buffer, size_t *lenp,
211 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000212{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700213 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000214 struct tcp_fastopen_context *ctxt;
215 int ret;
216 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
217
218 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
219 if (!tbl.data)
220 return -ENOMEM;
221
222 rcu_read_lock();
223 ctxt = rcu_dereference(tcp_fastopen_ctx);
224 if (ctxt)
225 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000226 else
227 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000228 rcu_read_unlock();
229
230 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
231 user_key[0], user_key[1], user_key[2], user_key[3]);
232 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
233
234 if (write && ret == 0) {
235 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
236 user_key + 2, user_key + 3) != 4) {
237 ret = -EINVAL;
238 goto bad_key;
239 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200240 /* Generate a dummy secret but don't publish it. This
241 * is needed so we don't regenerate a new key on the
242 * first invocation of tcp_fastopen_cookie_gen
243 */
244 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000245 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
246 }
247
248bad_key:
249 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
250 user_key[0], user_key[1], user_key[2], user_key[3],
251 (char *)tbl.data, ret);
252 kfree(tbl.data);
253 return ret;
254}
255
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800256static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .procname = "tcp_timestamps",
259 .data = &sysctl_tcp_timestamps,
260 .maxlen = sizeof(int),
261 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800262 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900264 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 .procname = "tcp_window_scaling",
266 .data = &sysctl_tcp_window_scaling,
267 .maxlen = sizeof(int),
268 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800269 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900271 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 .procname = "tcp_sack",
273 .data = &sysctl_tcp_sack,
274 .maxlen = sizeof(int),
275 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800276 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900278 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 .procname = "tcp_retrans_collapse",
280 .data = &sysctl_tcp_retrans_collapse,
281 .maxlen = sizeof(int),
282 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800283 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900285 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 .procname = "tcp_max_orphans",
287 .data = &sysctl_tcp_max_orphans,
288 .maxlen = sizeof(int),
289 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800290 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 },
292 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 .procname = "tcp_max_tw_buckets",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700294 .data = &tcp_death_row.sysctl_max_tw_buckets,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 .maxlen = sizeof(int),
296 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800297 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 },
299 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000300 .procname = "tcp_fastopen",
301 .data = &sysctl_tcp_fastopen,
302 .maxlen = sizeof(int),
303 .mode = 0644,
304 .proc_handler = proc_dointvec,
305 },
306 {
Jerry Chu10467162012-08-31 12:29:11 +0000307 .procname = "tcp_fastopen_key",
308 .mode = 0600,
309 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
310 .proc_handler = proc_tcp_fastopen_key,
311 },
312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 .procname = "tcp_tw_recycle",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700314 .data = &tcp_death_row.sysctl_tw_recycle,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 .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_abort_on_overflow",
321 .data = &sysctl_tcp_abort_on_overflow,
322 .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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 .procname = "tcp_stdurg",
328 .data = &sysctl_tcp_stdurg,
329 .maxlen = sizeof(int),
330 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800331 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 },
333 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 .procname = "tcp_rfc1337",
335 .data = &sysctl_tcp_rfc1337,
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_max_syn_backlog",
342 .data = &sysctl_max_syn_backlog,
343 .maxlen = sizeof(int),
344 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800345 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 .procname = "inet_peer_threshold",
349 .data = &inet_peer_threshold,
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 = "inet_peer_minttl",
356 .data = &inet_peer_minttl,
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 = "inet_peer_maxttl",
363 .data = &inet_peer_maxttl,
364 .maxlen = sizeof(int),
365 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800366 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 },
368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 .procname = "tcp_fack",
370 .data = &sysctl_tcp_fack,
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 {
Yuchung Cheng4f41b1c2015-10-16 21:57:47 -0700376 .procname = "tcp_recovery",
377 .data = &sysctl_tcp_recovery,
378 .maxlen = sizeof(int),
379 .mode = 0644,
380 .proc_handler = proc_dointvec,
381 },
382 {
Eric Dumazetdca145f2014-10-27 21:45:24 -0700383 .procname = "tcp_max_reordering",
384 .data = &sysctl_tcp_max_reordering,
385 .maxlen = sizeof(int),
386 .mode = 0644,
387 .proc_handler = proc_dointvec
388 },
389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 .procname = "tcp_dsack",
391 .data = &sysctl_tcp_dsack,
392 .maxlen = sizeof(int),
393 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800394 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 },
396 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700397 .procname = "tcp_mem",
398 .maxlen = sizeof(sysctl_tcp_mem),
399 .data = &sysctl_tcp_mem,
400 .mode = 0644,
401 .proc_handler = proc_doulongvec_minmax,
402 },
403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .procname = "tcp_wmem",
405 .data = &sysctl_tcp_wmem,
406 .maxlen = sizeof(sysctl_tcp_wmem),
407 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000408 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700409 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 },
411 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 .procname = "tcp_rmem",
413 .data = &sysctl_tcp_rmem,
414 .maxlen = sizeof(sysctl_tcp_rmem),
415 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000416 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700417 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 },
419 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 .procname = "tcp_app_win",
421 .data = &sysctl_tcp_app_win,
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_adv_win_scale",
428 .data = &sysctl_tcp_adv_win_scale,
429 .maxlen = sizeof(int),
430 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000431 .proc_handler = proc_dointvec_minmax,
432 .extra1 = &tcp_adv_win_scale_min,
433 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 },
435 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 .procname = "tcp_tw_reuse",
437 .data = &sysctl_tcp_tw_reuse,
438 .maxlen = sizeof(int),
439 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800440 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 },
442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 .procname = "tcp_frto",
444 .data = &sysctl_tcp_frto,
445 .maxlen = sizeof(int),
446 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800447 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 },
449 {
Yuchung Chengf6722582015-10-16 21:57:42 -0700450 .procname = "tcp_min_rtt_wlen",
451 .data = &sysctl_tcp_min_rtt_wlen,
452 .maxlen = sizeof(int),
453 .mode = 0644,
454 .proc_handler = proc_dointvec
455 },
456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .procname = "tcp_low_latency",
458 .data = &sysctl_tcp_low_latency,
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 = "tcp_no_metrics_save",
465 .data = &sysctl_tcp_nometrics_save,
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 = "tcp_moderate_rcvbuf",
472 .data = &sysctl_tcp_moderate_rcvbuf,
473 .maxlen = sizeof(int),
474 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800475 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 .procname = "tcp_tso_win_divisor",
479 .data = &sysctl_tcp_tso_win_divisor,
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 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700485 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700487 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800488 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800490 {
Rick Jones15d99e02006-03-20 22:40:29 -0800491 .procname = "tcp_workaround_signed_windows",
492 .data = &sysctl_tcp_workaround_signed_windows,
493 .maxlen = sizeof(int),
494 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800495 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800496 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000497 {
498 .procname = "tcp_limit_output_bytes",
499 .data = &sysctl_tcp_limit_output_bytes,
500 .maxlen = sizeof(int),
501 .mode = 0644,
502 .proc_handler = proc_dointvec
503 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200504 {
505 .procname = "tcp_challenge_ack_limit",
506 .data = &sysctl_tcp_challenge_ack_limit,
507 .maxlen = sizeof(int),
508 .mode = 0644,
509 .proc_handler = proc_dointvec
510 },
David S. Miller35089bb2006-06-13 22:33:04 -0700511 {
David S. Miller35089bb2006-06-13 22:33:04 -0700512 .procname = "tcp_slow_start_after_idle",
513 .data = &sysctl_tcp_slow_start_after_idle,
514 .maxlen = sizeof(int),
515 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800516 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700517 },
Paul Moore446fda42006-08-03 16:48:06 -0700518#ifdef CONFIG_NETLABEL
519 {
Paul Moore446fda42006-08-03 16:48:06 -0700520 .procname = "cipso_cache_enable",
521 .data = &cipso_v4_cache_enabled,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800524 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700525 },
526 {
Paul Moore446fda42006-08-03 16:48:06 -0700527 .procname = "cipso_cache_bucket_size",
528 .data = &cipso_v4_cache_bucketsize,
529 .maxlen = sizeof(int),
530 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800531 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700532 },
533 {
Paul Moore446fda42006-08-03 16:48:06 -0700534 .procname = "cipso_rbm_optfmt",
535 .data = &cipso_v4_rbm_optfmt,
536 .maxlen = sizeof(int),
537 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800538 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700539 },
540 {
Paul Moore446fda42006-08-03 16:48:06 -0700541 .procname = "cipso_rbm_strictvalid",
542 .data = &cipso_v4_rbm_strictvalid,
543 .maxlen = sizeof(int),
544 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800545 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700546 },
547#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800548 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800549 .procname = "tcp_available_congestion_control",
550 .maxlen = TCP_CA_BUF_MAX,
551 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800552 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800553 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800554 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800555 .procname = "tcp_allowed_congestion_control",
556 .maxlen = TCP_CA_BUF_MAX,
557 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800558 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800559 },
John Heffner886236c2007-03-25 19:21:45 -0700560 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000561 .procname = "tcp_thin_linear_timeouts",
562 .data = &sysctl_tcp_thin_linear_timeouts,
563 .maxlen = sizeof(int),
564 .mode = 0644,
565 .proc_handler = proc_dointvec
566 },
Weilong Chen5797deb2013-12-23 14:37:31 +0800567 {
Andreas Petlund7e380172010-02-18 04:48:19 +0000568 .procname = "tcp_thin_dupack",
569 .data = &sysctl_tcp_thin_dupack,
570 .maxlen = sizeof(int),
571 .mode = 0644,
572 .proc_handler = proc_dointvec
573 },
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000574 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000575 .procname = "tcp_early_retrans",
576 .data = &sysctl_tcp_early_retrans,
577 .maxlen = sizeof(int),
578 .mode = 0644,
579 .proc_handler = proc_dointvec_minmax,
580 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000581 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000582 },
583 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700584 .procname = "tcp_min_tso_segs",
585 .data = &sysctl_tcp_min_tso_segs,
586 .maxlen = sizeof(int),
587 .mode = 0644,
588 .proc_handler = proc_dointvec_minmax,
Eric Dumazetd6a4e262015-05-26 08:55:28 -0700589 .extra1 = &one,
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700590 .extra2 = &gso_max_segs,
591 },
592 {
Eric Dumazet43e122b2015-08-21 17:38:02 -0700593 .procname = "tcp_pacing_ss_ratio",
594 .data = &sysctl_tcp_pacing_ss_ratio,
595 .maxlen = sizeof(int),
596 .mode = 0644,
597 .proc_handler = proc_dointvec_minmax,
598 .extra1 = &zero,
599 .extra2 = &thousand,
600 },
601 {
602 .procname = "tcp_pacing_ca_ratio",
603 .data = &sysctl_tcp_pacing_ca_ratio,
604 .maxlen = sizeof(int),
605 .mode = 0644,
606 .proc_handler = proc_dointvec_minmax,
607 .extra1 = &zero,
608 .extra2 = &thousand,
609 },
610 {
Eric Dumazetf54b3112013-12-05 22:36:05 -0800611 .procname = "tcp_autocorking",
612 .data = &sysctl_tcp_autocorking,
613 .maxlen = sizeof(int),
614 .mode = 0644,
615 .proc_handler = proc_dointvec_minmax,
616 .extra1 = &zero,
617 .extra2 = &one,
618 },
619 {
Neal Cardwell032ee422015-02-06 16:04:38 -0500620 .procname = "tcp_invalid_ratelimit",
621 .data = &sysctl_tcp_invalid_ratelimit,
622 .maxlen = sizeof(int),
623 .mode = 0644,
624 .proc_handler = proc_dointvec_ms_jiffies,
625 },
626 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700627 .procname = "icmp_msgs_per_sec",
628 .data = &sysctl_icmp_msgs_per_sec,
629 .maxlen = sizeof(int),
630 .mode = 0644,
631 .proc_handler = proc_dointvec_minmax,
632 .extra1 = &zero,
633 },
634 {
635 .procname = "icmp_msgs_burst",
636 .data = &sysctl_icmp_msgs_burst,
637 .maxlen = sizeof(int),
638 .mode = 0644,
639 .proc_handler = proc_dointvec_minmax,
640 .extra1 = &zero,
641 },
642 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800643 .procname = "udp_mem",
644 .data = &sysctl_udp_mem,
645 .maxlen = sizeof(sysctl_udp_mem),
646 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000647 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800648 },
649 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800650 .procname = "udp_rmem_min",
651 .data = &sysctl_udp_rmem_min,
652 .maxlen = sizeof(sysctl_udp_rmem_min),
653 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800654 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700655 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800656 },
657 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800658 .procname = "udp_wmem_min",
659 .data = &sysctl_udp_wmem_min,
660 .maxlen = sizeof(sysctl_udp_wmem_min),
661 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800662 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700663 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800664 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800665 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800667
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700668static struct ctl_table ipv4_net_table[] = {
669 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700670 .procname = "icmp_echo_ignore_all",
671 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
672 .maxlen = sizeof(int),
673 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800674 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700675 },
676 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700677 .procname = "icmp_echo_ignore_broadcasts",
678 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
679 .maxlen = sizeof(int),
680 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800681 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700682 },
683 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700684 .procname = "icmp_ignore_bogus_error_responses",
685 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
686 .maxlen = sizeof(int),
687 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800688 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700689 },
690 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700691 .procname = "icmp_errors_use_inbound_ifaddr",
692 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
693 .maxlen = sizeof(int),
694 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800695 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700696 },
697 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700698 .procname = "icmp_ratelimit",
699 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
700 .maxlen = sizeof(int),
701 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800702 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700703 },
704 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700705 .procname = "icmp_ratemask",
706 .data = &init_net.ipv4.sysctl_icmp_ratemask,
707 .maxlen = sizeof(int),
708 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800709 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700710 },
Neil Horman1080d702008-10-27 12:28:25 -0700711 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000712 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700713 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600714 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000715 .mode = 0644,
716 .proc_handler = ipv4_ping_group_range,
717 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000718 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000719 .procname = "tcp_ecn",
720 .data = &init_net.ipv4.sysctl_tcp_ecn,
721 .maxlen = sizeof(int),
722 .mode = 0644,
723 .proc_handler = proc_dointvec
724 },
725 {
Daniel Borkmann49213552015-05-19 21:04:22 +0200726 .procname = "tcp_ecn_fallback",
727 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
728 .maxlen = sizeof(int),
729 .mode = 0644,
730 .proc_handler = proc_dointvec
731 },
732 {
Nikolay Borisov287b7f32016-02-15 12:11:29 +0200733 .procname = "ip_dynaddr",
734 .data = &init_net.ipv4.sysctl_ip_dynaddr,
735 .maxlen = sizeof(int),
736 .mode = 0644,
737 .proc_handler = proc_dointvec
738 },
739 {
Nikolay Borisove21145a2016-02-15 12:11:30 +0200740 .procname = "ip_early_demux",
741 .data = &init_net.ipv4.sysctl_ip_early_demux,
742 .maxlen = sizeof(int),
743 .mode = 0644,
744 .proc_handler = proc_dointvec
745 },
746 {
Nikolay Borisovfa50d972016-02-15 12:11:27 +0200747 .procname = "ip_default_ttl",
748 .data = &init_net.ipv4.sysctl_ip_default_ttl,
749 .maxlen = sizeof(int),
750 .mode = 0644,
751 .proc_handler = proc_dointvec_minmax,
752 .extra1 = &ip_ttl_min,
753 .extra2 = &ip_ttl_max,
754 },
755 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700756 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700757 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
758 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700759 .mode = 0644,
760 .proc_handler = ipv4_local_port_range,
761 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100762 {
WANG Cong122ff242014-05-12 16:04:53 -0700763 .procname = "ip_local_reserved_ports",
764 .data = &init_net.ipv4.sysctl_local_reserved_ports,
765 .maxlen = 65536,
766 .mode = 0644,
767 .proc_handler = proc_do_large_bitmap,
768 },
769 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100770 .procname = "ip_no_pmtu_disc",
771 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
772 .maxlen = sizeof(int),
773 .mode = 0644,
774 .proc_handler = proc_dointvec
775 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100776 {
777 .procname = "ip_forward_use_pmtu",
778 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
779 .maxlen = sizeof(int),
780 .mode = 0644,
781 .proc_handler = proc_dointvec,
782 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700783 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200784 .procname = "ip_nonlocal_bind",
785 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
786 .maxlen = sizeof(int),
787 .mode = 0644,
788 .proc_handler = proc_dointvec
789 },
790 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700791 .procname = "fwmark_reflect",
792 .data = &init_net.ipv4.sysctl_fwmark_reflect,
793 .maxlen = sizeof(int),
794 .mode = 0644,
795 .proc_handler = proc_dointvec,
796 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700797 {
798 .procname = "tcp_fwmark_accept",
799 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
800 .maxlen = sizeof(int),
801 .mode = 0644,
802 .proc_handler = proc_dointvec,
803 },
David Ahern6dd9a142015-12-16 13:20:44 -0800804#ifdef CONFIG_NET_L3_MASTER_DEV
805 {
806 .procname = "tcp_l3mdev_accept",
807 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
808 .maxlen = sizeof(int),
809 .mode = 0644,
810 .proc_handler = proc_dointvec_minmax,
811 .extra1 = &zero,
812 .extra2 = &one,
813 },
814#endif
Fan Dub0f9ca52015-02-10 09:53:16 +0800815 {
816 .procname = "tcp_mtu_probing",
817 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
818 .maxlen = sizeof(int),
819 .mode = 0644,
820 .proc_handler = proc_dointvec,
821 },
822 {
823 .procname = "tcp_base_mss",
824 .data = &init_net.ipv4.sysctl_tcp_base_mss,
825 .maxlen = sizeof(int),
826 .mode = 0644,
827 .proc_handler = proc_dointvec,
828 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800829 {
830 .procname = "tcp_probe_threshold",
831 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
832 .maxlen = sizeof(int),
833 .mode = 0644,
834 .proc_handler = proc_dointvec,
835 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800836 {
837 .procname = "tcp_probe_interval",
838 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
839 .maxlen = sizeof(int),
840 .mode = 0644,
841 .proc_handler = proc_dointvec,
842 },
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100843 {
844 .procname = "igmp_link_local_mcast_reports",
Nikolay Borisov87a8a2a2016-02-09 00:13:50 +0200845 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100846 .maxlen = sizeof(int),
847 .mode = 0644,
848 .proc_handler = proc_dointvec
849 },
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200850 {
Nikolay Borisov815c5272016-02-08 23:29:21 +0200851 .procname = "igmp_max_memberships",
852 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
853 .maxlen = sizeof(int),
854 .mode = 0644,
855 .proc_handler = proc_dointvec
856 },
857 {
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200858 .procname = "igmp_max_msf",
859 .data = &init_net.ipv4.sysctl_igmp_max_msf,
860 .maxlen = sizeof(int),
861 .mode = 0644,
862 .proc_handler = proc_dointvec
863 },
Nikolay Borisov165094a2016-02-08 23:29:24 +0200864#ifdef CONFIG_IP_MULTICAST
865 {
866 .procname = "igmp_qrv",
867 .data = &init_net.ipv4.sysctl_igmp_qrv,
868 .maxlen = sizeof(int),
869 .mode = 0644,
870 .proc_handler = proc_dointvec_minmax,
871 .extra1 = &one
872 },
873#endif
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200874 {
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200875 .procname = "tcp_keepalive_time",
876 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
877 .maxlen = sizeof(int),
878 .mode = 0644,
879 .proc_handler = proc_dointvec_jiffies,
880 },
Nikolay Borisov9bd68612016-01-07 16:38:44 +0200881 {
882 .procname = "tcp_keepalive_probes",
883 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
884 .maxlen = sizeof(int),
885 .mode = 0644,
886 .proc_handler = proc_dointvec
887 },
Nikolay Borisovb840d152016-01-07 16:38:45 +0200888 {
889 .procname = "tcp_keepalive_intvl",
890 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
891 .maxlen = sizeof(int),
892 .mode = 0644,
893 .proc_handler = proc_dointvec_jiffies,
894 },
Nikolay Borisov6fa25162016-02-03 09:46:49 +0200895 {
896 .procname = "tcp_syn_retries",
897 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
898 .maxlen = sizeof(int),
899 .mode = 0644,
900 .proc_handler = proc_dointvec_minmax,
901 .extra1 = &tcp_syn_retries_min,
902 .extra2 = &tcp_syn_retries_max
903 },
Nikolay Borisov7c083ec2016-02-03 09:46:50 +0200904 {
905 .procname = "tcp_synack_retries",
906 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
907 .maxlen = sizeof(int),
908 .mode = 0644,
909 .proc_handler = proc_dointvec
910 },
Nikolay Borisov12ed8242016-02-03 09:46:51 +0200911#ifdef CONFIG_SYN_COOKIES
912 {
913 .procname = "tcp_syncookies",
914 .data = &init_net.ipv4.sysctl_tcp_syncookies,
915 .maxlen = sizeof(int),
916 .mode = 0644,
917 .proc_handler = proc_dointvec
918 },
919#endif
Nikolay Borisov1043e252016-02-03 09:46:52 +0200920 {
921 .procname = "tcp_reordering",
922 .data = &init_net.ipv4.sysctl_tcp_reordering,
923 .maxlen = sizeof(int),
924 .mode = 0644,
925 .proc_handler = proc_dointvec
926 },
Nikolay Borisovae5c3f42016-02-03 09:46:53 +0200927 {
928 .procname = "tcp_retries1",
929 .data = &init_net.ipv4.sysctl_tcp_retries1,
930 .maxlen = sizeof(int),
931 .mode = 0644,
932 .proc_handler = proc_dointvec_minmax,
933 .extra2 = &tcp_retr1_max
934 },
Nikolay Borisovc6214a92016-02-03 09:46:54 +0200935 {
936 .procname = "tcp_retries2",
937 .data = &init_net.ipv4.sysctl_tcp_retries2,
938 .maxlen = sizeof(int),
939 .mode = 0644,
940 .proc_handler = proc_dointvec
941 },
Nikolay Borisovc402d9b2016-02-03 09:46:55 +0200942 {
943 .procname = "tcp_orphan_retries",
944 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
945 .maxlen = sizeof(int),
946 .mode = 0644,
947 .proc_handler = proc_dointvec
948 },
Nikolay Borisov1e579ca2016-02-03 09:46:56 +0200949 {
950 .procname = "tcp_fin_timeout",
951 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
952 .maxlen = sizeof(int),
953 .mode = 0644,
954 .proc_handler = proc_dointvec_jiffies,
955 },
Nikolay Borisov4979f2d2016-02-03 09:46:57 +0200956 {
957 .procname = "tcp_notsent_lowat",
958 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
959 .maxlen = sizeof(unsigned int),
960 .mode = 0644,
961 .proc_handler = proc_dointvec,
962 },
David Aherna6db4492016-04-07 07:21:00 -0700963#ifdef CONFIG_IP_ROUTE_MULTIPATH
964 {
965 .procname = "fib_multipath_use_neigh",
966 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
967 .maxlen = sizeof(int),
968 .mode = 0644,
969 .proc_handler = proc_dointvec_minmax,
970 .extra1 = &zero,
971 .extra2 = &one,
972 },
973#endif
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700974 { }
975};
976
Pavel Emelyanov15775192008-03-26 01:54:18 -0700977static __net_init int ipv4_sysctl_init_net(struct net *net)
978{
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700979 struct ctl_table *table;
980
981 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -0800982 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700983 int i;
984
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700985 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +0100986 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700987 goto err_alloc;
988
Eric W. Biederman0a6fa232013-10-19 16:27:03 -0700989 /* Update the variables to point into the current struct net */
990 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
991 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700992 }
993
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +0000994 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +0100995 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700996 goto err_reg;
997
WANG Cong122ff242014-05-12 16:04:53 -0700998 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
999 if (!net->ipv4.sysctl_local_reserved_ports)
1000 goto err_ports;
1001
Nikolay Borisovfa50d972016-02-15 12:11:27 +02001002 net->ipv4.sysctl_ip_default_ttl = IPDEFTTL;
Nikolay Borisov287b7f32016-02-15 12:11:29 +02001003 net->ipv4.sysctl_ip_dynaddr = 0;
Nikolay Borisove21145a2016-02-15 12:11:30 +02001004 net->ipv4.sysctl_ip_early_demux = 1;
Nikolay Borisovfa50d972016-02-15 12:11:27 +02001005
Pavel Emelyanov15775192008-03-26 01:54:18 -07001006 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001007
WANG Cong122ff242014-05-12 16:04:53 -07001008err_ports:
1009 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001010err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001011 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001012 kfree(table);
1013err_alloc:
1014 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -07001015}
1016
1017static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1018{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001019 struct ctl_table *table;
1020
WANG Cong122ff242014-05-12 16:04:53 -07001021 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001022 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1023 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1024 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001025}
1026
1027static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1028 .init = ipv4_sysctl_init_net,
1029 .exit = ipv4_sysctl_exit_net,
1030};
1031
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001032static __init int sysctl_ipv4_init(void)
1033{
1034 struct ctl_table_header *hdr;
1035
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001036 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +01001037 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -07001038 return -ENOMEM;
1039
1040 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +00001041 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001042 return -ENOMEM;
1043 }
1044
1045 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001046}
1047
1048__initcall(sysctl_ipv4_init);