<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>client_lease_preferred in mdc.c and reserved leases</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=2>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).<BR>
<BR>
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:<BR>
<BR>
client_lease_preferred(struct lease *cand, struct lease *lease)<BR>
{<BR>
        if (lease->flags & RESERVED_LEASE) {<BR>
                return ISC_TRUE;<BR>
        } else if (cand->binding_state == FTS_ACTIVE) {<BR>
                if (lease->binding_state == FTS_ACTIVE &&<BR>
                    lease->ends >= cand->ends)<BR>
                        return ISC_TRUE;<BR>
        } else if (cand->binding_state == FTS_EXPIRED ||<BR>
                   cand->binding_state == FTS_RELEASED) {<BR>
                if (lease->binding_state == FTS_ACTIVE)<BR>
                        return ISC_TRUE;<BR>
<BR>
                if ((lease->binding_state == FTS_EXPIRED ||<BR>
                     lease->binding_state == FTS_RELEASED) &&<BR>
                    lease->cltt >= cand->cltt)<BR>
                        return ISC_TRUE;<BR>
        } else if (cand->binding_state != FTS_ABANDONED) {<BR>
                if (lease->binding_state == FTS_ACTIVE ||<BR>
                    lease->binding_state == FTS_EXPIRED ||<BR>
                    lease->binding_state == FTS_RELEASED)<BR>
                        return ISC_TRUE;<BR>
<BR>
                if (lease->binding_state != FTS_ABANDONED &&<BR>
                    lease->cltt >= cand->cltt)<BR>
                        return ISC_TRUE;<BR>
        } else /* (cand->binding_state == FTS_ABANDONED) */ {<BR>
                if (lease->binding_state != FTS_ABANDONED ||<BR>
                    lease->cltt >= cand->cltt)<BR>
                        return ISC_TRUE;<BR>
        }<BR>
<BR>
        return ISC_FALSE;<BR>
}<BR>
<BR>
(not adding the first check for the RESERVED lease).... not sure if that's proper or not, let me know what you think!<BR>
<BR>
Nicola</FONT>
</P>

</BODY>
</HTML>