client_lease_preferred in mdc.c and reserved leases

Foggi, Nicola NFOGGI at depaul.edu
Fri Mar 20 18:02:12 UTC 2009


So far this seems to have solved our latest problems (running it for just under a week now)... not sure if it's proper, but given the notes in the file, it seems like it would make sense, that since a "reserved" lease would always be preferred over any candidate lease, it would return true... or am i reading that wrong?

Nicola

-----Original Message-----
From: dhcp-users-bounces at lists.isc.org on behalf of Foggi, Nicola
Sent: Mon 3/16/2009 1:31 PM
To: dhcp-users at lists.isc.org
Subject: client_lease_preferred in mdc.c and reserved leases
 

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!

Nicola

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


More information about the dhcp-users mailing list