bffe902
diff -up dhcp-4.3.4/client/dhclient.c.backoff dhcp-4.3.4/client/dhclient.c
bffe902
--- dhcp-4.3.4/client/dhclient.c.backoff	2016-04-29 12:16:26.976245611 +0200
bffe902
+++ dhcp-4.3.4/client/dhclient.c	2016-04-29 12:16:26.979245609 +0200
bffe902
@@ -1423,6 +1423,8 @@ void state_init (cpp)
bffe902
 	void *cpp;
bffe902
 {
bffe902
 	struct client_state *client = cpp;
bffe902
+	enum dhcp_state init_state = client->state;
bffe902
+	struct timeval tv;
bffe902
 
bffe902
 	ASSERT_STATE(state, S_INIT);
bffe902
 
bffe902
@@ -1435,9 +1437,18 @@ void state_init (cpp)
bffe902
 	client -> first_sending = cur_time;
bffe902
 	client -> interval = client -> config -> initial_interval;
bffe902
 
bffe902
-	/* Add an immediate timeout to cause the first DHCPDISCOVER packet
bffe902
-	   to go out. */
bffe902
-	send_discover (client);
bffe902
+	if (init_state != S_DECLINED) {
bffe902
+		/* Add an immediate timeout to cause the first DHCPDISCOVER packet
bffe902
+		   to go out. */
bffe902
+		send_discover(client);
bffe902
+	} else {
bffe902
+		/* We've received an OFFER and it has been DECLINEd by dhclient-script.
bffe902
+		 * wait for a random time between 1 and backoff_cutoff seconds before
bffe902
+		 * trying again. */
bffe902
+		tv . tv_sec = cur_time + ((1 + (random() >> 2)) %  client->config->backoff_cutoff);
bffe902
+		tv . tv_usec = 0;
bffe902
+		add_timeout(&tv, send_discover, client, 0, 0);
bffe902
+	}
bffe902
 }
bffe902
 
bffe902
 /*
bffe902
@@ -1734,5 +1745,6 @@ void bind_lease (client)
bffe902
#endif
bffe902
 			exit(2);
bffe902
 		} else {
bffe902
+			client -> state = S_DECLINED;
bffe902
 			state_init(client);
bffe902
 			return;
bffe902
 		}
bffe902
@@ -4626,6 +4638,7 @@ void client_location_changed ()
bffe902
 			      case S_INIT:
bffe902
 			      case S_REBINDING:
bffe902
 			      case S_STOPPED:
bffe902
+			      case S_DECLINED:
bffe902
 				break;
bffe902
 			}
bffe902
 			client -> state = S_INIT;
bffe902
diff -up dhcp-4.3.4/includes/dhcpd.h.backoff dhcp-4.3.4/includes/dhcpd.h
bffe902
--- dhcp-4.3.4/includes/dhcpd.h.backoff	2016-04-29 12:16:26.980245609 +0200
bffe902
+++ dhcp-4.3.4/includes/dhcpd.h	2016-04-29 12:17:30.893203533 +0200
bffe902
@@ -1171,7 +1171,8 @@ enum dhcp_state {
bffe902
 	S_BOUND = 5,
bffe902
 	S_RENEWING = 6,
bffe902
 	S_REBINDING = 7,
bffe902
-	S_STOPPED = 8
bffe902
+	S_STOPPED = 8,
bffe902
+	S_DECLINED = 9
bffe902
 };
bffe902
 
bffe902
 /* Possible pending client operations. */