diff --git a/src/libknot/updates/ddns.c b/src/libknot/updates/ddns.c index f4c3b7058911258eb7f9a7bc36b5c230aa5f6639..0dcf43cbfe922ae665788cb805881fd5badc2187 100644 --- a/src/libknot/updates/ddns.c +++ b/src/libknot/updates/ddns.c @@ -1760,9 +1760,10 @@ static int knot_ddns_process_rem_rr(const knot_rrset_t *rr, * 4) If the RRSet is empty, remove it and store in 'changes'. * Do this also if the RRSIGs are empty. * And if both are empty, remove both. + * RRSIG handling first, */ - if (type == KNOT_RRTYPE_RRSIG - && knot_rrset_rdata_rr_count(to_modify) == 0) { + if (type == KNOT_RRTYPE_RRSIG && + knot_rrset_rdata_rr_count(to_modify) == 0) { /* Empty RRSIGs, remove the RRSIG RRSet */ ret = knot_changes_rrsets_reserve(&changes->old_rrsets, &changes->old_rrsets_count, @@ -1785,31 +1786,30 @@ static int knot_ddns_process_rem_rr(const knot_rrset_t *rr, } } - /*! \note Copied from xfr-in.c - maybe extract to some function. */ - /*! \note This is not needed as rrset is already on the old_rrsets */ -// if (knot_rrset_rdata(rrset_copy) == NULL -// && knot_rrset_rrsigs(rrset_copy) == NULL) { -// // The RRSet should not be empty if we were removing NSs from -// // apex in case of DDNS -// assert(!is_apex); - -// ret = knot_changes_rrsets_reserve(&changes->old_rrsets, -// &changes->old_rrsets_count, -// &changes->old_rrsets_allocated, -// 1); -// if (ret == KNOT_EOK) { -// knot_rrset_t *tmp = knot_node_remove_rrset(node, type); -// dbg_xfrin_detail("Removed whole RRSet (%p).\n", tmp); - -// assert(tmp == rrset_copy); - -// // add the removed RRSet to list of old RRSets -// changes->old_rrsets[changes->old_rrsets_count++] -// = rrset_copy; -// } else { -// dbg_ddns("Failed to reserve space for empty RRSet.\n"); -// } -// } + // Remove empty RRSet from node and store to changeset + if (type != KNOT_RRTYPE_RRSIG && + knot_rrset_rdata_rr_count(to_modify) == 0) { + // The RRSet should not be empty if we were removing NSs from + // apex in case of DDNS + assert(!is_apex); + + ret = knot_changes_rrsets_reserve(&changes->old_rrsets, + &changes->old_rrsets_count, + &changes->old_rrsets_allocated, + 1); + if (ret == KNOT_EOK) { + knot_rrset_t *tmp = knot_node_remove_rrset(node, type); + dbg_xfrin_detail("Removed whole RRSet (%p).\n", tmp); + + assert(tmp == rrset_copy); + + // add the removed RRSet to list of old RRSets + changes->old_rrsets[changes->old_rrsets_count++] + = rrset_copy; + } else { + dbg_ddns("Failed to reserve space for empty RRSet.\n"); + } + } /* * 5) Check if the RR is not in the ADD section. If yes, remove it