NLnetLabs / ldns

LDNS is a DNS library that facilitates DNS tool programming
https://nlnetlabs.nl/ldns
BSD 3-Clause "New" or "Revised" License
285 stars 94 forks source link

Optionally exclude ZONEMD RRs in ldns-compare-zone #220

Open gjherbiet opened 1 year ago

gjherbiet commented 1 year ago

As with SOA, ZONEMD resource records may not be meaningful when comparing zones (because of the only difference may be the SOA SERIAL value, leading to different ZONEMD RDATA).

This pull request:

When setting -Z, the last argument to ldns_zone_new_frm_fp_l_e is set to LDNS_RR_TYPE_ZONEMD and this record type is ignored while reading the zone from file.

I know this change could have been implemented purely in examples/ldns-compare-zones.c (e.g. by creating a new empty rr_list, iterating over all the read RRs and only those with a type different from from LDNS_RR_TYPE_ZONEMD) but this seemed inefficient, especially for large zones.

The counterpart is this solution creates an additional "core" function in zone.c, for the sole purpose of this additional option. If this is deemed too obtrusive, I can fallback to the other alternative.

I am also aware that ZONEMD RRs can be filtered out using ldns-read-zone -e ZONEMD but this doubles the amount of parsing and pipes/redirections may not always be available (e. g. while using ldns-compare-zone in systemd Exec* directives).

wtoorop commented 5 days ago

Thanks @gjherbiet good feature, but I don't really like the introduction of the new function (as it is very specific). Could you perhaps make it so that ZONEMD will be removed from the zone files (when requested with -Z) in ldns-compare-zone.c?