dhcp-4.2.0-honor-expired.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. diff -up dhcp-4.2.0/client/dhc6.c.honor-expired dhcp-4.2.0/client/dhc6.c
  2. --- dhcp-4.2.0/client/dhc6.c.honor-expired 2010-10-07 12:55:37.000000000 +0200
  3. +++ dhcp-4.2.0/client/dhc6.c 2010-10-07 12:56:43.000000000 +0200
  4. @@ -1405,6 +1405,35 @@ 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. + if (lease == NULL)
  17. + return;
  18. +
  19. + for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
  20. + for (addr = ia->addrs ; addr != NULL ; addr = addr->next) {
  21. + if (addr->flags & DHC6_ADDR_EXPIRED)
  22. + continue;
  23. +
  24. + if (addr->starts + addr->max_life > cur_time) {
  25. + return ISC_TRUE;
  26. + }
  27. + }
  28. + }
  29. +
  30. + log_info("PRC: Previous lease is devoid of active addresses."
  31. + " Re-initializing.");
  32. +
  33. + return ISC_FALSE;
  34. +}
  35. +
  36. /*
  37. * start_confirm6() kicks off an "init-reboot" version of the process, at
  38. * startup to find out if old bindings are 'fair' and at runtime whenever
  39. @@ -1417,8 +1446,10 @@ start_confirm6(struct client_state *clie
  40. /* If there is no active lease, there is nothing to check. */
  41. if ((client->active_lease == NULL) ||
  42. - !active_prefix(client) ||
  43. - client->active_lease->released) {
  44. + !active_prefix(client) ||
  45. + client->active_lease->released ||
  46. + !unexpired_address_in_lease(client->active_lease)) {
  47. + dhc6_lease_destroy(&client->active_lease, MDL);
  48. start_init6(client);
  49. return;
  50. }