]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- A partner-down failover server no longer emits 'peer holds all free leases'
authorDavid Hankins <dhankins@isc.org>
Tue, 19 Aug 2008 18:00:24 +0000 (18:00 +0000)
committerDavid Hankins <dhankins@isc.org>
Tue, 19 Aug 2008 18:00:24 +0000 (18:00 +0000)
  if it is able to newly-allocate one of the peer's leases.  [ISC-Bugs #18437]

RELNOTES
server/dhcp.c

index d9f71f7a9f6913fb067f1cddb4331d912a8c608a..6223570b0a4a5b9a8fd1563cde4cd472ab30e39f 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -60,6 +60,9 @@ work on other platforms. Please report any problems and suggested fixes to
 
 - The server wasn't always sending the FQDN option when it should.
 
+- A partner-down failover server no longer emits 'peer holds all free leases'
+  if it is able to newly-allocate one of the peer's leases.
+
 - Fixed a coredump when adding a class via OMAPI.
 
 - Check whether files are zero length before trying to parse them.
index 30097f5524ba9a867b19bc9d52e5cece539f7ff5..72e34382ce3af053396a1b4cf6e66766ed136ebe 100644 (file)
@@ -3924,18 +3924,47 @@ int allocate_lease (struct lease **lp, struct packet *packet,
                 * XXX result in its being allocated. */
                /* Skip to the most expired lease in the pool that is not
                 * owned by a failover peer. */
-               if (pool -> failover_peer) {
-                       if (pool -> failover_peer -> i_am == primary) {
-                               if (pool -> backup)
-                                       *peer_has_leases = 1;
-                               candl = pool -> free;
-                               if (!candl)
-                                       candl = pool -> abandoned;
+               if (pool->failover_peer != NULL) {
+                       if (pool->failover_peer->i_am == primary) {
+                               candl = pool->free;
+
+                               /*
+                                * In normal operation, we never want to touch
+                                * the peer's leases.  In partner-down 
+                                * operation, we need to be able to pick up
+                                * the peer's leases after STOS+MCLT.
+                                */
+                               if (pool->backup != NULL) {
+                                       if (((candl == NULL) ||
+                                            (candl->ends >
+                                             pool->backup->ends)) &&
+                                           lease_mine_to_reallocate(
+                                                           pool->backup)) {
+                                               candl = pool->backup;
+                                       } else {
+                                               *peer_has_leases = 1;
+                                       }
+                               }
                        } else {
-                               if (pool -> free)
-                                       *peer_has_leases = 1;
-                               candl = pool -> backup;
+                               candl = pool->backup;
+
+                               if (pool->free != NULL) {
+                                       if (((candl == NULL) ||
+                                            (candl->ends >
+                                             pool->free->ends)) &&
+                                           lease_mine_to_reallocate(
+                                                           pool->free)) {
+                                               candl = pool->free;
+                                       } else {
+                                               *peer_has_leases = 1;
+                                       }
+                               }
                        }
+
+                       if ((candl == NULL) &&
+                           (pool->abandoned != NULL) &&
+                           lease_mine_to_reallocate(pool->abandoned))
+                               candl = pool->abandoned;
                } else
 #endif
                {
@@ -3945,6 +3974,15 @@ int allocate_lease (struct lease **lp, struct packet *packet,
                                candl = pool -> abandoned;
                }
 
+               /*
+                * XXX: This may not match with documented expectation.
+                * It's expected that when we OFFER a lease, we set its
+                * ends time forward 2 minutes so that it gets sorted to
+                * the end of its free list (avoiding a similar allocation
+                * to another client).  It is not expected that we issue a
+                * "no free leases" error when the last lease has been
+                * offered, but it's not exactly broken either.
+                */
                if (!candl || (candl -> ends > cur_time))
                        continue;