]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Order the diff from dns_db_diffx so that deletes proceed adds
authorMark Andrews <marka@isc.org>
Mon, 19 Jul 2021 22:46:32 +0000 (08:46 +1000)
committerMark Andrews <marka@isc.org>
Thu, 22 Jul 2021 23:20:25 +0000 (09:20 +1000)
for the same rdataset.  This allows the diff when passed to
dns_diff_apply to succeed.

(cherry picked from commit 76453961bd0b2fee550557dce59ef2c7caf831d1)

lib/dns/include/dns/diff.h
lib/dns/journal.c
lib/dns/zone.c

index ea535d442662610a7303b26650a702d6b0e11d70..b3ae0054bd77d55fadbcb9f3e8b90451ce16cc39 100644 (file)
@@ -66,6 +66,7 @@ typedef enum {
 } dns_diffop_t;
 
 typedef struct dns_difftuple dns_difftuple_t;
+typedef ISC_LIST(dns_difftuple_t) dns_difftuplelist_t;
 
 #define DNS_DIFFTUPLE_MAGIC    ISC_MAGIC('D', 'I', 'F', 'T')
 #define DNS_DIFFTUPLE_VALID(t) ISC_MAGIC_VALID(t, DNS_DIFFTUPLE_MAGIC)
@@ -92,9 +93,9 @@ typedef struct dns_diff dns_diff_t;
 #define DNS_DIFF_VALID(t) ISC_MAGIC_VALID(t, DNS_DIFF_MAGIC)
 
 struct dns_diff {
-       unsigned int magic;
-       isc_mem_t *  mctx;
-       ISC_LIST(dns_difftuple_t) tuples;
+       unsigned int        magic;
+       isc_mem_t *         mctx;
+       dns_difftuplelist_t tuples;
 };
 
 /* Type of comparison function for sorting diffs. */
index 7b355083fa4afcb8d5b075da72448e2392d5081a..180d6d46b7a7c1726761013b60a350d2eef0365b 100644 (file)
@@ -2193,9 +2193,12 @@ dns_diff_subtract(dns_diff_t diff[2], dns_diff_t *r) {
        dns_difftuple_t *p[2];
        int i, t;
        bool append;
+       dns_difftuplelist_t add, del;
 
        CHECK(dns_diff_sort(&diff[0], rdata_order));
        CHECK(dns_diff_sort(&diff[1], rdata_order));
+       ISC_LIST_INIT(add);
+       ISC_LIST_INIT(del);
 
        for (;;) {
                p[0] = ISC_LIST_HEAD(diff[0].tuples);
@@ -2206,23 +2209,21 @@ dns_diff_subtract(dns_diff_t diff[2], dns_diff_t *r) {
 
                for (i = 0; i < 2; i++) {
                        if (p[!i] == NULL) {
-                               {
-                                       ISC_LIST_UNLINK(diff[i].tuples, p[i],
-                                                       link);
-                                       ISC_LIST_APPEND(r->tuples, p[i], link);
-                                       goto next;
-                               }
+                               dns_difftuplelist_t *l = (i == 0) ? &add : &del;
+                               ISC_LIST_UNLINK(diff[i].tuples, p[i], link);
+                               ISC_LIST_APPEND(*l, p[i], link);
+                               goto next;
                        }
                }
                t = rdata_order(&p[0], &p[1]);
                if (t < 0) {
                        ISC_LIST_UNLINK(diff[0].tuples, p[0], link);
-                       ISC_LIST_APPEND(r->tuples, p[0], link);
+                       ISC_LIST_APPEND(add, p[0], link);
                        goto next;
                }
                if (t > 0) {
                        ISC_LIST_UNLINK(diff[1].tuples, p[1], link);
-                       ISC_LIST_APPEND(r->tuples, p[1], link);
+                       ISC_LIST_APPEND(del, p[1], link);
                        goto next;
                }
                INSIST(t == 0);
@@ -2234,13 +2235,16 @@ dns_diff_subtract(dns_diff_t diff[2], dns_diff_t *r) {
                for (i = 0; i < 2; i++) {
                        ISC_LIST_UNLINK(diff[i].tuples, p[i], link);
                        if (append) {
-                               ISC_LIST_APPEND(r->tuples, p[i], link);
+                               dns_difftuplelist_t *l = (i == 0) ? &add : &del;
+                               ISC_LIST_APPEND(*l, p[i], link);
                        } else {
                                dns_difftuple_free(&p[i]);
                        }
                }
        next:;
        }
+       ISC_LIST_APPENDLIST(r->tuples, del, link);
+       ISC_LIST_APPENDLIST(r->tuples, add, link);
        result = ISC_R_SUCCESS;
 failure:
        return (result);
index cc859a284c6690856e61f39f1f540872199fe34f..fc9157da6abe96d8f2bf2e494630f2092e745571 100644 (file)
@@ -16272,7 +16272,8 @@ sync_secure_db(dns_zone_t *seczone, dns_zone_t *raw, dns_db_t *secdb,
                 * If the SOA records are the same except for the serial
                 * remove them from the diff.
                 */
-               if (oldsoa.refresh == newsoa.refresh &&
+               if (oldtuple->ttl == newtuple->ttl &&
+                   oldsoa.refresh == newsoa.refresh &&
                    oldsoa.retry == newsoa.retry &&
                    oldsoa.minimum == newsoa.minimum &&
                    oldsoa.expire == newsoa.expire &&