]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
If a client REQUESTs an abandoned lease, reclaim it.
authorTed Lemon <source@isc.org>
Thu, 25 Jun 1998 21:20:41 +0000 (21:20 +0000)
committerTed Lemon <source@isc.org>
Thu, 25 Jun 1998 21:20:41 +0000 (21:20 +0000)
server/dhcp.c

index 94c31c5fbcaa2c954468414376d54677d4d2881b..2f1573c0ac5c4ce9a22df21fd32f45420af06cee 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.57.2.2 1998/06/25 21:11:35 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.57.2.3 1998/06/25 21:20:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1241,9 +1241,13 @@ struct lease *find_lease (packet, share, ours)
                *ours = 1;
 
        /* If the requested IP address isn't on the network the packet
-          came from, or if it's been abandoned, don't use it. */
-       if (ip_lease && (ip_lease -> shared_network != share ||
-                        (ip_lease -> flags & ABANDONED_LEASE)))
+          came from, don't use it.  Allow abandoned leases to be matched
+          here - if the client is requesting it, there's a decent chance
+          that it's because the lease database got trashed and a client
+          that thought it had this lease answered an ARP or PING, causing the
+          lease to be abandoned.   If so, this request probably came from
+          that client. */
+       if (ip_lease && (ip_lease -> shared_network != share))
                ip_lease = (struct lease *)0;
 
        /* Toss ip_lease if it hasn't yet expired and the uid doesn't
@@ -1377,6 +1381,15 @@ struct lease *find_lease (packet, share, ours)
                }
        }
 
+       /* 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 REQUESTed abandoned IP address %s.\n",
+                     piaddr (lease -> ip_addr));
+               lease -> flags &= ~ABANDONED_LEASE;
+       }
+
        return lease;
 }