From b8221d9512404344de3e90c0bf7f6df903bd1c31 Mon Sep 17 00:00:00 2001 From: David Hankins Date: Fri, 8 Jun 2007 18:56:30 +0000 Subject: [PATCH] - supersede_lease() now requeues leases in their respective hardware address hash bucket. This mirrors client identifier behaviour. [ISC-Bugs #16936] --- RELNOTES | 5 +++++ server/mdb.c | 45 +++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/RELNOTES b/RELNOTES index 5b5e8b7c..1b234329 100644 --- a/RELNOTES +++ b/RELNOTES @@ -372,6 +372,11 @@ suggested fixes to . - Encapsulated option spaces within encapsulated option spaces is now formally supported. + Changes since 3.0.6rc1 + +- supersede_lease() now requeues leases in their respective hardware + address hash bucket. This mirrors client identifier behaviour. + Changes since 3.0.5 - Assorted fixes for broken network devices: Packet length is now diff --git a/server/mdb.c b/server/mdb.c index 6c979cff..8bc73113 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: mdb.c,v 1.91 2007/05/19 19:16:27 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n"; +"$Id: mdb.c,v 1.92 2007/06/08 18:56:30 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -1064,8 +1064,6 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate) int propogate; int pimmediate; { - int enter_uid = 0; - int enter_hwaddr = 0; struct lease *lp, **lq, *prev; TIME lp_next_state; #if defined (FAILOVER_PROTOCOL) @@ -1113,28 +1111,21 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate) /* If there's a Unique ID, dissociate it from the hash table and free it if necessary. */ - if (comp -> uid) { - uid_hash_delete (comp); - enter_uid = 1; - if (comp -> uid != &comp -> uid_buf [0]) { - dfree (comp -> uid, MDL); - comp -> uid_max = 0; - comp -> uid_len = 0; + if (comp->uid) { + uid_hash_delete(comp); + if (comp->uid != comp->uid_buf) { + dfree(comp->uid, MDL); + comp->uid_max = 0; + comp->uid_len = 0; } comp -> uid = (unsigned char *)0; - } else - enter_uid = 1; + } - if (comp -> hardware_addr.hlen && - ((comp -> hardware_addr.hlen != - lease -> hardware_addr.hlen) || - memcmp (comp -> hardware_addr.hbuf, - lease -> hardware_addr.hbuf, - comp -> hardware_addr.hlen))) { - hw_hash_delete (comp); - enter_hwaddr = 1; - } else if (!comp -> hardware_addr.hlen) - enter_hwaddr = 1; + /* If there's a hardware address, remove the lease from its + * old position in the hash bucket's ordered list. + */ + if (comp->hardware_addr.hlen) + hw_hash_delete(comp); /* If the lease has been billed to a class, remove the billing. */ if (comp -> billing_class != lease -> billing_class) { @@ -1224,14 +1215,12 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate) } /* Record the lease in the uid hash if necessary. */ - if (enter_uid && comp -> uid) { - uid_hash_add (comp); - } + if (comp->uid) + uid_hash_add(comp); /* Record it in the hardware address hash if necessary. */ - if (enter_hwaddr && lease -> hardware_addr.hlen) { - hw_hash_add (comp); - } + if (comp->hardware_addr.hlen) + hw_hash_add(comp); comp->cltt = lease->cltt; #if defined (FAILOVER_PROTOCOL)