Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/dhcpv6-ia.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,11 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
/* UINT32_MAX is considered as infinite leasetime */
a->preferred_until = (pref == UINT32_MAX) ? 0 : pref + now;

o_ia.t1 = htonl((pref == UINT32_MAX) ? pref : pref * 5 / 10);
o_ia.t2 = htonl((pref == UINT32_MAX) ? pref : pref * 8 / 10);
/* if there's sufficient time left, subtract a pseudo random 127 seconds from the refresh timers */
o_ia.t1 = htonl((pref == UINT32_MAX) ? pref : (pref > 256) ?
pref * 5 / 10 - ((rand() >> 8) & 0x7f) : pref * 5 / 10);
o_ia.t2 = htonl((pref == UINT32_MAX) ? pref : (pref > 256) ?
pref * 8 / 10 - ((rand() >> 8) & 0x7f) : pref * 8 / 10);

if (!o_ia.t1)
o_ia.t1 = htonl(1);
Expand Down