Skip to content

Commit

Permalink
Randomize DHCP4 startup delay as suggested in RFC2131
Browse files Browse the repository at this point in the history
Signed-off-by: Olaf Hering <olaf@aepfle.de>
  • Loading branch information
olafhering committed Sep 2, 2014
1 parent 6169aa6 commit f62e4a3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dhcp4/device.c
Expand Up @@ -523,6 +523,7 @@ ni_dhcp4_device_start(ni_dhcp4_device_t *dev)
{
ni_netconfig_t *nc;
ni_netdev_t *ifp;
ni_int_range_t jitter = { .max = 500, /* msec */ };
unsigned long msec = dev->config->start_delay * 1000;

ni_dhcp4_device_drop_buffer(dev);
Expand All @@ -535,6 +536,7 @@ ni_dhcp4_device_start(ni_dhcp4_device_t *dev)
}

/* Reuse defer pointer for this one-shot timer */
msec = ni_timeout_randomize(msec, &jitter);
dev->defer.timer = ni_timer_register(msec, ni_dhcp4_device_start_delayed, dev);

return !ni_netdev_link_is_up(ifp);
Expand Down

0 comments on commit f62e4a3

Please sign in to comment.