]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
If we happen across an abandoned lease when trying to find a lease to allocate, try...
authorTed Lemon <source@isc.org>
Tue, 17 Mar 1998 18:14:51 +0000 (18:14 +0000)
committerTed Lemon <source@isc.org>
Tue, 17 Mar 1998 18:14:51 +0000 (18:14 +0000)
server/dhcp.c

index 7a7d3e7f402f345da331d20215fd1d571aa9be19..74898db58fb1af1dc3a723b0213313f298985f30 100644 (file)
@@ -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;