rfkill: add uevent notifications
[linux-2.6] / net / ipv4 / sysctl_net_ipv4.c
1 /*
2  * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
3  *
4  * 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>
11 #include <linux/igmp.h>
12 #include <linux/inetdevice.h>
13 #include <linux/seqlock.h>
14 #include <linux/init.h>
15 #include <net/snmp.h>
16 #include <net/icmp.h>
17 #include <net/ip.h>
18 #include <net/route.h>
19 #include <net/tcp.h>
20 #include <net/udp.h>
21 #include <net/cipso_ipv4.h>
22 #include <net/inet_frag.h>
23
24 static int zero;
25 static int tcp_retr1_max = 255;
26 static int ip_local_port_range_min[] = { 1, 1 };
27 static int ip_local_port_range_max[] = { 65535, 65535 };
28
29 extern seqlock_t sysctl_port_range_lock;
30 extern int sysctl_local_port_range[2];
31
32 /* Update system visible IP port range */
33 static void set_local_port_range(int range[2])
34 {
35         write_seqlock(&sysctl_port_range_lock);
36         sysctl_local_port_range[0] = range[0];
37         sysctl_local_port_range[1] = range[1];
38         write_sequnlock(&sysctl_port_range_lock);
39 }
40
41 /* Validate changes from /proc interface. */
42 static int ipv4_local_port_range(ctl_table *table, int write, struct file *filp,
43                                  void __user *buffer,
44                                  size_t *lenp, loff_t *ppos)
45 {
46         int ret;
47         int range[2] = { sysctl_local_port_range[0],
48                          sysctl_local_port_range[1] };
49         ctl_table tmp = {
50                 .data = &range,
51                 .maxlen = sizeof(range),
52                 .mode = table->mode,
53                 .extra1 = &ip_local_port_range_min,
54                 .extra2 = &ip_local_port_range_max,
55         };
56
57         ret = proc_dointvec_minmax(&tmp, write, filp, buffer, lenp, ppos);
58
59         if (write && ret == 0) {
60                 if (range[1] < range[0])
61                         ret = -EINVAL;
62                 else
63                         set_local_port_range(range);
64         }
65
66         return ret;
67 }
68
69 /* Validate changes from sysctl interface. */
70 static int ipv4_sysctl_local_port_range(ctl_table *table, int __user *name,
71                                          int nlen, void __user *oldval,
72                                          size_t __user *oldlenp,
73                                         void __user *newval, size_t newlen)
74 {
75         int ret;
76         int range[2] = { sysctl_local_port_range[0],
77                          sysctl_local_port_range[1] };
78         ctl_table tmp = {
79                 .data = &range,
80                 .maxlen = sizeof(range),
81                 .mode = table->mode,
82                 .extra1 = &ip_local_port_range_min,
83                 .extra2 = &ip_local_port_range_max,
84         };
85
86         ret = sysctl_intvec(&tmp, name, nlen, oldval, oldlenp, newval, newlen);
87         if (ret == 0 && newval && newlen) {
88                 if (range[1] < range[0])
89                         ret = -EINVAL;
90                 else
91                         set_local_port_range(range);
92         }
93         return ret;
94 }
95
96
97 static int proc_tcp_congestion_control(ctl_table *ctl, int write, struct file * filp,
98                                        void __user *buffer, size_t *lenp, loff_t *ppos)
99 {
100         char val[TCP_CA_NAME_MAX];
101         ctl_table tbl = {
102                 .data = val,
103                 .maxlen = TCP_CA_NAME_MAX,
104         };
105         int ret;
106
107         tcp_get_default_congestion_control(val);
108
109         ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
110         if (write && ret == 0)
111                 ret = tcp_set_default_congestion_control(val);
112         return ret;
113 }
114
115 static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
116                                          int nlen, void __user *oldval,
117                                          size_t __user *oldlenp,
118                                          void __user *newval, size_t newlen)
119 {
120         char val[TCP_CA_NAME_MAX];
121         ctl_table tbl = {
122                 .data = val,
123                 .maxlen = TCP_CA_NAME_MAX,
124         };
125         int ret;
126
127         tcp_get_default_congestion_control(val);
128         ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
129         if (ret == 1 && newval && newlen)
130                 ret = tcp_set_default_congestion_control(val);
131         return ret;
132 }
133
134 static int proc_tcp_available_congestion_control(ctl_table *ctl,
135                                                  int write, struct file * filp,
136                                                  void __user *buffer, size_t *lenp,
137                                                  loff_t *ppos)
138 {
139         ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
140         int ret;
141
142         tbl.data = kmalloc(tbl.maxlen, GFP_USER);
143         if (!tbl.data)
144                 return -ENOMEM;
145         tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
146         ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
147         kfree(tbl.data);
148         return ret;
149 }
150
151 static int proc_allowed_congestion_control(ctl_table *ctl,
152                                            int write, struct file * filp,
153                                            void __user *buffer, size_t *lenp,
154                                            loff_t *ppos)
155 {
156         ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
157         int ret;
158
159         tbl.data = kmalloc(tbl.maxlen, GFP_USER);
160         if (!tbl.data)
161                 return -ENOMEM;
162
163         tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
164         ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
165         if (write && ret == 0)
166                 ret = tcp_set_allowed_congestion_control(tbl.data);
167         kfree(tbl.data);
168         return ret;
169 }
170
171 static int strategy_allowed_congestion_control(ctl_table *table, int __user *name,
172                                                int nlen, void __user *oldval,
173                                                size_t __user *oldlenp,
174                                                void __user *newval,
175                                                size_t newlen)
176 {
177         ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
178         int ret;
179
180         tbl.data = kmalloc(tbl.maxlen, GFP_USER);
181         if (!tbl.data)
182                 return -ENOMEM;
183
184         tcp_get_available_congestion_control(tbl.data, tbl.maxlen);
185         ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
186         if (ret == 1 && newval && newlen)
187                 ret = tcp_set_allowed_congestion_control(tbl.data);
188         kfree(tbl.data);
189
190         return ret;
191
192 }
193
194 static struct ctl_table ipv4_table[] = {
195         {
196                 .ctl_name       = NET_IPV4_TCP_TIMESTAMPS,
197                 .procname       = "tcp_timestamps",
198                 .data           = &sysctl_tcp_timestamps,
199                 .maxlen         = sizeof(int),
200                 .mode           = 0644,
201                 .proc_handler   = &proc_dointvec
202         },
203         {
204                 .ctl_name       = NET_IPV4_TCP_WINDOW_SCALING,
205                 .procname       = "tcp_window_scaling",
206                 .data           = &sysctl_tcp_window_scaling,
207                 .maxlen         = sizeof(int),
208                 .mode           = 0644,
209                 .proc_handler   = &proc_dointvec
210         },
211         {
212                 .ctl_name       = NET_IPV4_TCP_SACK,
213                 .procname       = "tcp_sack",
214                 .data           = &sysctl_tcp_sack,
215                 .maxlen         = sizeof(int),
216                 .mode           = 0644,
217                 .proc_handler   = &proc_dointvec
218         },
219         {
220                 .ctl_name       = NET_IPV4_TCP_RETRANS_COLLAPSE,
221                 .procname       = "tcp_retrans_collapse",
222                 .data           = &sysctl_tcp_retrans_collapse,
223                 .maxlen         = sizeof(int),
224                 .mode           = 0644,
225                 .proc_handler   = &proc_dointvec
226         },
227         {
228                 .ctl_name       = NET_IPV4_DEFAULT_TTL,
229                 .procname       = "ip_default_ttl",
230                 .data           = &sysctl_ip_default_ttl,
231                 .maxlen         = sizeof(int),
232                 .mode           = 0644,
233                 .proc_handler   = &ipv4_doint_and_flush,
234                 .strategy       = &ipv4_doint_and_flush_strategy,
235         },
236         {
237                 .ctl_name       = NET_IPV4_NO_PMTU_DISC,
238                 .procname       = "ip_no_pmtu_disc",
239                 .data           = &ipv4_config.no_pmtu_disc,
240                 .maxlen         = sizeof(int),
241                 .mode           = 0644,
242                 .proc_handler   = &proc_dointvec
243         },
244         {
245                 .ctl_name       = NET_IPV4_NONLOCAL_BIND,
246                 .procname       = "ip_nonlocal_bind",
247                 .data           = &sysctl_ip_nonlocal_bind,
248                 .maxlen         = sizeof(int),
249                 .mode           = 0644,
250                 .proc_handler   = &proc_dointvec
251         },
252         {
253                 .ctl_name       = NET_IPV4_TCP_SYN_RETRIES,
254                 .procname       = "tcp_syn_retries",
255                 .data           = &sysctl_tcp_syn_retries,
256                 .maxlen         = sizeof(int),
257                 .mode           = 0644,
258                 .proc_handler   = &proc_dointvec
259         },
260         {
261                 .ctl_name       = NET_TCP_SYNACK_RETRIES,
262                 .procname       = "tcp_synack_retries",
263                 .data           = &sysctl_tcp_synack_retries,
264                 .maxlen         = sizeof(int),
265                 .mode           = 0644,
266                 .proc_handler   = &proc_dointvec
267         },
268         {
269                 .ctl_name       = NET_TCP_MAX_ORPHANS,
270                 .procname       = "tcp_max_orphans",
271                 .data           = &sysctl_tcp_max_orphans,
272                 .maxlen         = sizeof(int),
273                 .mode           = 0644,
274                 .proc_handler   = &proc_dointvec
275         },
276         {
277                 .ctl_name       = NET_TCP_MAX_TW_BUCKETS,
278                 .procname       = "tcp_max_tw_buckets",
279                 .data           = &tcp_death_row.sysctl_max_tw_buckets,
280                 .maxlen         = sizeof(int),
281                 .mode           = 0644,
282                 .proc_handler   = &proc_dointvec
283         },
284         {
285                 .ctl_name       = NET_IPV4_DYNADDR,
286                 .procname       = "ip_dynaddr",
287                 .data           = &sysctl_ip_dynaddr,
288                 .maxlen         = sizeof(int),
289                 .mode           = 0644,
290                 .proc_handler   = &proc_dointvec
291         },
292         {
293                 .ctl_name       = NET_IPV4_TCP_KEEPALIVE_TIME,
294                 .procname       = "tcp_keepalive_time",
295                 .data           = &sysctl_tcp_keepalive_time,
296                 .maxlen         = sizeof(int),
297                 .mode           = 0644,
298                 .proc_handler   = &proc_dointvec_jiffies,
299                 .strategy       = &sysctl_jiffies
300         },
301         {
302                 .ctl_name       = NET_IPV4_TCP_KEEPALIVE_PROBES,
303                 .procname       = "tcp_keepalive_probes",
304                 .data           = &sysctl_tcp_keepalive_probes,
305                 .maxlen         = sizeof(int),
306                 .mode           = 0644,
307                 .proc_handler   = &proc_dointvec
308         },
309         {
310                 .ctl_name       = NET_IPV4_TCP_KEEPALIVE_INTVL,
311                 .procname       = "tcp_keepalive_intvl",
312                 .data           = &sysctl_tcp_keepalive_intvl,
313                 .maxlen         = sizeof(int),
314                 .mode           = 0644,
315                 .proc_handler   = &proc_dointvec_jiffies,
316                 .strategy       = &sysctl_jiffies
317         },
318         {
319                 .ctl_name       = NET_IPV4_TCP_RETRIES1,
320                 .procname       = "tcp_retries1",
321                 .data           = &sysctl_tcp_retries1,
322                 .maxlen         = sizeof(int),
323                 .mode           = 0644,
324                 .proc_handler   = &proc_dointvec_minmax,
325                 .strategy       = &sysctl_intvec,
326                 .extra2         = &tcp_retr1_max
327         },
328         {
329                 .ctl_name       = NET_IPV4_TCP_RETRIES2,
330                 .procname       = "tcp_retries2",
331                 .data           = &sysctl_tcp_retries2,
332                 .maxlen         = sizeof(int),
333                 .mode           = 0644,
334                 .proc_handler   = &proc_dointvec
335         },
336         {
337                 .ctl_name       = NET_IPV4_TCP_FIN_TIMEOUT,
338                 .procname       = "tcp_fin_timeout",
339                 .data           = &sysctl_tcp_fin_timeout,
340                 .maxlen         = sizeof(int),
341                 .mode           = 0644,
342                 .proc_handler   = &proc_dointvec_jiffies,
343                 .strategy       = &sysctl_jiffies
344         },
345 #ifdef CONFIG_SYN_COOKIES
346         {
347                 .ctl_name       = NET_TCP_SYNCOOKIES,
348                 .procname       = "tcp_syncookies",
349                 .data           = &sysctl_tcp_syncookies,
350                 .maxlen         = sizeof(int),
351                 .mode           = 0644,
352                 .proc_handler   = &proc_dointvec
353         },
354 #endif
355         {
356                 .ctl_name       = NET_TCP_TW_RECYCLE,
357                 .procname       = "tcp_tw_recycle",
358                 .data           = &tcp_death_row.sysctl_tw_recycle,
359                 .maxlen         = sizeof(int),
360                 .mode           = 0644,
361                 .proc_handler   = &proc_dointvec
362         },
363         {
364                 .ctl_name       = NET_TCP_ABORT_ON_OVERFLOW,
365                 .procname       = "tcp_abort_on_overflow",
366                 .data           = &sysctl_tcp_abort_on_overflow,
367                 .maxlen         = sizeof(int),
368                 .mode           = 0644,
369                 .proc_handler   = &proc_dointvec
370         },
371         {
372                 .ctl_name       = NET_TCP_STDURG,
373                 .procname       = "tcp_stdurg",
374                 .data           = &sysctl_tcp_stdurg,
375                 .maxlen         = sizeof(int),
376                 .mode           = 0644,
377                 .proc_handler   = &proc_dointvec
378         },
379         {
380                 .ctl_name       = NET_TCP_RFC1337,
381                 .procname       = "tcp_rfc1337",
382                 .data           = &sysctl_tcp_rfc1337,
383                 .maxlen         = sizeof(int),
384                 .mode           = 0644,
385                 .proc_handler   = &proc_dointvec
386         },
387         {
388                 .ctl_name       = NET_TCP_MAX_SYN_BACKLOG,
389                 .procname       = "tcp_max_syn_backlog",
390                 .data           = &sysctl_max_syn_backlog,
391                 .maxlen         = sizeof(int),
392                 .mode           = 0644,
393                 .proc_handler   = &proc_dointvec
394         },
395         {
396                 .ctl_name       = NET_IPV4_LOCAL_PORT_RANGE,
397                 .procname       = "ip_local_port_range",
398                 .data           = &sysctl_local_port_range,
399                 .maxlen         = sizeof(sysctl_local_port_range),
400                 .mode           = 0644,
401                 .proc_handler   = &ipv4_local_port_range,
402                 .strategy       = &ipv4_sysctl_local_port_range,
403         },
404         {
405                 .ctl_name       = NET_IPV4_ROUTE,
406                 .procname       = "route",
407                 .maxlen         = 0,
408                 .mode           = 0555,
409                 .child          = ipv4_route_table
410         },
411 #ifdef CONFIG_IP_MULTICAST
412         {
413                 .ctl_name       = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
414                 .procname       = "igmp_max_memberships",
415                 .data           = &sysctl_igmp_max_memberships,
416                 .maxlen         = sizeof(int),
417                 .mode           = 0644,
418                 .proc_handler   = &proc_dointvec
419         },
420
421 #endif
422         {
423                 .ctl_name       = NET_IPV4_IGMP_MAX_MSF,
424                 .procname       = "igmp_max_msf",
425                 .data           = &sysctl_igmp_max_msf,
426                 .maxlen         = sizeof(int),
427                 .mode           = 0644,
428                 .proc_handler   = &proc_dointvec
429         },
430         {
431                 .ctl_name       = NET_IPV4_INET_PEER_THRESHOLD,
432                 .procname       = "inet_peer_threshold",
433                 .data           = &inet_peer_threshold,
434                 .maxlen         = sizeof(int),
435                 .mode           = 0644,
436                 .proc_handler   = &proc_dointvec
437         },
438         {
439                 .ctl_name       = NET_IPV4_INET_PEER_MINTTL,
440                 .procname       = "inet_peer_minttl",
441                 .data           = &inet_peer_minttl,
442                 .maxlen         = sizeof(int),
443                 .mode           = 0644,
444                 .proc_handler   = &proc_dointvec_jiffies,
445                 .strategy       = &sysctl_jiffies
446         },
447         {
448                 .ctl_name       = NET_IPV4_INET_PEER_MAXTTL,
449                 .procname       = "inet_peer_maxttl",
450                 .data           = &inet_peer_maxttl,
451                 .maxlen         = sizeof(int),
452                 .mode           = 0644,
453                 .proc_handler   = &proc_dointvec_jiffies,
454                 .strategy       = &sysctl_jiffies
455         },
456         {
457                 .ctl_name       = NET_IPV4_INET_PEER_GC_MINTIME,
458                 .procname       = "inet_peer_gc_mintime",
459                 .data           = &inet_peer_gc_mintime,
460                 .maxlen         = sizeof(int),
461                 .mode           = 0644,
462                 .proc_handler   = &proc_dointvec_jiffies,
463                 .strategy       = &sysctl_jiffies
464         },
465         {
466                 .ctl_name       = NET_IPV4_INET_PEER_GC_MAXTIME,
467                 .procname       = "inet_peer_gc_maxtime",
468                 .data           = &inet_peer_gc_maxtime,
469                 .maxlen         = sizeof(int),
470                 .mode           = 0644,
471                 .proc_handler   = &proc_dointvec_jiffies,
472                 .strategy       = &sysctl_jiffies
473         },
474         {
475                 .ctl_name       = NET_TCP_ORPHAN_RETRIES,
476                 .procname       = "tcp_orphan_retries",
477                 .data           = &sysctl_tcp_orphan_retries,
478                 .maxlen         = sizeof(int),
479                 .mode           = 0644,
480                 .proc_handler   = &proc_dointvec
481         },
482         {
483                 .ctl_name       = NET_TCP_FACK,
484                 .procname       = "tcp_fack",
485                 .data           = &sysctl_tcp_fack,
486                 .maxlen         = sizeof(int),
487                 .mode           = 0644,
488                 .proc_handler   = &proc_dointvec
489         },
490         {
491                 .ctl_name       = NET_TCP_REORDERING,
492                 .procname       = "tcp_reordering",
493                 .data           = &sysctl_tcp_reordering,
494                 .maxlen         = sizeof(int),
495                 .mode           = 0644,
496                 .proc_handler   = &proc_dointvec
497         },
498         {
499                 .ctl_name       = NET_TCP_ECN,
500                 .procname       = "tcp_ecn",
501                 .data           = &sysctl_tcp_ecn,
502                 .maxlen         = sizeof(int),
503                 .mode           = 0644,
504                 .proc_handler   = &proc_dointvec
505         },
506         {
507                 .ctl_name       = NET_TCP_DSACK,
508                 .procname       = "tcp_dsack",
509                 .data           = &sysctl_tcp_dsack,
510                 .maxlen         = sizeof(int),
511                 .mode           = 0644,
512                 .proc_handler   = &proc_dointvec
513         },
514         {
515                 .ctl_name       = NET_TCP_MEM,
516                 .procname       = "tcp_mem",
517                 .data           = &sysctl_tcp_mem,
518                 .maxlen         = sizeof(sysctl_tcp_mem),
519                 .mode           = 0644,
520                 .proc_handler   = &proc_dointvec
521         },
522         {
523                 .ctl_name       = NET_TCP_WMEM,
524                 .procname       = "tcp_wmem",
525                 .data           = &sysctl_tcp_wmem,
526                 .maxlen         = sizeof(sysctl_tcp_wmem),
527                 .mode           = 0644,
528                 .proc_handler   = &proc_dointvec
529         },
530         {
531                 .ctl_name       = NET_TCP_RMEM,
532                 .procname       = "tcp_rmem",
533                 .data           = &sysctl_tcp_rmem,
534                 .maxlen         = sizeof(sysctl_tcp_rmem),
535                 .mode           = 0644,
536                 .proc_handler   = &proc_dointvec
537         },
538         {
539                 .ctl_name       = NET_TCP_APP_WIN,
540                 .procname       = "tcp_app_win",
541                 .data           = &sysctl_tcp_app_win,
542                 .maxlen         = sizeof(int),
543                 .mode           = 0644,
544                 .proc_handler   = &proc_dointvec
545         },
546         {
547                 .ctl_name       = NET_TCP_ADV_WIN_SCALE,
548                 .procname       = "tcp_adv_win_scale",
549                 .data           = &sysctl_tcp_adv_win_scale,
550                 .maxlen         = sizeof(int),
551                 .mode           = 0644,
552                 .proc_handler   = &proc_dointvec
553         },
554         {
555                 .ctl_name       = NET_TCP_TW_REUSE,
556                 .procname       = "tcp_tw_reuse",
557                 .data           = &sysctl_tcp_tw_reuse,
558                 .maxlen         = sizeof(int),
559                 .mode           = 0644,
560                 .proc_handler   = &proc_dointvec
561         },
562         {
563                 .ctl_name       = NET_TCP_FRTO,
564                 .procname       = "tcp_frto",
565                 .data           = &sysctl_tcp_frto,
566                 .maxlen         = sizeof(int),
567                 .mode           = 0644,
568                 .proc_handler   = &proc_dointvec
569         },
570         {
571                 .ctl_name       = NET_TCP_FRTO_RESPONSE,
572                 .procname       = "tcp_frto_response",
573                 .data           = &sysctl_tcp_frto_response,
574                 .maxlen         = sizeof(int),
575                 .mode           = 0644,
576                 .proc_handler   = &proc_dointvec
577         },
578         {
579                 .ctl_name       = NET_TCP_LOW_LATENCY,
580                 .procname       = "tcp_low_latency",
581                 .data           = &sysctl_tcp_low_latency,
582                 .maxlen         = sizeof(int),
583                 .mode           = 0644,
584                 .proc_handler   = &proc_dointvec
585         },
586         {
587                 .ctl_name       = NET_TCP_NO_METRICS_SAVE,
588                 .procname       = "tcp_no_metrics_save",
589                 .data           = &sysctl_tcp_nometrics_save,
590                 .maxlen         = sizeof(int),
591                 .mode           = 0644,
592                 .proc_handler   = &proc_dointvec,
593         },
594         {
595                 .ctl_name       = NET_TCP_MODERATE_RCVBUF,
596                 .procname       = "tcp_moderate_rcvbuf",
597                 .data           = &sysctl_tcp_moderate_rcvbuf,
598                 .maxlen         = sizeof(int),
599                 .mode           = 0644,
600                 .proc_handler   = &proc_dointvec,
601         },
602         {
603                 .ctl_name       = NET_TCP_TSO_WIN_DIVISOR,
604                 .procname       = "tcp_tso_win_divisor",
605                 .data           = &sysctl_tcp_tso_win_divisor,
606                 .maxlen         = sizeof(int),
607                 .mode           = 0644,
608                 .proc_handler   = &proc_dointvec,
609         },
610         {
611                 .ctl_name       = NET_TCP_CONG_CONTROL,
612                 .procname       = "tcp_congestion_control",
613                 .mode           = 0644,
614                 .maxlen         = TCP_CA_NAME_MAX,
615                 .proc_handler   = &proc_tcp_congestion_control,
616                 .strategy       = &sysctl_tcp_congestion_control,
617         },
618         {
619                 .ctl_name       = NET_TCP_ABC,
620                 .procname       = "tcp_abc",
621                 .data           = &sysctl_tcp_abc,
622                 .maxlen         = sizeof(int),
623                 .mode           = 0644,
624                 .proc_handler   = &proc_dointvec,
625         },
626         {
627                 .ctl_name       = NET_TCP_MTU_PROBING,
628                 .procname       = "tcp_mtu_probing",
629                 .data           = &sysctl_tcp_mtu_probing,
630                 .maxlen         = sizeof(int),
631                 .mode           = 0644,
632                 .proc_handler   = &proc_dointvec,
633         },
634         {
635                 .ctl_name       = NET_TCP_BASE_MSS,
636                 .procname       = "tcp_base_mss",
637                 .data           = &sysctl_tcp_base_mss,
638                 .maxlen         = sizeof(int),
639                 .mode           = 0644,
640                 .proc_handler   = &proc_dointvec,
641         },
642         {
643                 .ctl_name       = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
644                 .procname       = "tcp_workaround_signed_windows",
645                 .data           = &sysctl_tcp_workaround_signed_windows,
646                 .maxlen         = sizeof(int),
647                 .mode           = 0644,
648                 .proc_handler   = &proc_dointvec
649         },
650 #ifdef CONFIG_NET_DMA
651         {
652                 .ctl_name       = NET_TCP_DMA_COPYBREAK,
653                 .procname       = "tcp_dma_copybreak",
654                 .data           = &sysctl_tcp_dma_copybreak,
655                 .maxlen         = sizeof(int),
656                 .mode           = 0644,
657                 .proc_handler   = &proc_dointvec
658         },
659 #endif
660         {
661                 .ctl_name       = NET_TCP_SLOW_START_AFTER_IDLE,
662                 .procname       = "tcp_slow_start_after_idle",
663                 .data           = &sysctl_tcp_slow_start_after_idle,
664                 .maxlen         = sizeof(int),
665                 .mode           = 0644,
666                 .proc_handler   = &proc_dointvec
667         },
668 #ifdef CONFIG_NETLABEL
669         {
670                 .ctl_name       = NET_CIPSOV4_CACHE_ENABLE,
671                 .procname       = "cipso_cache_enable",
672                 .data           = &cipso_v4_cache_enabled,
673                 .maxlen         = sizeof(int),
674                 .mode           = 0644,
675                 .proc_handler   = &proc_dointvec,
676         },
677         {
678                 .ctl_name       = NET_CIPSOV4_CACHE_BUCKET_SIZE,
679                 .procname       = "cipso_cache_bucket_size",
680                 .data           = &cipso_v4_cache_bucketsize,
681                 .maxlen         = sizeof(int),
682                 .mode           = 0644,
683                 .proc_handler   = &proc_dointvec,
684         },
685         {
686                 .ctl_name       = NET_CIPSOV4_RBM_OPTFMT,
687                 .procname       = "cipso_rbm_optfmt",
688                 .data           = &cipso_v4_rbm_optfmt,
689                 .maxlen         = sizeof(int),
690                 .mode           = 0644,
691                 .proc_handler   = &proc_dointvec,
692         },
693         {
694                 .ctl_name       = NET_CIPSOV4_RBM_STRICTVALID,
695                 .procname       = "cipso_rbm_strictvalid",
696                 .data           = &cipso_v4_rbm_strictvalid,
697                 .maxlen         = sizeof(int),
698                 .mode           = 0644,
699                 .proc_handler   = &proc_dointvec,
700         },
701 #endif /* CONFIG_NETLABEL */
702         {
703                 .procname       = "tcp_available_congestion_control",
704                 .maxlen         = TCP_CA_BUF_MAX,
705                 .mode           = 0444,
706                 .proc_handler   = &proc_tcp_available_congestion_control,
707         },
708         {
709                 .ctl_name       = NET_TCP_ALLOWED_CONG_CONTROL,
710                 .procname       = "tcp_allowed_congestion_control",
711                 .maxlen         = TCP_CA_BUF_MAX,
712                 .mode           = 0644,
713                 .proc_handler   = &proc_allowed_congestion_control,
714                 .strategy       = &strategy_allowed_congestion_control,
715         },
716         {
717                 .ctl_name       = NET_TCP_MAX_SSTHRESH,
718                 .procname       = "tcp_max_ssthresh",
719                 .data           = &sysctl_tcp_max_ssthresh,
720                 .maxlen         = sizeof(int),
721                 .mode           = 0644,
722                 .proc_handler   = &proc_dointvec,
723         },
724         {
725                 .ctl_name       = CTL_UNNUMBERED,
726                 .procname       = "udp_mem",
727                 .data           = &sysctl_udp_mem,
728                 .maxlen         = sizeof(sysctl_udp_mem),
729                 .mode           = 0644,
730                 .proc_handler   = &proc_dointvec_minmax,
731                 .strategy       = &sysctl_intvec,
732                 .extra1         = &zero
733         },
734         {
735                 .ctl_name       = CTL_UNNUMBERED,
736                 .procname       = "udp_rmem_min",
737                 .data           = &sysctl_udp_rmem_min,
738                 .maxlen         = sizeof(sysctl_udp_rmem_min),
739                 .mode           = 0644,
740                 .proc_handler   = &proc_dointvec_minmax,
741                 .strategy       = &sysctl_intvec,
742                 .extra1         = &zero
743         },
744         {
745                 .ctl_name       = CTL_UNNUMBERED,
746                 .procname       = "udp_wmem_min",
747                 .data           = &sysctl_udp_wmem_min,
748                 .maxlen         = sizeof(sysctl_udp_wmem_min),
749                 .mode           = 0644,
750                 .proc_handler   = &proc_dointvec_minmax,
751                 .strategy       = &sysctl_intvec,
752                 .extra1         = &zero
753         },
754         { .ctl_name = 0 }
755 };
756
757 static struct ctl_table ipv4_net_table[] = {
758         {
759                 .ctl_name       = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
760                 .procname       = "icmp_echo_ignore_all",
761                 .data           = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
762                 .maxlen         = sizeof(int),
763                 .mode           = 0644,
764                 .proc_handler   = &proc_dointvec
765         },
766         {
767                 .ctl_name       = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
768                 .procname       = "icmp_echo_ignore_broadcasts",
769                 .data           = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
770                 .maxlen         = sizeof(int),
771                 .mode           = 0644,
772                 .proc_handler   = &proc_dointvec
773         },
774         {
775                 .ctl_name       = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
776                 .procname       = "icmp_ignore_bogus_error_responses",
777                 .data           = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
778                 .maxlen         = sizeof(int),
779                 .mode           = 0644,
780                 .proc_handler   = &proc_dointvec
781         },
782         {
783                 .ctl_name       = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
784                 .procname       = "icmp_errors_use_inbound_ifaddr",
785                 .data           = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
786                 .maxlen         = sizeof(int),
787                 .mode           = 0644,
788                 .proc_handler   = &proc_dointvec
789         },
790         {
791                 .ctl_name       = NET_IPV4_ICMP_RATELIMIT,
792                 .procname       = "icmp_ratelimit",
793                 .data           = &init_net.ipv4.sysctl_icmp_ratelimit,
794                 .maxlen         = sizeof(int),
795                 .mode           = 0644,
796                 .proc_handler   = &proc_dointvec
797         },
798         {
799                 .ctl_name       = NET_IPV4_ICMP_RATEMASK,
800                 .procname       = "icmp_ratemask",
801                 .data           = &init_net.ipv4.sysctl_icmp_ratemask,
802                 .maxlen         = sizeof(int),
803                 .mode           = 0644,
804                 .proc_handler   = &proc_dointvec
805         },
806         { }
807 };
808
809 struct ctl_path net_ipv4_ctl_path[] = {
810         { .procname = "net", .ctl_name = CTL_NET, },
811         { .procname = "ipv4", .ctl_name = NET_IPV4, },
812         { },
813 };
814 EXPORT_SYMBOL_GPL(net_ipv4_ctl_path);
815
816 static __net_init int ipv4_sysctl_init_net(struct net *net)
817 {
818         struct ctl_table *table;
819
820         table = ipv4_net_table;
821         if (net != &init_net) {
822                 table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
823                 if (table == NULL)
824                         goto err_alloc;
825
826                 table[0].data =
827                         &net->ipv4.sysctl_icmp_echo_ignore_all;
828                 table[1].data =
829                         &net->ipv4.sysctl_icmp_echo_ignore_broadcasts;
830                 table[2].data =
831                         &net->ipv4.sysctl_icmp_ignore_bogus_error_responses;
832                 table[3].data =
833                         &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr;
834                 table[4].data =
835                         &net->ipv4.sysctl_icmp_ratelimit;
836                 table[5].data =
837                         &net->ipv4.sysctl_icmp_ratemask;
838         }
839
840         net->ipv4.ipv4_hdr = register_net_sysctl_table(net,
841                         net_ipv4_ctl_path, table);
842         if (net->ipv4.ipv4_hdr == NULL)
843                 goto err_reg;
844
845         return 0;
846
847 err_reg:
848         if (net != &init_net)
849                 kfree(table);
850 err_alloc:
851         return -ENOMEM;
852 }
853
854 static __net_exit void ipv4_sysctl_exit_net(struct net *net)
855 {
856         struct ctl_table *table;
857
858         table = net->ipv4.ipv4_hdr->ctl_table_arg;
859         unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
860         kfree(table);
861 }
862
863 static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
864         .init = ipv4_sysctl_init_net,
865         .exit = ipv4_sysctl_exit_net,
866 };
867
868 static __init int sysctl_ipv4_init(void)
869 {
870         struct ctl_table_header *hdr;
871
872         hdr = register_sysctl_paths(net_ipv4_ctl_path, ipv4_table);
873         if (hdr == NULL)
874                 return -ENOMEM;
875
876         if (register_pernet_subsys(&ipv4_sysctl_ops)) {
877                 unregister_sysctl_table(hdr);
878                 return -ENOMEM;
879         }
880
881         return 0;
882 }
883
884 __initcall(sysctl_ipv4_init);