ipv6: Clamp reported valid_lft to a minimum of 0
authorBen Hutchings <ben@decadent.org.uk>
Sat, 26 Jun 2010 11:37:47 +0000 (11:37 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Jun 2010 17:28:43 +0000 (10:28 -0700)
Since addresses are only revalidated every 2 minutes, the reported
valid_lft can underflow shortly before the address is deleted.
Clamp it to a minimum of 0, as for prefered_lft.

Reported-by: Piotr Lewandowski <piotr.lewandowski@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/addrconf.c

index c20a7c260a8f1e18528cebf31695983a78038bc8..51a273fe3d2190089cb923d15143da702a1fc598 100644 (file)
@@ -3495,8 +3495,12 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
                                preferred -= tval;
                        else
                                preferred = 0;
-                       if (valid != INFINITY_LIFE_TIME)
-                               valid -= tval;
+                       if (valid != INFINITY_LIFE_TIME) {
+                               if (valid > tval)
+                                       valid -= tval;
+                               else
+                                       valid = 0;
+                       }
                }
        } else {
                preferred = INFINITY_LIFE_TIME;