Merge branch 'kill-jffs' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/misc-2.6
[powerpc.git] / net / ipv4 / sysctl_net_ipv4.c
index e82a5be..0aa3047 100644 (file)
@@ -24,7 +24,7 @@ extern int sysctl_ip_nonlocal_bind;
 
 #ifdef CONFIG_SYSCTL
 static int zero;
-static int tcp_retr1_max = 255; 
+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
@@ -51,8 +51,7 @@ int ipv4_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
 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, 
-                        void **context)
+                        void __user *newval, size_t newlen)
 {
        int *valp = table->data;
        int new;
@@ -111,8 +110,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write, struct file *
 static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
                                         int nlen, void __user *oldval,
                                         size_t __user *oldlenp,
-                                        void __user *newval, size_t newlen,
-                                        void **context)
+                                        void __user *newval, size_t newlen)
 {
        char val[TCP_CA_NAME_MAX];
        ctl_table tbl = {
@@ -122,22 +120,74 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
        int ret;
 
        tcp_get_default_congestion_control(val);
-       ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen,
-                           context);
+       ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
        if (ret == 0 && newval && newlen)
                ret = tcp_set_default_congestion_control(val);
        return ret;
 }
 
-static int __init tcp_congestion_default(void)
+static int proc_tcp_available_congestion_control(ctl_table *ctl,
+                                                int write, struct file * filp,
+                                                void __user *buffer, size_t *lenp,
+                                                loff_t *ppos)
 {
-       return tcp_set_default_congestion_control(CONFIG_DEFAULT_TCP_CONG);
+       ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
+       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);
+       ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
+       kfree(tbl.data);
+       return ret;
+}
+
+static int proc_allowed_congestion_control(ctl_table *ctl,
+                                          int write, struct file * filp,
+                                          void __user *buffer, size_t *lenp,
+                                          loff_t *ppos)
+{
+       ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
+       int ret;
+
+       tbl.data = kmalloc(tbl.maxlen, GFP_USER);
+       if (!tbl.data)
+               return -ENOMEM;
+
+       tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
+       ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
+       if (write && ret == 0)
+               ret = tcp_set_allowed_congestion_control(tbl.data);
+       kfree(tbl.data);
+       return ret;
 }
 
-late_initcall(tcp_congestion_default);
+static int strategy_allowed_congestion_control(ctl_table *table, int __user *name,
+                                              int nlen, void __user *oldval,
+                                              size_t __user *oldlenp,
+                                              void __user *newval,
+                                              size_t newlen)
+{
+       ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
+       int ret;
+
+       tbl.data = kmalloc(tbl.maxlen, GFP_USER);
+       if (!tbl.data)
+               return -ENOMEM;
+
+       tcp_get_available_congestion_control(tbl.data, tbl.maxlen);
+       ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
+       if (ret == 0 && newval && newlen)
+               ret = tcp_set_allowed_congestion_control(tbl.data);
+       kfree(tbl.data);
+
+       return ret;
+
+}
 
 ctl_table ipv4_table[] = {
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_TIMESTAMPS,
                .procname       = "tcp_timestamps",
                .data           = &sysctl_tcp_timestamps,
@@ -145,7 +195,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_WINDOW_SCALING,
                .procname       = "tcp_window_scaling",
                .data           = &sysctl_tcp_window_scaling,
@@ -153,7 +203,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_SACK,
                .procname       = "tcp_sack",
                .data           = &sysctl_tcp_sack,
@@ -161,7 +211,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_RETRANS_COLLAPSE,
                .procname       = "tcp_retrans_collapse",
                .data           = &sysctl_tcp_retrans_collapse,
@@ -169,7 +219,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
        },
-        {
+       {
                .ctl_name       = NET_IPV4_FORWARD,
                .procname       = "ip_forward",
                .data           = &ipv4_devconf.forwarding,
@@ -178,16 +228,16 @@ ctl_table ipv4_table[] = {
                .proc_handler   = &ipv4_sysctl_forward,
                .strategy       = &ipv4_sysctl_forward_strategy
        },
-        {
+       {
                .ctl_name       = NET_IPV4_DEFAULT_TTL,
                .procname       = "ip_default_ttl",
-               .data           = &sysctl_ip_default_ttl,
+               .data           = &sysctl_ip_default_ttl,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &ipv4_doint_and_flush,
                .strategy       = &ipv4_doint_and_flush_strategy,
        },
-        {
+       {
                .ctl_name       = NET_IPV4_NO_PMTU_DISC,
                .procname       = "ip_no_pmtu_disc",
                .data           = &ipv4_config.no_pmtu_disc,
@@ -678,7 +728,7 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
-        {
+       {
                .ctl_name       = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
                .procname       = "tcp_workaround_signed_windows",
                .data           = &sysctl_tcp_workaround_signed_windows,
@@ -738,6 +788,21 @@ ctl_table ipv4_table[] = {
                .proc_handler   = &proc_dointvec,
        },
 #endif /* CONFIG_NETLABEL */
+       {
+               .ctl_name       = NET_TCP_AVAIL_CONG_CONTROL,
+               .procname       = "tcp_available_congestion_control",
+               .maxlen         = TCP_CA_BUF_MAX,
+               .mode           = 0444,
+               .proc_handler   = &proc_tcp_available_congestion_control,
+       },
+       {
+               .ctl_name       = NET_TCP_ALLOWED_CONG_CONTROL,
+               .procname       = "tcp_allowed_congestion_control",
+               .maxlen         = TCP_CA_BUF_MAX,
+               .mode           = 0644,
+               .proc_handler   = &proc_allowed_congestion_control,
+               .strategy       = &strategy_allowed_congestion_control,
+       },
        { .ctl_name = 0 }
 };