]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
preserve cache when reload fails
authorColin Vidal <colin@isc.org>
Tue, 16 Sep 2025 15:14:33 +0000 (17:14 +0200)
committerColin Vidal <colin@isc.org>
Thu, 18 Sep 2025 07:06:31 +0000 (09:06 +0200)
If the server is reloaded, new views are created and preexisting cache
is attached to those _but_ something goes wrong later, the previous
views are restored but the previous cache list is destroyed. This makes
the subsequent reload to drop the existing cache. This fixes it by
avoiding a mutation of the old cache list.

(cherry picked from commit a1703fa35b1ad3e2be1ff961122b5fdc39654b5e)

bin/named/server.c

index 5168c47ca0b1a68eb34e10af8c9d061b4f1d52ef..6145e9181e1f25db996a7df0b84d0e426994abb7 100644 (file)
@@ -4839,13 +4839,15 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
                                      dns_cache_getname(nsc->cache));
                        nsc = NULL;
                } else {
+                       shared_cache = true;
+                       dns_cache_attach(nsc->cache, &cache);
                        if (oldcache) {
-                               ISC_LIST_UNLINK(*oldcachelist, nsc, link);
-                               ISC_LIST_APPEND(*cachelist, nsc, link);
-                               nsc->primaryview = view;
+                               /*
+                                * We need to re-use the cache, but we don't
+                                * want to mutate the old production list.
+                                */
+                               nsc = NULL;
                        }
-                       dns_cache_attach(nsc->cache, &cache);
-                       shared_cache = true;
                }
        } else if (strcmp(cachename, view->name) == 0) {
                result = dns_viewlist_find(&named_g_server->viewlist, cachename,