]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make whether to follow additional data records generic
authorMark Andrews <marka@isc.org>
Tue, 23 Mar 2021 23:58:09 +0000 (10:58 +1100)
committerMark Andrews <marka@isc.org>
Wed, 18 Aug 2021 03:49:48 +0000 (13:49 +1000)
Adds dns_rdatatype_followadditional() and
DNS_RDATATYPEATTR_FOLLOWADDITIONAL

lib/dns/include/dns/rdata.h
lib/dns/rdata.c
lib/dns/rdata/in_1/srv_33.c
lib/ns/query.c

index 359f69d674cca2ed0b50a4136688fc073f454e43..476ef5f9c70f96bf112962a996f9c031f2aa8465 100644 (file)
@@ -695,6 +695,21 @@ dns_rdatatype_atcname(dns_rdatatype_t type);
  *
  */
 
+bool
+dns_rdatatype_followadditional(dns_rdatatype_t type);
+/*%<
+ * Return true if adding a record of type 'type' to the ADDITIONAL section
+ * of a message can itself trigger the addition of still more data to the
+ * additional section.
+ *
+ * (For example: adding SRV to the ADDITIONAL section may trigger
+ * the addition of address records associated with that SRV.)
+ *
+ * Requires:
+ * \li 'type' is a valid rdata type.
+ *
+ */
+
 unsigned int
 dns_rdatatype_attributes(dns_rdatatype_t rdtype);
 /*%<
@@ -729,6 +744,8 @@ dns_rdatatype_attributes(dns_rdatatype_t rdtype);
 #define DNS_RDATATYPEATTR_ATPARENT 0x00000200U
 /*% Can exist along side a CNAME */
 #define DNS_RDATATYPEATTR_ATCNAME 0x00000400U
+/*% Follow additional */
+#define DNS_RDATATYPEATTR_FOLLOWADDITIONAL 0x00000800U
 
 dns_rdatatype_t
 dns_rdata_covers(dns_rdata_t *rdata);
index 6fb7bc3d22860abbdb72b79ec8aaea4be3be5395..c8d684a38c12e46dfaa1e7b034fbfae7be7b5c36 100644 (file)
@@ -2131,6 +2131,15 @@ dns_rdatatype_atparent(dns_rdatatype_t type) {
        return (false);
 }
 
+bool
+dns_rdatatype_followadditional(dns_rdatatype_t type) {
+       if ((dns_rdatatype_attributes(type) &
+            DNS_RDATATYPEATTR_FOLLOWADDITIONAL) != 0) {
+               return (true);
+       }
+       return (false);
+}
+
 bool
 dns_rdataclass_ismeta(dns_rdataclass_t rdclass) {
        if (rdclass == dns_rdataclass_reserved0 ||
index 268c0e9385c7dfa75a12809553d01a30d88debbb..80dd1d637c78112cff92c4b3393dd3fdeee98fc4 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef RDATA_IN_1_SRV_33_C
 #define RDATA_IN_1_SRV_33_C
 
-#define RRTYPE_SRV_ATTRIBUTES (0)
+#define RRTYPE_SRV_ATTRIBUTES (DNS_RDATATYPEATTR_FOLLOWADDITIONAL)
 
 static inline isc_result_t
 fromtext_in_srv(ARGS_FROMTEXT) {
index a9b1cd9dbb3a14f4380f91679b6cb81bf0809004..81ff6abfe7692009f5615f1f8525713f80117016 100644 (file)
@@ -2041,22 +2041,11 @@ addname:
        fname = NULL;
 
        /*
-        * In a few cases, we want to add additional data for additional
-        * data.  It's simpler to just deal with special cases here than
-        * to try to create a general purpose mechanism and allow the
-        * rdata implementations to do it themselves.
-        *
-        * This involves recursion, but the depth is limited.  The
-        * most complex case is adding a SRV rdataset, which involves
-        * recursing to add address records, which in turn can cause
-        * recursion to add KEYs.
+        * In some cases, a record that has been added as additional
+        * data may *also* trigger the addition of additional data.
+        * This cannot go more than MAX_RESTARTS levels deep.
         */
-       if (type == dns_rdatatype_srv && trdataset != NULL) {
-               /*
-                * If we're adding SRV records to the additional data
-                * section, it's helpful if we add the SRV additional data
-                * as well.
-                */
+       if (trdataset != NULL && dns_rdatatype_followadditional(type)) {
                eresult = dns_rdataset_additionaldata(
                        trdataset, query_additional_cb, qctx);
        }