Blame SOURCES/dhcp-4.2.0-dhclient-decline-backoff.patch

54343e
diff -up dhcp-4.2.0/client/dhclient.c.backoff dhcp-4.2.0/client/dhclient.c
54343e
--- dhcp-4.2.0/client/dhclient.c.backoff	2010-07-21 13:37:03.000000000 +0200
54343e
+++ dhcp-4.2.0/client/dhclient.c	2010-07-21 13:38:31.000000000 +0200
54343e
@@ -1208,6 +1208,8 @@ void state_init (cpp)
54343e
 	void *cpp;
54343e
 {
54343e
 	struct client_state *client = cpp;
54343e
+	enum dhcp_state init_state = client->state;
54343e
+	struct timeval tv;
54343e
 
54343e
 	ASSERT_STATE(state, S_INIT);
54343e
 
54343e
@@ -1220,9 +1222,18 @@ void state_init (cpp)
54343e
 	client -> first_sending = cur_time;
54343e
 	client -> interval = client -> config -> initial_interval;
54343e
 
54343e
-	/* Add an immediate timeout to cause the first DHCPDISCOVER packet
54343e
-	   to go out. */
54343e
-	send_discover (client);
54343e
+	if (init_state != S_DECLINED) {
54343e
+		/* Add an immediate timeout to cause the first DHCPDISCOVER packet
54343e
+		   to go out. */
54343e
+		send_discover(client);
54343e
+	} else {
54343e
+		/* We've received an OFFER and it has been DECLINEd by dhclient-script.
54343e
+		 * wait for a random time between 1 and backoff_cutoff seconds before
54343e
+		 * trying again. */
54343e
+		tv . tv_sec = cur_time + ((1 + (random() >> 2)) %  client->config->backoff_cutoff);
54343e
+		tv . tv_usec = 0;
54343e
+		add_timeout(&tv, send_discover, client, 0, 0);
54343e
+	}
54343e
 }
54343e
 
54343e
 /*
54343e
@@ -1501,6 +1512,7 @@ void bind_lease (client)
54343e
 		send_decline (client);
54343e
 		destroy_client_lease (client -> new);
54343e
 		client -> new = (struct client_lease *)0;
54343e
+		client -> state = S_DECLINED;
54343e
 		state_init (client);
54343e
 		return;
54343e
 	}
54343e
@@ -3711,6 +3723,7 @@ void client_location_changed ()
54343e
 			      case S_INIT:
54343e
 			      case S_REBINDING:
54343e
 			      case S_STOPPED:
54343e
+			      case S_DECLINED:
54343e
 				break;
54343e
 			}
54343e
 			client -> state = S_INIT;
54343e
diff -up dhcp-4.2.0/includes/dhcpd.h.backoff dhcp-4.2.0/includes/dhcpd.h
54343e
--- dhcp-4.2.0/includes/dhcpd.h.backoff	2010-07-21 13:29:05.000000000 +0200
54343e
+++ dhcp-4.2.0/includes/dhcpd.h	2010-07-21 13:38:31.000000000 +0200
54343e
@@ -1056,7 +1056,8 @@ enum dhcp_state {
54343e
 	S_BOUND = 5,
54343e
 	S_RENEWING = 6,
54343e
 	S_REBINDING = 7,
54343e
-	S_STOPPED = 8
54343e
+	S_STOPPED = 8,
54343e
+	S_DECLINED = 9
54343e
 };
54343e
 
54343e
 /* Authentication and BOOTP policy possibilities (not all values work