netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] route: Fix caught BUG_ON during rt_secret_rebuild_oneshot()
@ 2010-03-16 11:07 Vitaliy Gusev
  2010-03-16 14:34 ` Neil Horman
  0 siblings, 1 reply; 8+ messages in thread
From: Vitaliy Gusev @ 2010-03-16 11:07 UTC (permalink / raw)
  To: David S. Miller; +Cc: Neil Horman, Eric Dumazet, Herbert Xu, netdev

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: Vitaliy Gusev <vgusev@openvz.org>

---
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 4f11faa..8a77318 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -922,10 +922,8 @@ static void rt_secret_rebuild_oneshot(struct net *net)
 {
 	del_timer_sync(&net->ipv4.rt_secret_timer);
 	rt_cache_invalidate(net);
-	if (ip_rt_secret_interval) {
-		net->ipv4.rt_secret_timer.expires += ip_rt_secret_interval;
-		add_timer(&net->ipv4.rt_secret_timer);
-	}
+	if (ip_rt_secret_interval)
+		mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval);
 }
 
 static void rt_emergency_hash_rebuild(struct net *net)
@@ -3072,22 +3070,20 @@ static void rt_secret_reschedule(int old)
 	rtnl_lock();
 	for_each_net(net) {
 		int deleted = del_timer_sync(&net->ipv4.rt_secret_timer);
+		long time;
 
 		if (!new)
 			continue;
 
 		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)
 				time = 0;
-
-			net->ipv4.rt_secret_timer.expires = time;
 		} else
-			net->ipv4.rt_secret_timer.expires = new;
+			time = new;
 
-		net->ipv4.rt_secret_timer.expires += jiffies;
-		add_timer(&net->ipv4.rt_secret_timer);
+		mod_timer(&net->ipv4.rt_secret_timer, jiffies + time);
 	}
 	rtnl_unlock();
 }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-17  0:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-16 11:07 [PATCH] route: Fix caught BUG_ON during rt_secret_rebuild_oneshot() Vitaliy Gusev
2010-03-16 14:34 ` Neil Horman
2010-03-16 15:27   ` Vitaliy Gusev
2010-03-16 17:35     ` Neil Horman
2010-03-16 18:08       ` Eric Dumazet
2010-03-16 18:18         ` Neil Horman
2010-03-16 21:30           ` David Miller
2010-03-17  0:54             ` Neil Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).