diff options
| author | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 15:06:28 +0900 | 
|---|---|---|
| committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 15:06:28 +0900 | 
| commit | f43dc23d5ea91fca257be02138a255f02d98e806 (patch) | |
| tree | b29722f6e965316e90ac97abf79923ced250dc21 /net/core/sysctl_net_core.c | |
| parent | f8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff) | |
| parent | 4162cf64973df51fc885825bc9ca4d055891c49f (diff) | |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts:
	arch/sh/kernel/cpu/sh2/setup-sh7619.c
	arch/sh/kernel/cpu/sh2a/setup-mxg.c
	arch/sh/kernel/cpu/sh2a/setup-sh7201.c
	arch/sh/kernel/cpu/sh2a/setup-sh7203.c
	arch/sh/kernel/cpu/sh2a/setup-sh7206.c
	arch/sh/kernel/cpu/sh3/setup-sh7705.c
	arch/sh/kernel/cpu/sh3/setup-sh770x.c
	arch/sh/kernel/cpu/sh3/setup-sh7710.c
	arch/sh/kernel/cpu/sh3/setup-sh7720.c
	arch/sh/kernel/cpu/sh4/setup-sh4-202.c
	arch/sh/kernel/cpu/sh4/setup-sh7750.c
	arch/sh/kernel/cpu/sh4/setup-sh7760.c
	arch/sh/kernel/cpu/sh4a/setup-sh7343.c
	arch/sh/kernel/cpu/sh4a/setup-sh7366.c
	arch/sh/kernel/cpu/sh4a/setup-sh7722.c
	arch/sh/kernel/cpu/sh4a/setup-sh7723.c
	arch/sh/kernel/cpu/sh4a/setup-sh7724.c
	arch/sh/kernel/cpu/sh4a/setup-sh7763.c
	arch/sh/kernel/cpu/sh4a/setup-sh7770.c
	arch/sh/kernel/cpu/sh4a/setup-sh7780.c
	arch/sh/kernel/cpu/sh4a/setup-sh7785.c
	arch/sh/kernel/cpu/sh4a/setup-sh7786.c
	arch/sh/kernel/cpu/sh4a/setup-shx3.c
	arch/sh/kernel/cpu/sh5/setup-sh5.c
	drivers/serial/sh-sci.c
	drivers/serial/sh-sci.h
	include/linux/serial_sci.h
Diffstat (limited to 'net/core/sysctl_net_core.c')
| -rw-r--r-- | net/core/sysctl_net_core.c | 102 | 
1 files changed, 84 insertions, 18 deletions
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 7db1de0497c..385b6095fdc 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -10,14 +10,77 @@  #include <linux/module.h>  #include <linux/socket.h>  #include <linux/netdevice.h> +#include <linux/ratelimit.h> +#include <linux/vmalloc.h>  #include <linux/init.h> +#include <linux/slab.h> +  #include <net/ip.h>  #include <net/sock.h> +#ifdef CONFIG_RPS +static int rps_sock_flow_sysctl(ctl_table *table, int write, +				void __user *buffer, size_t *lenp, loff_t *ppos) +{ +	unsigned int orig_size, size; +	int ret, i; +	ctl_table tmp = { +		.data = &size, +		.maxlen = sizeof(size), +		.mode = table->mode +	}; +	struct rps_sock_flow_table *orig_sock_table, *sock_table; +	static DEFINE_MUTEX(sock_flow_mutex); + +	mutex_lock(&sock_flow_mutex); + +	orig_sock_table = rcu_dereference_protected(rps_sock_flow_table, +					lockdep_is_held(&sock_flow_mutex)); +	size = orig_size = orig_sock_table ? orig_sock_table->mask + 1 : 0; + +	ret = proc_dointvec(&tmp, write, buffer, lenp, ppos); + +	if (write) { +		if (size) { +			if (size > 1<<30) { +				/* Enforce limit to prevent overflow */ +				mutex_unlock(&sock_flow_mutex); +				return -EINVAL; +			} +			size = roundup_pow_of_two(size); +			if (size != orig_size) { +				sock_table = +				    vmalloc(RPS_SOCK_FLOW_TABLE_SIZE(size)); +				if (!sock_table) { +					mutex_unlock(&sock_flow_mutex); +					return -ENOMEM; +				} + +				sock_table->mask = size - 1; +			} else +				sock_table = orig_sock_table; + +			for (i = 0; i < size; i++) +				sock_table->ents[i] = RPS_NO_CPU; +		} else +			sock_table = NULL; + +		if (sock_table != orig_sock_table) { +			rcu_assign_pointer(rps_sock_flow_table, sock_table); +			synchronize_rcu(); +			vfree(orig_sock_table); +		} +	} + +	mutex_unlock(&sock_flow_mutex); + +	return ret; +} +#endif /* CONFIG_RPS */ +  static struct ctl_table net_core_table[] = {  #ifdef CONFIG_NET  	{ -		.ctl_name	= NET_CORE_WMEM_MAX,  		.procname	= "wmem_max",  		.data		= &sysctl_wmem_max,  		.maxlen		= sizeof(int), @@ -25,7 +88,6 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_RMEM_MAX,  		.procname	= "rmem_max",  		.data		= &sysctl_rmem_max,  		.maxlen		= sizeof(int), @@ -33,7 +95,6 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_WMEM_DEFAULT,  		.procname	= "wmem_default",  		.data		= &sysctl_wmem_default,  		.maxlen		= sizeof(int), @@ -41,7 +102,6 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_RMEM_DEFAULT,  		.procname	= "rmem_default",  		.data		= &sysctl_rmem_default,  		.maxlen		= sizeof(int), @@ -49,7 +109,6 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_DEV_WEIGHT,  		.procname	= "dev_weight",  		.data		= &weight_p,  		.maxlen		= sizeof(int), @@ -57,7 +116,6 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_MAX_BACKLOG,  		.procname	= "netdev_max_backlog",  		.data		= &netdev_max_backlog,  		.maxlen		= sizeof(int), @@ -65,16 +123,20 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_MSG_COST, +		.procname	= "netdev_tstamp_prequeue", +		.data		= &netdev_tstamp_prequeue, +		.maxlen		= sizeof(int), +		.mode		= 0644, +		.proc_handler	= proc_dointvec +	}, +	{  		.procname	= "message_cost",  		.data		= &net_ratelimit_state.interval,  		.maxlen		= sizeof(int),  		.mode		= 0644,  		.proc_handler	= proc_dointvec_jiffies, -		.strategy	= sysctl_jiffies,  	},  	{ -		.ctl_name	= NET_CORE_MSG_BURST,  		.procname	= "message_burst",  		.data		= &net_ratelimit_state.burst,  		.maxlen		= sizeof(int), @@ -82,16 +144,22 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec,  	},  	{ -		.ctl_name	= NET_CORE_OPTMEM_MAX,  		.procname	= "optmem_max",  		.data		= &sysctl_optmem_max,  		.maxlen		= sizeof(int),  		.mode		= 0644,  		.proc_handler	= proc_dointvec  	}, +#ifdef CONFIG_RPS +	{ +		.procname	= "rps_sock_flow_entries", +		.maxlen		= sizeof(int), +		.mode		= 0644, +		.proc_handler	= rps_sock_flow_sysctl +	}, +#endif  #endif /* CONFIG_NET */  	{ -		.ctl_name	= NET_CORE_BUDGET,  		.procname	= "netdev_budget",  		.data		= &netdev_budget,  		.maxlen		= sizeof(int), @@ -99,31 +167,29 @@ static struct ctl_table net_core_table[] = {  		.proc_handler	= proc_dointvec  	},  	{ -		.ctl_name	= NET_CORE_WARNINGS,  		.procname	= "warnings",  		.data		= &net_msg_warn,  		.maxlen		= sizeof(int),  		.mode		= 0644,  		.proc_handler	= proc_dointvec  	}, -	{ .ctl_name = 0 } +	{ }  };  static struct ctl_table netns_core_table[] = {  	{ -		.ctl_name	= NET_CORE_SOMAXCONN,  		.procname	= "somaxconn",  		.data		= &init_net.core.sysctl_somaxconn,  		.maxlen		= sizeof(int),  		.mode		= 0644,  		.proc_handler	= proc_dointvec  	}, -	{ .ctl_name = 0 } +	{ }  };  __net_initdata struct ctl_path net_core_path[] = { -	{ .procname = "net", .ctl_name = CTL_NET, }, -	{ .procname = "core", .ctl_name = NET_CORE, }, +	{ .procname = "net", }, +	{ .procname = "core", },  	{ },  }; @@ -134,7 +200,7 @@ static __net_init int sysctl_core_net_init(struct net *net)  	net->core.sysctl_somaxconn = SOMAXCONN;  	tbl = netns_core_table; -	if (net != &init_net) { +	if (!net_eq(net, &init_net)) {  		tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);  		if (tbl == NULL)  			goto err_dup;  | 
