netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH: ipv6: avoid wraparound for expired lifetimes
@ 2009-06-25  7:39 Jens Rosenboom
  2009-06-25  8:40 ` Ilpo Järvinen
  0 siblings, 1 reply; 7+ messages in thread
From: Jens Rosenboom @ 2009-06-25  7:39 UTC (permalink / raw)
  To: netdev

If the valid or preferred lifetime for an address expires, the kernel
shows huge values for these due to a counter wrap, the following patch
should fix this, at least it did in the test I ran.

--- linux-2.6.30.orig/net/ipv6/addrconf.c	2009-06-10 05:05:27.000000000 +0200
+++ linux-2.6.30/net/ipv6/addrconf.c	2009-06-25 09:33:38.000000000 +0200
@@ -3361,9 +3361,17 @@
 		valid = ifa->valid_lft;
 		if (preferred != INFINITY_LIFE_TIME) {
 			long tval = (jiffies - ifa->tstamp)/HZ;
-			preferred -= tval;
-			if (valid != INFINITY_LIFE_TIME)
-				valid -= tval;
+			if (preferred > tval) {
+				preferred -= tval;
+			} else {
+				preferred = 0;
+			}
+			if (valid != INFINITY_LIFE_TIME) {
+				if (valid > tval) {
+					valid -= tval;
+				} else {
+					valid = 0;
+				}
 		}
 	} else {
 		preferred = INFINITY_LIFE_TIME;

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

end of thread, other threads:[~2009-06-25  9:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-25  7:39 PATCH: ipv6: avoid wraparound for expired lifetimes Jens Rosenboom
2009-06-25  8:40 ` Ilpo Järvinen
2009-06-25  8:42   ` David Miller
2009-06-25  9:06   ` Jens Rosenboom
2009-06-25  9:25     ` Wei Yongjun
2009-06-25  9:33     ` David Miller
2009-06-25  9:35     ` Ilpo Järvinen

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