]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- The peer_wants_leases() changes pulled up from 3.1.0 were corrected,
authorDavid Hankins <dhankins@isc.org>
Tue, 9 Oct 2007 22:32:49 +0000 (22:32 +0000)
committerDavid Hankins <dhankins@isc.org>
Tue, 9 Oct 2007 22:32:49 +0000 (22:32 +0000)
  'never used' leases will no longer consistently shift between servers
  on every pool rebalance run.  [ISC-Bugs #17211]

RELNOTES
server/failover.c

index b4f6c7b36ad39ff8745110dae51fe27021273d07..40d161cb0915752ceb94908dd31355345498820e 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -57,6 +57,10 @@ suggested fixes to <dhcp-users@isc.org>.
 - A number of bugs with the internal handling of lease state on the 
   server have been fixed. Some of these could cause server crashes.
 
+- The peer_wants_leases() changes pulled up from 3.1.0 were corrected,
+  'never used' leases will no longer consistently shift between servers
+  on every pool rebalance run.
+
                        Changes since 4.0.0a3
 
 - The DHCP server no longer requires a "ddns-update-style" statement, 
index 8371955458a94336985d0c42842d2f85439450e4..36451fb03b689dccaf096f195132c2e0d3255e56 100644 (file)
@@ -2362,17 +2362,40 @@ static int dhcp_failover_pool_dobalance(dhcp_failover_state_t *state)
                pass = 0;
                lease_reference(&lp, *lq, MDL);
 
-               /* In the case where there are 2 leases, hold is zero, and
-                * lts is 1 if both leases are on the local server.  If
-                * there is only 1 lease, both lts and hold are zero.  Let's
-                * not play ping pong.
-                */
-               while (lp && (lts > (pass ? hold : -hold))) {
+               while (lp) {
                        if (next)
                            lease_dereference(&next, MDL);
                        if (lp->next)
                            lease_reference(&next, lp->next, MDL);
 
+                       /*
+                        * Stop if the pool is 'balanced enough.'
+                        *
+                        * The pool is balanced enough if:
+                        *
+                        * 1) We're on the first run through and the peer has
+                        *    its fair share of leases already (lts reaches
+                        *    -hold).
+                        * 2) We're on the second run through, we are shifting
+                        *    never-used leases, and there is a perfectly even
+                        *    balance (lts reaches zero).
+                        * 3) Second run through, we are shifting previously
+                        *    used leases, and the local system has its fair
+                        *    share but no more (lts reaches hold).
+                        *
+                        * Note that this is implemented below in 3,2,1 order.
+                        */
+                       if (pass) {
+                               if (lp->ends) {
+                                       if (lts <= hold)
+                                               break;
+                               } else {
+                                       if (lts <= 0)
+                                               break;
+                               }
+                       } else if (lts <= -hold)
+                               break;
+
                        if (pass || peer_wants_lease(lp)) {
                            --lts;
                            ++leases_queued;
@@ -5512,8 +5535,8 @@ peer_wants_lease(struct lease *lp)
                 */
                hbaix = loadb_p_hash(lp->hardware_addr.hbuf + 1,
                                     lp->hardware_addr.hlen - 1);
-       else /* Consistent 50/50 split */
-               return(lp->ip_addr.iabuf[lp->ip_addr.len-1] & 0x01);
+       else /* impossible to categorize into LBA */
+               return 0;
 
        hm = state->hba[(hbaix >> 3) & 0x1F] & (1 << (hbaix & 0x07));