client_lease_preferred in mdc.c and reserved leases

Foggi, Nicola NFOGGI at
Mon Mar 16 18:31:08 UTC 2009

OK... so again had problems with the "reserved" flag, this time somehow (not sure how) the device got an active lease OTHER than it's reserved lease.  The server would then prefer that lease over the reserved lease (despite the previous talk about the fix to the find_lease hash and such).

Digging into it I found "client_lease_preferred" in mdb.c, which looks like it returns which lease is preferred to within the "find_lease_by_hw_addr" where according to the notes (and the code) it doesn't seem to address RESERVED leases.  Would something like this be proper:

client_lease_preferred(struct lease *cand, struct lease *lease)
        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;
        } else if (cand->binding_state == FTS_EXPIRED ||
                   cand->binding_state == FTS_RELEASED) {
                if (lease->binding_state == FTS_ACTIVE)
                        return ISC_TRUE;

                if ((lease->binding_state == FTS_EXPIRED ||
                     lease->binding_state == FTS_RELEASED) &&
                    lease->cltt >= cand->cltt)
                        return ISC_TRUE;
        } else if (cand->binding_state != FTS_ABANDONED) {
                if (lease->binding_state == FTS_ACTIVE ||
                    lease->binding_state == FTS_EXPIRED ||
                    lease->binding_state == FTS_RELEASED)
                        return ISC_TRUE;

                if (lease->binding_state != FTS_ABANDONED &&
                    lease->cltt >= cand->cltt)
                        return ISC_TRUE;
        } else /* (cand->binding_state == FTS_ABANDONED) */ {
                if (lease->binding_state != FTS_ABANDONED ||
                    lease->cltt >= cand->cltt)
                        return ISC_TRUE;

        return ISC_FALSE;

(not adding the first check for the RESERVED lease).... not sure if that's proper or not, let me know what you think!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the dhcp-users mailing list