dhcp-4.2.0-dhclient-decline-backoff.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. diff -up dhcp-4.2.0/client/dhclient.c.backoff dhcp-4.2.0/client/dhclient.c
  2. --- dhcp-4.2.0/client/dhclient.c.backoff 2010-07-21 13:37:03.000000000 +0200
  3. +++ dhcp-4.2.0/client/dhclient.c 2010-07-21 13:38:31.000000000 +0200
  4. @@ -1208,6 +1208,8 @@ void state_init (cpp)
  5. void *cpp;
  6. {
  7. struct client_state *client = cpp;
  8. + enum dhcp_state init_state = client->state;
  9. + struct timeval tv;
  10. ASSERT_STATE(state, S_INIT);
  11. @@ -1220,9 +1222,18 @@ void state_init (cpp)
  12. client -> first_sending = cur_time;
  13. client -> interval = client -> config -> initial_interval;
  14. - /* Add an immediate timeout to cause the first DHCPDISCOVER packet
  15. - to go out. */
  16. - send_discover (client);
  17. + if (init_state != S_DECLINED) {
  18. + /* Add an immediate timeout to cause the first DHCPDISCOVER packet
  19. + to go out. */
  20. + send_discover(client);
  21. + } else {
  22. + /* We've received an OFFER and it has been DECLINEd by dhclient-script.
  23. + * wait for a random time between 1 and backoff_cutoff seconds before
  24. + * trying again. */
  25. + tv . tv_sec = cur_time + ((1 + (random() >> 2)) % client->config->backoff_cutoff);
  26. + tv . tv_usec = 0;
  27. + add_timeout(&tv, send_discover, client, 0, 0);
  28. + }
  29. }
  30. /*
  31. @@ -1501,6 +1512,7 @@ void bind_lease (client)
  32. send_decline (client);
  33. destroy_client_lease (client -> new);
  34. client -> new = (struct client_lease *)0;
  35. + client -> state = S_DECLINED;
  36. state_init (client);
  37. return;
  38. }
  39. @@ -3711,6 +3723,7 @@ void client_location_changed ()
  40. case S_INIT:
  41. case S_REBINDING:
  42. case S_STOPPED:
  43. + case S_DECLINED:
  44. break;
  45. }
  46. client -> state = S_INIT;
  47. diff -up dhcp-4.2.0/includes/dhcpd.h.backoff dhcp-4.2.0/includes/dhcpd.h
  48. --- dhcp-4.2.0/includes/dhcpd.h.backoff 2010-07-21 13:29:05.000000000 +0200
  49. +++ dhcp-4.2.0/includes/dhcpd.h 2010-07-21 13:38:31.000000000 +0200
  50. @@ -1056,7 +1056,8 @@ enum dhcp_state {
  51. S_BOUND = 5,
  52. S_RENEWING = 6,
  53. S_REBINDING = 7,
  54. - S_STOPPED = 8
  55. + S_STOPPED = 8,
  56. + S_DECLINED = 9
  57. };
  58. /* Authentication and BOOTP policy possibilities (not all values work