From: Ted Lemon Date: Tue, 17 Mar 1998 18:14:51 +0000 (+0000) Subject: If we happen across an abandoned lease when trying to find a lease to allocate, try... X-Git-Tag: carrel-2~148 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=48984237a157864707118bad783cdcd7ec765016;p=thirdparty%2Fdhcp.git If we happen across an abandoned lease when trying to find a lease to allocate, try using the abandoned lease. If the client asks for a lease on one address, but we find another lease that's also assigned to it, make every effort to free the duplicate lease, since a client can't have two leases on the same network at the same time. --- diff --git a/server/dhcp.c b/server/dhcp.c index 7a7d3e7f4..74898db58 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.60 1998/03/17 06:20:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.61 1998/03/17 18:14:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -116,6 +116,15 @@ void dhcpdiscover (packet) return; } + /* If we find an abandoned lease, take it, but print a + warning message, so that if it continues to lose, + the administrator will eventually investigate. */ + if (lease -> flags & ABANDONED_LEASE) { + warn ("Reclaiming abandoned IP address %s.\n", + piaddr (lease -> ip_addr)); + lease -> flags &= ~ABANDONED_LEASE; + } + /* Try to find a host_decl that matches the client identifier or hardware address on the packet, and has no fixed IP address. If there is one, hang @@ -1290,6 +1299,16 @@ struct lease *find_lease (packet, share, ours) packet -> raw -> hlen, packet -> raw -> chaddr), ip_lease -> shared_network -> name); + + /* If the client is REQUESTing the lease, it shouldn't + still be using the old one, so we can free it for + allocation. This is only true if the duplicate + lease is on the same network, of course. */ + + if (packet -> packet_type == DHCPREQUEST && + share == uid_lease -> shared_network) + dissociate_lease (uid_lease); + uid_lease = ip_lease; } ip_lease = (struct lease *)0;