From: Steven Barth Date: Mon, 20 May 2013 14:27:23 +0000 (+0200) Subject: Fix IA expiring logic X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=feec1ad5767b977ce47e6738930c99c22ba0ce9c;p=project%2Fodhcp6c.git Fix IA expiring logic --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index d2cd656..9b4247c 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -667,13 +667,15 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, uint8_t *odata; uint16_t otype, olen; - static time_t last_update = 0; - time_t now = odhcp6c_get_milli_time() / 1000; - - uint32_t elapsed = now - last_update; odhcp6c_expire(); if (orig == DHCPV6_MSG_UNKNOWN) { + static time_t last_update = 0; + time_t now = odhcp6c_get_milli_time() / 1000; + + uint32_t elapsed = (last_update > 0) ? now - last_update : 0; + last_update = now; + t1 -= elapsed; t2 -= elapsed; t3 -= elapsed; diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 274a97a..d70546b 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -470,7 +470,7 @@ void odhcp6c_expire(void) static time_t last_update = 0; time_t now = odhcp6c_get_milli_time() / 1000; - uint32_t elapsed = now - last_update; + uint32_t elapsed = (last_update > 0) ? now - last_update : 0; last_update = now; odhcp6c_expire_list(STATE_RA_PREFIX, elapsed);