[Dnsmasq-discuss] [PATCH 1/2] Keep the hash chain order when an entry becomes immortal.
Dominik Derigs
git at dl6er.de
Fri Oct 30 06:34:44 UTC 2026
From: DL6ER <dl6er at dl6er.de>
make_non_terminals() marks an existing entry for a parent name immortal
when a name below it gets an infinite DHCP lease, but leaves the entry
where it is in its hash chain. cache_hash() keeps non-reverse immortal
entries at the end of the chain, and the expiry scan in
cache_scan_free() stops at the first one, so expired entries behind
such an entry are skipped by the scan.
Re-insert the entry with cache_hash() when it becomes immortal.
Signed-off-by: DL6ER <dl6er at dl6er.de>
---
src/cache.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/cache.c b/src/cache.c
index 6bcb1b2..ad4936b 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1924,7 +1924,14 @@ static void make_non_terminals(struct crec *source)
if (!(crecp->flags & F_IMMORTAL))
{
if (source->flags & F_IMMORTAL)
- crecp->flags |= F_IMMORTAL;
+ {
+ /* Re-hash it, cache_hash() keeps immortal entries
+ where the expiry scan in cache_scan_free() expects them. */
+ for (up = hash_bucket(name); *up != crecp; up = &(*up)->hash_next);
+ *up = crecp->hash_next;
+ crecp->flags |= F_IMMORTAL;
+ cache_hash(crecp);
+ }
else if (difftime(crecp->ttd, source->ttd) < 0)
crecp->ttd = source->ttd;
}
--
2.53.0
More information about the Dnsmasq-discuss
mailing list