Commit 81c684d1 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

ipv4: remove flush_mutex from ipv4_sysctl_rtcache_flush

It is possible to avoid locking at all in ipv4_sysctl_rtcache_flush by
defining local ctl_table on the stack.

The patch is based on the suggestion from Eric W. Biederman.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2c693610
...@@ -2873,22 +2873,20 @@ void ip_rt_multicast_event(struct in_device *in_dev) ...@@ -2873,22 +2873,20 @@ void ip_rt_multicast_event(struct in_device *in_dev)
} }
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
static int ipv4_sysctl_rtcache_flush(ctl_table *ctl, int write, static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
struct file *filp, void __user *buffer, struct file *filp, void __user *buffer,
size_t *lenp, loff_t *ppos) size_t *lenp, loff_t *ppos)
{ {
if (write) { if (write) {
int flush_delay; int flush_delay;
ctl_table ctl;
struct net *net; struct net *net;
static DEFINE_MUTEX(flush_mutex);
mutex_lock(&flush_mutex); memcpy(&ctl, __ctl, sizeof(ctl));
ctl->data = &flush_delay; ctl.data = &flush_delay;
proc_dointvec(ctl, write, filp, buffer, lenp, ppos); proc_dointvec(&ctl, write, filp, buffer, lenp, ppos);
ctl->data = NULL;
mutex_unlock(&flush_mutex);
net = (struct net *)ctl->extra1; net = (struct net *)__ctl->extra1;
rt_cache_flush(net, flush_delay); rt_cache_flush(net, flush_delay);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment