dhcpv6: fix handling of infinite lifetimes
authorSteven Barth <steven@midlink.org>
Mon, 6 Apr 2015 10:47:28 +0000 (12:47 +0200)
committerSteven Barth <steven@midlink.org>
Mon, 6 Apr 2015 10:47:28 +0000 (12:47 +0200)
src/dhcpv6-ia.c

index 74e344195710888b5fb37e598a4ce49dea1a7861..de445816116693d0aa70343a2a9fc75fcfcfa7e8 100644 (file)
@@ -728,13 +728,19 @@ static size_t append_reply(uint8_t *buf, size_t buflen, uint16_t status,
                                        m = i;
 
                        for (size_t i = 0; i < addrlen; ++i) {
-                               uint32_t prefix_pref = addrs[i].preferred - now;
-                               uint32_t prefix_valid = addrs[i].valid - now;
+                               uint32_t prefix_pref = addrs[i].preferred;
+                               uint32_t prefix_valid = addrs[i].valid;
 
                                if (addrs[i].prefix > 96 ||
                                                addrs[i].preferred <= (uint32_t)now)
                                        continue;
 
+                               if (prefix_pref != UINT32_MAX)
+                                       prefix_pref -= now;
+
+                               if (prefix_valid != UINT32_MAX)
+                                       prefix_valid -= now;
+
                                if (a->length < 128) {
                                        struct dhcpv6_ia_prefix p = {
                                                .type = htons(DHCPV6_OPT_IA_PREFIX),