summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2000-06-23 01:44:16 +0000
committerBob Beck <beck@cvs.openbsd.org>2000-06-23 01:44:16 +0000
commit7a6687eb64e6597c95207ad1d28b714e510d014c (patch)
treedf089c50b148d0ca53f17459e66d5d94865de3bb
parente2f7edfa11c12a52c8e6348a71eb2b7554dee7ab (diff)
fix dhcpd to not abandon addresses forever when they are pinged before use
which creates a nice denial of service when people use static addresses in the dhcp range. - instead abandon the address only for the default lease time so that it may be re-used afterwards. Tested and committed with aaron and jason while drinking beer and wearing balloons on my head in the bar at the USENIX party.
-rw-r--r--usr.sbin/dhcp/common/memory.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/dhcp/common/memory.c b/usr.sbin/dhcp/common/memory.c
index d425bf54ad5..bdc90a97c02 100644
--- a/usr.sbin/dhcp/common/memory.c
+++ b/usr.sbin/dhcp/common/memory.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: memory.c,v 1.1 1998/08/18 03:43:26 deraadt Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: memory.c,v 1.2 2000/06/23 01:44:15 beck Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -630,20 +630,23 @@ void release_lease (lease)
supersede_lease (lease, &lt, 1);
}
-/* Abandon the specified lease (set its timeout to infinity and its
- particulars to zero, and re-hash it as appropriate. */
+/* Abandon the specified lease for the specified time. sets it's
+ particulars to zero, the end time apropriately and re-hash it as
+ appropriate. abandons permanently if abtime is 0 */
void abandon_lease (lease, message)
struct lease *lease;
char *message;
{
struct lease lt;
+ TIME abtime;
+ abtime = lease -> subnet -> group -> default_lease_time;
lease -> flags |= ABANDONED_LEASE;
lt = *lease;
- lt.ends = MAX_TIME;
- warn ("Abandoning IP address %s: %s",
- piaddr (lease -> ip_addr), message);
+ lt.ends = cur_time + abtime;
+ warn ("Abandoning IP address %s for %d seconds: %s",
+ piaddr (lease -> ip_addr), abtime, message);
lt.hardware_addr.htype = 0;
lt.hardware_addr.hlen = 0;
lt.uid = (unsigned char *)0;