Blame view

net/ipv4/sysctl_net_ipv4.c 35.4 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  // SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
  /*
   * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
8
9
10
11
   * Begun April 1, 1996, Mike Shaver.
   * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
   */
  
  #include <linux/mm.h>
  #include <linux/module.h>
  #include <linux/sysctl.h>
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
12
  #include <linux/igmp.h>
14c850212   Arnaldo Carvalho de Melo   [INET_SOCK]: Move...
13
  #include <linux/inetdevice.h>
227b60f51   Stephen Hemminger   [INET]: local por...
14
  #include <linux/seqlock.h>
3e37c3f99   Pavel Emelyanov   [IPV4]: Use ctl p...
15
  #include <linux/init.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
16
  #include <linux/slab.h>
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
17
  #include <linux/nsproxy.h>
3dc43e3e4   Glauber Costa   per-netns ipv4 sy...
18
  #include <linux/swap.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
  #include <net/snmp.h>
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
20
  #include <net/icmp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
23
  #include <net/ip.h>
  #include <net/route.h>
  #include <net/tcp.h>
95766fff6   Hideo Aoki   [UDP]: Add memory...
24
  #include <net/udp.h>
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
25
  #include <net/cipso_ipv4.h>
04128f233   Pavel Emelyanov   [INET]: Collect c...
26
  #include <net/inet_frag.h>
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
27
  #include <net/ping.h>
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
28
  #include <net/protocol.h>
3ae6ec082   Ido Schimmel   ipv4: Send a nete...
29
  #include <net/netevent.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

79e9fed46   Maciej Żenczykowski   net-tcp: extend t...
31
  static int two = 2;
6ba8a3b19   Nandita Dukkipati   tcp: Tail loss pr...
32
  static int four = 4;
43e122b01   Eric Dumazet   tcp: refine pacin...
33
  static int thousand = 1000;
95bd09eb2   Eric Dumazet   tcp: TSO packets ...
34
  static int gso_max_segs = GSO_MAX_SEGS;
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
35
  static int tcp_retr1_max = 255;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
  static int ip_local_port_range_min[] = { 1, 1 };
  static int ip_local_port_range_max[] = { 65535, 65535 };
0147fc058   Alexey Dobriyan   tcp: restrict net...
38
39
  static int tcp_adv_win_scale_min = -31;
  static int tcp_adv_win_scale_max = 31;
5f3e2bf00   Eric Dumazet   tcp: add tcp_min_...
40
41
  static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
  static int tcp_min_snd_mss_max = 65535;
4548b683b   Krister Johansen   Introduce a sysct...
42
43
  static int ip_privileged_port_min;
  static int ip_privileged_port_max = 65535;
249fab773   Eric Dumazet   net: add limits t...
44
45
  static int ip_ttl_min = 1;
  static int ip_ttl_max = 255;
651e92716   Michal Tesar   sysctl net: Keep ...
46
47
  static int tcp_syn_retries_min = 1;
  static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
48
49
  static int ip_ping_group_range_min[] = { 0, 0 };
  static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
9c21d2fc4   Eric Dumazet   tcp: add tcp_comp...
50
  static int comp_sack_nr_max = 255;
d4ce58082   Maciej Żenczykowski   net-tcp: /proc/sy...
51
  static u32 u32_max_div_HZ = UINT_MAX / HZ;
19fad20d1   ZhangXiaoxu   ipv4: set the tcp...
52
  static int one_day_secs = 24 * 3600;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53

b6690b143   Florian Westphal   tcp: remove low_l...
54
55
  /* obsolete */
  static int sysctl_tcp_low_latency __read_mostly;
227b60f51   Stephen Hemminger   [INET]: local por...
56
  /* Update system visible IP port range */
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
57
  static void set_local_port_range(struct net *net, int range[2])
227b60f51   Stephen Hemminger   [INET]: local por...
58
  {
ed2dfd900   Eric Dumazet   tcp/dccp: warn us...
59
  	bool same_parity = !((range[0] ^ range[1]) & 1);
4ee3bd4a8   WANG Cong   ipv4: disable BH ...
60
  	write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
ed2dfd900   Eric Dumazet   tcp/dccp: warn us...
61
62
63
64
65
  	if (same_parity && !net->ipv4.ip_local_ports.warned) {
  		net->ipv4.ip_local_ports.warned = true;
  		pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.
  ");
  	}
c9d8f1a64   Cong Wang   ipv4: move local_...
66
67
  	net->ipv4.ip_local_ports.range[0] = range[0];
  	net->ipv4.ip_local_ports.range[1] = range[1];
4ee3bd4a8   WANG Cong   ipv4: disable BH ...
68
  	write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
227b60f51   Stephen Hemminger   [INET]: local por...
69
70
71
  }
  
  /* Validate changes from /proc interface. */
fe2c6338f   Joe Perches   net: Convert uses...
72
  static int ipv4_local_port_range(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
73
  				 void *buffer, size_t *lenp, loff_t *ppos)
227b60f51   Stephen Hemminger   [INET]: local por...
74
  {
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
75
  	struct net *net =
c9d8f1a64   Cong Wang   ipv4: move local_...
76
  		container_of(table->data, struct net, ipv4.ip_local_ports.range);
227b60f51   Stephen Hemminger   [INET]: local por...
77
  	int ret;
3c689b732   Eric Dumazet   inet: cleanup of ...
78
  	int range[2];
fe2c6338f   Joe Perches   net: Convert uses...
79
  	struct ctl_table tmp = {
227b60f51   Stephen Hemminger   [INET]: local por...
80
81
82
83
84
85
  		.data = &range,
  		.maxlen = sizeof(range),
  		.mode = table->mode,
  		.extra1 = &ip_local_port_range_min,
  		.extra2 = &ip_local_port_range_max,
  	};
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
86
  	inet_get_local_port_range(net, &range[0], &range[1]);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
87
  	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
227b60f51   Stephen Hemminger   [INET]: local por...
88
89
  
  	if (write && ret == 0) {
4548b683b   Krister Johansen   Introduce a sysct...
90
91
92
93
94
95
  		/* Ensure that the upper limit is not smaller than the lower,
  		 * and that the lower does not encroach upon the privileged
  		 * port limit.
  		 */
  		if ((range[1] < range[0]) ||
  		    (range[0] < net->ipv4.sysctl_ip_prot_sock))
227b60f51   Stephen Hemminger   [INET]: local por...
96
97
  			ret = -EINVAL;
  		else
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
98
  			set_local_port_range(net, range);
227b60f51   Stephen Hemminger   [INET]: local por...
99
100
101
102
  	}
  
  	return ret;
  }
4548b683b   Krister Johansen   Introduce a sysct...
103
104
  /* Validate changes from /proc interface. */
  static int ipv4_privileged_ports(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
105
  				void *buffer, size_t *lenp, loff_t *ppos)
4548b683b   Krister Johansen   Introduce a sysct...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  {
  	struct net *net = container_of(table->data, struct net,
  	    ipv4.sysctl_ip_prot_sock);
  	int ret;
  	int pports;
  	int range[2];
  	struct ctl_table tmp = {
  		.data = &pports,
  		.maxlen = sizeof(pports),
  		.mode = table->mode,
  		.extra1 = &ip_privileged_port_min,
  		.extra2 = &ip_privileged_port_max,
  	};
  
  	pports = net->ipv4.sysctl_ip_prot_sock;
  
  	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
  
  	if (write && ret == 0) {
  		inet_get_local_port_range(net, &range[0], &range[1]);
  		/* Ensure that the local port range doesn't overlap with the
  		 * privileged port range.
  		 */
  		if (range[0] < pports)
  			ret = -EINVAL;
  		else
  			net->ipv4.sysctl_ip_prot_sock = pports;
  	}
  
  	return ret;
  }
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
137

7064d16e1   Eric W. Biederman   userns: Use kgids...
138
  static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
139
  {
7064d16e1   Eric W. Biederman   userns: Use kgids...
140
  	kgid_t *data = table->data;
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
141
  	struct net *net =
ba6b918ab   Cong Wang   ping: move ping_g...
142
  		container_of(table->data, struct net, ipv4.ping_group_range.range);
95c961747   Eric Dumazet   net: cleanup unsi...
143
  	unsigned int seq;
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
144
  	do {
396a30cce   WANG Cong   ipv4: use the rig...
145
  		seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
146
147
148
  
  		*low = data[0];
  		*high = data[1];
396a30cce   WANG Cong   ipv4: use the rig...
149
  	} while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
150
151
152
  }
  
  /* Update system visible IP port range */
7064d16e1   Eric W. Biederman   userns: Use kgids...
153
  static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
154
  {
7064d16e1   Eric W. Biederman   userns: Use kgids...
155
  	kgid_t *data = table->data;
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
156
  	struct net *net =
ba6b918ab   Cong Wang   ping: move ping_g...
157
  		container_of(table->data, struct net, ipv4.ping_group_range.range);
396a30cce   WANG Cong   ipv4: use the rig...
158
  	write_seqlock(&net->ipv4.ping_group_range.lock);
7064d16e1   Eric W. Biederman   userns: Use kgids...
159
160
  	data[0] = low;
  	data[1] = high;
396a30cce   WANG Cong   ipv4: use the rig...
161
  	write_sequnlock(&net->ipv4.ping_group_range.lock);
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
162
163
164
  }
  
  /* Validate changes from /proc interface. */
fe2c6338f   Joe Perches   net: Convert uses...
165
  static int ipv4_ping_group_range(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
166
  				 void *buffer, size_t *lenp, loff_t *ppos)
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
167
  {
7064d16e1   Eric W. Biederman   userns: Use kgids...
168
  	struct user_namespace *user_ns = current_user_ns();
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
169
  	int ret;
7064d16e1   Eric W. Biederman   userns: Use kgids...
170
171
  	gid_t urange[2];
  	kgid_t low, high;
fe2c6338f   Joe Perches   net: Convert uses...
172
  	struct ctl_table tmp = {
7064d16e1   Eric W. Biederman   userns: Use kgids...
173
174
  		.data = &urange,
  		.maxlen = sizeof(urange),
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
175
176
177
178
  		.mode = table->mode,
  		.extra1 = &ip_ping_group_range_min,
  		.extra2 = &ip_ping_group_range_max,
  	};
7064d16e1   Eric W. Biederman   userns: Use kgids...
179
180
181
  	inet_get_ping_group_range_table(table, &low, &high);
  	urange[0] = from_kgid_munged(user_ns, low);
  	urange[1] = from_kgid_munged(user_ns, high);
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
182
  	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
7064d16e1   Eric W. Biederman   userns: Use kgids...
183
184
185
  	if (write && ret == 0) {
  		low = make_kgid(user_ns, urange[0]);
  		high = make_kgid(user_ns, urange[1]);
70ba5b6db   Tyler Hicks   ipv4: Return EINV...
186
187
188
  		if (!gid_valid(low) || !gid_valid(high))
  			return -EINVAL;
  		if (urange[1] < urange[0] || gid_lt(high, low)) {
7064d16e1   Eric W. Biederman   userns: Use kgids...
189
190
191
192
193
  			low = make_kgid(&init_user_ns, 1);
  			high = make_kgid(&init_user_ns, 0);
  		}
  		set_ping_group_range(table, low, high);
  	}
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
194
195
196
  
  	return ret;
  }
d18c5d199   Petr Machata   net: ipv4: Notify...
197
  static int ipv4_fwd_update_priority(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
198
  				    void *buffer, size_t *lenp, loff_t *ppos)
d18c5d199   Petr Machata   net: ipv4: Notify...
199
200
201
202
203
204
205
206
207
208
209
210
211
  {
  	struct net *net;
  	int ret;
  
  	net = container_of(table->data, struct net,
  			   ipv4.sysctl_ip_fwd_update_priority);
  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  	if (write && ret == 0)
  		call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
  					net);
  
  	return ret;
  }
fe2c6338f   Joe Perches   net: Convert uses...
212
  static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
213
  				       void *buffer, size_t *lenp, loff_t *ppos)
317a76f9a   Stephen Hemminger   [TCP]: Add plugga...
214
  {
6670e1524   Stephen Hemminger   tcp: Namespace-if...
215
216
  	struct net *net = container_of(ctl->data, struct net,
  				       ipv4.tcp_congestion_control);
317a76f9a   Stephen Hemminger   [TCP]: Add plugga...
217
  	char val[TCP_CA_NAME_MAX];
fe2c6338f   Joe Perches   net: Convert uses...
218
  	struct ctl_table tbl = {
317a76f9a   Stephen Hemminger   [TCP]: Add plugga...
219
220
221
222
  		.data = val,
  		.maxlen = TCP_CA_NAME_MAX,
  	};
  	int ret;
6670e1524   Stephen Hemminger   tcp: Namespace-if...
223
  	tcp_get_default_congestion_control(net, val);
317a76f9a   Stephen Hemminger   [TCP]: Add plugga...
224

8d65af789   Alexey Dobriyan   sysctl: remove "s...
225
  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
317a76f9a   Stephen Hemminger   [TCP]: Add plugga...
226
  	if (write && ret == 0)
6670e1524   Stephen Hemminger   tcp: Namespace-if...
227
  		ret = tcp_set_default_congestion_control(net, val);
317a76f9a   Stephen Hemminger   [TCP]: Add plugga...
228
229
  	return ret;
  }
fe2c6338f   Joe Perches   net: Convert uses...
230
  static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
32927393d   Christoph Hellwig   sysctl: pass kern...
231
232
  						 int write, void *buffer,
  						 size_t *lenp, loff_t *ppos)
3ff825b28   Stephen Hemminger   [TCP]: Add tcp_av...
233
  {
fe2c6338f   Joe Perches   net: Convert uses...
234
  	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
3ff825b28   Stephen Hemminger   [TCP]: Add tcp_av...
235
236
237
238
239
240
  	int ret;
  
  	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
  	if (!tbl.data)
  		return -ENOMEM;
  	tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
241
  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
3ff825b28   Stephen Hemminger   [TCP]: Add tcp_av...
242
243
244
  	kfree(tbl.data);
  	return ret;
  }
fe2c6338f   Joe Perches   net: Convert uses...
245
  static int proc_allowed_congestion_control(struct ctl_table *ctl,
32927393d   Christoph Hellwig   sysctl: pass kern...
246
247
  					   int write, void *buffer,
  					   size_t *lenp, loff_t *ppos)
ce7bc3bf1   Stephen Hemminger   [TCP]: Restrict c...
248
  {
fe2c6338f   Joe Perches   net: Convert uses...
249
  	struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
ce7bc3bf1   Stephen Hemminger   [TCP]: Restrict c...
250
251
252
253
254
255
256
  	int ret;
  
  	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
  	if (!tbl.data)
  		return -ENOMEM;
  
  	tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
257
  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
ce7bc3bf1   Stephen Hemminger   [TCP]: Restrict c...
258
259
260
261
262
  	if (write && ret == 0)
  		ret = tcp_set_allowed_congestion_control(tbl.data);
  	kfree(tbl.data);
  	return ret;
  }
aa1236cdf   Jason Baron   tcp: add support ...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
  static int sscanf_key(char *buf, __le32 *key)
  {
  	u32 user_key[4];
  	int i, ret = 0;
  
  	if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
  		   user_key + 2, user_key + 3) != 4) {
  		ret = -EINVAL;
  	} else {
  		for (i = 0; i < ARRAY_SIZE(user_key); i++)
  			key[i] = cpu_to_le32(user_key[i]);
  	}
  	pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u
  ",
  		 user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
  
  	return ret;
  }
437138485   Haishuang Yan   ipv4: Namespaceif...
281
  static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
282
  				 void *buffer, size_t *lenp, loff_t *ppos)
104671636   Jerry Chu   tcp: TCP Fast Ope...
283
  {
437138485   Haishuang Yan   ipv4: Namespaceif...
284
285
  	struct net *net = container_of(table->data, struct net,
  	    ipv4.sysctl_tcp_fastopen);
aa1236cdf   Jason Baron   tcp: add support ...
286
287
288
289
290
291
  	/* maxlen to print the list of keys in hex (*2), with dashes
  	 * separating doublewords and a comma in between keys.
  	 */
  	struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
  					    2 * TCP_FASTOPEN_KEY_MAX) +
  					    (TCP_FASTOPEN_KEY_MAX * 5)) };
f19008e67   Jason Baron   tcp: correct read...
292
293
  	u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
  	__le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
aa1236cdf   Jason Baron   tcp: add support ...
294
  	char *backup_data;
f19008e67   Jason Baron   tcp: correct read...
295
  	int ret, i = 0, off = 0, n_keys;
104671636   Jerry Chu   tcp: TCP Fast Ope...
296
297
298
299
  
  	tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
  	if (!tbl.data)
  		return -ENOMEM;
f19008e67   Jason Baron   tcp: correct read...
300
  	n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
aa1236cdf   Jason Baron   tcp: add support ...
301
302
303
304
305
306
  	if (!n_keys) {
  		memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
  		n_keys = 1;
  	}
  
  	for (i = 0; i < n_keys * 4; i++)
c860e997e   Yuchung Cheng   tcp: fix Fast Ope...
307
  		user_key[i] = le32_to_cpu(key[i]);
aa1236cdf   Jason Baron   tcp: add support ...
308
309
310
311
312
313
314
  	for (i = 0; i < n_keys; i++) {
  		off += snprintf(tbl.data + off, tbl.maxlen - off,
  				"%08x-%08x-%08x-%08x",
  				user_key[i * 4],
  				user_key[i * 4 + 1],
  				user_key[i * 4 + 2],
  				user_key[i * 4 + 3]);
9bb59a21f   Hangbin Liu   tcp: warn if offs...
315
316
317
  
  		if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
  			break;
aa1236cdf   Jason Baron   tcp: add support ...
318
319
320
  		if (i + 1 < n_keys)
  			off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
  	}
104671636   Jerry Chu   tcp: TCP Fast Ope...
321
322
323
  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  
  	if (write && ret == 0) {
aa1236cdf   Jason Baron   tcp: add support ...
324
325
326
327
328
329
  		backup_data = strchr(tbl.data, ',');
  		if (backup_data) {
  			*backup_data = '\0';
  			backup_data++;
  		}
  		if (sscanf_key(tbl.data, key)) {
104671636   Jerry Chu   tcp: TCP Fast Ope...
330
331
332
  			ret = -EINVAL;
  			goto bad_key;
  		}
aa1236cdf   Jason Baron   tcp: add support ...
333
334
335
336
337
338
339
  		if (backup_data) {
  			if (sscanf_key(backup_data, key + 4)) {
  				ret = -EINVAL;
  				goto bad_key;
  			}
  		}
  		tcp_fastopen_reset_cipher(net, NULL, key,
438ac8800   Ard Biesheuvel   net: fastopen: ro...
340
  					  backup_data ? key + 4 : NULL);
104671636   Jerry Chu   tcp: TCP Fast Ope...
341
342
343
  	}
  
  bad_key:
104671636   Jerry Chu   tcp: TCP Fast Ope...
344
345
346
  	kfree(tbl.data);
  	return ret;
  }
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
347
348
349
350
351
352
  static void proc_configure_early_demux(int enabled, int protocol)
  {
  	struct net_protocol *ipprot;
  #if IS_ENABLED(CONFIG_IPV6)
  	struct inet6_protocol *ip6prot;
  #endif
58c4c6a3f   David Ahern   net: add rcu lock...
353
  	rcu_read_lock();
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
354
355
356
357
358
359
360
361
362
363
364
  	ipprot = rcu_dereference(inet_protos[protocol]);
  	if (ipprot)
  		ipprot->early_demux = enabled ? ipprot->early_demux_handler :
  						NULL;
  
  #if IS_ENABLED(CONFIG_IPV6)
  	ip6prot = rcu_dereference(inet6_protos[protocol]);
  	if (ip6prot)
  		ip6prot->early_demux = enabled ? ip6prot->early_demux_handler :
  						 NULL;
  #endif
58c4c6a3f   David Ahern   net: add rcu lock...
365
  	rcu_read_unlock();
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
366
367
368
  }
  
  static int proc_tcp_early_demux(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
369
  				void *buffer, size_t *lenp, loff_t *ppos)
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
  {
  	int ret = 0;
  
  	ret = proc_dointvec(table, write, buffer, lenp, ppos);
  
  	if (write && !ret) {
  		int enabled = init_net.ipv4.sysctl_tcp_early_demux;
  
  		proc_configure_early_demux(enabled, IPPROTO_TCP);
  	}
  
  	return ret;
  }
  
  static int proc_udp_early_demux(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
385
  				void *buffer, size_t *lenp, loff_t *ppos)
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
386
387
388
389
390
391
392
393
394
395
396
397
398
  {
  	int ret = 0;
  
  	ret = proc_dointvec(table, write, buffer, lenp, ppos);
  
  	if (write && !ret) {
  		int enabled = init_net.ipv4.sysctl_udp_early_demux;
  
  		proc_configure_early_demux(enabled, IPPROTO_UDP);
  	}
  
  	return ret;
  }
cf1ef3f07   Wei Wang   net/tcp_fastopen:...
399
  static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
32927393d   Christoph Hellwig   sysctl: pass kern...
400
  					     int write, void *buffer,
cf1ef3f07   Wei Wang   net/tcp_fastopen:...
401
402
  					     size_t *lenp, loff_t *ppos)
  {
3733be14a   Haishuang Yan   ipv4: Namespaceif...
403
404
  	struct net *net = container_of(table->data, struct net,
  	    ipv4.sysctl_tcp_fastopen_blackhole_timeout);
cf1ef3f07   Wei Wang   net/tcp_fastopen:...
405
406
407
408
  	int ret;
  
  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  	if (write && ret == 0)
3733be14a   Haishuang Yan   ipv4: Namespaceif...
409
  		atomic_set(&net->ipv4.tfo_active_disable_times, 0);
734942cc4   Dave Watson   tcp: ULP infrastr...
410
411
412
413
414
  
  	return ret;
  }
  
  static int proc_tcp_available_ulp(struct ctl_table *ctl,
32927393d   Christoph Hellwig   sysctl: pass kern...
415
  				  int write, void *buffer, size_t *lenp,
734942cc4   Dave Watson   tcp: ULP infrastr...
416
417
418
419
420
421
422
423
424
425
426
  				  loff_t *ppos)
  {
  	struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
  	int ret;
  
  	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
  	if (!tbl.data)
  		return -ENOMEM;
  	tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  	kfree(tbl.data);
cf1ef3f07   Wei Wang   net/tcp_fastopen:...
427
428
  	return ret;
  }
3ae6ec082   Ido Schimmel   ipv4: Send a nete...
429
430
  #ifdef CONFIG_IP_ROUTE_MULTIPATH
  static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
32927393d   Christoph Hellwig   sysctl: pass kern...
431
  					  void *buffer, size_t *lenp,
3ae6ec082   Ido Schimmel   ipv4: Send a nete...
432
433
434
435
436
437
438
439
  					  loff_t *ppos)
  {
  	struct net *net = container_of(table->data, struct net,
  	    ipv4.sysctl_fib_multipath_hash_policy);
  	int ret;
  
  	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  	if (write && ret == 0)
3192dac64   David Ahern   net: Rename NETEV...
440
  		call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
3ae6ec082   Ido Schimmel   ipv4: Send a nete...
441
442
443
444
  
  	return ret;
  }
  #endif
3e37c3f99   Pavel Emelyanov   [IPV4]: Use ctl p...
445
  static struct ctl_table ipv4_table[] = {
e905a9eda   YOSHIFUJI Hideaki   [NET] IPV4: Fix w...
446
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
447
448
449
450
  		.procname	= "tcp_max_orphans",
  		.data		= &sysctl_tcp_max_orphans,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
451
  		.proc_handler	= proc_dointvec
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
452
453
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
454
455
456
457
  		.procname	= "inet_peer_threshold",
  		.data		= &inet_peer_threshold,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
458
  		.proc_handler	= proc_dointvec
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
459
460
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
461
462
463
464
  		.procname	= "inet_peer_minttl",
  		.data		= &inet_peer_minttl,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
465
  		.proc_handler	= proc_dointvec_jiffies,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
466
467
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
468
469
470
471
  		.procname	= "inet_peer_maxttl",
  		.data		= &inet_peer_maxttl,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
472
  		.proc_handler	= proc_dointvec_jiffies,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
473
474
  	},
  	{
a4fe34bf9   Eric W. Biederman   tcp_memcontrol: R...
475
476
477
478
479
480
481
  		.procname	= "tcp_mem",
  		.maxlen		= sizeof(sysctl_tcp_mem),
  		.data		= &sysctl_tcp_mem,
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
  	{
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
482
483
484
485
  		.procname	= "tcp_low_latency",
  		.data		= &sysctl_tcp_low_latency,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
486
  		.proc_handler	= proc_dointvec
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
487
  	},
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
488
489
  #ifdef CONFIG_NETLABEL
  	{
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
490
491
492
493
  		.procname	= "cipso_cache_enable",
  		.data		= &cipso_v4_cache_enabled,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
494
  		.proc_handler	= proc_dointvec,
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
495
496
  	},
  	{
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
497
498
499
500
  		.procname	= "cipso_cache_bucket_size",
  		.data		= &cipso_v4_cache_bucketsize,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
501
  		.proc_handler	= proc_dointvec,
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
502
503
  	},
  	{
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
504
505
506
507
  		.procname	= "cipso_rbm_optfmt",
  		.data		= &cipso_v4_rbm_optfmt,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
508
  		.proc_handler	= proc_dointvec,
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
509
510
  	},
  	{
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
511
512
513
514
  		.procname	= "cipso_rbm_strictvalid",
  		.data		= &cipso_v4_rbm_strictvalid,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
515
  		.proc_handler	= proc_dointvec,
446fda4f2   Paul Moore   [NetLabel]: CIPSO...
516
517
  	},
  #endif /* CONFIG_NETLABEL */
3ff825b28   Stephen Hemminger   [TCP]: Add tcp_av...
518
  	{
734942cc4   Dave Watson   tcp: ULP infrastr...
519
520
521
522
523
524
  		.procname	= "tcp_available_ulp",
  		.maxlen		= TCP_ULP_BUF_MAX,
  		.mode		= 0444,
  		.proc_handler   = proc_tcp_available_ulp,
  	},
  	{
4cdf507d5   Eric Dumazet   icmp: add a globa...
525
526
527
528
529
  		.procname	= "icmp_msgs_per_sec",
  		.data		= &sysctl_icmp_msgs_per_sec,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
530
  		.extra1		= SYSCTL_ZERO,
4cdf507d5   Eric Dumazet   icmp: add a globa...
531
532
533
534
535
536
537
  	},
  	{
  		.procname	= "icmp_msgs_burst",
  		.data		= &sysctl_icmp_msgs_burst,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
538
  		.extra1		= SYSCTL_ZERO,
4cdf507d5   Eric Dumazet   icmp: add a globa...
539
540
  	},
  	{
95766fff6   Hideo Aoki   [UDP]: Add memory...
541
542
543
544
  		.procname	= "udp_mem",
  		.data		= &sysctl_udp_mem,
  		.maxlen		= sizeof(sysctl_udp_mem),
  		.mode		= 0644,
8d987e5c7   Eric Dumazet   net: avoid limits...
545
  		.proc_handler	= proc_doulongvec_minmax,
95766fff6   Hideo Aoki   [UDP]: Add memory...
546
  	},
9ab948a91   David Ahern   ipv4: Allow amoun...
547
548
549
550
551
552
553
554
555
  	{
  		.procname	= "fib_sync_mem",
  		.data		= &sysctl_fib_sync_mem,
  		.maxlen		= sizeof(sysctl_fib_sync_mem),
  		.mode		= 0644,
  		.proc_handler	= proc_douintvec_minmax,
  		.extra1		= &sysctl_fib_sync_mem_min,
  		.extra2		= &sysctl_fib_sync_mem_max,
  	},
ede61ca47   Eric Dumazet   tcp: add tcp_rx_s...
556
557
558
559
560
561
  	{
  		.procname	= "tcp_rx_skb_cache",
  		.data		= &tcp_rx_skb_cache_key.key,
  		.mode		= 0644,
  		.proc_handler	= proc_do_static_key,
  	},
0b7d7f6b2   Eric Dumazet   tcp: add tcp_tx_s...
562
563
564
565
566
567
  	{
  		.procname	= "tcp_tx_skb_cache",
  		.data		= &tcp_tx_skb_cache_key.key,
  		.mode		= 0644,
  		.proc_handler	= proc_do_static_key,
  	},
f8572d8f2   Eric W. Biederman   sysctl net: Remov...
568
  	{ }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
569
  };
3e37c3f99   Pavel Emelyanov   [IPV4]: Use ctl p...
570

68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
571
572
  static struct ctl_table ipv4_net_table[] = {
  	{
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
573
574
575
576
  		.procname	= "icmp_echo_ignore_all",
  		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_all,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
577
  		.proc_handler	= proc_dointvec
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
578
579
  	},
  	{
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
580
581
582
583
  		.procname	= "icmp_echo_ignore_broadcasts",
  		.data		= &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
584
  		.proc_handler	= proc_dointvec
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
585
586
  	},
  	{
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
587
588
589
590
  		.procname	= "icmp_ignore_bogus_error_responses",
  		.data		= &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
591
  		.proc_handler	= proc_dointvec
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
592
593
  	},
  	{
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
594
595
596
597
  		.procname	= "icmp_errors_use_inbound_ifaddr",
  		.data		= &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
598
  		.proc_handler	= proc_dointvec
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
599
600
  	},
  	{
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
601
602
603
604
  		.procname	= "icmp_ratelimit",
  		.data		= &init_net.ipv4.sysctl_icmp_ratelimit,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
605
  		.proc_handler	= proc_dointvec_ms_jiffies,
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
606
607
  	},
  	{
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
608
609
610
611
  		.procname	= "icmp_ratemask",
  		.data		= &init_net.ipv4.sysctl_icmp_ratemask,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
6d9f239a1   Alexey Dobriyan   net: '&' redux
612
  		.proc_handler	= proc_dointvec
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
613
  	},
1080d709f   Neil Horman   net: implement em...
614
  	{
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
615
  		.procname	= "ping_group_range",
ba6b918ab   Cong Wang   ping: move ping_g...
616
  		.data		= &init_net.ipv4.ping_group_range.range,
7064d16e1   Eric W. Biederman   userns: Use kgids...
617
  		.maxlen		= sizeof(gid_t)*2,
c319b4d76   Vasiliy Kulikov   net: ipv4: add IP...
618
619
620
  		.mode		= 0644,
  		.proc_handler	= ipv4_ping_group_range,
  	},
6897445fb   Mike Manning   net: provide a sy...
621
622
623
624
625
626
627
  #ifdef CONFIG_NET_L3_MASTER_DEV
  	{
  		.procname	= "raw_l3mdev_accept",
  		.data		= &init_net.ipv4.sysctl_raw_l3mdev_accept,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
628
629
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
6897445fb   Mike Manning   net: provide a sy...
630
631
  	},
  #endif
3dc43e3e4   Glauber Costa   per-netns ipv4 sy...
632
  	{
5d134f1c1   Hannes Frederic Sowa   tcp: make sysctl_...
633
634
635
636
637
638
639
  		.procname	= "tcp_ecn",
  		.data		= &init_net.ipv4.sysctl_tcp_ecn,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
492135557   Daniel Borkmann   tcp: add rfc3168,...
640
641
642
643
644
645
646
  		.procname	= "tcp_ecn_fallback",
  		.data		= &init_net.ipv4.sysctl_tcp_ecn_fallback,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
287b7f38f   Nikolay Borisov   ipv4: Namespacify...
647
648
649
650
651
652
653
  		.procname	= "ip_dynaddr",
  		.data		= &init_net.ipv4.sysctl_ip_dynaddr,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
e21145a98   Nikolay Borisov   ipv4: namespacify...
654
655
656
657
658
659
660
  		.procname	= "ip_early_demux",
  		.data		= &init_net.ipv4.sysctl_ip_early_demux,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
dddb64bcb   subashab@codeaurora.org   net: Add sysctl t...
661
662
663
664
665
666
667
668
669
670
671
672
673
674
  		.procname       = "udp_early_demux",
  		.data           = &init_net.ipv4.sysctl_udp_early_demux,
  		.maxlen         = sizeof(int),
  		.mode           = 0644,
  		.proc_handler   = proc_udp_early_demux
  	},
  	{
  		.procname       = "tcp_early_demux",
  		.data           = &init_net.ipv4.sysctl_tcp_early_demux,
  		.maxlen         = sizeof(int),
  		.mode           = 0644,
  		.proc_handler   = proc_tcp_early_demux
  	},
  	{
4f80116d3   Roopa Prabhu   net: ipv4: add sy...
675
676
677
678
679
680
681
682
683
  		.procname       = "nexthop_compat_mode",
  		.data           = &init_net.ipv4.sysctl_nexthop_compat_mode,
  		.maxlen         = sizeof(int),
  		.mode           = 0644,
  		.proc_handler   = proc_dointvec_minmax,
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
  	},
  	{
fa50d974d   Nikolay Borisov   ipv4: Namespaceif...
684
685
686
687
688
689
690
691
692
  		.procname	= "ip_default_ttl",
  		.data		= &init_net.ipv4.sysctl_ip_default_ttl,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &ip_ttl_min,
  		.extra2		= &ip_ttl_max,
  	},
  	{
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
693
  		.procname	= "ip_local_port_range",
c9d8f1a64   Cong Wang   ipv4: move local_...
694
695
  		.maxlen		= sizeof(init_net.ipv4.ip_local_ports.range),
  		.data		= &init_net.ipv4.ip_local_ports.range,
0bbf87d85   Eric W. Biederman   net ipv4: Convert...
696
697
698
  		.mode		= 0644,
  		.proc_handler	= ipv4_local_port_range,
  	},
974eda11c   Hannes Frederic Sowa   inet: make no_pmt...
699
  	{
122ff243f   WANG Cong   ipv4: make ip_loc...
700
701
702
703
704
705
706
  		.procname	= "ip_local_reserved_ports",
  		.data		= &init_net.ipv4.sysctl_local_reserved_ports,
  		.maxlen		= 65536,
  		.mode		= 0644,
  		.proc_handler	= proc_do_large_bitmap,
  	},
  	{
974eda11c   Hannes Frederic Sowa   inet: make no_pmt...
707
708
709
710
711
712
  		.procname	= "ip_no_pmtu_disc",
  		.data		= &init_net.ipv4.sysctl_ip_no_pmtu_disc,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
f87c10a8a   Hannes Frederic Sowa   ipv4: introduce i...
713
714
715
716
717
718
719
  	{
  		.procname	= "ip_forward_use_pmtu",
  		.data		= &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
e110861f8   Lorenzo Colitti   net: add a sysctl...
720
  	{
432e05d32   Petr Machata   net: ipv4: Contro...
721
722
723
724
  		.procname	= "ip_forward_update_priority",
  		.data		= &init_net.ipv4.sysctl_ip_fwd_update_priority,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
d18c5d199   Petr Machata   net: ipv4: Notify...
725
  		.proc_handler   = ipv4_fwd_update_priority,
eec4844fa   Matteo Croce   proc/sysctl: add ...
726
727
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
432e05d32   Petr Machata   net: ipv4: Contro...
728
729
  	},
  	{
49a601589   Vincent Bernat   net/ipv4: bind ip...
730
731
732
733
734
735
736
  		.procname	= "ip_nonlocal_bind",
  		.data		= &init_net.ipv4.sysctl_ip_nonlocal_bind,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
4b01a9674   Kuniyuki Iwashima   tcp: bind(0) remo...
737
738
739
740
741
742
743
744
745
  		.procname	= "ip_autobind_reuse",
  		.data		= &init_net.ipv4.sysctl_ip_autobind_reuse,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1         = SYSCTL_ZERO,
  		.extra2         = SYSCTL_ONE,
  	},
  	{
e110861f8   Lorenzo Colitti   net: add a sysctl...
746
747
748
749
750
751
  		.procname	= "fwmark_reflect",
  		.data		= &init_net.ipv4.sysctl_fwmark_reflect,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
84f39b08d   Lorenzo Colitti   net: support mark...
752
753
754
755
756
757
758
  	{
  		.procname	= "tcp_fwmark_accept",
  		.data		= &init_net.ipv4.sysctl_tcp_fwmark_accept,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
6dd9a14e9   David Ahern   net: Allow accept...
759
760
761
762
763
764
765
  #ifdef CONFIG_NET_L3_MASTER_DEV
  	{
  		.procname	= "tcp_l3mdev_accept",
  		.data		= &init_net.ipv4.sysctl_tcp_l3mdev_accept,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
766
767
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
6dd9a14e9   David Ahern   net: Allow accept...
768
769
  	},
  #endif
b0f9ca53c   Fan Du   ipv4: Namespecify...
770
771
772
773
774
775
776
777
778
779
780
781
782
783
  	{
  		.procname	= "tcp_mtu_probing",
  		.data		= &init_net.ipv4.sysctl_tcp_mtu_probing,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
  	{
  		.procname	= "tcp_base_mss",
  		.data		= &init_net.ipv4.sysctl_tcp_base_mss,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
6b58e0a5f   Fan Du   ipv4: Use binary ...
784
  	{
5f3e2bf00   Eric Dumazet   tcp: add tcp_min_...
785
786
787
788
789
790
791
792
793
  		.procname	= "tcp_min_snd_mss",
  		.data		= &init_net.ipv4.sysctl_tcp_min_snd_mss,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &tcp_min_snd_mss_min,
  		.extra2		= &tcp_min_snd_mss_max,
  	},
  	{
c04b79b6c   Josh Hunt   tcp: add new tcp_...
794
795
796
797
798
799
800
801
802
  		.procname	= "tcp_mtu_probe_floor",
  		.data		= &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &tcp_min_snd_mss_min,
  		.extra2		= &tcp_min_snd_mss_max,
  	},
  	{
6b58e0a5f   Fan Du   ipv4: Use binary ...
803
804
805
806
807
808
  		.procname	= "tcp_probe_threshold",
  		.data		= &init_net.ipv4.sysctl_tcp_probe_threshold,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
05cbc0db0   Fan Du   ipv4: Create prob...
809
810
811
  	{
  		.procname	= "tcp_probe_interval",
  		.data		= &init_net.ipv4.sysctl_tcp_probe_interval,
d4ce58082   Maciej Żenczykowski   net-tcp: /proc/sy...
812
  		.maxlen		= sizeof(u32),
05cbc0db0   Fan Du   ipv4: Create prob...
813
  		.mode		= 0644,
d4ce58082   Maciej Żenczykowski   net-tcp: /proc/sy...
814
815
  		.proc_handler	= proc_douintvec_minmax,
  		.extra2		= &u32_max_div_HZ,
05cbc0db0   Fan Du   ipv4: Create prob...
816
  	},
df2cf4a78   Philip Downey   IGMP: Inhibit rep...
817
818
  	{
  		.procname	= "igmp_link_local_mcast_reports",
87a8a2ae6   Nikolay Borisov   igmp: Namespaceif...
819
  		.data		= &init_net.ipv4.sysctl_igmp_llm_reports,
df2cf4a78   Philip Downey   IGMP: Inhibit rep...
820
821
822
823
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
13b287e8d   Nikolay Borisov   ipv4: Namespaceif...
824
  	{
815c52700   Nikolay Borisov   igmp: Namespaceif...
825
826
827
828
829
830
831
  		.procname	= "igmp_max_memberships",
  		.data		= &init_net.ipv4.sysctl_igmp_max_memberships,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
166b6b2d6   Nikolay Borisov   igmp: Namespaceif...
832
833
834
835
836
837
  		.procname	= "igmp_max_msf",
  		.data		= &init_net.ipv4.sysctl_igmp_max_msf,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
165094afc   Nikolay Borisov   igmp: Namespacify...
838
839
840
841
842
843
844
  #ifdef CONFIG_IP_MULTICAST
  	{
  		.procname	= "igmp_qrv",
  		.data		= &init_net.ipv4.sysctl_igmp_qrv,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
845
  		.extra1		= SYSCTL_ONE
165094afc   Nikolay Borisov   igmp: Namespacify...
846
847
  	},
  #endif
166b6b2d6   Nikolay Borisov   igmp: Namespaceif...
848
  	{
6670e1524   Stephen Hemminger   tcp: Namespace-if...
849
850
851
852
853
854
855
  		.procname	= "tcp_congestion_control",
  		.data		= &init_net.ipv4.tcp_congestion_control,
  		.mode		= 0644,
  		.maxlen		= TCP_CA_NAME_MAX,
  		.proc_handler	= proc_tcp_congestion_control,
  	},
  	{
9cb8e048e   Christian Brauner   net/ipv4/sysctl: ...
856
857
858
859
860
861
862
863
864
865
866
867
  		.procname	= "tcp_available_congestion_control",
  		.maxlen		= TCP_CA_BUF_MAX,
  		.mode		= 0444,
  		.proc_handler   = proc_tcp_available_congestion_control,
  	},
  	{
  		.procname	= "tcp_allowed_congestion_control",
  		.maxlen		= TCP_CA_BUF_MAX,
  		.mode		= 0644,
  		.proc_handler   = proc_allowed_congestion_control,
  	},
  	{
13b287e8d   Nikolay Borisov   ipv4: Namespaceif...
868
869
870
871
872
873
  		.procname	= "tcp_keepalive_time",
  		.data		= &init_net.ipv4.sysctl_tcp_keepalive_time,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_jiffies,
  	},
9bd6861bd   Nikolay Borisov   ipv4: Namespecify...
874
875
876
877
878
879
880
  	{
  		.procname	= "tcp_keepalive_probes",
  		.data		= &init_net.ipv4.sysctl_tcp_keepalive_probes,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
b840d15d3   Nikolay Borisov   ipv4: Namespecify...
881
882
883
884
885
886
887
  	{
  		.procname	= "tcp_keepalive_intvl",
  		.data		= &init_net.ipv4.sysctl_tcp_keepalive_intvl,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_jiffies,
  	},
6fa251663   Nikolay Borisov   ipv4: Namespaceif...
888
889
890
891
892
893
894
895
896
  	{
  		.procname	= "tcp_syn_retries",
  		.data		= &init_net.ipv4.sysctl_tcp_syn_retries,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &tcp_syn_retries_min,
  		.extra2		= &tcp_syn_retries_max
  	},
7c083ecb3   Nikolay Borisov   ipv4: Namespaceif...
897
898
899
900
901
902
903
  	{
  		.procname	= "tcp_synack_retries",
  		.data		= &init_net.ipv4.sysctl_tcp_synack_retries,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
12ed8244e   Nikolay Borisov   ipv4: Namespaceif...
904
905
906
907
908
909
910
911
912
  #ifdef CONFIG_SYN_COOKIES
  	{
  		.procname	= "tcp_syncookies",
  		.data		= &init_net.ipv4.sysctl_tcp_syncookies,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  #endif
1043e25ff   Nikolay Borisov   ipv4: Namespaceif...
913
914
915
916
917
918
919
  	{
  		.procname	= "tcp_reordering",
  		.data		= &init_net.ipv4.sysctl_tcp_reordering,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
ae5c3f406   Nikolay Borisov   ipv4: Namespaceif...
920
921
922
923
924
925
926
927
  	{
  		.procname	= "tcp_retries1",
  		.data		= &init_net.ipv4.sysctl_tcp_retries1,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra2		= &tcp_retr1_max
  	},
c6214a97c   Nikolay Borisov   ipv4: Namespaceif...
928
929
930
931
932
933
934
  	{
  		.procname	= "tcp_retries2",
  		.data		= &init_net.ipv4.sysctl_tcp_retries2,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
c402d9bef   Nikolay Borisov   ipv4: Namespaceif...
935
936
937
938
939
940
941
  	{
  		.procname	= "tcp_orphan_retries",
  		.data		= &init_net.ipv4.sysctl_tcp_orphan_retries,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
1e579caa1   Nikolay Borisov   ipv4: Namespaceif...
942
943
944
945
946
947
948
  	{
  		.procname	= "tcp_fin_timeout",
  		.data		= &init_net.ipv4.sysctl_tcp_fin_timeout,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_jiffies,
  	},
4979f2d9f   Nikolay Borisov   ipv4: Namespaceif...
949
950
951
952
953
  	{
  		.procname	= "tcp_notsent_lowat",
  		.data		= &init_net.ipv4.sysctl_tcp_notsent_lowat,
  		.maxlen		= sizeof(unsigned int),
  		.mode		= 0644,
b007f0907   Pavel Tikhomirov   ipv4: make tcp_no...
954
  		.proc_handler	= proc_douintvec,
4979f2d9f   Nikolay Borisov   ipv4: Namespaceif...
955
  	},
56ab6b930   Haishuang Yan   ipv4: Namespaceif...
956
957
958
959
960
  	{
  		.procname	= "tcp_tw_reuse",
  		.data		= &init_net.ipv4.sysctl_tcp_tw_reuse,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
79e9fed46   Maciej Żenczykowski   net-tcp: extend t...
961
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
962
  		.extra1		= SYSCTL_ZERO,
79e9fed46   Maciej Żenczykowski   net-tcp: extend t...
963
  		.extra2		= &two,
56ab6b930   Haishuang Yan   ipv4: Namespaceif...
964
  	},
1946e672c   Haishuang Yan   ipv4: Namespaceif...
965
966
967
968
969
970
971
972
  	{
  		.procname	= "tcp_max_tw_buckets",
  		.data		= &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
  	{
fee83d097   Haishuang Yan   ipv4: Namespaceif...
973
974
975
976
977
978
  		.procname	= "tcp_max_syn_backlog",
  		.data		= &init_net.ipv4.sysctl_max_syn_backlog,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
e1cfcbe82   Haishuang Yan   ipv4: Namespaceif...
979
980
981
982
983
984
985
  	{
  		.procname	= "tcp_fastopen",
  		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
437138485   Haishuang Yan   ipv4: Namespaceif...
986
987
988
989
  	{
  		.procname	= "tcp_fastopen_key",
  		.mode		= 0600,
  		.data		= &init_net.ipv4.sysctl_tcp_fastopen,
aa1236cdf   Jason Baron   tcp: add support ...
990
991
992
993
994
995
  		/* maxlen to print the list of keys in hex (*2), with dashes
  		 * separating doublewords and a comma in between keys.
  		 */
  		.maxlen		= ((TCP_FASTOPEN_KEY_LENGTH *
  				   2 * TCP_FASTOPEN_KEY_MAX) +
  				   (TCP_FASTOPEN_KEY_MAX * 5)),
437138485   Haishuang Yan   ipv4: Namespaceif...
996
997
  		.proc_handler	= proc_tcp_fastopen_key,
  	},
3733be14a   Haishuang Yan   ipv4: Namespaceif...
998
999
1000
1001
1002
1003
  	{
  		.procname	= "tcp_fastopen_blackhole_timeout_sec",
  		.data		= &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_tfo_blackhole_detect_timeout,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1004
  		.extra1		= SYSCTL_ZERO,
3733be14a   Haishuang Yan   ipv4: Namespaceif...
1005
  	},
a6db4494d   David Ahern   net: ipv4: Consid...
1006
1007
1008
1009
1010
1011
1012
  #ifdef CONFIG_IP_ROUTE_MULTIPATH
  	{
  		.procname	= "fib_multipath_use_neigh",
  		.data		= &init_net.ipv4.sysctl_fib_multipath_use_neigh,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1013
1014
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
bf4e0a3db   Nikolay Aleksandrov   net: ipv4: add su...
1015
1016
1017
1018
1019
1020
  	},
  	{
  		.procname	= "fib_multipath_hash_policy",
  		.data		= &init_net.ipv4.sysctl_fib_multipath_hash_policy,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
3ae6ec082   Ido Schimmel   ipv4: Send a nete...
1021
  		.proc_handler	= proc_fib_multipath_hash_policy,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1022
  		.extra1		= SYSCTL_ZERO,
ca749bbb1   Marcelo Ricardo Leitner   net/ipv4: fix sys...
1023
  		.extra2		= &two,
a6db4494d   David Ahern   net: ipv4: Consid...
1024
1025
  	},
  #endif
4548b683b   Krister Johansen   Introduce a sysct...
1026
1027
1028
1029
1030
1031
1032
  	{
  		.procname	= "ip_unprivileged_port_start",
  		.maxlen		= sizeof(int),
  		.data		= &init_net.ipv4.sysctl_ip_prot_sock,
  		.mode		= 0644,
  		.proc_handler	= ipv4_privileged_ports,
  	},
63a6fff35   Robert Shearman   net: Avoid receiv...
1033
1034
1035
1036
1037
1038
1039
  #ifdef CONFIG_NET_L3_MASTER_DEV
  	{
  		.procname	= "udp_l3mdev_accept",
  		.data		= &init_net.ipv4.sysctl_udp_l3mdev_accept,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1040
1041
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
63a6fff35   Robert Shearman   net: Avoid receiv...
1042
1043
  	},
  #endif
f93010342   Eric Dumazet   tcp: Namespaceify...
1044
1045
1046
1047
1048
1049
1050
  	{
  		.procname	= "tcp_sack",
  		.data		= &init_net.ipv4.sysctl_tcp_sack,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
9bb37ef00   Eric Dumazet   tcp: Namespaceify...
1051
1052
1053
1054
1055
1056
1057
  	{
  		.procname	= "tcp_window_scaling",
  		.data		= &init_net.ipv4.sysctl_tcp_window_scaling,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
5d2ed0521   Eric Dumazet   tcp: Namespaceify...
1058
1059
1060
1061
1062
1063
1064
  	{
  		.procname	= "tcp_timestamps",
  		.data		= &init_net.ipv4.sysctl_tcp_timestamps,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
2ae21cf52   Eric Dumazet   tcp: Namespace-if...
1065
1066
1067
1068
1069
1070
  	{
  		.procname	= "tcp_early_retrans",
  		.data		= &init_net.ipv4.sysctl_tcp_early_retrans,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1071
  		.extra1		= SYSCTL_ZERO,
2ae21cf52   Eric Dumazet   tcp: Namespace-if...
1072
1073
  		.extra2		= &four,
  	},
e20223f19   Eric Dumazet   tcp: Namespace-if...
1074
1075
1076
1077
1078
1079
1080
  	{
  		.procname	= "tcp_recovery",
  		.data		= &init_net.ipv4.sysctl_tcp_recovery,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
2c04ac8ae   Eric Dumazet   tcp: Namespace-if...
1081
1082
1083
1084
1085
1086
1087
  	{
  		.procname       = "tcp_thin_linear_timeouts",
  		.data           = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
  		.maxlen         = sizeof(int),
  		.mode           = 0644,
  		.proc_handler   = proc_dointvec
  	},
b510f0d23   Eric Dumazet   tcp: Namespace-if...
1088
1089
1090
1091
1092
1093
1094
  	{
  		.procname	= "tcp_slow_start_after_idle",
  		.data		= &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
e0a1e5b51   Eric Dumazet   tcp: Namespace-if...
1095
1096
1097
1098
1099
1100
1101
  	{
  		.procname	= "tcp_retrans_collapse",
  		.data		= &init_net.ipv4.sysctl_tcp_retrans_collapse,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
3f4c7c6f6   Eric Dumazet   tcp: Namespace-if...
1102
1103
1104
1105
1106
1107
1108
  	{
  		.procname	= "tcp_stdurg",
  		.data		= &init_net.ipv4.sysctl_tcp_stdurg,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
625357aa1   Eric Dumazet   tcp: Namespace-if...
1109
1110
1111
1112
1113
1114
1115
  	{
  		.procname	= "tcp_rfc1337",
  		.data		= &init_net.ipv4.sysctl_tcp_rfc1337,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
65c9410cf   Eric Dumazet   tcp: Namespace-if...
1116
1117
1118
1119
1120
1121
1122
  	{
  		.procname	= "tcp_abort_on_overflow",
  		.data		= &init_net.ipv4.sysctl_tcp_abort_on_overflow,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
0bc65a28a   Eric Dumazet   tcp: Namespace-if...
1123
1124
1125
1126
1127
1128
1129
  	{
  		.procname	= "tcp_fack",
  		.data		= &init_net.ipv4.sysctl_tcp_fack,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
c6e218035   Eric Dumazet   tcp: Namespace-if...
1130
1131
1132
1133
1134
1135
1136
  	{
  		.procname	= "tcp_max_reordering",
  		.data		= &init_net.ipv4.sysctl_tcp_max_reordering,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
6496f6bde   Eric Dumazet   tcp: Namespace-if...
1137
1138
1139
1140
1141
1142
1143
  	{
  		.procname	= "tcp_dsack",
  		.data		= &init_net.ipv4.sysctl_tcp_dsack,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
0c12654ac   Eric Dumazet   tcp: Namespace-if...
1144
1145
1146
1147
1148
1149
1150
  	{
  		.procname	= "tcp_app_win",
  		.data		= &init_net.ipv4.sysctl_tcp_app_win,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
94f0893e0   Eric Dumazet   tcp: Namespace-if...
1151
1152
1153
1154
1155
1156
1157
1158
1159
  	{
  		.procname	= "tcp_adv_win_scale",
  		.data		= &init_net.ipv4.sysctl_tcp_adv_win_scale,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= &tcp_adv_win_scale_min,
  		.extra2		= &tcp_adv_win_scale_max,
  	},
af9b69a7a   Eric Dumazet   tcp: Namespace-if...
1160
1161
1162
1163
1164
1165
1166
  	{
  		.procname	= "tcp_frto",
  		.data		= &init_net.ipv4.sysctl_tcp_frto,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
ec36e416f   Eric Dumazet   tcp: Namespace-if...
1167
1168
1169
1170
1171
1172
1173
  	{
  		.procname	= "tcp_no_metrics_save",
  		.data		= &init_net.ipv4.sysctl_tcp_nometrics_save,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
4540c0cf9   Eric Dumazet   tcp: Namespace-if...
1174
  	{
65e6d9016   Kevin(Yudong) Yang   net-tcp: Disable ...
1175
1176
1177
1178
1179
1180
1181
1182
1183
  		.procname	= "tcp_no_ssthresh_metrics_save",
  		.data		= &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
  	},
  	{
4540c0cf9   Eric Dumazet   tcp: Namespace-if...
1184
1185
1186
1187
1188
1189
  		.procname	= "tcp_moderate_rcvbuf",
  		.data		= &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
d06a99045   Eric Dumazet   tcp: Namespace-if...
1190
1191
1192
1193
1194
1195
1196
  	{
  		.procname	= "tcp_tso_win_divisor",
  		.data		= &init_net.ipv4.sysctl_tcp_tso_win_divisor,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec,
  	},
ceef9ab6b   Eric Dumazet   tcp: Namespace-if...
1197
1198
1199
1200
1201
1202
1203
  	{
  		.procname	= "tcp_workaround_signed_windows",
  		.data		= &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
9184d8bb4   Eric Dumazet   tcp: Namespace-if...
1204
1205
1206
1207
1208
1209
1210
  	{
  		.procname	= "tcp_limit_output_bytes",
  		.data		= &init_net.ipv4.sysctl_tcp_limit_output_bytes,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
b530b6814   Eric Dumazet   tcp: Namespace-if...
1211
1212
1213
1214
1215
1216
1217
  	{
  		.procname	= "tcp_challenge_ack_limit",
  		.data		= &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec
  	},
26e9596e5   Eric Dumazet   tcp: Namespace-if...
1218
1219
1220
1221
1222
1223
  	{
  		.procname	= "tcp_min_tso_segs",
  		.data		= &init_net.ipv4.sysctl_tcp_min_tso_segs,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1224
  		.extra1		= SYSCTL_ONE,
26e9596e5   Eric Dumazet   tcp: Namespace-if...
1225
1226
  		.extra2		= &gso_max_segs,
  	},
bd2397042   Eric Dumazet   tcp: Namespace-if...
1227
1228
1229
1230
1231
  	{
  		.procname	= "tcp_min_rtt_wlen",
  		.data		= &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
19fad20d1   ZhangXiaoxu   ipv4: set the tcp...
1232
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1233
  		.extra1		= SYSCTL_ZERO,
19fad20d1   ZhangXiaoxu   ipv4: set the tcp...
1234
  		.extra2		= &one_day_secs
bd2397042   Eric Dumazet   tcp: Namespace-if...
1235
  	},
790f00e19   Eric Dumazet   tcp: Namespace-if...
1236
1237
1238
1239
1240
1241
  	{
  		.procname	= "tcp_autocorking",
  		.data		= &init_net.ipv4.sysctl_tcp_autocorking,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1242
1243
  		.extra1		= SYSCTL_ZERO,
  		.extra2		= SYSCTL_ONE,
790f00e19   Eric Dumazet   tcp: Namespace-if...
1244
  	},
4170ba6b5   Eric Dumazet   tcp: Namespace-if...
1245
1246
1247
1248
1249
1250
1251
  	{
  		.procname	= "tcp_invalid_ratelimit",
  		.data		= &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_ms_jiffies,
  	},
23a7102a2   Eric Dumazet   tcp: Namespace-if...
1252
1253
1254
1255
1256
1257
  	{
  		.procname	= "tcp_pacing_ss_ratio",
  		.data		= &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1258
  		.extra1		= SYSCTL_ZERO,
23a7102a2   Eric Dumazet   tcp: Namespace-if...
1259
1260
  		.extra2		= &thousand,
  	},
c26e91f8b   Eric Dumazet   tcp: Namespace-if...
1261
1262
1263
1264
1265
1266
  	{
  		.procname	= "tcp_pacing_ca_ratio",
  		.data		= &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1267
  		.extra1		= SYSCTL_ZERO,
c26e91f8b   Eric Dumazet   tcp: Namespace-if...
1268
1269
  		.extra2		= &thousand,
  	},
356d1833b   Eric Dumazet   tcp: Namespace-if...
1270
1271
1272
1273
1274
1275
  	{
  		.procname	= "tcp_wmem",
  		.data		= &init_net.ipv4.sysctl_tcp_wmem,
  		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_wmem),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1276
  		.extra1		= SYSCTL_ONE,
356d1833b   Eric Dumazet   tcp: Namespace-if...
1277
1278
1279
1280
1281
1282
1283
  	},
  	{
  		.procname	= "tcp_rmem",
  		.data		= &init_net.ipv4.sysctl_tcp_rmem,
  		.maxlen		= sizeof(init_net.ipv4.sysctl_tcp_rmem),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1284
  		.extra1		= SYSCTL_ONE,
356d1833b   Eric Dumazet   tcp: Namespace-if...
1285
  	},
1e8029515   Tonghao Zhang   udp: Move the udp...
1286
  	{
6d82aa242   Eric Dumazet   tcp: add tcp_comp...
1287
1288
1289
1290
1291
1292
1293
  		.procname	= "tcp_comp_sack_delay_ns",
  		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
  		.maxlen		= sizeof(unsigned long),
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
  	{
a70437cc0   Eric Dumazet   tcp: add hrtimer ...
1294
1295
1296
1297
1298
1299
1300
  		.procname	= "tcp_comp_sack_slack_ns",
  		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
  		.maxlen		= sizeof(unsigned long),
  		.mode		= 0644,
  		.proc_handler	= proc_doulongvec_minmax,
  	},
  	{
9c21d2fc4   Eric Dumazet   tcp: add tcp_comp...
1301
1302
1303
1304
1305
  		.procname	= "tcp_comp_sack_nr",
  		.data		= &init_net.ipv4.sysctl_tcp_comp_sack_nr,
  		.maxlen		= sizeof(int),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1306
  		.extra1		= SYSCTL_ZERO,
9c21d2fc4   Eric Dumazet   tcp: add tcp_comp...
1307
1308
1309
  		.extra2		= &comp_sack_nr_max,
  	},
  	{
ac8f1710c   Wei Wang   tcp: reflect tos ...
1310
1311
1312
1313
1314
1315
1316
1317
1318
  		.procname       = "tcp_reflect_tos",
  		.data           = &init_net.ipv4.sysctl_tcp_reflect_tos,
  		.maxlen         = sizeof(int),
  		.mode           = 0644,
  		.proc_handler   = proc_dointvec_minmax,
  		.extra1         = SYSCTL_ZERO,
  		.extra2         = SYSCTL_ONE,
  	},
  	{
1e8029515   Tonghao Zhang   udp: Move the udp...
1319
1320
1321
1322
1323
  		.procname	= "udp_rmem_min",
  		.data		= &init_net.ipv4.sysctl_udp_rmem_min,
  		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_rmem_min),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1324
  		.extra1		= SYSCTL_ONE
1e8029515   Tonghao Zhang   udp: Move the udp...
1325
1326
1327
1328
1329
1330
1331
  	},
  	{
  		.procname	= "udp_wmem_min",
  		.data		= &init_net.ipv4.sysctl_udp_wmem_min,
  		.maxlen		= sizeof(init_net.ipv4.sysctl_udp_wmem_min),
  		.mode		= 0644,
  		.proc_handler	= proc_dointvec_minmax,
eec4844fa   Matteo Croce   proc/sysctl: add ...
1332
  		.extra1		= SYSCTL_ONE
1e8029515   Tonghao Zhang   udp: Move the udp...
1333
  	},
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1334
1335
  	{ }
  };
1577519d6   Pavel Emelyanov   [NETNS][ICMP]: Re...
1336
1337
  static __net_init int ipv4_sysctl_init_net(struct net *net)
  {
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1338
1339
1340
  	struct ctl_table *table;
  
  	table = ipv4_net_table;
09ad9bc75   Octavian Purdila   net: use net_eq t...
1341
  	if (!net_eq(net, &init_net)) {
0a6fa23dc   Eric W. Biederman   ipv4: Use math to...
1342
  		int i;
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1343
  		table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
51456b291   Ian Morris   ipv4: coding styl...
1344
  		if (!table)
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1345
  			goto err_alloc;
0a6fa23dc   Eric W. Biederman   ipv4: Use math to...
1346
1347
1348
  		/* Update the variables to point into the current struct net */
  		for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
  			table[i].data += (void *)net - (void *)&init_net;
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1349
  	}
ec8f23ce0   Eric W. Biederman   net: Convert all ...
1350
  	net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
51456b291   Ian Morris   ipv4: coding styl...
1351
  	if (!net->ipv4.ipv4_hdr)
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1352
  		goto err_reg;
122ff243f   WANG Cong   ipv4: make ip_loc...
1353
1354
1355
  	net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
  	if (!net->ipv4.sysctl_local_reserved_ports)
  		goto err_ports;
1577519d6   Pavel Emelyanov   [NETNS][ICMP]: Re...
1356
  	return 0;
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1357

122ff243f   WANG Cong   ipv4: make ip_loc...
1358
1359
  err_ports:
  	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1360
  err_reg:
09ad9bc75   Octavian Purdila   net: use net_eq t...
1361
  	if (!net_eq(net, &init_net))
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1362
1363
1364
  		kfree(table);
  err_alloc:
  	return -ENOMEM;
1577519d6   Pavel Emelyanov   [NETNS][ICMP]: Re...
1365
1366
1367
1368
  }
  
  static __net_exit void ipv4_sysctl_exit_net(struct net *net)
  {
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1369
  	struct ctl_table *table;
122ff243f   WANG Cong   ipv4: make ip_loc...
1370
  	kfree(net->ipv4.sysctl_local_reserved_ports);
68528f099   Pavel Emelyanov   [NETNS][ICMP]: Ma...
1371
1372
1373
  	table = net->ipv4.ipv4_hdr->ctl_table_arg;
  	unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
  	kfree(table);
1577519d6   Pavel Emelyanov   [NETNS][ICMP]: Re...
1374
1375
1376
1377
1378
1379
  }
  
  static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
  	.init = ipv4_sysctl_init_net,
  	.exit = ipv4_sysctl_exit_net,
  };
3e37c3f99   Pavel Emelyanov   [IPV4]: Use ctl p...
1380
1381
1382
  static __init int sysctl_ipv4_init(void)
  {
  	struct ctl_table_header *hdr;
ec8f23ce0   Eric W. Biederman   net: Convert all ...
1383
  	hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
51456b291   Ian Morris   ipv4: coding styl...
1384
  	if (!hdr)
1577519d6   Pavel Emelyanov   [NETNS][ICMP]: Re...
1385
1386
1387
  		return -ENOMEM;
  
  	if (register_pernet_subsys(&ipv4_sysctl_ops)) {
5dd3df105   Eric W. Biederman   net: Move all of ...
1388
  		unregister_net_sysctl_table(hdr);
1577519d6   Pavel Emelyanov   [NETNS][ICMP]: Re...
1389
1390
1391
1392
  		return -ENOMEM;
  	}
  
  	return 0;
3e37c3f99   Pavel Emelyanov   [IPV4]: Use ctl p...
1393
1394
1395
  }
  
  __initcall(sysctl_ipv4_init);