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