From ba2d393cd8aeed8fe4da7dde8d7a1a2e95798f9b Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Tue, 7 Sep 1999 05:26:26 +0000 Subject: [PATCH] don't ignore updates that change only the TTL --- lib/dns/include/dns/journal.h | 17 ++++++++++++----- lib/dns/journal.c | 24 +++++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lib/dns/include/dns/journal.h b/lib/dns/include/dns/journal.h index e64d14016f..9d6771f875 100644 --- a/lib/dns/include/dns/journal.h +++ b/lib/dns/include/dns/journal.h @@ -32,6 +32,9 @@ #include #include +#include +#include +#include /*** *** Types @@ -43,12 +46,16 @@ ISC_LANG_BEGINDECLS * A dns_difftuple_t represents a single RR being added or deleted. * The RR type and class are in the 'rdata' member; the class is always * the real one, not a DynDNS meta-class, so that the rdatas can be - * compared using dns_rdata_compare(). The TTL is ignored for - * RRs to be deleted. + * compared using dns_rdata_compare(). The TTL is significant + * even for deletions, because a deletion/addition pair cannot + * be canceled out if the TTL differs (it might be an explicit + * TTL update). * - * Tuples are also used to represent the individual RRs of a - * a "RRset exists (value dependent)" prerequisite set. In this case, - * op==DNS_DIFFOP_EXISTS, and the TTL is ignored. + * Tuples are also used to represent complete RRs with owner + * names for a couple of other purposes, such as the + * individual RRs of a "RRset exists (value dependent)" + * prerequisite set. In this case, op==DNS_DIFFOP_EXISTS, + * and the TTL is ignored. */ typedef enum { diff --git a/lib/dns/journal.c b/lib/dns/journal.c index e8f712b202..b09b0b32da 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -293,10 +293,12 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep) REQUIRE(VALID_DIFFTUPLE(*tuplep)); /* - * Look for an existing tuple with the same owner name - * and rdata. If we are doing an addition and find a + * Look for an existing tuple with the same owner name, + * rdata, and TTL. If we are doing an addition and find a * deletion or vice versa, remove both the old and the - * new tuple since they cancel each other out. + * new tuple since they cancel each other out (assuming + * that we never delete nonexistent data or add existing + * data). * * If we find an old update of the same kind as * the one we are doing, there must be a programming @@ -307,7 +309,8 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep) { next_ot = ISC_LIST_NEXT(ot, link); if (dns_name_equal(&ot->name, &(*tuplep)->name) && - dns_rdata_compare(&ot->rdata, &(*tuplep)->rdata) == 0) + dns_rdata_compare(&ot->rdata, &(*tuplep)->rdata) == 0 && + ot->ttl == (*tuplep)->ttl) { ISC_LIST_UNLINK(diff->tuples, ot, link); if ((*tuplep)->op == ot->op) { @@ -388,7 +391,14 @@ dns_diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver) ISC_LINK_INIT(&rdl, link); while (t != NULL && dns_name_equal(&t->name, name) && - t->op == op && t->rdata.type == type) { + t->op == op && t->rdata.type == type) + { + if (t->ttl != rdl.ttl) { + printf("TTL differs in rdataset, " + "adjusting %lu -> %lu\n", + (unsigned long) t->ttl, + (unsigned long) rdl.ttl); + } ISC_LIST_APPEND(rdl.rdata, &t->rdata, link); t = ISC_LIST_NEXT(t, link); } @@ -412,8 +422,8 @@ dns_diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver) if (result == DNS_R_UNCHANGED) { /* * This will not happen when executing a - * dynamic * update, because that code will - * generate strictly * minimal diffs. + * dynamic update, because that code will + * generate strictly minimal diffs. * It may happen when receiving an IXFR * from a server that is not as careful. * Issue a warning and continue.