]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/sysctl_net_ipv4.c
tcp FRTO: Fix fallback to conventional recovery
[linux-2.6-omap-h63xx.git] / net / ipv4 / sysctl_net_ipv4.c
index bec6fe880657b9149228ac191ac1cb309f6bc05a..c437f804ee3883ccab3a4ad1ce462d929061d8ac 100644 (file)
 #include <linux/igmp.h>
 #include <linux/inetdevice.h>
 #include <linux/seqlock.h>
+#include <linux/init.h>
 #include <net/snmp.h>
 #include <net/icmp.h>
 #include <net/ip.h>
 #include <net/route.h>
 #include <net/tcp.h>
+#include <net/udp.h>
 #include <net/cipso_ipv4.h>
 #include <net/inet_frag.h>
 
-/* From af_inet.c */
-extern int sysctl_ip_nonlocal_bind;
-
-#ifdef CONFIG_SYSCTL
 static int zero;
 static int tcp_retr1_max = 255;
 static int ip_local_port_range_min[] = { 1, 1 };
 static int ip_local_port_range_max[] = { 65535, 65535 };
-#endif
-
-struct ipv4_config ipv4_config;
-
-#ifdef CONFIG_SYSCTL
-
-static
-int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
-                       void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int val = IPV4_DEVCONF_ALL(FORWARDING);
-       int ret;
-
-       ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
-
-       if (write && IPV4_DEVCONF_ALL(FORWARDING) != val)
-               inet_forward_change();
-
-       return ret;
-}
-
-static int ipv4_sysctl_forward_strategy(ctl_table *table,
-                        int __user *name, int nlen,
-                        void __user *oldval, size_t __user *oldlenp,
-                        void __user *newval, size_t newlen)
-{
-       int *valp = table->data;
-       int new;
-
-       if (!newval || !newlen)
-               return 0;
-
-       if (newlen != sizeof(int))
-               return -EINVAL;
-
-       if (get_user(new, (int __user *)newval))
-               return -EFAULT;
-
-       if (new == *valp)
-               return 0;
-
-       if (oldval && oldlenp) {
-               size_t len;
-
-               if (get_user(len, oldlenp))
-                       return -EFAULT;
-
-               if (len) {
-                       if (len > table->maxlen)
-                               len = table->maxlen;
-                       if (copy_to_user(oldval, valp, len))
-                               return -EFAULT;
-                       if (put_user(len, oldlenp))
-                               return -EFAULT;
-               }
-       }
-
-       *valp = new;
-       inet_forward_change();
-       return 1;
-}
 
 extern seqlock_t sysctl_port_range_lock;
 extern int sysctl_local_port_range[2];
@@ -248,7 +185,7 @@ static int strategy_allowed_congestion_control(ctl_table *table, int __user *nam
 
        tcp_get_available_congestion_control(tbl.data, tbl.maxlen);
        ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
-       if (ret == 0 && newval && newlen)
+       if (ret == 1 && newval && newlen)
                ret = tcp_set_allowed_congestion_control(tbl.data);
        kfree(tbl.data);
 
@@ -256,7 +193,7 @@ static int strategy_allowed_congestion_control(ctl_table *table, int __user *nam
 
 }
 
-ctl_table ipv4_table[] = {
+static struct ctl_table ipv4_table[] = {
        {
                .ctl_name       = NET_IPV4_TCP_TIMESTAMPS,
                .procname       = "tcp_timestamps",
@@ -289,15 +226,6 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-       {
-               .ctl_name       = NET_IPV4_FORWARD,
-               .procname       = "ip_forward",
-               .data           = &IPV4_DEVCONF_ALL(FORWARDING),
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &ipv4_sysctl_forward,
-               .strategy       = &ipv4_sysctl_forward_strategy
-       },
        {
                .ctl_name       = NET_IPV4_DEFAULT_TTL,
                .procname       = "ip_default_ttl",
@@ -355,22 +283,6 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-       {
-               .ctl_name       = NET_IPV4_IPFRAG_HIGH_THRESH,
-               .procname       = "ipfrag_high_thresh",
-               .data           = &ip4_frags_ctl.high_thresh,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
-       {
-               .ctl_name       = NET_IPV4_IPFRAG_LOW_THRESH,
-               .procname       = "ipfrag_low_thresh",
-               .data           = &ip4_frags_ctl.low_thresh,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
        {
                .ctl_name       = NET_IPV4_DYNADDR,
                .procname       = "ip_dynaddr",
@@ -379,15 +291,6 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-       {
-               .ctl_name       = NET_IPV4_IPFRAG_TIME,
-               .procname       = "ipfrag_time",
-               .data           = &ip4_frags_ctl.timeout,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_jiffies,
-               .strategy       = &sysctl_jiffies
-       },
        {
                .ctl_name       = NET_IPV4_TCP_KEEPALIVE_TIME,
                .procname       = "tcp_keepalive_time",
@@ -500,38 +403,6 @@ ctl_table ipv4_table[] = {
                .proc_handler   = &ipv4_local_port_range,
                .strategy       = &ipv4_sysctl_local_port_range,
        },
-       {
-               .ctl_name       = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
-               .procname       = "icmp_echo_ignore_all",
-               .data           = &sysctl_icmp_echo_ignore_all,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
-       {
-               .ctl_name       = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
-               .procname       = "icmp_echo_ignore_broadcasts",
-               .data           = &sysctl_icmp_echo_ignore_broadcasts,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
-       {
-               .ctl_name       = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
-               .procname       = "icmp_ignore_bogus_error_responses",
-               .data           = &sysctl_icmp_ignore_bogus_error_responses,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
-       {
-               .ctl_name       = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
-               .procname       = "icmp_errors_use_inbound_ifaddr",
-               .data           = &sysctl_icmp_errors_use_inbound_ifaddr,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
        {
                .ctl_name       = NET_IPV4_ROUTE,
                .procname       = "route",
@@ -682,22 +553,6 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-       {
-               .ctl_name       = NET_IPV4_ICMP_RATELIMIT,
-               .procname       = "icmp_ratelimit",
-               .data           = &sysctl_icmp_ratelimit,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
-       {
-               .ctl_name       = NET_IPV4_ICMP_RATEMASK,
-               .procname       = "icmp_ratemask",
-               .data           = &sysctl_icmp_ratemask,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec
-       },
        {
                .ctl_name       = NET_TCP_TW_REUSE,
                .procname       = "tcp_tw_reuse",
@@ -730,23 +585,6 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-       {
-               .ctl_name       = NET_IPV4_IPFRAG_SECRET_INTERVAL,
-               .procname       = "ipfrag_secret_interval",
-               .data           = &ip4_frags_ctl.secret_interval,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_jiffies,
-               .strategy       = &sysctl_jiffies
-       },
-       {
-               .procname       = "ipfrag_max_dist",
-               .data           = &sysctl_ipfrag_max_dist,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = &proc_dointvec_minmax,
-               .extra1         = &zero
-       },
        {
                .ctl_name       = NET_TCP_NO_METRICS_SAVE,
                .procname       = "tcp_no_metrics_save",
@@ -885,9 +723,164 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "udp_mem",
+               .data           = &sysctl_udp_mem,
+               .maxlen         = sizeof(sysctl_udp_mem),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &zero
+       },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "udp_rmem_min",
+               .data           = &sysctl_udp_rmem_min,
+               .maxlen         = sizeof(sysctl_udp_rmem_min),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &zero
+       },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "udp_wmem_min",
+               .data           = &sysctl_udp_wmem_min,
+               .maxlen         = sizeof(sysctl_udp_wmem_min),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec_minmax,
+               .strategy       = &sysctl_intvec,
+               .extra1         = &zero
+       },
        { .ctl_name = 0 }
 };
 
-#endif /* CONFIG_SYSCTL */
+static struct ctl_table ipv4_net_table[] = {
+       {
+               .ctl_name       = NET_IPV4_ICMP_ECHO_IGNORE_ALL,
+               .procname       = "icmp_echo_ignore_all",
+               .data           = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,
+               .procname       = "icmp_echo_ignore_broadcasts",
+               .data           = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES,
+               .procname       = "icmp_ignore_bogus_error_responses",
+               .data           = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
+               .procname       = "icmp_errors_use_inbound_ifaddr",
+               .data           = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_RATELIMIT,
+               .procname       = "icmp_ratelimit",
+               .data           = &init_net.ipv4.sysctl_icmp_ratelimit,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       {
+               .ctl_name       = NET_IPV4_ICMP_RATEMASK,
+               .procname       = "icmp_ratemask",
+               .data           = &init_net.ipv4.sysctl_icmp_ratemask,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
+       { }
+};
+
+struct ctl_path net_ipv4_ctl_path[] = {
+       { .procname = "net", .ctl_name = CTL_NET, },
+       { .procname = "ipv4", .ctl_name = NET_IPV4, },
+       { },
+};
+EXPORT_SYMBOL_GPL(net_ipv4_ctl_path);
+
+static __net_init int ipv4_sysctl_init_net(struct net *net)
+{
+       struct ctl_table *table;
+
+       table = ipv4_net_table;
+       if (net != &init_net) {
+               table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
+               if (table == NULL)
+                       goto err_alloc;
+
+               table[0].data =
+                       &net->ipv4.sysctl_icmp_echo_ignore_all;
+               table[1].data =
+                       &net->ipv4.sysctl_icmp_echo_ignore_broadcasts;
+               table[2].data =
+                       &net->ipv4.sysctl_icmp_ignore_bogus_error_responses;
+               table[3].data =
+                       &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr;
+               table[4].data =
+                       &net->ipv4.sysctl_icmp_ratelimit;
+               table[5].data =
+                       &net->ipv4.sysctl_icmp_ratemask;
+       }
+
+       net->ipv4.ipv4_hdr = register_net_sysctl_table(net,
+                       net_ipv4_ctl_path, table);
+       if (net->ipv4.ipv4_hdr == NULL)
+               goto err_reg;
+
+       return 0;
+
+err_reg:
+       if (net != &init_net)
+               kfree(table);
+err_alloc:
+       return -ENOMEM;
+}
+
+static __net_exit void ipv4_sysctl_exit_net(struct net *net)
+{
+       struct ctl_table *table;
+
+       table = net->ipv4.ipv4_hdr->ctl_table_arg;
+       unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
+       kfree(table);
+}
+
+static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
+       .init = ipv4_sysctl_init_net,
+       .exit = ipv4_sysctl_exit_net,
+};
+
+static __init int sysctl_ipv4_init(void)
+{
+       struct ctl_table_header *hdr;
+
+       hdr = register_sysctl_paths(net_ipv4_ctl_path, ipv4_table);
+       if (hdr == NULL)
+               return -ENOMEM;
+
+       if (register_pernet_subsys(&ipv4_sysctl_ops)) {
+               unregister_sysctl_table(hdr);
+               return -ENOMEM;
+       }
+
+       return 0;
+}
 
-EXPORT_SYMBOL(ipv4_config);
+__initcall(sysctl_ipv4_init);