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