rpms/dhcp/FC-3 dhcp-3.0.1-decline_backoff.patch,NONE,1.1
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Thu Jul 7 22:25:13 UTC 2005
Author: jvdias
Update of /cvs/dist/rpms/dhcp/FC-3
In directory cvs.devel.redhat.com:/tmp/cvs-serv18407
Added Files:
dhcp-3.0.1-decline_backoff.patch
Log Message:
fix bug 162080: prevent DHCPDECLINE network flood
dhcp-3.0.1-decline_backoff.patch:
client/dhclient.c | 28 +++++++++++++++++++++-------
includes/dhcpd.h | 3 ++-
2 files changed, 23 insertions(+), 8 deletions(-)
--- NEW FILE dhcp-3.0.1-decline_backoff.patch ---
--- dhcp-3.0.1/client/dhclient.c.decline_backoff 2005-06-09 14:48:06.000000000 -0400
+++ dhcp-3.0.1/client/dhclient.c 2005-06-09 14:57:35.000000000 -0400
@@ -658,6 +658,7 @@
void *cpp;
{
struct client_state *client = cpp;
+ enum dhcp_state init_state = client -> state;
ASSERT_STATE(state, S_INIT);
@@ -667,12 +668,25 @@
client -> xid = client -> packet.xid;
client -> destination = iaddr_broadcast;
client -> state = S_SELECTING;
- 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 )
+ {
+ 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);
+ }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.
+ */
+ client -> first_sending = cur_time;
+ client -> interval = client -> config -> initial_interval;
+ add_timeout( cur_time + (( 1 + (random () >> 2) ) % client -> config -> backoff_cutoff),
+ send_discover, client, 0, 0
+ );
+ }
}
/* state_selecting is called when one or more DHCPOFFER packets have been
@@ -945,6 +959,7 @@
send_decline (client);
destroy_client_lease (client -> new);
client -> new = (struct client_lease *)0;
+ client -> state = S_DECLINED;
state_init (client);
return;
}
@@ -2115,7 +2130,6 @@
option_state_dereference (&options, MDL);
if (client -> packet_length < BOOTP_MIN_LEN)
client -> packet_length = BOOTP_MIN_LEN;
- option_state_dereference (&options, MDL);
client -> packet.op = BOOTREQUEST;
client -> packet.htype = client -> interface -> hw_address.hbuf [0];
--- dhcp-3.0.1/includes/dhcpd.h.decline_backoff 2004-06-10 13:59:29.000000000 -0400
+++ dhcp-3.0.1/includes/dhcpd.h 2005-06-09 14:48:06.000000000 -0400
@@ -658,7 +658,8 @@
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
More information about the fedora-cvs-commits
mailing list