Blob Blame History Raw
diff -up dhcp-4.3.1b1/client/dhclient.c.JwFUZj dhcp-4.3.1b1/client/dhclient.c
--- dhcp-4.3.1b1/client/dhclient.c.JwFUZj	2014-07-10 17:38:50.511265091 +0200
+++ dhcp-4.3.1b1/client/dhclient.c	2014-07-10 17:39:16.164901267 +0200
@@ -1281,6 +1281,8 @@ void state_init (cpp)
 	void *cpp;
 {
 	struct client_state *client = cpp;
+	enum dhcp_state init_state = client->state;
+	struct timeval tv;
 
 	ASSERT_STATE(state, S_INIT);
 
@@ -1293,9 +1295,18 @@ void state_init (cpp)
 	client -> first_sending = cur_time;
 	client -> interval = client -> config -> initial_interval;
 
-	/* Add an immediate timeout to cause the first DHCPDISCOVER packet
-	   to go out. */
-	send_discover (client);
+	if (init_state != S_DECLINED) {
+		/* Add an immediate timeout to cause the first DHCPDISCOVER packet
+		   to go out. */
+		send_discover(client);
+	} else {
+		/* We've received an OFFER and it has been DECLINEd by dhclient-script.
+		 * wait for a random time between 1 and backoff_cutoff seconds before
+		 * trying again. */
+		tv . tv_sec = cur_time + ((1 + (random() >> 2)) %  client->config->backoff_cutoff);
+		tv . tv_usec = 0;
+		add_timeout(&tv, send_discover, client, 0, 0);
+	}
 }
 
 /*
@@ -1592,6 +1603,7 @@ void bind_lease (client)
 					 "try (declined).  Exiting.");
 			exit(2);
 		} else {
+			client -> state = S_DECLINED;
 			state_init(client);
 			return;
 		}
@@ -4059,6 +4071,7 @@ void client_location_changed ()
 			      case S_INIT:
 			      case S_REBINDING:
 			      case S_STOPPED:
+			      case S_DECLINED:
 				break;
 			}
 			client -> state = S_INIT;
diff -up dhcp-4.3.1b1/includes/dhcpd.h.JwFUZj dhcp-4.3.1b1/includes/dhcpd.h
--- dhcp-4.3.1b1/includes/dhcpd.h.JwFUZj	2014-07-10 17:38:26.941599360 +0200
+++ dhcp-4.3.1b1/includes/dhcpd.h	2014-07-10 17:38:50.526264878 +0200
@@ -1087,7 +1087,8 @@ enum dhcp_state {
 	S_BOUND = 5,
 	S_RENEWING = 6,
 	S_REBINDING = 7,
-	S_STOPPED = 8
+	S_STOPPED = 8,
+	S_DECLINED = 9
 };
 
 /* Authentication and BOOTP policy possibilities (not all values work