Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcpv6-ia: add some noise to the T1 and T2 periods #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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