0001-dhcp-honor-expired.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. diff -up dhcp-4.3.0a1/client/dhc6.c.honor-expired dhcp-4.3.0a1/client/dhc6.c
  2. --- dhcp-4.3.0a1/client/dhc6.c.honor-expired 2013-12-19 16:00:28.062183037 +0100
  3. +++ dhcp-4.3.0a1/client/dhc6.c 2013-12-19 16:00:28.076182842 +0100
  4. @@ -1351,6 +1351,32 @@ start_info_request6(struct client_state
  5. go_daemon();
  6. }
  7. +/* Run through the addresses in lease and return true if there's any unexpired.
  8. + * Return false otherwise.
  9. + */
  10. +isc_boolean_t
  11. +unexpired_address_in_lease(struct dhc6_lease *lease)
  12. +{
  13. + struct dhc6_ia *ia;
  14. + struct dhc6_addr *addr;
  15. +
  16. + for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
  17. + for (addr = ia->addrs ; addr != NULL ; addr = addr->next) {
  18. + if (addr->flags & DHC6_ADDR_EXPIRED)
  19. + continue;
  20. +
  21. + if (addr->starts + addr->max_life > cur_time) {
  22. + return ISC_TRUE;
  23. + }
  24. + }
  25. + }
  26. +
  27. + log_info("PRC: Previous lease is devoid of active addresses."
  28. + " Re-initializing.");
  29. +
  30. + return ISC_FALSE;
  31. +}
  32. +
  33. /*
  34. * start_confirm6() kicks off an "init-reboot" version of the process, at
  35. * startup to find out if old bindings are 'fair' and at runtime whenever
  36. @@ -1363,8 +1389,10 @@ start_confirm6(struct client_state *clie
  37. /* If there is no active lease, there is nothing to check. */
  38. if ((client->active_lease == NULL) ||
  39. - !active_prefix(client) ||
  40. - client->active_lease->released) {
  41. + !active_prefix(client) ||
  42. + client->active_lease->released ||
  43. + !unexpired_address_in_lease(client->active_lease)) {
  44. + dhc6_lease_destroy(&client->active_lease, MDL);
  45. start_init6(client);
  46. return;
  47. }