Make whether to follow additional data records generic

Adds dns_rdatatype_followadditional() and
DNS_RDATATYPEATTR_FOLLOWADDITIONAL
This commit is contained in:
Mark Andrews 2021-03-24 10:58:09 +11:00
parent b5b6c1f6d8
commit f0265b8fa6
4 changed files with 31 additions and 16 deletions

View 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);

View 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 ||

View 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) {

View 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);
}