blob: 08605a44469c0757a0a2620ee3ac8184dc97a8fb [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 {
WANG Cong396a30c2016-10-20 14:19:46 -070099 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000100
101 *low = data[0];
102 *high = data[1];
WANG Cong396a30c2016-10-20 14:19:46 -0700103 } while (read_seqretry(&net->ipv4.ping_group_range.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);
WANG Cong396a30c2016-10-20 14:19:46 -0700112 write_seqlock(&net->ipv4.ping_group_range.lock);
Eric W. Biederman7064d162012-05-24 10:34:21 -0600113 data[0] = low;
114 data[1] = high;
WANG Cong396a30c2016-10-20 14:19:46 -0700115 write_sequnlock(&net->ipv4.ping_group_range.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
JP Abgrall2c170102014-02-07 18:40:10 -0800154/* Validate changes from /proc interface. */
Dmitry Shmidt76d09922015-10-27 18:09:40 -0700155static int proc_tcp_default_init_rwnd(struct ctl_table *ctl, int write,
JP Abgrall2c170102014-02-07 18:40:10 -0800156 void __user *buffer,
157 size_t *lenp, loff_t *ppos)
158{
159 int old_value = *(int *)ctl->data;
160 int ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
161 int new_value = *(int *)ctl->data;
162
163 if (write && ret == 0 && (new_value < 3 || new_value > 100))
164 *(int *)ctl->data = old_value;
165
166 return ret;
167}
168
Joe Perchesfe2c6332013-06-11 23:04:25 -0700169static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700170 void __user *buffer, size_t *lenp, loff_t *ppos)
171{
172 char val[TCP_CA_NAME_MAX];
Joe Perchesfe2c6332013-06-11 23:04:25 -0700173 struct ctl_table tbl = {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700174 .data = val,
175 .maxlen = TCP_CA_NAME_MAX,
176 };
177 int ret;
178
179 tcp_get_default_congestion_control(val);
180
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700181 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700182 if (write && ret == 0)
183 ret = tcp_set_default_congestion_control(val);
184 return ret;
185}
186
Joe Perchesfe2c6332013-06-11 23:04:25 -0700187static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700188 int write,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800189 void __user *buffer, size_t *lenp,
190 loff_t *ppos)
191{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700192 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800193 int ret;
194
195 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
196 if (!tbl.data)
197 return -ENOMEM;
198 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700199 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800200 kfree(tbl.data);
201 return ret;
202}
203
Joe Perchesfe2c6332013-06-11 23:04:25 -0700204static int proc_allowed_congestion_control(struct ctl_table *ctl,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700205 int write,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800206 void __user *buffer, size_t *lenp,
207 loff_t *ppos)
208{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700209 struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800210 int ret;
211
212 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
213 if (!tbl.data)
214 return -ENOMEM;
215
216 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700217 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800218 if (write && ret == 0)
219 ret = tcp_set_allowed_congestion_control(tbl.data);
220 kfree(tbl.data);
221 return ret;
222}
223
Joe Perchesfe2c6332013-06-11 23:04:25 -0700224static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
225 void __user *buffer, size_t *lenp,
226 loff_t *ppos)
Jerry Chu10467162012-08-31 12:29:11 +0000227{
Joe Perchesfe2c6332013-06-11 23:04:25 -0700228 struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
Jerry Chu10467162012-08-31 12:29:11 +0000229 struct tcp_fastopen_context *ctxt;
230 int ret;
231 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
232
233 tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
234 if (!tbl.data)
235 return -ENOMEM;
236
237 rcu_read_lock();
238 ctxt = rcu_dereference(tcp_fastopen_ctx);
239 if (ctxt)
240 memcpy(user_key, ctxt->key, TCP_FASTOPEN_KEY_LENGTH);
Alan Cox0e24c4f2012-10-11 06:24:14 +0000241 else
242 memset(user_key, 0, sizeof(user_key));
Jerry Chu10467162012-08-31 12:29:11 +0000243 rcu_read_unlock();
244
245 snprintf(tbl.data, tbl.maxlen, "%08x-%08x-%08x-%08x",
246 user_key[0], user_key[1], user_key[2], user_key[3]);
247 ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
248
249 if (write && ret == 0) {
250 if (sscanf(tbl.data, "%x-%x-%x-%x", user_key, user_key + 1,
251 user_key + 2, user_key + 3) != 4) {
252 ret = -EINVAL;
253 goto bad_key;
254 }
Hannes Frederic Sowa222e83d2013-10-19 21:48:58 +0200255 /* Generate a dummy secret but don't publish it. This
256 * is needed so we don't regenerate a new key on the
257 * first invocation of tcp_fastopen_cookie_gen
258 */
259 tcp_fastopen_init_key_once(false);
Jerry Chu10467162012-08-31 12:29:11 +0000260 tcp_fastopen_reset_cipher(user_key, TCP_FASTOPEN_KEY_LENGTH);
261 }
262
263bad_key:
264 pr_debug("proc FO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
265 user_key[0], user_key[1], user_key[2], user_key[3],
266 (char *)tbl.data, ret);
267 kfree(tbl.data);
268 return ret;
269}
270
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800271static struct ctl_table ipv4_table[] = {
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 .procname = "tcp_timestamps",
274 .data = &sysctl_tcp_timestamps,
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_window_scaling",
281 .data = &sysctl_tcp_window_scaling,
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 = "tcp_sack",
288 .data = &sysctl_tcp_sack,
289 .maxlen = sizeof(int),
290 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800291 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900293 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 .procname = "tcp_retrans_collapse",
295 .data = &sysctl_tcp_retrans_collapse,
296 .maxlen = sizeof(int),
297 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800298 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 },
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900300 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 .procname = "tcp_max_orphans",
302 .data = &sysctl_tcp_max_orphans,
303 .maxlen = sizeof(int),
304 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800305 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 },
307 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 .procname = "tcp_max_tw_buckets",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700309 .data = &tcp_death_row.sysctl_max_tw_buckets,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 .maxlen = sizeof(int),
311 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800312 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 },
314 {
Yuchung Cheng2100c8d2012-07-19 06:43:05 +0000315 .procname = "tcp_fastopen",
316 .data = &sysctl_tcp_fastopen,
317 .maxlen = sizeof(int),
318 .mode = 0644,
319 .proc_handler = proc_dointvec,
320 },
321 {
Jerry Chu10467162012-08-31 12:29:11 +0000322 .procname = "tcp_fastopen_key",
323 .mode = 0600,
324 .maxlen = ((TCP_FASTOPEN_KEY_LENGTH * 2) + 10),
325 .proc_handler = proc_tcp_fastopen_key,
326 },
327 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 .procname = "tcp_tw_recycle",
Arnaldo Carvalho de Melo295ff7e2005-08-09 20:44:40 -0700329 .data = &tcp_death_row.sysctl_tw_recycle,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 .maxlen = sizeof(int),
331 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800332 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 },
334 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 .procname = "tcp_abort_on_overflow",
336 .data = &sysctl_tcp_abort_on_overflow,
337 .maxlen = sizeof(int),
338 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800339 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 },
341 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 .procname = "tcp_stdurg",
343 .data = &sysctl_tcp_stdurg,
344 .maxlen = sizeof(int),
345 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800346 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 },
348 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 .procname = "tcp_rfc1337",
350 .data = &sysctl_tcp_rfc1337,
351 .maxlen = sizeof(int),
352 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800353 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 },
355 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 .procname = "tcp_max_syn_backlog",
357 .data = &sysctl_max_syn_backlog,
358 .maxlen = sizeof(int),
359 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800360 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 .procname = "inet_peer_threshold",
364 .data = &inet_peer_threshold,
365 .maxlen = sizeof(int),
366 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800367 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 },
369 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 .procname = "inet_peer_minttl",
371 .data = &inet_peer_minttl,
372 .maxlen = sizeof(int),
373 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800374 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 },
376 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 .procname = "inet_peer_maxttl",
378 .data = &inet_peer_maxttl,
379 .maxlen = sizeof(int),
380 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800381 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 },
383 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 .procname = "tcp_fack",
385 .data = &sysctl_tcp_fack,
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 {
Yuchung Cheng4f41b1c2015-10-16 21:57:47 -0700391 .procname = "tcp_recovery",
392 .data = &sysctl_tcp_recovery,
393 .maxlen = sizeof(int),
394 .mode = 0644,
395 .proc_handler = proc_dointvec,
396 },
397 {
Eric Dumazetdca145f2014-10-27 21:45:24 -0700398 .procname = "tcp_max_reordering",
399 .data = &sysctl_tcp_max_reordering,
400 .maxlen = sizeof(int),
401 .mode = 0644,
402 .proc_handler = proc_dointvec
403 },
404 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 .procname = "tcp_dsack",
406 .data = &sysctl_tcp_dsack,
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 {
Eric W. Biedermana4fe34b2013-10-19 16:25:36 -0700412 .procname = "tcp_mem",
413 .maxlen = sizeof(sysctl_tcp_mem),
414 .data = &sysctl_tcp_mem,
415 .mode = 0644,
416 .proc_handler = proc_doulongvec_minmax,
417 },
418 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 .procname = "tcp_wmem",
420 .data = &sysctl_tcp_wmem,
421 .maxlen = sizeof(sysctl_tcp_wmem),
422 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000423 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700424 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 },
426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 .procname = "tcp_rmem",
428 .data = &sysctl_tcp_rmem,
429 .maxlen = sizeof(sysctl_tcp_rmem),
430 .mode = 0644,
bingtian.ly@taobao.comcdda8892013-01-23 20:35:28 +0000431 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700432 .extra1 = &one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 },
434 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 .procname = "tcp_app_win",
436 .data = &sysctl_tcp_app_win,
437 .maxlen = sizeof(int),
438 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800439 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 },
441 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 .procname = "tcp_adv_win_scale",
443 .data = &sysctl_tcp_adv_win_scale,
444 .maxlen = sizeof(int),
445 .mode = 0644,
Alexey Dobriyan0147fc02010-11-22 12:54:21 +0000446 .proc_handler = proc_dointvec_minmax,
447 .extra1 = &tcp_adv_win_scale_min,
448 .extra2 = &tcp_adv_win_scale_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 },
450 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 .procname = "tcp_tw_reuse",
452 .data = &sysctl_tcp_tw_reuse,
453 .maxlen = sizeof(int),
454 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800455 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 },
457 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 .procname = "tcp_frto",
459 .data = &sysctl_tcp_frto,
460 .maxlen = sizeof(int),
461 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800462 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 },
464 {
Yuchung Chengf6722582015-10-16 21:57:42 -0700465 .procname = "tcp_min_rtt_wlen",
466 .data = &sysctl_tcp_min_rtt_wlen,
467 .maxlen = sizeof(int),
468 .mode = 0644,
469 .proc_handler = proc_dointvec
470 },
471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "tcp_low_latency",
473 .data = &sysctl_tcp_low_latency,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800476 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 .procname = "tcp_no_metrics_save",
480 .data = &sysctl_tcp_nometrics_save,
481 .maxlen = sizeof(int),
482 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800483 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 },
485 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 .procname = "tcp_moderate_rcvbuf",
487 .data = &sysctl_tcp_moderate_rcvbuf,
488 .maxlen = sizeof(int),
489 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800490 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 },
492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 .procname = "tcp_tso_win_divisor",
494 .data = &sysctl_tcp_tso_win_divisor,
495 .maxlen = sizeof(int),
496 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800497 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 },
499 {
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700500 .procname = "tcp_congestion_control",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 .mode = 0644,
Stephen Hemminger317a76f2005-06-23 12:19:55 -0700502 .maxlen = TCP_CA_NAME_MAX,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800503 .proc_handler = proc_tcp_congestion_control,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 },
Stephen Hemminger9772efb2005-11-10 17:09:53 -0800505 {
Rick Jones15d99e02006-03-20 22:40:29 -0800506 .procname = "tcp_workaround_signed_windows",
507 .data = &sysctl_tcp_workaround_signed_windows,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800510 .proc_handler = proc_dointvec
Rick Jones15d99e02006-03-20 22:40:29 -0800511 },
Eric Dumazet46d3cea2012-07-11 05:50:31 +0000512 {
513 .procname = "tcp_limit_output_bytes",
514 .data = &sysctl_tcp_limit_output_bytes,
515 .maxlen = sizeof(int),
516 .mode = 0644,
517 .proc_handler = proc_dointvec
518 },
Eric Dumazet282f23c2012-07-17 10:13:05 +0200519 {
520 .procname = "tcp_challenge_ack_limit",
521 .data = &sysctl_tcp_challenge_ack_limit,
522 .maxlen = sizeof(int),
523 .mode = 0644,
524 .proc_handler = proc_dointvec
525 },
David S. Miller35089bb2006-06-13 22:33:04 -0700526 {
David S. Miller35089bb2006-06-13 22:33:04 -0700527 .procname = "tcp_slow_start_after_idle",
528 .data = &sysctl_tcp_slow_start_after_idle,
529 .maxlen = sizeof(int),
530 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800531 .proc_handler = proc_dointvec
David S. Miller35089bb2006-06-13 22:33:04 -0700532 },
Paul Moore446fda42006-08-03 16:48:06 -0700533#ifdef CONFIG_NETLABEL
534 {
Paul Moore446fda42006-08-03 16:48:06 -0700535 .procname = "cipso_cache_enable",
536 .data = &cipso_v4_cache_enabled,
537 .maxlen = sizeof(int),
538 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800539 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700540 },
541 {
Paul Moore446fda42006-08-03 16:48:06 -0700542 .procname = "cipso_cache_bucket_size",
543 .data = &cipso_v4_cache_bucketsize,
544 .maxlen = sizeof(int),
545 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800546 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700547 },
548 {
Paul Moore446fda42006-08-03 16:48:06 -0700549 .procname = "cipso_rbm_optfmt",
550 .data = &cipso_v4_rbm_optfmt,
551 .maxlen = sizeof(int),
552 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800553 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700554 },
555 {
Paul Moore446fda42006-08-03 16:48:06 -0700556 .procname = "cipso_rbm_strictvalid",
557 .data = &cipso_v4_rbm_strictvalid,
558 .maxlen = sizeof(int),
559 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800560 .proc_handler = proc_dointvec,
Paul Moore446fda42006-08-03 16:48:06 -0700561 },
562#endif /* CONFIG_NETLABEL */
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800563 {
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800564 .procname = "tcp_available_congestion_control",
565 .maxlen = TCP_CA_BUF_MAX,
566 .mode = 0444,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800567 .proc_handler = proc_tcp_available_congestion_control,
Stephen Hemminger3ff825b2006-11-09 16:32:06 -0800568 },
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800569 {
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800570 .procname = "tcp_allowed_congestion_control",
571 .maxlen = TCP_CA_BUF_MAX,
572 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800573 .proc_handler = proc_allowed_congestion_control,
Stephen Hemmingerce7bc3b2006-11-09 16:35:15 -0800574 },
John Heffner886236c2007-03-25 19:21:45 -0700575 {
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000576 .procname = "tcp_thin_linear_timeouts",
577 .data = &sysctl_tcp_thin_linear_timeouts,
578 .maxlen = sizeof(int),
579 .mode = 0644,
580 .proc_handler = proc_dointvec
581 },
Weilong Chen5797deb2013-12-23 14:37:31 +0800582 {
Andreas Petlund7e380172010-02-18 04:48:19 +0000583 .procname = "tcp_thin_dupack",
584 .data = &sysctl_tcp_thin_dupack,
585 .maxlen = sizeof(int),
586 .mode = 0644,
587 .proc_handler = proc_dointvec
588 },
Andreas Petlund36e31b0a2010-02-18 02:47:01 +0000589 {
Yuchung Chengeed530b2012-05-02 13:30:03 +0000590 .procname = "tcp_early_retrans",
591 .data = &sysctl_tcp_early_retrans,
592 .maxlen = sizeof(int),
593 .mode = 0644,
594 .proc_handler = proc_dointvec_minmax,
595 .extra1 = &zero,
Nandita Dukkipati6ba8a3b2013-03-11 10:00:43 +0000596 .extra2 = &four,
Yuchung Chengeed530b2012-05-02 13:30:03 +0000597 },
598 {
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700599 .procname = "tcp_min_tso_segs",
600 .data = &sysctl_tcp_min_tso_segs,
601 .maxlen = sizeof(int),
602 .mode = 0644,
603 .proc_handler = proc_dointvec_minmax,
Eric Dumazetd6a4e262015-05-26 08:55:28 -0700604 .extra1 = &one,
Eric Dumazet95bd09e2013-08-27 05:46:32 -0700605 .extra2 = &gso_max_segs,
606 },
607 {
Eric Dumazet43e122b2015-08-21 17:38:02 -0700608 .procname = "tcp_pacing_ss_ratio",
609 .data = &sysctl_tcp_pacing_ss_ratio,
610 .maxlen = sizeof(int),
611 .mode = 0644,
612 .proc_handler = proc_dointvec_minmax,
613 .extra1 = &zero,
614 .extra2 = &thousand,
615 },
616 {
617 .procname = "tcp_pacing_ca_ratio",
618 .data = &sysctl_tcp_pacing_ca_ratio,
619 .maxlen = sizeof(int),
620 .mode = 0644,
621 .proc_handler = proc_dointvec_minmax,
622 .extra1 = &zero,
623 .extra2 = &thousand,
624 },
625 {
Eric Dumazetf54b3112013-12-05 22:36:05 -0800626 .procname = "tcp_autocorking",
627 .data = &sysctl_tcp_autocorking,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = proc_dointvec_minmax,
631 .extra1 = &zero,
632 .extra2 = &one,
633 },
634 {
Neal Cardwell032ee422015-02-06 16:04:38 -0500635 .procname = "tcp_invalid_ratelimit",
636 .data = &sysctl_tcp_invalid_ratelimit,
637 .maxlen = sizeof(int),
638 .mode = 0644,
639 .proc_handler = proc_dointvec_ms_jiffies,
640 },
641 {
JP Abgrall2c170102014-02-07 18:40:10 -0800642 .procname = "tcp_default_init_rwnd",
643 .data = &sysctl_tcp_default_init_rwnd,
644 .maxlen = sizeof(int),
645 .mode = 0644,
646 .proc_handler = proc_tcp_default_init_rwnd
647 },
648 {
Eric Dumazet4cdf5072014-09-19 07:38:40 -0700649 .procname = "icmp_msgs_per_sec",
650 .data = &sysctl_icmp_msgs_per_sec,
651 .maxlen = sizeof(int),
652 .mode = 0644,
653 .proc_handler = proc_dointvec_minmax,
654 .extra1 = &zero,
655 },
656 {
657 .procname = "icmp_msgs_burst",
658 .data = &sysctl_icmp_msgs_burst,
659 .maxlen = sizeof(int),
660 .mode = 0644,
661 .proc_handler = proc_dointvec_minmax,
662 .extra1 = &zero,
663 },
664 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800665 .procname = "udp_mem",
666 .data = &sysctl_udp_mem,
667 .maxlen = sizeof(sysctl_udp_mem),
668 .mode = 0644,
Eric Dumazet8d987e52010-11-09 23:24:26 +0000669 .proc_handler = proc_doulongvec_minmax,
Hideo Aoki95766ff2007-12-31 00:29:24 -0800670 },
671 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800672 .procname = "udp_rmem_min",
673 .data = &sysctl_udp_rmem_min,
674 .maxlen = sizeof(sysctl_udp_rmem_min),
675 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800676 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700677 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800678 },
679 {
Hideo Aoki95766ff2007-12-31 00:29:24 -0800680 .procname = "udp_wmem_min",
681 .data = &sysctl_udp_wmem_min,
682 .maxlen = sizeof(sysctl_udp_wmem_min),
683 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800684 .proc_handler = proc_dointvec_minmax,
Calvin Owens5d378522015-08-13 14:21:34 -0700685 .extra1 = &one
Hideo Aoki95766ff2007-12-31 00:29:24 -0800686 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800687 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688};
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -0800689
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700690static struct ctl_table ipv4_net_table[] = {
691 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700692 .procname = "icmp_echo_ignore_all",
693 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
694 .maxlen = sizeof(int),
695 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800696 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700697 },
698 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700699 .procname = "icmp_echo_ignore_broadcasts",
700 .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
701 .maxlen = sizeof(int),
702 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800703 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700704 },
705 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700706 .procname = "icmp_ignore_bogus_error_responses",
707 .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
708 .maxlen = sizeof(int),
709 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800710 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700711 },
712 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700713 .procname = "icmp_errors_use_inbound_ifaddr",
714 .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800717 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700718 },
719 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700720 .procname = "icmp_ratelimit",
721 .data = &init_net.ipv4.sysctl_icmp_ratelimit,
722 .maxlen = sizeof(int),
723 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800724 .proc_handler = proc_dointvec_ms_jiffies,
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700725 },
726 {
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700727 .procname = "icmp_ratemask",
728 .data = &init_net.ipv4.sysctl_icmp_ratemask,
729 .maxlen = sizeof(int),
730 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800731 .proc_handler = proc_dointvec
Pavel Emelyanov68528f02008-03-26 01:56:24 -0700732 },
Neil Horman1080d702008-10-27 12:28:25 -0700733 {
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000734 .procname = "ping_group_range",
Cong Wangba6b9182014-05-06 11:02:50 -0700735 .data = &init_net.ipv4.ping_group_range.range,
Eric W. Biederman7064d162012-05-24 10:34:21 -0600736 .maxlen = sizeof(gid_t)*2,
Vasiliy Kulikovc319b4d2011-05-13 10:01:00 +0000737 .mode = 0644,
738 .proc_handler = ipv4_ping_group_range,
739 },
Glauber Costa3dc43e32011-12-11 21:47:05 +0000740 {
Hannes Frederic Sowa5d134f12013-01-05 16:10:48 +0000741 .procname = "tcp_ecn",
742 .data = &init_net.ipv4.sysctl_tcp_ecn,
743 .maxlen = sizeof(int),
744 .mode = 0644,
745 .proc_handler = proc_dointvec
746 },
747 {
Daniel Borkmann49213552015-05-19 21:04:22 +0200748 .procname = "tcp_ecn_fallback",
749 .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
750 .maxlen = sizeof(int),
751 .mode = 0644,
752 .proc_handler = proc_dointvec
753 },
754 {
Nikolay Borisov287b7f32016-02-15 12:11:29 +0200755 .procname = "ip_dynaddr",
756 .data = &init_net.ipv4.sysctl_ip_dynaddr,
757 .maxlen = sizeof(int),
758 .mode = 0644,
759 .proc_handler = proc_dointvec
760 },
761 {
Nikolay Borisove21145a2016-02-15 12:11:30 +0200762 .procname = "ip_early_demux",
763 .data = &init_net.ipv4.sysctl_ip_early_demux,
764 .maxlen = sizeof(int),
765 .mode = 0644,
766 .proc_handler = proc_dointvec
767 },
768 {
Nikolay Borisovfa50d972016-02-15 12:11:27 +0200769 .procname = "ip_default_ttl",
770 .data = &init_net.ipv4.sysctl_ip_default_ttl,
771 .maxlen = sizeof(int),
772 .mode = 0644,
773 .proc_handler = proc_dointvec_minmax,
774 .extra1 = &ip_ttl_min,
775 .extra2 = &ip_ttl_max,
776 },
777 {
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700778 .procname = "ip_local_port_range",
Cong Wangc9d8f1a2014-05-06 11:02:49 -0700779 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
780 .data = &init_net.ipv4.ip_local_ports.range,
Eric W. Biederman0bbf87d2013-09-28 14:10:59 -0700781 .mode = 0644,
782 .proc_handler = ipv4_local_port_range,
783 },
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100784 {
WANG Cong122ff242014-05-12 16:04:53 -0700785 .procname = "ip_local_reserved_ports",
786 .data = &init_net.ipv4.sysctl_local_reserved_ports,
787 .maxlen = 65536,
788 .mode = 0644,
789 .proc_handler = proc_do_large_bitmap,
790 },
791 {
Subash Abhinov Kasiviswanathan51ce9472017-06-01 13:27:12 -0600792 .procname = "reserved_port_bind",
793 .data = &sysctl_reserved_port_bind,
794 .maxlen = sizeof(int),
795 .mode = 0644,
796 .proc_handler = proc_dointvec
797 },
798 {
Hannes Frederic Sowa974eda12013-12-14 05:13:38 +0100799 .procname = "ip_no_pmtu_disc",
800 .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
801 .maxlen = sizeof(int),
802 .mode = 0644,
803 .proc_handler = proc_dointvec
804 },
Hannes Frederic Sowaf87c10a2014-01-09 10:01:15 +0100805 {
806 .procname = "ip_forward_use_pmtu",
807 .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
808 .maxlen = sizeof(int),
809 .mode = 0644,
810 .proc_handler = proc_dointvec,
811 },
Lorenzo Colittie1108612014-05-13 10:17:33 -0700812 {
Vincent Bernat49a60152014-09-05 15:09:03 +0200813 .procname = "ip_nonlocal_bind",
814 .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
815 .maxlen = sizeof(int),
816 .mode = 0644,
817 .proc_handler = proc_dointvec
818 },
819 {
Lorenzo Colittie1108612014-05-13 10:17:33 -0700820 .procname = "fwmark_reflect",
821 .data = &init_net.ipv4.sysctl_fwmark_reflect,
822 .maxlen = sizeof(int),
823 .mode = 0644,
824 .proc_handler = proc_dointvec,
825 },
Lorenzo Colitti84f39b02014-05-13 10:17:35 -0700826 {
827 .procname = "tcp_fwmark_accept",
828 .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
829 .maxlen = sizeof(int),
830 .mode = 0644,
831 .proc_handler = proc_dointvec,
832 },
David Ahern6dd9a142015-12-16 13:20:44 -0800833#ifdef CONFIG_NET_L3_MASTER_DEV
834 {
835 .procname = "tcp_l3mdev_accept",
836 .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
837 .maxlen = sizeof(int),
838 .mode = 0644,
839 .proc_handler = proc_dointvec_minmax,
840 .extra1 = &zero,
841 .extra2 = &one,
842 },
843#endif
Fan Dub0f9ca52015-02-10 09:53:16 +0800844 {
845 .procname = "tcp_mtu_probing",
846 .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
847 .maxlen = sizeof(int),
848 .mode = 0644,
849 .proc_handler = proc_dointvec,
850 },
851 {
852 .procname = "tcp_base_mss",
853 .data = &init_net.ipv4.sysctl_tcp_base_mss,
854 .maxlen = sizeof(int),
855 .mode = 0644,
856 .proc_handler = proc_dointvec,
857 },
Fan Du6b58e0a2015-03-06 11:18:23 +0800858 {
859 .procname = "tcp_probe_threshold",
860 .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
861 .maxlen = sizeof(int),
862 .mode = 0644,
863 .proc_handler = proc_dointvec,
864 },
Fan Du05cbc0d2015-03-06 11:18:24 +0800865 {
866 .procname = "tcp_probe_interval",
867 .data = &init_net.ipv4.sysctl_tcp_probe_interval,
868 .maxlen = sizeof(int),
869 .mode = 0644,
870 .proc_handler = proc_dointvec,
871 },
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100872 {
873 .procname = "igmp_link_local_mcast_reports",
Nikolay Borisov87a8a2a2016-02-09 00:13:50 +0200874 .data = &init_net.ipv4.sysctl_igmp_llm_reports,
Philip Downeydf2cf4a2015-08-27 16:46:26 +0100875 .maxlen = sizeof(int),
876 .mode = 0644,
877 .proc_handler = proc_dointvec
878 },
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200879 {
Nikolay Borisov815c5272016-02-08 23:29:21 +0200880 .procname = "igmp_max_memberships",
881 .data = &init_net.ipv4.sysctl_igmp_max_memberships,
882 .maxlen = sizeof(int),
883 .mode = 0644,
884 .proc_handler = proc_dointvec
885 },
886 {
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200887 .procname = "igmp_max_msf",
888 .data = &init_net.ipv4.sysctl_igmp_max_msf,
889 .maxlen = sizeof(int),
890 .mode = 0644,
891 .proc_handler = proc_dointvec
892 },
Nikolay Borisov165094a2016-02-08 23:29:24 +0200893#ifdef CONFIG_IP_MULTICAST
894 {
895 .procname = "igmp_qrv",
896 .data = &init_net.ipv4.sysctl_igmp_qrv,
897 .maxlen = sizeof(int),
898 .mode = 0644,
899 .proc_handler = proc_dointvec_minmax,
900 .extra1 = &one
901 },
902#endif
Nikolay Borisov166b6b22016-02-08 23:29:22 +0200903 {
Nikolay Borisov13b287e2016-01-07 16:38:43 +0200904 .procname = "tcp_keepalive_time",
905 .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
906 .maxlen = sizeof(int),
907 .mode = 0644,
908 .proc_handler = proc_dointvec_jiffies,
909 },
Nikolay Borisov9bd68612016-01-07 16:38:44 +0200910 {
911 .procname = "tcp_keepalive_probes",
912 .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
913 .maxlen = sizeof(int),
914 .mode = 0644,
915 .proc_handler = proc_dointvec
916 },
Nikolay Borisovb840d152016-01-07 16:38:45 +0200917 {
918 .procname = "tcp_keepalive_intvl",
919 .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
920 .maxlen = sizeof(int),
921 .mode = 0644,
922 .proc_handler = proc_dointvec_jiffies,
923 },
Nikolay Borisov6fa25162016-02-03 09:46:49 +0200924 {
925 .procname = "tcp_syn_retries",
926 .data = &init_net.ipv4.sysctl_tcp_syn_retries,
927 .maxlen = sizeof(int),
928 .mode = 0644,
929 .proc_handler = proc_dointvec_minmax,
930 .extra1 = &tcp_syn_retries_min,
931 .extra2 = &tcp_syn_retries_max
932 },
Nikolay Borisov7c083ec2016-02-03 09:46:50 +0200933 {
934 .procname = "tcp_synack_retries",
935 .data = &init_net.ipv4.sysctl_tcp_synack_retries,
936 .maxlen = sizeof(int),
937 .mode = 0644,
938 .proc_handler = proc_dointvec
939 },
Nikolay Borisov12ed8242016-02-03 09:46:51 +0200940#ifdef CONFIG_SYN_COOKIES
941 {
942 .procname = "tcp_syncookies",
943 .data = &init_net.ipv4.sysctl_tcp_syncookies,
944 .maxlen = sizeof(int),
945 .mode = 0644,
946 .proc_handler = proc_dointvec
947 },
948#endif
Nikolay Borisov1043e252016-02-03 09:46:52 +0200949 {
950 .procname = "tcp_reordering",
951 .data = &init_net.ipv4.sysctl_tcp_reordering,
952 .maxlen = sizeof(int),
953 .mode = 0644,
954 .proc_handler = proc_dointvec
955 },
Nikolay Borisovae5c3f42016-02-03 09:46:53 +0200956 {
957 .procname = "tcp_retries1",
958 .data = &init_net.ipv4.sysctl_tcp_retries1,
959 .maxlen = sizeof(int),
960 .mode = 0644,
961 .proc_handler = proc_dointvec_minmax,
962 .extra2 = &tcp_retr1_max
963 },
Nikolay Borisovc6214a92016-02-03 09:46:54 +0200964 {
965 .procname = "tcp_retries2",
966 .data = &init_net.ipv4.sysctl_tcp_retries2,
967 .maxlen = sizeof(int),
968 .mode = 0644,
969 .proc_handler = proc_dointvec
970 },
Nikolay Borisovc402d9b2016-02-03 09:46:55 +0200971 {
972 .procname = "tcp_orphan_retries",
973 .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
974 .maxlen = sizeof(int),
975 .mode = 0644,
976 .proc_handler = proc_dointvec
977 },
Nikolay Borisov1e579ca2016-02-03 09:46:56 +0200978 {
979 .procname = "tcp_fin_timeout",
980 .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
981 .maxlen = sizeof(int),
982 .mode = 0644,
983 .proc_handler = proc_dointvec_jiffies,
984 },
Nikolay Borisov4979f2d2016-02-03 09:46:57 +0200985 {
986 .procname = "tcp_notsent_lowat",
987 .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
988 .maxlen = sizeof(unsigned int),
989 .mode = 0644,
990 .proc_handler = proc_dointvec,
991 },
David Aherna6db4492016-04-07 07:21:00 -0700992#ifdef CONFIG_IP_ROUTE_MULTIPATH
993 {
994 .procname = "fib_multipath_use_neigh",
995 .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
996 .maxlen = sizeof(int),
997 .mode = 0644,
998 .proc_handler = proc_dointvec_minmax,
999 .extra1 = &zero,
1000 .extra2 = &one,
1001 },
1002#endif
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001003 { }
1004};
1005
Pavel Emelyanov15775192008-03-26 01:54:18 -07001006static __net_init int ipv4_sysctl_init_net(struct net *net)
1007{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001008 struct ctl_table *table;
1009
1010 table = ipv4_net_table;
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001011 if (!net_eq(net, &init_net)) {
Eric W. Biederman0a6fa232013-10-19 16:27:03 -07001012 int i;
1013
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001014 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
Ian Morris51456b22015-04-03 09:17:26 +01001015 if (!table)
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001016 goto err_alloc;
1017
Eric W. Biederman0a6fa232013-10-19 16:27:03 -07001018 /* Update the variables to point into the current struct net */
1019 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
1020 table[i].data += (void *)net - (void *)&init_net;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001021 }
1022
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001023 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
Ian Morris51456b22015-04-03 09:17:26 +01001024 if (!net->ipv4.ipv4_hdr)
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001025 goto err_reg;
1026
WANG Cong122ff242014-05-12 16:04:53 -07001027 net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
1028 if (!net->ipv4.sysctl_local_reserved_ports)
1029 goto err_ports;
1030
Pavel Emelyanov15775192008-03-26 01:54:18 -07001031 return 0;
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001032
WANG Cong122ff242014-05-12 16:04:53 -07001033err_ports:
1034 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001035err_reg:
Octavian Purdila09ad9bc2009-11-25 15:14:13 -08001036 if (!net_eq(net, &init_net))
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001037 kfree(table);
1038err_alloc:
1039 return -ENOMEM;
Pavel Emelyanov15775192008-03-26 01:54:18 -07001040}
1041
1042static __net_exit void ipv4_sysctl_exit_net(struct net *net)
1043{
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001044 struct ctl_table *table;
1045
WANG Cong122ff242014-05-12 16:04:53 -07001046 kfree(net->ipv4.sysctl_local_reserved_ports);
Pavel Emelyanov68528f02008-03-26 01:56:24 -07001047 table = net->ipv4.ipv4_hdr->ctl_table_arg;
1048 unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
1049 kfree(table);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001050}
1051
1052static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
1053 .init = ipv4_sysctl_init_net,
1054 .exit = ipv4_sysctl_exit_net,
1055};
1056
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001057static __init int sysctl_ipv4_init(void)
1058{
1059 struct ctl_table_header *hdr;
1060
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +00001061 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
Ian Morris51456b22015-04-03 09:17:26 +01001062 if (!hdr)
Pavel Emelyanov15775192008-03-26 01:54:18 -07001063 return -ENOMEM;
1064
1065 if (register_pernet_subsys(&ipv4_sysctl_ops)) {
Eric W. Biederman5dd3df12012-04-19 13:24:33 +00001066 unregister_net_sysctl_table(hdr);
Pavel Emelyanov15775192008-03-26 01:54:18 -07001067 return -ENOMEM;
1068 }
1069
1070 return 0;
Pavel Emelyanov3e37c3f2007-12-05 01:41:26 -08001071}
1072
1073__initcall(sysctl_ipv4_init);