dhcpd 3.1.2b1 failover with reserved flags

Foggi, Nicola NFOGGI at depaul.edu
Mon Nov 16 16:29:04 UTC 2009


I just submitted this email to dhcp-bugs, but wanted to put it out on the mailing list incase anyone else sees problems like this that i ran into

****
I wanted to run these in production for awhile before submitting them, not sure if they've been resolved in newer versions (given the release notes, i didn't see much around them), but then i forgot to submit them.  We've been running them in production for quite a while now and they seemed to have fixed problems around a failover pair and reserved leases.  We were having 2 problems if I remember correctly:

1.  In mdb.c it was not always preferring a reserved lease
2.  in the failover pair, a secondary server wouldn't allocate a reserved lease

I am not a coder, so i'm not sure if it's kosher or not, but as i said it's been running in production for a few months now on our end and it fixed the 2 problems above.

Let me know what you think.

--- mdb.c.orig  2009-03-16 13:27:37.000000000 -0500
+++ mdb.c       2009-03-16 22:35:35.000000000 -0500
@@ -1684,18 +1684,21 @@
  * the 'uid_hash_add' and 'hw_hash_add' functions (this is common logic
  * to those two functions).
  *
- * 1) ACTIVE leases are preferred.  The active lease with
+ * 1) RESERVED leases are always preferred
+ * 2) ACTIVE leases are preferred.  The active lease with
  *    the longest lifetime is preferred over shortest.
- * 2) "transitional states" are next, this time with the
+ * 3) "transitional states" are next, this time with the
  *    most recent CLTT.
- * 3) free/backup/etc states are next, again with CLTT.  In truth we
+ * 4) free/backup/etc states are next, again with CLTT.  In truth we
  *    should never see reset leases for this.
- * 4) Abandoned leases are always dead last.
+ * 5) Abandoned leases are always dead last.
  */
 static isc_boolean_t
 client_lease_preferred(struct lease *cand, struct lease *lease)
 {
-       if (cand->binding_state == FTS_ACTIVE) {
+       if (lease->flags & RESERVED_LEASE) {
+               return ISC_TRUE;
+       } else if (cand->binding_state == FTS_ACTIVE) {
                if (lease->binding_state == FTS_ACTIVE &&
                    lease->ends >= cand->ends)
                        return ISC_TRUE;

--- failover.c.orig     2008-09-24 11:20:26.000000000 -0500
+++ failover.c  2009-03-26 16:52:46.000000000 -0500
@@ -6068,6 +6068,18 @@
                        if (peer -> i_am == primary)
                                return 1;
 
+                       if (lease->flags & RESERVED_LEASE)
+                               return 1;
+
+                        /* If lease is RESERVED allow secondary to allocate
+                         * lease
+                         */
+
+                        if ((peer -> i_am == secondary) &&
+                             (lease->flags & RESERVED_LEASE)) {
+                                return 1;
+                        }
+
                        return(peer->service_state == service_partner_down &&
                               ((lease->tsfp < peer->me.stos) ?
                                (peer->me.stos + peer->mclt < cur_time) :
@@ -6091,6 +6103,10 @@
                         * to MCLT, rather than a TSFP-optimal lease, which is
                         * the only danger for a lease in one of these states.
                         */
+
+                       if (lease->flags & RESERVED_LEASE)
+                               return 1;
+
                        return((peer->service_state == service_partner_down) &&
                               (lease->tsfp < cur_time));
 
@@ -6100,9 +6116,20 @@
                         * least TSFP+MCLT or STOS+MCLT must have expired,
                         * whichever is greater.
                         */
-                       if (peer->i_am == secondary)
+                       if (peer->i_am == secondary) 
+                               return 1;
+
+                       if (lease->flags & RESERVED_LEASE)
                                return 1;
 
+                        /* If lease is RESERVED allow primary to allocate
+                         * lease
+                         */
+                        if ((peer -> i_am == primary) &&
+                             (lease->flags & RESERVED_LEASE)) {
+                                return 1;
+                        }
+
                        return((peer->service_state == service_partner_down) &&
                               ((lease->tsfp < peer->me.stos) ?
                                (peer->me.stos + peer->mclt < cur_time) :



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20091116/9c1677a5/attachment.html>


More information about the dhcp-users mailing list