Commit 858a18a6 authored by Vitaliy Gusev's avatar Vitaliy Gusev Committed by David S. Miller

route: Fix caught BUG_ON during rt_secret_rebuild_oneshot()

route: Fix caught BUG_ON during rt_secret_rebuild_oneshot()

Call rt_secret_rebuild can cause BUG_ON(timer_pending(&net->ipv4.rt_secret_timer)) in
add_timer as there is not any synchronization for call rt_secret_rebuild_oneshot()
for the same net namespace.

Also this issue affects to rt_secret_reschedule().

Thus use mod_timer enstead.
Signed-off-by: default avatarVitaliy Gusev <vgusev@openvz.org>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8440853b
...@@ -932,10 +932,8 @@ static void rt_secret_rebuild_oneshot(struct net *net) ...@@ -932,10 +932,8 @@ static void rt_secret_rebuild_oneshot(struct net *net)
{ {
del_timer_sync(&net->ipv4.rt_secret_timer); del_timer_sync(&net->ipv4.rt_secret_timer);
rt_cache_invalidate(net); rt_cache_invalidate(net);
if (ip_rt_secret_interval) { if (ip_rt_secret_interval)
net->ipv4.rt_secret_timer.expires += ip_rt_secret_interval; mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
add_timer(&net->ipv4.rt_secret_timer);
}
} }
static void rt_emergency_hash_rebuild(struct net *net) static void rt_emergency_hash_rebuild(struct net *net)
...@@ -3103,22 +3101,20 @@ static void rt_secret_reschedule(int old) ...@@ -3103,22 +3101,20 @@ static void rt_secret_reschedule(int old)
rtnl_lock(); rtnl_lock();
for_each_net(net) { for_each_net(net) {
int deleted = del_timer_sync(&net->ipv4.rt_secret_timer); int deleted = del_timer_sync(&net->ipv4.rt_secret_timer);
long time;
if (!new) if (!new)
continue; continue;
if (deleted) { if (deleted) {
long time = net->ipv4.rt_secret_timer.expires - jiffies; time = net->ipv4.rt_secret_timer.expires - jiffies;
if (time <= 0 || (time += diff) <= 0) if (time <= 0 || (time += diff) <= 0)
time = 0; time = 0;
net->ipv4.rt_secret_timer.expires = time;
} else } else
net->ipv4.rt_secret_timer.expires = new; time = new;
net->ipv4.rt_secret_timer.expires += jiffies; mod_timer(&net->ipv4.rt_secret_timer, jiffies + time);
add_timer(&net->ipv4.rt_secret_timer);
} }
rtnl_unlock(); rtnl_unlock();
} }
......
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