]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor the conditions when adding new NEGATIVE header
authorOndřej Surý <ondrej@isc.org>
Sat, 8 Nov 2025 11:09:18 +0000 (12:09 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 28 Nov 2025 09:10:14 +0000 (10:10 +0100)
Refactor the block when adding existing negative header under common
block, so it is easier to understand that the two conditions inside are
related.

lib/dns/qpcache.c

index fe69818f547454b4ce9ecab743aa8c7cf2848dca..e7948db4d997b9f2bbed4813b1246d5a785ffd9e 100644 (file)
@@ -2681,35 +2681,32 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, dns_slabheader_t *newheader,
                        continue;
                }
 
-               if (EXISTS(newheader) && NEGATIVE(newheader) &&
-                   rdtype == dns_rdatatype_any)
-               {
-                       /*
-                        * We're adding a negative cache entry which
-                        * covers all types (NXDOMAIN, NODATA(QTYPE=ANY)).
-                        *
-                        * Make all other data ancient so that the only
-                        * rdataset that can be found at this node is the
-                        * negative cache entry.
-                        */
-                       mark_ancient(header);
-               }
-
-               if (EXISTS(newheader) && NEGATIVE(newheader) &&
-                   rdtype == dns_rdatatype_rrsig)
-               {
-                       /*
-                        * We're adding a proof that a signature doesn't exist.
-                        *
-                        * Mark all existing signatures as ancient.
-                        */
-                       if (DNS_TYPEPAIR_TYPE(top->typepair) ==
-                           dns_rdatatype_rrsig)
-                       {
+               if (EXISTS(newheader) && NEGATIVE(newheader)) {
+                       if (rdtype == dns_rdatatype_any) {
+                               /*
+                                * We're adding a negative cache entry which
+                                * covers all types (NXDOMAIN,
+                                * NODATA(QTYPE=ANY)).
+                                *
+                                * Make all other data ancient so that the only
+                                * rdataset that can be found at this node is
+                                * the negative cache entry.
+                                */
                                mark_ancient(header);
+                       } else if (rdtype == dns_rdatatype_rrsig) {
+                               /*
+                                * We're adding a proof that a signature doesn't
+                                * exist.
+                                *
+                                * Mark all existing signatures as ancient.
+                                */
+                               if (DNS_TYPEPAIR_TYPE(top->typepair) ==
+                                   dns_rdatatype_rrsig)
+                               {
+                                       mark_ancient(header);
+                               }
                        }
                }
-
                if (EXISTS(newheader) && !NEGATIVE(newheader) &&
                    NEGATIVE(header) && EXISTS(header) && ACTIVE(header, now))
                {