From: Steven Barth Date: Mon, 20 May 2013 14:27:23 +0000 (+0200) Subject: Fix IA expiring logic X-Git-Tag: debian/1.1+git20160131-1~147 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=commitdiff_plain;h=feec1ad5767b977ce47e6738930c99c22ba0ce9c;hp=dbf89816bd12d727dc7b006406f619ff3d2da382 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);