From 5fca0fb5193c0336305501264b1a253d00f8eb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 18 Oct 2023 16:19:41 +0200 Subject: [PATCH 1/4] Remove unused dns_message_movename() method Since dns_message_movename() was unused, it could be removed from the code based to declutter the API. --- lib/dns/include/dns/message.h | 17 ----------------- lib/dns/message.c | 16 ---------------- 2 files changed, 33 deletions(-) diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index acf06a9218..a4b4b3ffbe 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -880,23 +880,6 @@ dns_message_find(const dns_name_t *name, dns_rdataclass_t rdclass, *\li #ISC_R_NOTFOUND -- the desired type does not exist. */ -void -dns_message_movename(dns_message_t *msg, dns_name_t *name, - dns_section_t fromsection, dns_section_t tosection); -/*%< - * Move a name from one section to another. - * - * Requires: - * - *\li 'msg' be valid. - * - *\li 'name' must be a name already in 'fromsection'. - * - *\li 'fromsection' must be a valid section. - * - *\li 'tosection' must be a valid section. - */ - void dns_message_addname(dns_message_t *msg, dns_name_t *name, dns_section_t section); diff --git a/lib/dns/message.c b/lib/dns/message.c index 5ec09c6f7d..601bc1c98e 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -2469,22 +2469,6 @@ dns_message_findname(dns_message_t *msg, dns_section_t section, return (result); } -void -dns_message_movename(dns_message_t *msg, dns_name_t *name, - dns_section_t fromsection, dns_section_t tosection) { - REQUIRE(msg != NULL); - REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER); - REQUIRE(name != NULL); - REQUIRE(VALID_NAMED_SECTION(fromsection)); - REQUIRE(VALID_NAMED_SECTION(tosection)); - - /* - * Unlink the name from the old section - */ - ISC_LIST_UNLINK(msg->sections[fromsection], name, link); - ISC_LIST_APPEND(msg->sections[tosection], name, link); -} - void dns_message_addname(dns_message_t *msg, dns_name_t *name, dns_section_t section) { From fd732a7fb5068adcd0f93d0c1f07015503210f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 19 Oct 2023 09:41:55 +0200 Subject: [PATCH 2/4] Add dns__message_putassociatedrdataset() to deduplicate code There was a lot of internal code looking like this: INSIST(dns_rdataset_isassociated(rdataset)); dns_rdataset_disassociated(rdataset) isc_mempool_put(msg->rdspool, rdataset); Deduplicate the code into local dns__message_puttemprdataset() routine, and drop the INSIST() which is checked in dns_rdataset_disassociate(). --- lib/dns/message.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/lib/dns/message.c b/lib/dns/message.c index 601bc1c98e..4437763179 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -178,6 +178,15 @@ msgblock_allocate(isc_mem_t *, unsigned int, unsigned int); #define msgblock_get(block, type) \ ((type *)msgblock_internalget(block, sizeof(type))) +/* + * This function differs from public dns_message_puttemprdataset() that it + * requires the *rdatasetp to be associated, and it will disassociate and + * put it back to the memory pool. + */ +static void +dns__message_putassociatedrdataset(dns_message_t *msg, + dns_rdataset_t **rdatasetp); + static void * msgblock_internalget(dns_msgblock_t *, unsigned int); @@ -453,9 +462,7 @@ msgresetnames(dns_message_t *msg, unsigned int first_section) { next_rds = ISC_LIST_NEXT(rds, link); ISC_LIST_UNLINK(name->list, rds, link); - INSIST(dns_rdataset_isassociated(rds)); - dns_rdataset_disassociate(rds); - isc_mempool_put(msg->rdspool, rds); + dns__message_putassociatedrdataset(msg, &rds); rds = next_rds; } dns_message_puttempname(msg, &name); @@ -471,9 +478,7 @@ msgresetopt(dns_message_t *msg) { dns_message_renderrelease(msg, msg->opt_reserved); msg->opt_reserved = 0; } - INSIST(dns_rdataset_isassociated(msg->opt)); - dns_rdataset_disassociate(msg->opt); - isc_mempool_put(msg->rdspool, msg->opt); + dns__message_putassociatedrdataset(msg, &msg->opt); msg->opt = NULL; msg->cc_ok = 0; msg->cc_bad = 0; @@ -493,24 +498,20 @@ msgresetsigs(dns_message_t *msg, bool replying) { INSIST(msg->querytsig == NULL); msg->querytsig = msg->tsig; } else { - dns_rdataset_disassociate(msg->tsig); - isc_mempool_put(msg->rdspool, msg->tsig); + dns__message_putassociatedrdataset(msg, &msg->tsig); if (msg->querytsig != NULL) { - dns_rdataset_disassociate(msg->querytsig); - isc_mempool_put(msg->rdspool, msg->querytsig); + dns__message_putassociatedrdataset( + msg, &msg->querytsig); } } dns_message_puttempname(msg, &msg->tsigname); msg->tsig = NULL; } else if (msg->querytsig != NULL && !replying) { - dns_rdataset_disassociate(msg->querytsig); - isc_mempool_put(msg->rdspool, msg->querytsig); + dns__message_putassociatedrdataset(msg, &msg->querytsig); msg->querytsig = NULL; } if (msg->sig0 != NULL) { - INSIST(dns_rdataset_isassociated(msg->sig0)); - dns_rdataset_disassociate(msg->sig0); - isc_mempool_put(msg->rdspool, msg->sig0); + dns__message_putassociatedrdataset(msg, &msg->sig0); msg->sig0 = NULL; } if (msg->sig0name != NULL) { @@ -1081,8 +1082,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t dctx, cleanup: if (rdataset != NULL) { - INSIST(!dns_rdataset_isassociated(rdataset)); - isc_mempool_put(msg->rdspool, rdataset); + dns_message_puttemprdataset(msg, &rdataset); } if (free_name) { dns_message_puttempname(msg, &name); @@ -1580,7 +1580,8 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t dctx, dns_message_puttempname(msg, &name); } if (free_rdataset) { - isc_mempool_put(msg->rdspool, rdataset); + dns__message_putassociatedrdataset(msg, + &rdataset); } free_name = free_rdataset = false; } @@ -1612,7 +1613,7 @@ cleanup: dns_message_puttempname(msg, &name); } if (free_rdataset) { - isc_mempool_put(msg->rdspool, rdataset); + dns__message_putassociatedrdataset(msg, &rdataset); } return (result); @@ -2564,6 +2565,13 @@ dns_message_puttemprdata(dns_message_t *msg, dns_rdata_t **item) { *item = NULL; } +static void +dns__message_putassociatedrdataset(dns_message_t *msg, dns_rdataset_t **item) { + dns_rdataset_disassociate(*item); + isc_mempool_put(msg->rdspool, *item); + *item = NULL; +} + void dns_message_puttemprdataset(dns_message_t *msg, dns_rdataset_t **item) { REQUIRE(DNS_MESSAGE_VALID(msg)); From d2e84a4b9713b85beaf5604ff67f3530c5a96a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 19 Oct 2023 10:21:20 +0200 Subject: [PATCH 3/4] Add ISC_LIST_FOREACH_REV(_SAFE) macros Add complementary macros to ISC_LIST_FOREACH(_SAFE) that walk the lists in reverse. * ISC_LIST_FOREACH_REV(list, elt, link) - walk the static list from tail to head * ISC_LIST_FOREACH_REV_SAFE(list, elt, link, next) - walk the list from tail to head in a manner that's safe against list member deletions --- .clang-format | 2 +- lib/isc/include/isc/list.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 124d82a269..54a39fdb4d 100644 --- a/.clang-format +++ b/.clang-format @@ -78,4 +78,4 @@ PenaltyBreakString: 80 PenaltyExcessCharacter: 100 Standard: Cpp11 ContinuationIndentWidth: 8 -ForEachMacros: [ 'cds_lfs_for_each', 'cds_lfs_for_each_safe', 'cds_list_for_each_entry_safe', 'ISC_LIST_FOREACH', 'ISC_LIST_FOREACH_SAFE' ] +ForEachMacros: [ 'cds_lfs_for_each', 'cds_lfs_for_each_safe', 'cds_list_for_each_entry_safe', 'ISC_LIST_FOREACH', 'ISC_LIST_FOREACH_SAFE', 'ISC_LIST_FOREACH_REV', 'ISC_LIST_FOREACH_REV_SAFE' ] diff --git a/lib/isc/include/isc/list.h b/lib/isc/include/isc/list.h index a168254d40..67ed208c2c 100644 --- a/lib/isc/include/isc/list.h +++ b/lib/isc/include/isc/list.h @@ -241,3 +241,17 @@ elt != NULL; \ elt = next, next = (elt != NULL) ? ISC_LIST_NEXT(elt, link) : NULL) /* clang-format on */ + +/* clang-format off */ +#define ISC_LIST_FOREACH_REV(list, elt, link) \ + for (elt = ISC_LIST_TAIL(list); \ + elt != NULL; \ + elt = ISC_LIST_PREV(elt, link)) +/* clang-format on */ + +/* clang-format off */ +#define ISC_LIST_FOREACH_REV_SAFE(list, elt, link, prev) \ + for (elt = ISC_LIST_TAIL(list), prev = (elt != NULL) ? ISC_LIST_PREV(elt, link) : NULL; \ + elt != NULL; \ + elt = prev, prev = (elt != NULL) ? ISC_LIST_PREV(elt, link) : NULL) +/* clang-format on */ From 6bb42939cf5897a9ea31b9817cc83650a35e05f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 19 Oct 2023 10:22:59 +0200 Subject: [PATCH 4/4] Refactor dns_message using ISC_LIST_FOREACH macros Do a light refactoring and cleanups that replaces common list walking patterns with ISC_LIST_FOREACH macros and split some nested loops into separate static functions to reduce the nesting depth. --- lib/dns/message.c | 252 ++++++++++++++++++++++------------------------ 1 file changed, 118 insertions(+), 134 deletions(-) diff --git a/lib/dns/message.c b/lib/dns/message.c index 4437763179..39b2ef3460 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -443,30 +443,29 @@ msginit(dns_message_t *m) { } static void -msgresetnames(dns_message_t *msg, unsigned int first_section) { - unsigned int i; - dns_name_t *name, *next_name; - dns_rdataset_t *rds, *next_rds; +msgresetname(dns_message_t *msg, dns_name_t *name) { + dns_rdataset_t *rds = NULL, *next_rds = NULL; - /* - * Clean up name lists by calling the rdataset disassociate function. - */ - for (i = first_section; i < DNS_SECTION_MAX; i++) { - name = ISC_LIST_HEAD(msg->sections[i]); - while (name != NULL) { - next_name = ISC_LIST_NEXT(name, link); + ISC_LIST_FOREACH_SAFE (name->list, rds, link, next_rds) { + ISC_LIST_UNLINK(name->list, rds, link); + + dns__message_putassociatedrdataset(msg, &rds); + } +} + +static void +msgresetnames(dns_message_t *msg, unsigned int first_section) { + /* Clean up name lists. */ + for (size_t i = first_section; i < DNS_SECTION_MAX; i++) { + dns_name_t *name = NULL, *next_name = NULL; + + ISC_LIST_FOREACH_SAFE (msg->sections[i], name, link, next_name) + { ISC_LIST_UNLINK(msg->sections[i], name, link); - rds = ISC_LIST_HEAD(name->list); - while (rds != NULL) { - next_rds = ISC_LIST_NEXT(rds, link); - ISC_LIST_UNLINK(name->list, rds, link); + msgresetname(msg, name); - dns__message_putassociatedrdataset(msg, &rds); - rds = next_rds; - } dns_message_puttempname(msg, &name); - name = next_name; } } } @@ -525,10 +524,10 @@ msgresetsigs(dns_message_t *msg, bool replying) { */ static void msgreset(dns_message_t *msg, bool everything) { - dns_msgblock_t *msgblock, *next_msgblock; - isc_buffer_t *dynbuf, *next_dynbuf; - dns_rdata_t *rdata; - dns_rdatalist_t *rdatalist; + dns_msgblock_t *msgblock = NULL, *next_msgblock = NULL; + isc_buffer_t *dynbuf = NULL, *next_dynbuf = NULL; + dns_rdata_t *rdata = NULL; + dns_rdatalist_t *rdatalist = NULL; msgresetnames(msg, 0); msgresetopt(msg); @@ -783,14 +782,12 @@ ISC_REFCOUNT_IMPL(dns_message, dns__message_destroy); static isc_result_t findname(dns_name_t **foundname, const dns_name_t *target, dns_namelist_t *section) { - dns_name_t *curr; + dns_name_t *name = NULL; - for (curr = ISC_LIST_TAIL(*section); curr != NULL; - curr = ISC_LIST_PREV(curr, link)) - { - if (dns_name_equal(curr, target)) { + ISC_LIST_FOREACH_REV (*section, name, link) { + if (dns_name_equal(name, target)) { if (foundname != NULL) { - *foundname = curr; + *foundname = name; } return (ISC_R_SUCCESS); } @@ -802,21 +799,18 @@ findname(dns_name_t **foundname, const dns_name_t *target, isc_result_t dns_message_find(const dns_name_t *name, dns_rdataclass_t rdclass, dns_rdatatype_t type, dns_rdatatype_t covers, - dns_rdataset_t **rdataset) { - dns_rdataset_t *curr; + dns_rdataset_t **rdatasetp) { + dns_rdataset_t *rds = NULL; REQUIRE(name != NULL); - REQUIRE(rdataset == NULL || *rdataset == NULL); + REQUIRE(rdatasetp == NULL || *rdatasetp == NULL); - for (curr = ISC_LIST_TAIL(name->list); curr != NULL; - curr = ISC_LIST_PREV(curr, link)) - { - if (curr->rdclass == rdclass && curr->type == type && - curr->covers == covers) + ISC_LIST_FOREACH_REV (name->list, rds, link) { + if (rds->rdclass == rdclass && rds->type == type && + rds->covers == covers) { - if (rdataset != NULL) { - *rdataset = curr; - } + SET_IF_NOT_NULL(rdatasetp, rds); + return (ISC_R_SUCCESS); } } @@ -826,19 +820,16 @@ dns_message_find(const dns_name_t *name, dns_rdataclass_t rdclass, isc_result_t dns_message_findtype(const dns_name_t *name, dns_rdatatype_t type, - dns_rdatatype_t covers, dns_rdataset_t **rdataset) { - dns_rdataset_t *curr; + dns_rdatatype_t covers, dns_rdataset_t **rdatasetp) { + dns_rdataset_t *rds = NULL; REQUIRE(name != NULL); - REQUIRE(rdataset == NULL || *rdataset == NULL); + REQUIRE(rdatasetp == NULL || *rdatasetp == NULL); + + ISC_LIST_FOREACH_REV (name->list, rds, link) { + if (rds->type == type && rds->covers == covers) { + SET_IF_NOT_NULL(rdatasetp, rds); - for (curr = ISC_LIST_TAIL(name->list); curr != NULL; - curr = ISC_LIST_PREV(curr, link)) - { - if (curr->type == type && curr->covers == covers) { - if (rdataset != NULL) { - *rdataset = curr; - } return (ISC_R_SUCCESS); } } @@ -1109,17 +1100,13 @@ update(dns_section_t section, dns_rdataclass_t rdclass) { */ static bool auth_signed(dns_namelist_t *section) { - dns_name_t *name; + dns_name_t *name = NULL; - for (name = ISC_LIST_HEAD(*section); name != NULL; - name = ISC_LIST_NEXT(name, link)) - { + ISC_LIST_FOREACH (*section, name, link) { int auth_dnssec = 0, auth_rrsig = 0; - dns_rdataset_t *rds; + dns_rdataset_t *rds = NULL; - for (rds = ISC_LIST_HEAD(name->list); rds != NULL; - rds = ISC_LIST_NEXT(rds, link)) - { + ISC_LIST_FOREACH (name->list, rds, link) { switch (rds->type) { case dns_rdatatype_ds: auth_dnssec |= 0x1; @@ -2336,10 +2323,6 @@ dns_message_renderend(dns_message_t *msg) { void dns_message_renderreset(dns_message_t *msg) { - unsigned int i; - dns_name_t *name; - dns_rdataset_t *rds; - /* * Reset the message so that it may be rendered again. */ @@ -2349,15 +2332,14 @@ dns_message_renderreset(dns_message_t *msg) { msg->buffer = NULL; - for (i = 0; i < DNS_SECTION_MAX; i++) { + for (size_t i = 0; i < DNS_SECTION_MAX; i++) { + dns_name_t *name = NULL; + msg->cursors[i] = NULL; msg->counts[i] = 0; - for (name = ISC_LIST_HEAD(msg->sections[i]); name != NULL; - name = ISC_LIST_NEXT(name, link)) - { - for (rds = ISC_LIST_HEAD(name->list); rds != NULL; - rds = ISC_LIST_NEXT(rds, link)) - { + ISC_LIST_FOREACH (msg->sections[i], name, link) { + dns_rdataset_t *rds = NULL; + ISC_LIST_FOREACH (name->list, rds, link) { rds->attributes &= ~DNS_RDATASETATTR_RENDERED; } } @@ -3220,7 +3202,9 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) { dns_masterstyle_flags_t __flags = dns_master_styleflags(sp); \ if ((__flags & DNS_STYLEFLAG_INDENT) == 0ULL && \ (__flags & DNS_STYLEFLAG_YAML) == 0ULL) \ + { \ break; \ + } \ for (__i = 0; __i < msg->indent.count; __i++) { \ ADD_STRING(target, msg->indent.string); \ } \ @@ -3230,8 +3214,7 @@ isc_result_t dns_message_sectiontotext(dns_message_t *msg, dns_section_t section, const dns_master_style_t *style, dns_messagetextflag_t flags, isc_buffer_t *target) { - dns_name_t *name, empty_name; - dns_rdataset_t *rdataset; + dns_name_t empty_name; isc_result_t result = ISC_R_SUCCESS; bool seensoa = false; size_t saved_count; @@ -3276,13 +3259,13 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section, msg->indent.count++; } do { - name = NULL; + dns_name_t *name = NULL; dns_message_currentname(msg, section, &name); - for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; - rdataset = ISC_LIST_NEXT(rdataset, link)) - { + + dns_rdataset_t *rds = NULL; + ISC_LIST_FOREACH (name->list, rds, link) { if (section == DNS_SECTION_ANSWER && - rdataset->type == dns_rdatatype_soa) + rds->type == dns_rdatatype_soa) { if ((flags & DNS_MESSAGETEXTFLAG_OMITSOA) != 0) { @@ -3303,11 +3286,10 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section, ADD_STRING(target, ";"); } result = dns_master_questiontotext( - name, rdataset, style, target); + name, rds, style, target); } else { result = dns_master_rdatasettotext( - name, rdataset, style, &msg->indent, - target); + name, rds, style, &msg->indent, target); } if (result != ISC_R_SUCCESS) { goto cleanup; @@ -3337,7 +3319,7 @@ cleanup: static isc_result_t render_ecs(isc_buffer_t *ecsbuf, isc_buffer_t *target) { int i; - char addr[16], addr_text[64]; + char addr[16] = { 0 }, addr_text[64]; uint16_t family; uint8_t addrlen, addrbytes, scopelen; isc_result_t result; @@ -3362,7 +3344,6 @@ render_ecs(isc_buffer_t *ecsbuf, isc_buffer_t *target) { return (DNS_R_OPTERR); } - memset(addr, 0, sizeof(addr)); for (i = 0; i < addrbytes; i++) { addr[i] = isc_buffer_getuint8(ecsbuf); } @@ -4652,10 +4633,56 @@ dns_message_clonebuffer(dns_message_t *msg) { } static isc_result_t -message_authority_soa_min(dns_message_t *msg, dns_ttl_t *pttl) { +rdataset_soa_min(dns_rdataset_t *rds, dns_ttl_t *ttlp) { + isc_result_t result; + /* loop over the rdatas */ + for (result = dns_rdataset_first(rds); result == ISC_R_SUCCESS; + result = dns_rdataset_next(rds)) + { + dns_name_t tmp; + isc_region_t r = { 0 }; + dns_rdata_t rdata = DNS_RDATA_INIT; + + dns_rdataset_current(rds, &rdata); + + switch (rdata.type) { + case dns_rdatatype_soa: + /* SOA rdataset */ + break; + case dns_rdatatype_none: + /* + * Negative cache rdataset: we need + * to inspect the rdata to determine + * whether it's an SOA. + */ + dns_rdata_toregion(&rdata, &r); + dns_name_init(&tmp, NULL); + dns_name_fromregion(&tmp, &r); + isc_region_consume(&r, tmp.length); + if (r.length < 2) { + continue; + } + rdata.type = r.base[0] << 8 | r.base[1]; + if (rdata.type != dns_rdatatype_soa) { + continue; + } + break; + default: + continue; + } + + if (rdata.type == dns_rdatatype_soa) { + *ttlp = ISC_MIN(rds->ttl, dns_soa_getminimum(&rdata)); + return (ISC_R_SUCCESS); + } + } + + return (ISC_R_NOTFOUND); +} + +static isc_result_t +message_authority_soa_min(dns_message_t *msg, dns_ttl_t *ttlp) { isc_result_t result; - dns_rdataset_t *rdataset = NULL; - dns_name_t *name = NULL; if (msg->counts[DNS_SECTION_AUTHORITY] == 0) { return (ISC_R_NOTFOUND); @@ -4665,62 +4692,19 @@ message_authority_soa_min(dns_message_t *msg, dns_ttl_t *pttl) { result == ISC_R_SUCCESS; result = dns_message_nextname(msg, DNS_SECTION_AUTHORITY)) { - name = NULL; + dns_name_t *name = NULL; dns_message_currentname(msg, DNS_SECTION_AUTHORITY, &name); - for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; - rdataset = ISC_LIST_NEXT(rdataset, link)) - { - isc_result_t tresult; - if ((rdataset->attributes & - DNS_RDATASETATTR_RENDERED) == 0) + dns_rdataset_t *rds = NULL; + ISC_LIST_FOREACH (name->list, rds, link) { + if ((rds->attributes & DNS_RDATASETATTR_RENDERED) == 0) { continue; } - /* loop over the rdatas */ - for (tresult = dns_rdataset_first(rdataset); - tresult == ISC_R_SUCCESS; - tresult = dns_rdataset_next(rdataset)) - { - dns_name_t tmp; - isc_region_t r = { 0 }; - dns_rdata_t rdata = DNS_RDATA_INIT; - - dns_rdataset_current(rdataset, &rdata); - - switch (rdata.type) { - case dns_rdatatype_soa: - /* SOA rdataset */ - break; - case dns_rdatatype_none: - /* - * Negative cache rdataset: we need - * to inspect the rdata to determine - * whether it's an SOA. - */ - dns_rdata_toregion(&rdata, &r); - dns_name_init(&tmp, NULL); - dns_name_fromregion(&tmp, &r); - isc_region_consume(&r, tmp.length); - if (r.length < 2) { - continue; - } - rdata.type = r.base[0] << 8 | r.base[1]; - if (rdata.type != dns_rdatatype_soa) { - continue; - } - break; - default: - continue; - } - - if (rdata.type == dns_rdatatype_soa) { - *pttl = ISC_MIN( - rdataset->ttl, - dns_soa_getminimum(&rdata)); - return (ISC_R_SUCCESS); - } + result = rdataset_soa_min(rds, ttlp); + if (result == ISC_R_SUCCESS) { + return (ISC_R_SUCCESS); } } }