netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] core: linkwatch should use jiffies64
@ 2006-05-07 10:13 Stefan Rompf
  2006-05-08  6:07 ` David S. Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Rompf @ 2006-05-07 10:13 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller

Hi,

the linkwatch code can overflow on a jiffies wrap, scheduling
work with a too large delay. If the delay is >0x80000000,
internal_add_timer() seems to overflow too, hiding the bug, so
this isn't triggered too easily.

Best solution is to use jiffies64 for calculation as these
events happen with any possible delay in between.

This should be 2.6.17 stuff.

Signed-off-by: Stefan Rompf <stefan@loplof.de>

--- linux-2.6.17-rc3/net/core/link_watch.c.orig	2006-04-27 20:37:09.000000000 +0200
+++ linux-2.6.17-rc3/net/core/link_watch.c	2006-04-27 21:49:00.000000000 +0200
@@ -32,8 +32,8 @@
 	LW_SE_USED
 };
 
+static u64 linkwatch_nextevent;
 static unsigned long linkwatch_flags;
-static unsigned long linkwatch_nextevent;
 
 static void linkwatch_event(void *dummy);
 static DECLARE_WORK(linkwatch_work, linkwatch_event, NULL);
@@ -136,7 +136,7 @@
 	 * cause a storm of messages on the netlink
 	 * socket
 	 */	
-	linkwatch_nextevent = jiffies + HZ;
+	linkwatch_nextevent = get_jiffies_64() + HZ;
 	clear_bit(LW_RUNNING, &linkwatch_flags);
 
 	rtnl_lock();
@@ -170,7 +170,7 @@
 		spin_unlock_irqrestore(&lweventlist_lock, flags);
 
 		if (!test_and_set_bit(LW_RUNNING, &linkwatch_flags)) {
-			unsigned long thisevent = jiffies;
+			u64 thisevent = get_jiffies_64();
 
 			if (thisevent >= linkwatch_nextevent) {
 				schedule_work(&linkwatch_work);

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

end of thread, other threads:[~2006-05-09 22:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-07 10:13 [PATCH] core: linkwatch should use jiffies64 Stefan Rompf
2006-05-08  6:07 ` David S. Miller
2006-05-08 18:28   ` Stefan Rompf
2006-05-09 11:26     ` [NET] linkwatch: Handle jiffies wrap-around Herbert Xu
2006-05-09 16:51       ` Stefan Rompf
2006-05-09 22:28         ` David S. Miller

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).